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

📄 layout.h

📁 linux 内核源代码
💻 H
📖 第 1 页 / 共 5 页
字号:
typedef u64 MFT_REF;typedef le64 leMFT_REF;#define MK_MREF(m, s)	((MFT_REF)(((MFT_REF)(s) << 48) |		\					((MFT_REF)(m) & MFT_REF_MASK_CPU)))#define MK_LE_MREF(m, s) cpu_to_le64(MK_MREF(m, s))#define MREF(x)		((unsigned long)((x) & MFT_REF_MASK_CPU))#define MSEQNO(x)	((u16)(((x) >> 48) & 0xffff))#define MREF_LE(x)	((unsigned long)(le64_to_cpu(x) & MFT_REF_MASK_CPU))#define MSEQNO_LE(x)	((u16)((le64_to_cpu(x) >> 48) & 0xffff))#define IS_ERR_MREF(x)	(((x) & 0x0000800000000000ULL) ? true : false)#define ERR_MREF(x)	((u64)((s64)(x)))#define MREF_ERR(x)	((int)((s64)(x)))/* * 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_TYPE magic;	/* Usually the magic is "FILE". */	le16 usa_ofs;		/* See NTFS_RECORD definition above. */	le16 usa_count;		/* See NTFS_RECORD definition above. *//*  8*/	le64 lsn;		/* $LogFile sequence number for this record.				   Changed every time the record is modified. *//* 16*/	le16 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*/	le16 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*/	le16 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*/	le32 bytes_in_use;	/* Number of bytes used in this mft record.				   NOTE: Must be aligned to 8-byte boundary. *//* 28*/	le32 bytes_allocated;	/* Number of bytes allocated for this mft				   record. This should be equal to the mft				   record size. *//* 32*/	leMFT_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*/	le16 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*/ le16 reserved;		/* Reserved/alignment. *//* 44*/ le32 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;/* 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_TYPE magic;	/* Usually the magic is "FILE". */	le16 usa_ofs;		/* See NTFS_RECORD definition above. */	le16 usa_count;		/* See NTFS_RECORD definition above. *//*  8*/	le64 lsn;		/* $LogFile sequence number for this record.				   Changed every time the record is modified. *//* 16*/	le16 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*/	le16 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*/	le16 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*/	le32 bytes_in_use;	/* Number of bytes used in this mft record.				   NOTE: Must be aligned to 8-byte boundary. *//* 28*/	le32 bytes_allocated;	/* Number of bytes allocated for this mft				   record. This should be equal to the mft				   record size. *//* 32*/	leMFT_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*/	le16 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;/* * 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 defines exchanging AT_ for the dollar sign ($).  If that is not * a revealing choice of symbol I do not know what is... (-; */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)};typedef le32 ATTR_TYPE;/* * The collation rules for sorting views/indexes/etc (32-bit). * * COLLATION_BINARY - Collate by binary compare where the first byte is most *	significant. * 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 le32 key *	values. E.g. used for $SII index in FILE_Secure, which sorts by *	security_id (le32). * 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 *	le32 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 *	le32 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 le32 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 le32 value of the 1st object_id is less than the first le32 of *	the 2nd object_id. If the first le32 values of both object_ids were *	equal then the second le32 values would be compared, etc. */enum {	COLLATION_BINARY		= const_cpu_to_le32(0x00),	COLLATION_FILE_NAME		= const_cpu_to_le32(0x01),	COLLATION_UNICODE_STRING	= const_cpu_to_le32(0x02),	COLLATION_NTOFS_ULONG		= const_cpu_to_le32(0x10),	COLLATION_NTOFS_SID		= const_cpu_to_le32(0x11),	COLLATION_NTOFS_SECURITY_HASH	= const_cpu_to_le32(0x12),	COLLATION_NTOFS_ULONGS		= const_cpu_to_le32(0x13),};typedef le32 COLLATION_RULE;/* * 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. */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. */};typedef le32 ATTR_DEF_FLAGS;/* * 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_TYPE type;			/* Type of the attribute. *//* 84*/	le32 display_rule;		/* Default display rule.					   FIXME: What does it mean? (AIA) *//* 88*/ COLLATION_RULE collation_rule;	/* Default collation rule. *//* 8c*/	ATTR_DEF_FLAGS flags;		/* Flags describing the attribute. *//* 90*/	sle64 min_size;			/* Optional minimum attribute size. *//* 98*/	sle64 max_size;			/* Maximum size of attribute. *//* sizeof() = 0xa0 or 160 bytes */} __attribute__ ((__packed__)) ATTR_DEF;/* * Attribute flags (16-bit). */enum {	ATTR_IS_COMPRESSED    = const_cpu_to_le16(0x0001),	ATTR_COMPRESSION_MASK = const_cpu_to_le16(0x00ff), /* Compression method							      mask.  Also, first							      illegal value. */	ATTR_IS_ENCRYPTED     = const_cpu_to_le16(0x4000),	ATTR_IS_SPARSE	      = const_cpu_to_le16(0x8000),} __attribute__ ((__packed__));typedef le16 ATTR_FLAGS;

⌨️ 快捷键说明

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