⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 layout.h

📁 上一个上传的有问题,这个是好的。visopsys包括系统内核和GUI的全部SOURCE code ,还包括一些基本的docs文档。里面src子目录对应所有SOURCE code.对于想研究操作系统的朋
💻 H
📖 第 1 页 / 共 5 页
字号:
					((MFT_REF)(m) & MFT_REF_MASK_CPU)))#define MK_LE_MREF(m, s) const_cpu_to_le64(((MFT_REF)(((MFT_REF)(s) << 48) | \					((MFT_REF)(m) & MFT_REF_MASK_CPU))))#define MREF(x)		((u64)((x) & MFT_REF_MASK_CPU))#define MSEQNO(x)	((u16)(((x) >> 48) & 0xffff))#define MREF_LE(x)	((u64)(const_le64_to_cpu(x) & MFT_REF_MASK_CPU))#define MSEQNO_LE(x)	((u16)((const_le64_to_cpu(x) >> 48) & 0xffff))#define IS_ERR_MREF(x)	(((x) & 0x0000800000000000ULL) ? 1 : 0)#define ERR_MREF(x)	((u64)((s64)(x)))#define MREF_ERR(x)	((int)((s64)(x)))/** * struct MFT_RECORD - An MFT record layout (NTFS 3.1+) * * The mft record header present at the beginning of every record in the mft. * This is followed by a sequence of variable length attribute records which * is terminated by an attribute of type AT_END which is a truncated attribute * in that it only consists of the attribute type code AT_END and none of the * other members of the attribute structure are present. */typedef struct {/*Ofs*//*  0	NTFS_RECORD; -- Unfolded here as gcc doesn't like unnamed structs. */	NTFS_RECORD_TYPES magic;/* Usually the magic is "FILE". */	u16 usa_ofs;		/* See NTFS_RECORD definition above. */	u16 usa_count;		/* See NTFS_RECORD definition above. *//*  8*/	LSN lsn;		/* $LogFile sequence number for this record.				   Changed every time the record is modified. *//* 16*/	u16 sequence_number;	/* Number of times this mft record has been				   reused. (See description for MFT_REF				   above.) NOTE: The increment (skipping zero)				   is done when the file is deleted. NOTE: If				   this is zero it is left zero. *//* 18*/	u16 link_count;		/* Number of hard links, i.e. the number of				   directory entries referencing this record.				   NOTE: Only used in mft base records.				   NOTE: When deleting a directory entry we				   check the link_count and if it is 1 we				   delete the file. Otherwise we delete the				   FILE_NAME_ATTR being referenced by the				   directory entry from the mft record and				   decrement the link_count.				   FIXME: Careful with Win32 + DOS names! *//* 20*/	u16 attrs_offset;	/* Byte offset to the first attribute in this				   mft record from the start of the mft record.				   NOTE: Must be aligned to 8-byte boundary. *//* 22*/	MFT_RECORD_FLAGS flags;	/* Bit array of MFT_RECORD_FLAGS. When a file				   is deleted, the MFT_RECORD_IN_USE flag is				   set to zero. *//* 24*/	u32 bytes_in_use;	/* Number of bytes used in this mft record.				   NOTE: Must be aligned to 8-byte boundary. *//* 28*/	u32 bytes_allocated;	/* Number of bytes allocated for this mft				   record. This should be equal to the mft				   record size. *//* 32*/	MFT_REF base_mft_record; /* This is zero for base mft records.				   When it is not zero it is a mft reference				   pointing to the base mft record to which				   this record belongs (this is then used to				   locate the attribute list attribute present				   in the base record which describes this				   extension record and hence might need				   modification when the extension record				   itself is modified, also locating the				   attribute list also means finding the other				   potential extents, belonging to the non-base				   mft record). *//* 40*/	u16 next_attr_instance; /* The instance number that will be				   assigned to the next attribute added to this				   mft record. NOTE: Incremented each time				   after it is used. NOTE: Every time the mft				   record is reused this number is set to zero.				   NOTE: The first instance number is always 0.				 *//* The below fields are specific to NTFS 3.1+ (Windows XP and above): *//* 42*/ u16 reserved;		/* Reserved/alignment. *//* 44*/ u32 mft_record_number;	/* Number of this mft record. *//* sizeof() = 48 bytes *//* * When (re)using the mft record, we place the update sequence array at this * offset, i.e. before we start with the attributes. This also makes sense, * otherwise we could run into problems with the update sequence array * containing in itself the last two bytes of a sector which would mean that * multi sector transfer protection wouldn't work. As you can't protect data * by overwriting it since you then can't get it back... * When reading we obviously use the data from the ntfs record header. */} __attribute__((__packed__)) MFT_RECORD;/** * struct MFT_RECORD_OLD - An MFT record layout (NTFS <=3.0) * * This is the version without the NTFS 3.1+ specific fields. */typedef struct {/*Ofs*//*  0	NTFS_RECORD; -- Unfolded here as gcc doesn't like unnamed structs. */	NTFS_RECORD_TYPES magic;/* Usually the magic is "FILE". */	u16 usa_ofs;		/* See NTFS_RECORD definition above. */	u16 usa_count;		/* See NTFS_RECORD definition above. *//*  8*/	LSN lsn;		/* $LogFile sequence number for this record.				   Changed every time the record is modified. *//* 16*/	u16 sequence_number;	/* Number of times this mft record has been				   reused. (See description for MFT_REF				   above.) NOTE: The increment (skipping zero)				   is done when the file is deleted. NOTE: If				   this is zero it is left zero. *//* 18*/	u16 link_count;		/* Number of hard links, i.e. the number of				   directory entries referencing this record.				   NOTE: Only used in mft base records.				   NOTE: When deleting a directory entry we				   check the link_count and if it is 1 we				   delete the file. Otherwise we delete the				   FILE_NAME_ATTR being referenced by the				   directory entry from the mft record and				   decrement the link_count.				   FIXME: Careful with Win32 + DOS names! *//* 20*/	u16 attrs_offset;	/* Byte offset to the first attribute in this				   mft record from the start of the mft record.				   NOTE: Must be aligned to 8-byte boundary. *//* 22*/	MFT_RECORD_FLAGS flags;	/* Bit array of MFT_RECORD_FLAGS. When a file				   is deleted, the MFT_RECORD_IN_USE flag is				   set to zero. *//* 24*/	u32 bytes_in_use;	/* Number of bytes used in this mft record.				   NOTE: Must be aligned to 8-byte boundary. *//* 28*/	u32 bytes_allocated;	/* Number of bytes allocated for this mft				   record. This should be equal to the mft				   record size. *//* 32*/	MFT_REF base_mft_record; /* This is zero for base mft records.				   When it is not zero it is a mft reference				   pointing to the base mft record to which				   this record belongs (this is then used to				   locate the attribute list attribute present				   in the base record which describes this				   extension record and hence might need				   modification when the extension record				   itself is modified, also locating the				   attribute list also means finding the other				   potential extents, belonging to the non-base				   mft record). *//* 40*/	u16 next_attr_instance; /* The instance number that will be				   assigned to the next attribute added to this				   mft record. NOTE: Incremented each time				   after it is used. NOTE: Every time the mft				   record is reused this number is set to zero.				   NOTE: The first instance number is always 0.				 *//* sizeof() = 42 bytes *//* * When (re)using the mft record, we place the update sequence array at this * offset, i.e. before we start with the attributes. This also makes sense, * otherwise we could run into problems with the update sequence array * containing in itself the last two bytes of a sector which would mean that * multi sector transfer protection wouldn't work. As you can't protect data * by overwriting it since you then can't get it back... * When reading we obviously use the data from the ntfs record header. */} __attribute__((__packed__)) MFT_RECORD_OLD;/** * enum ATTR_TYPES - System defined attributes (32-bit). * * Each attribute type has a corresponding attribute name (Unicode string of * maximum 64 character length) as described by the attribute definitions * present in the data attribute of the $AttrDef system file. *  * On NTFS 3.0 volumes the names are just as the types are named in the below * enum exchanging AT_ for the dollar sign ($). If that isn't a revealing * choice of symbol... (-; */typedef enum {	AT_UNUSED			= const_cpu_to_le32(         0),	AT_STANDARD_INFORMATION		= const_cpu_to_le32(      0x10),	AT_ATTRIBUTE_LIST		= const_cpu_to_le32(      0x20),	AT_FILE_NAME			= const_cpu_to_le32(      0x30),	AT_OBJECT_ID			= const_cpu_to_le32(      0x40),	AT_SECURITY_DESCRIPTOR		= const_cpu_to_le32(      0x50),	AT_VOLUME_NAME			= const_cpu_to_le32(      0x60),	AT_VOLUME_INFORMATION		= const_cpu_to_le32(      0x70),	AT_DATA				= const_cpu_to_le32(      0x80),	AT_INDEX_ROOT			= const_cpu_to_le32(      0x90),	AT_INDEX_ALLOCATION		= const_cpu_to_le32(      0xa0),	AT_BITMAP			= const_cpu_to_le32(      0xb0),	AT_REPARSE_POINT		= const_cpu_to_le32(      0xc0),	AT_EA_INFORMATION		= const_cpu_to_le32(      0xd0),	AT_EA				= const_cpu_to_le32(      0xe0),	AT_PROPERTY_SET			= const_cpu_to_le32(      0xf0),	AT_LOGGED_UTILITY_STREAM	= const_cpu_to_le32(     0x100),	AT_FIRST_USER_DEFINED_ATTRIBUTE	= const_cpu_to_le32(    0x1000),	AT_END				= const_cpu_to_le32(0xffffffff),} ATTR_TYPES;/** * enum COLLATION_RULES - The collation rules for sorting views/indexes/etc * (32-bit). * * COLLATION_UNICODE_STRING - Collate Unicode strings by comparing their binary *	Unicode values, except that when a character can be uppercased, the *	upper case value collates before the lower case one. * COLLATION_FILE_NAME - Collate file names as Unicode strings. The collation *	is done very much like COLLATION_UNICODE_STRING. In fact I have no idea *	what the difference is. Perhaps the difference is that file names *	would treat some special characters in an odd way (see *	unistr.c::ntfs_collate_names() and unistr.c::legal_ansi_char_array[] *	for what I mean but COLLATION_UNICODE_STRING would not give any special *	treatment to any characters at all, but this is speculation. * COLLATION_NTOFS_ULONG - Sorting is done according to ascending u32 key *	values. E.g. used for $SII index in FILE_Secure, which sorts by *	security_id (u32). * COLLATION_NTOFS_SID - Sorting is done according to ascending SID values. *	E.g. used for $O index in FILE_Extend/$Quota. * COLLATION_NTOFS_SECURITY_HASH - Sorting is done first by ascending hash *	values and second by ascending security_id values. E.g. used for $SDH *	index in FILE_Secure. * COLLATION_NTOFS_ULONGS - Sorting is done according to a sequence of ascending *	u32 key values. E.g. used for $O index in FILE_Extend/$ObjId, which *	sorts by object_id (16-byte), by splitting up the object_id in four *	u32 values and using them as individual keys. E.g. take the following *	two security_ids, stored as follows on disk: *		1st: a1 61 65 b7 65 7b d4 11 9e 3d 00 e0 81 10 42 59 *		2nd: 38 14 37 d2 d2 f3 d4 11 a5 21 c8 6b 79 b1 97 45 *	To compare them, they are split into four u32 values each, like so: *		1st: 0xb76561a1 0x11d47b65 0xe0003d9e 0x59421081 *		2nd: 0xd2371438 0x11d4f3d2 0x6bc821a5 0x4597b179 *	Now, it is apparent why the 2nd object_id collates after the 1st: the *	first u32 value of the 1st object_id is less than the first u32 of *	the 2nd object_id. If the first u32 values of both object_ids were *	equal then the second u32 values would be compared, etc. */typedef enum {	COLLATION_BINARY	 = const_cpu_to_le32(0), /* Collate by binary					compare where the first byte is most					significant. */	COLLATION_FILE_NAME	 = const_cpu_to_le32(1), /* Collate file names					as Unicode strings. */	COLLATION_UNICODE_STRING = const_cpu_to_le32(2), /* Collate Unicode					strings by comparing their binary					Unicode values, except that when a					character can be uppercased, the upper					case value collates before the lower					case one. */	COLLATION_NTOFS_ULONG		= const_cpu_to_le32(16),	COLLATION_NTOFS_SID		= const_cpu_to_le32(17),	COLLATION_NTOFS_SECURITY_HASH	= const_cpu_to_le32(18),	COLLATION_NTOFS_ULONGS		= const_cpu_to_le32(19),} COLLATION_RULES;/** * enum ATTR_DEF_FLAGS - * * The flags (32-bit) describing attribute properties in the attribute * definition structure.  FIXME: This information is based on Regis's * information and, according to him, it is not certain and probably * incomplete.  The INDEXABLE flag is fairly certainly correct as only the file * name attribute has this flag set and this is the only attribute indexed in * NT4. */typedef enum {	ATTR_DEF_INDEXABLE	= const_cpu_to_le32(0x02), /* Attribute can be					indexed. */	ATTR_DEF_MULTIPLE	= const_cpu_to_le32(0x04), /* Attribute type					can be present multiple times in the					mft records of an inode. */	ATTR_DEF_NOT_ZERO	= const_cpu_to_le32(0x08), /* Attribute value					must contain at least one non-zero					byte. */	ATTR_DEF_INDEXED_UNIQUE	= const_cpu_to_le32(0x10), /* Attribute must be					indexed and the attribute value must be					unique for the attribute type in all of					the mft records of an inode. */	ATTR_DEF_NAMED_UNIQUE	= const_cpu_to_le32(0x20), /* Attribute must be					named and the name must be unique for					the attribute type in all of the mft					records of an inode. */	ATTR_DEF_RESIDENT	= const_cpu_to_le32(0x40), /* Attribute must be					resident. */	ATTR_DEF_ALWAYS_LOG	= const_cpu_to_le32(0x80), /* Always log					modifications to this attribute,					regardless of whether it is resident or					non-resident.  Without this, only log					modifications if the attribute is					resident. */} ATTR_DEF_FLAGS;/** * struct ATTR_DEF - * * The data attribute of FILE_AttrDef contains a sequence of attribute * definitions for the NTFS volume. With this, it is supposed to be safe for an * older NTFS driver to mount a volume containing a newer NTFS version without * damaging it (that's the theory. In practice it's: not damaging it too much). * Entries are sorted by attribute type. The flags describe whether the * attribute can be resident/non-resident and possibly other things, but the * actual bits are unknown. */typedef struct {/*hex ofs*//*  0*/	ntfschar name[0x40];		/* Unicode name of the attribute. Zero					   terminated. *//* 80*/	ATTR_TYPES type;		/* Type of the attribute. *//* 84*/	u32 display_rule;		/* Default display rule.					   FIXME: What does it mean? (AIA) *//* 88*/ COLLATION_RULES collation_rule;	/* Default collation rule. *//* 8c*/	ATTR_DEF_FLAGS flags;		/* Flags describing the attribute. *//* 90*/	s64 min_size;			/* Optional minimum attribute size. *//* 98*/	s64 max_size;			/* Maximum size of attribute. *//* sizeof() = 0xa0 or 160 bytes */} __attribute__((__packed__)) ATTR_DEF;/** * enum ATTR_FLAGS - Attribute flags (16-bit).

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -