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

📄 layout.h

📁 上一个上传的有问题,这个是好的。visopsys包括系统内核和GUI的全部SOURCE code ,还包括一些基本的docs文档。里面src子目录对应所有SOURCE code.对于想研究操作系统的朋
💻 H
📖 第 1 页 / 共 5 页
字号:
 */typedef 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__)) ATTR_FLAGS;/* * Attribute compression. * * Only the data attribute is ever compressed in the current ntfs driver in * Windows. Further, compression is only applied when the data attribute is * non-resident. Finally, to use compression, the maximum allowed cluster size * on a volume is 4kib. * * The compression method is based on independently compressing blocks of X * clusters, where X is determined from the compression_unit value found in the * non-resident attribute record header (more precisely: X = 2^compression_unit * clusters). On Windows NT/2k, X always is 16 clusters (compression_unit = 4). * * There are three different cases of how a compression block of X clusters * can be stored: * *   1) The data in the block is all zero (a sparse block): *	  This is stored as a sparse block in the runlist, i.e. the runlist *	  entry has length = X and lcn = -1. The mapping pairs array actually *	  uses a delta_lcn value length of 0, i.e. delta_lcn is not present at *	  all, which is then interpreted by the driver as lcn = -1. *	  NOTE: Even uncompressed files can be sparse on NTFS 3.0 volumes, then *	  the same principles apply as above, except that the length is not *	  restricted to being any particular value. * *   2) The data in the block is not compressed: *	  This happens when compression doesn't reduce the size of the block *	  in clusters. I.e. if compression has a small effect so that the *	  compressed data still occupies X clusters, then the uncompressed data *	  is stored in the block. *	  This case is recognised by the fact that the runlist entry has *	  length = X and lcn >= 0. The mapping pairs array stores this as *	  normal with a run length of X and some specific delta_lcn, i.e. *	  delta_lcn has to be present. * *   3) The data in the block is compressed: *	  The common case. This case is recognised by the fact that the run *	  list entry has length L < X and lcn >= 0. The mapping pairs array *	  stores this as normal with a run length of X and some specific *	  delta_lcn, i.e. delta_lcn has to be present. This runlist entry is *	  immediately followed by a sparse entry with length = X - L and *	  lcn = -1. The latter entry is to make up the vcn counting to the *	  full compression block size X. * * In fact, life is more complicated because adjacent entries of the same type * can be coalesced. This means that one has to keep track of the number of * clusters handled and work on a basis of X clusters at a time being one * block. An example: if length L > X this means that this particular runlist * entry contains a block of length X and part of one or more blocks of length * L - X. Another example: if length L < X, this does not necessarily mean that * the block is compressed as it might be that the lcn changes inside the block * and hence the following runlist entry describes the continuation of the * potentially compressed block. The block would be compressed if the * following runlist entry describes at least X - L sparse clusters, thus * making up the compression block length as described in point 3 above. (Of * course, there can be several runlist entries with small lengths so that the * sparse entry does not follow the first data containing entry with * length < X.) * * NOTE: At the end of the compressed attribute value, there most likely is not * just the right amount of data to make up a compression block, thus this data * is not even attempted to be compressed. It is just stored as is, unless * the number of clusters it occupies is reduced when compressed in which case * it is stored as a compressed compression block, complete with sparse * clusters at the end. *//** * enum RESIDENT_ATTR_FLAGS - Flags of resident attributes (8-bit). */typedef enum {	RESIDENT_ATTR_IS_INDEXED = 0x01, /* Attribute is referenced in an index					    (has implications for deleting and					    modifying the attribute). */} __attribute__((__packed__)) RESIDENT_ATTR_FLAGS;/** * struct ATTR_RECORD - Attribute record header. * * Always aligned to 8-byte boundary. */typedef struct {/*Ofs*//*  0*/	ATTR_TYPES type;	/* The (32-bit) type of the attribute. *//*  4*/	u32 length;		/* Byte size of the resident part of the				   attribute (aligned to 8-byte boundary).				   Used to get to the next attribute. *//*  8*/	u8 non_resident;	/* If 0, attribute is resident.				   If 1, attribute is non-resident. *//*  9*/	u8 name_length;		/* Unicode character size of name of attribute.				   0 if unnamed. *//* 10*/	u16 name_offset;	/* If name_length != 0, the byte offset to the				   beginning of the name from the attribute				   record. Note that the name is stored as a				   Unicode string. When creating, place offset				   just at the end of the record header. Then,				   follow with attribute value or mapping pairs				   array, resident and non-resident attributes				   respectively, aligning to an 8-byte				   boundary. *//* 12*/	ATTR_FLAGS flags;	/* Flags describing the attribute. *//* 14*/	u16 instance;		/* The instance of this attribute record. This				   number is unique within this mft record (see				   MFT_RECORD/next_attribute_instance notes				   above for more details). *//* 16*/	union {		/* Resident attributes. */		struct {/* 16 */		u32 value_length; /* Byte size of attribute value. *//* 20 */		u16 value_offset; /* Byte offset of the attribute					       value from the start of the					       attribute record. When creating,					       align to 8-byte boundary if we					       have a name present as this might					       not have a length of a multiple					       of 8-bytes. *//* 22 */		RESIDENT_ATTR_FLAGS resident_flags; /* See above. *//* 23 */		s8 reservedR;	    /* Reserved/alignment to 8-byte					       boundary. *//* 24 */		void *resident_end[0]; /* Use offsetof(ATTR_RECORD,						  resident_end) to get size of						  a resident attribute. */		} __attribute__((__packed__));		/* Non-resident attributes. */		struct {/* 16*/			VCN lowest_vcn;	/* Lowest valid virtual cluster number				for this portion of the attribute value or				0 if this is the only extent (usually the				case). - Only when an attribute list is used				does lowest_vcn != 0 ever occur. *//* 24*/			VCN highest_vcn; /* Highest valid vcn of this extent of				the attribute value. - Usually there is only one				portion, so this usually equals the attribute				value size in clusters minus 1. Can be -1 for				zero length files. Can be 0 for "single extent"				attributes. *//* 32*/			u16 mapping_pairs_offset; /* Byte offset from the				beginning of the structure to the mapping pairs				array which contains the mappings between the				vcns and the logical cluster numbers (lcns).				When creating, place this at the end of this				record header aligned to 8-byte boundary. *//* 34*/			u8 compression_unit; /* The compression unit expressed				as the log to the base 2 of the number of				clusters in a compression unit. 0 means not				compressed. (This effectively limits the				compression unit size to be a power of two				clusters.) WinNT4 only uses a value of 4. *//* 35*/			u8 reserved1[5];	/* Align to 8-byte boundary. *//* The sizes below are only used when lowest_vcn is zero, as otherwise it would   be difficult to keep them up-to-date.*//* 40*/			s64 allocated_size;	/* Byte size of disk space				allocated to hold the attribute value. Always				is a multiple of the cluster size. When a file				is compressed, this field is a multiple of the				compression block size (2^compression_unit) and				it represents the logically allocated space				rather than the actual on disk usage. For this				use the compressed_size (see below). *//* 48*/			s64 data_size;	/* Byte size of the attribute				value. Can be larger than allocated_size if				attribute value is compressed or sparse. *//* 56*/			s64 initialized_size;	/* Byte size of initialized				portion of the attribute value. Usually equals				data_size. *//* 64 */		void *non_resident_end[0]; /* Use offsetof(ATTR_RECORD,						      non_resident_end) to get						      size of a non resident						      attribute. *//* sizeof(uncompressed attr) = 64*//* 64*/			s64 compressed_size;	/* Byte size of the attribute				value after compression. Only present when				compressed. Always is a multiple of the				cluster size. Represents the actual amount of				disk space being used on the disk. *//* 72 */		void *compressed_end[0];				/* Use offsetof(ATTR_RECORD, compressed_end) to				   get size of a compressed attribute. *//* sizeof(compressed attr) = 72*/		} __attribute__((__packed__));	} __attribute__((__packed__));} __attribute__((__packed__)) ATTR_RECORD;typedef ATTR_RECORD ATTR_REC;/** * enum FILE_ATTR_FLAGS - File attribute flags (32-bit). */typedef enum {	/*	 * These flags are only present in the STANDARD_INFORMATION attribute	 * (in the field file_attributes).	 */	FILE_ATTR_READONLY		= const_cpu_to_le32(0x00000001),	FILE_ATTR_HIDDEN		= const_cpu_to_le32(0x00000002),	FILE_ATTR_SYSTEM		= const_cpu_to_le32(0x00000004),	/* Old DOS volid. Unused in NT.	= cpu_to_le32(0x00000008), */	FILE_ATTR_DIRECTORY		= const_cpu_to_le32(0x00000010),	/* FILE_ATTR_DIRECTORY is not considered valid in NT. It is reserved	   for the DOS SUBDIRECTORY flag. */	FILE_ATTR_ARCHIVE		= const_cpu_to_le32(0x00000020),	FILE_ATTR_DEVICE		= const_cpu_to_le32(0x00000040),	FILE_ATTR_NORMAL		= const_cpu_to_le32(0x00000080),	FILE_ATTR_TEMPORARY		= const_cpu_to_le32(0x00000100),	FILE_ATTR_SPARSE_FILE		= const_cpu_to_le32(0x00000200),	FILE_ATTR_REPARSE_POINT		= const_cpu_to_le32(0x00000400),	FILE_ATTR_COMPRESSED		= const_cpu_to_le32(0x00000800),	FILE_ATTR_OFFLINE		= const_cpu_to_le32(0x00001000),	FILE_ATTR_NOT_CONTENT_INDEXED	= const_cpu_to_le32(0x00002000),	FILE_ATTR_ENCRYPTED		= const_cpu_to_le32(0x00004000),	FILE_ATTR_VALID_FLAGS		= const_cpu_to_le32(0x00007fb7),	/* FILE_ATTR_VALID_FLAGS masks out the old DOS VolId and the	   FILE_ATTR_DEVICE and preserves everything else. This mask	   is used to obtain all flags that are valid for reading. */	FILE_ATTR_VALID_SET_FLAGS	= const_cpu_to_le32(0x000031a7),	/* FILE_ATTR_VALID_SET_FLAGS masks out the old DOS VolId, the	   FILE_ATTR_DEVICE, FILE_ATTR_DIRECTORY, FILE_ATTR_SPARSE_FILE,	   FILE_ATTR_REPARSE_POINT, FILE_ATRE_COMPRESSED and FILE_ATTR_ENCRYPTED	   and preserves the rest. This mask is used to to obtain all flags that	   are valid for setting. */	/**	 * FILE_ATTR_I30_INDEX_PRESENT - Is it a directory?	 *	 * This is a copy of the MFT_RECORD_IS_DIRECTORY bit from the mft	 * record, telling us whether this is a directory or not, i.e. whether	 * it has an index root attribute named "$I30" or not.	 * 	 * This flag is only present in the FILE_NAME attribute (in the 	 * file_attributes field).	 */	FILE_ATTR_I30_INDEX_PRESENT	= const_cpu_to_le32(0x10000000),		/**	 * FILE_ATTR_VIEW_INDEX_PRESENT - Does have a non-directory index?	 * 	 * This is a copy of the MFT_RECORD_IS_VIEW_INDEX bit from the mft	 * record, telling us whether this file has a view index present (eg.	 * object id index, quota index, one of the security indexes and the	 * reparse points index).	 *	 * This flag is only present in the $STANDARD_INFORMATION and	 * $FILE_NAME attributes.	 */	FILE_ATTR_VIEW_INDEX_PRESENT	= const_cpu_to_le32(0x20000000),} __attribute__((__packed__)) FILE_ATTR_FLAGS;/* * NOTE on times in NTFS: All times are in MS standard time format, i.e. they * are the number of 100-nanosecond intervals since 1st January 1601, 00:00:00 * universal coordinated time (UTC). (In Linux time starts 1st January 1970, * 00:00:00 UTC and is stored as the number of 1-second intervals since then.) *//** * struct STANDARD_INFORMATION - Attribute: Standard information (0x10). * * NOTE: Always resident. * NOTE: Present in all base file records on a volume. * NOTE: There is conflicting information about the meaning of each of the time *	 fields but the meaning as defined below has been verified to be *	 correct by practical experimentation on Windows NT4 SP6a and is hence *	 assumed to be the one and only correct interpretation. */typedef struct {/*Ofs*//*  0*/	s64 creation_time;		/* Time file was created. Updated when					   a filename is changed(?). *//*  8*/	s64 last_data_change_time;	/* Time the data attribute was last					   modified. *//* 16*/	s64 last_mft_change_time;	/* Time this mft record was last					   modified. *//* 24*/	s64 last_access_time;		/* Approximate time when the file was					   last accessed (obviously this is not					   updated on read-only volumes). In					   Windows this is only updated when					   accessed if some time delta has					   passed since the last update. Also,					   last access times updates can be					   disabled altogether for speed. *//* 32*/	FILE_ATTR_FLAGS file_attributes; /* Flags describing the file. *//* 36*/	union {		/* NTFS 1.2 (and previous, presumably) */		struct {		/* 36 */ u8 reserved12[12];	/* Reserved/alignment to 8-byte						   boundary. */		/* 48 */ void *v1_end[0];	/* Marker for offsetof(). */		} __attribute__((__packed__));/* sizeof() = 48 bytes */		/* NTFS 3.0 */		struct {/* * If a volume has been upgraded from a previous NTFS version, then these * fields are present only if the file has been accessed since the upgrade. * Recognize the difference by comparing the length of the resident attribute * value. If it is 48, then the following fields are missing. If it is 72 then * the fields are present. Maybe just check like this: *	if (resident.ValueLength < sizeof(STANDARD_INFORMATION)) { *		Assume NTFS 1.2- format. *		If (volume version is 3.0+)

⌨️ 快捷键说明

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