fs/ntfs/layout.h

Source file repositories/reference/linux-study-clean/fs/ntfs/layout.h

File Facts

System
Linux kernel
Corpus path
fs/ntfs/layout.h
Extension
.h
Size
99154 bytes
Lines
2366
Domain
Core OS
Bucket
VFS And Filesystem Core
Inferred role
Core OS: implementation source
Status
source implementation candidate

Why This File Exists

Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.

Dependency Surface

Detected Declarations

Annotated Snippet

struct bios_parameter_block {
	__le16 bytes_per_sector;
	u8 sectors_per_cluster;
	__le16 reserved_sectors;
	u8 fats;
	__le16 root_entries;
	__le16 sectors;
	u8 media_type;
	__le16 sectors_per_fat;
	__le16 sectors_per_track;
	__le16 heads;
	__le32 hidden_sectors;
	__le32 large_sectors;
} __packed;

/*
 * NTFS boot sector structure.
 *
 * @jump:               3-byte jump instruction to boot code (irrelevant for NTFS).
 *                      Typically 0xEB 0x52 0x90 or similar.
 * @oem_id:             OEM identifier string (8 bytes).
 *                      Always "NTFS    " (with trailing spaces) in NTFS volumes.
 * @bpb:                Legacy BIOS Parameter Block (see struct bios_parameter_block).
 *                      Mostly zeroed or set to fixed values for NTFS compatibility.
 * @unused:             4 bytes, reserved/unused.
 *                      NTFS disk editors show it as:
 *                        - physical_drive (0x80 for fixed disk)
 *                        - current_head (0)
 *                        - extended_boot_signature (0x80 or 0x28)
 *                        - unused (0)
 *                      Always zero in practice for NTFS.
 * @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. (-;
 * @mft_lcn:            Logical cluster number (LCN) of the $MFT data attribute.
 *                      Location of the Master File Table.
 * @mftmirr_lcn:        LCN of the $MFTMirr (first 3-4 MFT records copy).
 *                      Mirror for boot-time recovery.
 * @clusters_per_mft_record:
 *                      Size of each MFT record in clusters.
 * @reserved0:          3 bytes, reserved/zero.
 * @clusters_per_index_record:
 *                      Size of each index block/record in clusters.
 * @reserved1:          3 bytes, reserved/zero.
 * @volume_serial_number:
 *                      64-bit volume serial number.
 *                      Used for identification (irrelevant for NTFS operation).
 * @checksum:           32-bit checksum of the boot sector (excluding this field).
 *                      Used to detect boot sector corruption.
 * @bootstrap:          426 bytes of bootstrap code.
 *                      Irrelevant for NTFS (contains x86 boot loader stub).
 * @end_of_sector_marker:
 *                      2-byte end-of-sector signature.
 *                      Always 0xAA55 (little-endian magic number).
 */
struct ntfs_boot_sector {
	u8 jump[3];
	__le64 oem_id;
	struct bios_parameter_block bpb;
	u8 unused[4];
	__le64 number_of_sectors;
	__le64 mft_lcn;
	__le64 mftmirr_lcn;
	s8 clusters_per_mft_record;
	u8 reserved0[3];
	s8 clusters_per_index_record;
	u8 reserved1[3];
	__le64 volume_serial_number;
	__le32 checksum;
	u8 bootstrap[426];
	__le16 end_of_sector_marker;
} __packed;

static_assert(sizeof(struct ntfs_boot_sector) == 512);

/*
 * Magic identifiers present at the beginning of all ntfs record containing
 * records (like mft records for example).
 *
 * magic_FILE:      MFT entry header ("FILE" in ASCII).
 *                  Used in $MFT/$DATA for all master file table records.
 * magic_INDX:      Index buffer header ("INDX" in ASCII).
 *                  Used in $INDEX_ALLOCATION attributes (directories, $I30 indexes).
 * magic_HOLE:      Hole marker ("HOLE" in ASCII).
 *                  Introduced in NTFS 3.0+, used for sparse/hole regions in some contexts.
 * magic_RSTR:      Restart page header ("RSTR" in ASCII).
 *                  Used in LogFile for restart pages (transaction log recovery).
 * magic_RCRD:      Log record page header ("RCRD" in ASCII).
 *                  Used in LogFile for individual log record pages.

Annotation

Implementation Notes