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

📄 layout.h

📁 Linux Kernel 2.6.9 for OMAP1710
💻 H
📖 第 1 页 / 共 5 页
字号:
/* * layout.h - All NTFS associated on-disk structures. Part of the Linux-NTFS *	      project. * * Copyright (c) 2001-2004 Anton Altaparmakov * Copyright (c) 2002 Richard Russon * * This program/include file is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as published * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program/include file is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program (in the main directory of the Linux-NTFS * distribution in the file COPYING); if not, write to the Free Software * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */#ifndef _LINUX_NTFS_LAYOUT_H#define _LINUX_NTFS_LAYOUT_H#include <linux/types.h>#include <linux/bitops.h>#include <linux/list.h>#include <asm/byteorder.h>#include "types.h"/* * Constant endianness conversion defines. */#define const_le16_to_cpu(x)	__constant_le16_to_cpu(x)#define const_le32_to_cpu(x)	__constant_le32_to_cpu(x)#define const_le64_to_cpu(x)	__constant_le64_to_cpu(x)#define const_cpu_to_le16(x)	__constant_cpu_to_le16(x)#define const_cpu_to_le32(x)	__constant_cpu_to_le32(x)#define const_cpu_to_le64(x)	__constant_cpu_to_le64(x)/* The NTFS oem_id "NTFS    " */#define magicNTFS	const_cpu_to_le64(0x202020205346544eULL)/* * Location of bootsector on partition: *	The standard NTFS_BOOT_SECTOR is on sector 0 of the partition. *	On NT4 and above there is one backup copy of the boot sector to *	be found on the last sector of the partition (not normally accessible *	from within Windows as the bootsector contained number of sectors *	value is one less than the actual value!). *	On versions of NT 3.51 and earlier, the backup copy was located at *	number of sectors/2 (integer divide), i.e. in the middle of the volume. *//* * BIOS parameter block (bpb) structure. */typedef struct {	le16 bytes_per_sector;		/* Size of a sector in bytes. */	u8  sectors_per_cluster;	/* Size of a cluster in sectors. */	le16 reserved_sectors;		/* zero */	u8  fats;			/* zero */	le16 root_entries;		/* zero */	le16 sectors;			/* zero */	u8  media_type;			/* 0xf8 = hard disk */	le16 sectors_per_fat;		/* zero */	le16 sectors_per_track;		/* irrelevant */	le16 heads;			/* irrelevant */	le32 hidden_sectors;		/* zero */	le32 large_sectors;		/* zero */} __attribute__ ((__packed__)) BIOS_PARAMETER_BLOCK;/* * NTFS boot sector structure. */typedef struct {	u8  jump[3];			/* Irrelevant (jump to boot up code).*/	le64 oem_id;			/* Magic "NTFS    ". */	BIOS_PARAMETER_BLOCK bpb;	/* See BIOS_PARAMETER_BLOCK. */	u8  unused[4];			/* zero, NTFS diskedit.exe states that					   this is actually:						__u8 physical_drive;	// 0x80						__u8 current_head;	// zero						__u8 extended_boot_signature;									// 0x80						__u8 unused;		// zero					 *//*0x28*/sle64 number_of_sectors;	/* Number of sectors in volume. Gives					   maximum volume size of 2^63 sectors.					   Assuming standard sector size of 512					   bytes, the maximum byte size is					   approx. 4.7x10^21 bytes. (-; */	sle64 mft_lcn;			/* Cluster location of mft data. */	sle64 mftmirr_lcn;		/* Cluster location of copy of mft. */	s8  clusters_per_mft_record;	/* Mft record size in clusters. */	u8  reserved0[3];		/* zero */	s8  clusters_per_index_record;	/* Index block size in clusters. */	u8  reserved1[3];		/* zero */	le64 volume_serial_number;	/* Irrelevant (serial number). */	le32 checksum;			/* Boot sector checksum. *//*0x54*/u8  bootstrap[426];		/* Irrelevant (boot up code). */	le16 end_of_sector_marker;	/* End of bootsector magic. Always is					   0xaa55 in little endian. *//* sizeof() = 512 (0x200) bytes */} __attribute__ ((__packed__)) NTFS_BOOT_SECTOR;/* * Magic identifiers present at the beginning of all ntfs record containing * records (like mft records for example). */enum {	/* Found in $MFT/$DATA. */	magic_FILE = const_cpu_to_le32(0x454c4946), /* Mft entry. */	magic_INDX = const_cpu_to_le32(0x58444e49), /* Index buffer. */	magic_HOLE = const_cpu_to_le32(0x454c4f48), /* ? (NTFS 3.0+?) */	/* Found in $LogFile/$DATA. */	magic_RSTR = const_cpu_to_le32(0x52545352), /* Restart page. */	magic_RCRD = const_cpu_to_le32(0x44524352), /* Log record page. */	/* Found in $LogFile/$DATA.  (May be found in $MFT/$DATA, also?) */	magic_CHKD = const_cpu_to_le32(0x424b4843), /* Modified by chkdsk. */	/* Found in all ntfs record containing records. */	magic_BAAD = const_cpu_to_le32(0x44414142), /* Failed multi sector						       transfer was detected. */	/*	 * Found in $LogFile/$DATA when a page is full of 0xff bytes and is	 * thus not initialized.  Page must be initialized before using it.	 */	magic_empty = const_cpu_to_le32(0xffffffff) /* Record is empty. */};typedef le32 NTFS_RECORD_TYPE;/* * Generic magic comparison macros. Finally found a use for the ## preprocessor * operator! (-8 */static inline BOOL __ntfs_is_magic(le32 x, NTFS_RECORD_TYPE r){	return (x == r);}#define ntfs_is_magic(x, m)	__ntfs_is_magic(x, magic_##m)static inline BOOL __ntfs_is_magicp(le32 *p, NTFS_RECORD_TYPE r){	return (*p == r);}#define ntfs_is_magicp(p, m)	__ntfs_is_magicp(p, magic_##m)/* * Specialised magic comparison macros for the NTFS_RECORD_TYPEs defined above. */#define ntfs_is_file_record(x)		( ntfs_is_magic (x, FILE) )#define ntfs_is_file_recordp(p)		( ntfs_is_magicp(p, FILE) )#define ntfs_is_mft_record(x)		( ntfs_is_file_record (x) )#define ntfs_is_mft_recordp(p)		( ntfs_is_file_recordp(p) )#define ntfs_is_indx_record(x)		( ntfs_is_magic (x, INDX) )#define ntfs_is_indx_recordp(p)		( ntfs_is_magicp(p, INDX) )#define ntfs_is_hole_record(x)		( ntfs_is_magic (x, HOLE) )#define ntfs_is_hole_recordp(p)		( ntfs_is_magicp(p, HOLE) )#define ntfs_is_rstr_record(x)		( ntfs_is_magic (x, RSTR) )#define ntfs_is_rstr_recordp(p)		( ntfs_is_magicp(p, RSTR) )#define ntfs_is_rcrd_record(x)		( ntfs_is_magic (x, RCRD) )#define ntfs_is_rcrd_recordp(p)		( ntfs_is_magicp(p, RCRD) )#define ntfs_is_chkd_record(x)		( ntfs_is_magic (x, CHKD) )#define ntfs_is_chkd_recordp(p)		( ntfs_is_magicp(p, CHKD) )#define ntfs_is_baad_record(x)		( ntfs_is_magic (x, BAAD) )#define ntfs_is_baad_recordp(p)		( ntfs_is_magicp(p, BAAD) )#define ntfs_is_empty_record(x)		( ntfs_is_magic (x, empty) )#define ntfs_is_empty_recordp(p)	( ntfs_is_magicp(p, empty) )/* * The Update Sequence Array (usa) is an array of the le16 values which belong * to the end of each sector protected by the update sequence record in which * this array is contained. Note that the first entry is the Update Sequence * Number (usn), a cyclic counter of how many times the protected record has * been written to disk. The values 0 and -1 (ie. 0xffff) are not used. All * last le16's of each sector have to be equal to the usn (during reading) or * are set to it (during writing). If they are not, an incomplete multi sector * transfer has occurred when the data was written. * The maximum size for the update sequence array is fixed to: *	maximum size = usa_ofs + (usa_count * 2) = 510 bytes * The 510 bytes comes from the fact that the last le16 in the array has to * (obviously) finish before the last le16 of the first 512-byte sector. * This formula can be used as a consistency check in that usa_ofs + * (usa_count * 2) has to be less than or equal to 510. */typedef struct {	NTFS_RECORD_TYPE magic;	/* A four-byte magic identifying the record				   type and/or status. */	le16 usa_ofs;		/* Offset to the Update Sequence Array (usa)				   from the start of the ntfs record. */	le16 usa_count;		/* Number of le16 sized entries in the usa				   including the Update Sequence Number (usn),				   thus the number of fixups is the usa_count				   minus 1. */} __attribute__ ((__packed__)) NTFS_RECORD;/* * System files mft record numbers. All these files are always marked as used * in the bitmap attribute of the mft; presumably in order to avoid accidental * allocation for random other mft records. Also, the sequence number for each * of the system files is always equal to their mft record number and it is * never modified. */typedef enum {	FILE_MFT       = 0,	/* Master file table (mft). Data attribute				   contains the entries and bitmap attribute				   records which ones are in use (bit==1). */	FILE_MFTMirr   = 1,	/* Mft mirror: copy of first four mft records				   in data attribute. If cluster size > 4kiB,				   copy of first N mft records, with					N = cluster_size / mft_record_size. */	FILE_LogFile   = 2,	/* Journalling log in data attribute. */	FILE_Volume    = 3,	/* Volume name attribute and volume information				   attribute (flags and ntfs version). Windows				   refers to this file as volume DASD (Direct				   Access Storage Device). */	FILE_AttrDef   = 4,	/* Array of attribute definitions in data				   attribute. */	FILE_root      = 5,	/* Root directory. */	FILE_Bitmap    = 6,	/* Allocation bitmap of all clusters (lcns) in				   data attribute. */	FILE_Boot      = 7,	/* Boot sector (always at cluster 0) in data				   attribute. */	FILE_BadClus   = 8,	/* Contains all bad clusters in the non-resident				   data attribute. */	FILE_Secure    = 9,	/* Shared security descriptors in data attribute				   and two indexes into the descriptors.				   Appeared in Windows 2000. Before that, this				   file was named $Quota but was unused. */	FILE_UpCase    = 10,	/* Uppercase equivalents of all 65536 Unicode				   characters in data attribute. */	FILE_Extend    = 11,	/* Directory containing other system files (eg.				   $ObjId, $Quota, $Reparse and $UsnJrnl). This				   is new to NTFS3.0. */	FILE_reserved12 = 12,	/* Reserved for future use (records 12-15). */	FILE_reserved13 = 13,	FILE_reserved14 = 14,	FILE_reserved15 = 15,	FILE_first_user = 16,	/* First user file, used as test limit for				   whether to allow opening a file or not. */} NTFS_SYSTEM_FILES;/* * These are the so far known MFT_RECORD_* flags (16-bit) which contain * information about the mft record in which they are present. */enum {	MFT_RECORD_IN_USE	= const_cpu_to_le16(0x0001),	MFT_RECORD_IS_DIRECTORY = const_cpu_to_le16(0x0002),};typedef le16 MFT_RECORD_FLAGS;/* * mft references (aka file references or file record segment references) are * used whenever a structure needs to refer to a record in the mft. * * A reference consists of a 48-bit index into the mft and a 16-bit sequence * number used to detect stale references. * * For error reporting purposes we treat the 48-bit index as a signed quantity. * * The sequence number is a circular counter (skipping 0) describing how many * times the referenced mft record has been (re)used. This has to match the * sequence number of the mft record being referenced, otherwise the reference * is considered stale and removed (FIXME: only ntfsck or the driver itself?). * * If the sequence number is zero it is assumed that no sequence number * consistency checking should be performed. * * FIXME: Since inodes are 32-bit as of now, the driver needs to always check * for high_part being 0 and if not either BUG(), cause a panic() or handle * the situation in some other way. This shouldn't be a problem as a volume has * to become HUGE in order to need more than 32-bits worth of mft records. * Assuming the standard mft record size of 1kb only the records (never mind * the non-resident attributes, etc.) would require 4Tb of space on their own * for the first 32 bits worth of records. This is only if some strange person * doesn't decide to foul play and make the mft sparse which would be a really * horrible thing to do as it would trash our current driver implementation. )-: * Do I hear screams "we want 64-bit inodes!" ?!? (-; * * FIXME: The mft zone is defined as the first 12% of the volume. This space is * reserved so that the mft can grow contiguously and hence doesn't become * fragmented. Volume free space includes the empty part of the mft zone and * when the volume's free 88% are used up, the mft zone is shrunk by a factor * of 2, thus making more space available for more files/data. This process is * repeated everytime there is no more free space except for the mft zone until * there really is no more free space. *//* * Typedef the MFT_REF as a 64-bit value for easier handling. * Also define two unpacking macros to get to the reference (MREF) and * sequence number (MSEQNO) respectively. * The _LE versions are to be applied on little endian MFT_REFs. * Note: The _LE versions will return a CPU endian formatted value! */typedef enum {	MFT_REF_MASK_CPU	= 0x0000ffffffffffffULL,	MFT_REF_MASK_LE		= const_cpu_to_le64(0x0000ffffffffffffULL),} MFT_REF_CONSTS;typedef u64 MFT_REF;typedef le64 leMFT_REF;#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))

⌨️ 快捷键说明

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