162306a36Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0 262306a36Sopenharmony_ci 362306a36Sopenharmony_ciIndex Nodes 462306a36Sopenharmony_ci----------- 562306a36Sopenharmony_ci 662306a36Sopenharmony_ciIn a regular UNIX filesystem, the inode stores all the metadata 762306a36Sopenharmony_cipertaining to the file (time stamps, block maps, extended attributes, 862306a36Sopenharmony_cietc), not the directory entry. To find the information associated with a 962306a36Sopenharmony_cifile, one must traverse the directory files to find the directory entry 1062306a36Sopenharmony_ciassociated with a file, then load the inode to find the metadata for 1162306a36Sopenharmony_cithat file. ext4 appears to cheat (for performance reasons) a little bit 1262306a36Sopenharmony_ciby storing a copy of the file type (normally stored in the inode) in the 1362306a36Sopenharmony_cidirectory entry. (Compare all this to FAT, which stores all the file 1462306a36Sopenharmony_ciinformation directly in the directory entry, but does not support hard 1562306a36Sopenharmony_cilinks and is in general more seek-happy than ext4 due to its simpler 1662306a36Sopenharmony_ciblock allocator and extensive use of linked lists.) 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ciThe inode table is a linear array of ``struct ext4_inode``. The table is 1962306a36Sopenharmony_cisized to have enough blocks to store at least 2062306a36Sopenharmony_ci``sb.s_inode_size * sb.s_inodes_per_group`` bytes. The number of the 2162306a36Sopenharmony_ciblock group containing an inode can be calculated as 2262306a36Sopenharmony_ci``(inode_number - 1) / sb.s_inodes_per_group``, and the offset into the 2362306a36Sopenharmony_cigroup's table is ``(inode_number - 1) % sb.s_inodes_per_group``. There 2462306a36Sopenharmony_ciis no inode 0. 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ciThe inode checksum is calculated against the FS UUID, the inode number, 2762306a36Sopenharmony_ciand the inode structure itself. 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_ciThe inode table entry is laid out in ``struct ext4_inode``. 3062306a36Sopenharmony_ci 3162306a36Sopenharmony_ci.. list-table:: 3262306a36Sopenharmony_ci :widths: 8 8 24 40 3362306a36Sopenharmony_ci :header-rows: 1 3462306a36Sopenharmony_ci :class: longtable 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_ci * - Offset 3762306a36Sopenharmony_ci - Size 3862306a36Sopenharmony_ci - Name 3962306a36Sopenharmony_ci - Description 4062306a36Sopenharmony_ci * - 0x0 4162306a36Sopenharmony_ci - __le16 4262306a36Sopenharmony_ci - i_mode 4362306a36Sopenharmony_ci - File mode. See the table i_mode_ below. 4462306a36Sopenharmony_ci * - 0x2 4562306a36Sopenharmony_ci - __le16 4662306a36Sopenharmony_ci - i_uid 4762306a36Sopenharmony_ci - Lower 16-bits of Owner UID. 4862306a36Sopenharmony_ci * - 0x4 4962306a36Sopenharmony_ci - __le32 5062306a36Sopenharmony_ci - i_size_lo 5162306a36Sopenharmony_ci - Lower 32-bits of size in bytes. 5262306a36Sopenharmony_ci * - 0x8 5362306a36Sopenharmony_ci - __le32 5462306a36Sopenharmony_ci - i_atime 5562306a36Sopenharmony_ci - Last access time, in seconds since the epoch. However, if the EA_INODE 5662306a36Sopenharmony_ci inode flag is set, this inode stores an extended attribute value and 5762306a36Sopenharmony_ci this field contains the checksum of the value. 5862306a36Sopenharmony_ci * - 0xC 5962306a36Sopenharmony_ci - __le32 6062306a36Sopenharmony_ci - i_ctime 6162306a36Sopenharmony_ci - Last inode change time, in seconds since the epoch. However, if the 6262306a36Sopenharmony_ci EA_INODE inode flag is set, this inode stores an extended attribute 6362306a36Sopenharmony_ci value and this field contains the lower 32 bits of the attribute value's 6462306a36Sopenharmony_ci reference count. 6562306a36Sopenharmony_ci * - 0x10 6662306a36Sopenharmony_ci - __le32 6762306a36Sopenharmony_ci - i_mtime 6862306a36Sopenharmony_ci - Last data modification time, in seconds since the epoch. However, if the 6962306a36Sopenharmony_ci EA_INODE inode flag is set, this inode stores an extended attribute 7062306a36Sopenharmony_ci value and this field contains the number of the inode that owns the 7162306a36Sopenharmony_ci extended attribute. 7262306a36Sopenharmony_ci * - 0x14 7362306a36Sopenharmony_ci - __le32 7462306a36Sopenharmony_ci - i_dtime 7562306a36Sopenharmony_ci - Deletion Time, in seconds since the epoch. 7662306a36Sopenharmony_ci * - 0x18 7762306a36Sopenharmony_ci - __le16 7862306a36Sopenharmony_ci - i_gid 7962306a36Sopenharmony_ci - Lower 16-bits of GID. 8062306a36Sopenharmony_ci * - 0x1A 8162306a36Sopenharmony_ci - __le16 8262306a36Sopenharmony_ci - i_links_count 8362306a36Sopenharmony_ci - Hard link count. Normally, ext4 does not permit an inode to have more 8462306a36Sopenharmony_ci than 65,000 hard links. This applies to files as well as directories, 8562306a36Sopenharmony_ci which means that there cannot be more than 64,998 subdirectories in a 8662306a36Sopenharmony_ci directory (each subdirectory's '..' entry counts as a hard link, as does 8762306a36Sopenharmony_ci the '.' entry in the directory itself). With the DIR_NLINK feature 8862306a36Sopenharmony_ci enabled, ext4 supports more than 64,998 subdirectories by setting this 8962306a36Sopenharmony_ci field to 1 to indicate that the number of hard links is not known. 9062306a36Sopenharmony_ci * - 0x1C 9162306a36Sopenharmony_ci - __le32 9262306a36Sopenharmony_ci - i_blocks_lo 9362306a36Sopenharmony_ci - Lower 32-bits of “block” count. If the huge_file feature flag is not 9462306a36Sopenharmony_ci set on the filesystem, the file consumes ``i_blocks_lo`` 512-byte blocks 9562306a36Sopenharmony_ci on disk. If huge_file is set and EXT4_HUGE_FILE_FL is NOT set in 9662306a36Sopenharmony_ci ``inode.i_flags``, then the file consumes ``i_blocks_lo + (i_blocks_hi 9762306a36Sopenharmony_ci << 32)`` 512-byte blocks on disk. If huge_file is set and 9862306a36Sopenharmony_ci EXT4_HUGE_FILE_FL IS set in ``inode.i_flags``, then this file 9962306a36Sopenharmony_ci consumes (``i_blocks_lo + i_blocks_hi`` << 32) filesystem blocks on 10062306a36Sopenharmony_ci disk. 10162306a36Sopenharmony_ci * - 0x20 10262306a36Sopenharmony_ci - __le32 10362306a36Sopenharmony_ci - i_flags 10462306a36Sopenharmony_ci - Inode flags. See the table i_flags_ below. 10562306a36Sopenharmony_ci * - 0x24 10662306a36Sopenharmony_ci - 4 bytes 10762306a36Sopenharmony_ci - i_osd1 10862306a36Sopenharmony_ci - See the table i_osd1_ for more details. 10962306a36Sopenharmony_ci * - 0x28 11062306a36Sopenharmony_ci - 60 bytes 11162306a36Sopenharmony_ci - i_block[EXT4_N_BLOCKS=15] 11262306a36Sopenharmony_ci - Block map or extent tree. See the section “The Contents of inode.i_block”. 11362306a36Sopenharmony_ci * - 0x64 11462306a36Sopenharmony_ci - __le32 11562306a36Sopenharmony_ci - i_generation 11662306a36Sopenharmony_ci - File version (for NFS). 11762306a36Sopenharmony_ci * - 0x68 11862306a36Sopenharmony_ci - __le32 11962306a36Sopenharmony_ci - i_file_acl_lo 12062306a36Sopenharmony_ci - Lower 32-bits of extended attribute block. ACLs are of course one of 12162306a36Sopenharmony_ci many possible extended attributes; I think the name of this field is a 12262306a36Sopenharmony_ci result of the first use of extended attributes being for ACLs. 12362306a36Sopenharmony_ci * - 0x6C 12462306a36Sopenharmony_ci - __le32 12562306a36Sopenharmony_ci - i_size_high / i_dir_acl 12662306a36Sopenharmony_ci - Upper 32-bits of file/directory size. In ext2/3 this field was named 12762306a36Sopenharmony_ci i_dir_acl, though it was usually set to zero and never used. 12862306a36Sopenharmony_ci * - 0x70 12962306a36Sopenharmony_ci - __le32 13062306a36Sopenharmony_ci - i_obso_faddr 13162306a36Sopenharmony_ci - (Obsolete) fragment address. 13262306a36Sopenharmony_ci * - 0x74 13362306a36Sopenharmony_ci - 12 bytes 13462306a36Sopenharmony_ci - i_osd2 13562306a36Sopenharmony_ci - See the table i_osd2_ for more details. 13662306a36Sopenharmony_ci * - 0x80 13762306a36Sopenharmony_ci - __le16 13862306a36Sopenharmony_ci - i_extra_isize 13962306a36Sopenharmony_ci - Size of this inode - 128. Alternately, the size of the extended inode 14062306a36Sopenharmony_ci fields beyond the original ext2 inode, including this field. 14162306a36Sopenharmony_ci * - 0x82 14262306a36Sopenharmony_ci - __le16 14362306a36Sopenharmony_ci - i_checksum_hi 14462306a36Sopenharmony_ci - Upper 16-bits of the inode checksum. 14562306a36Sopenharmony_ci * - 0x84 14662306a36Sopenharmony_ci - __le32 14762306a36Sopenharmony_ci - i_ctime_extra 14862306a36Sopenharmony_ci - Extra change time bits. This provides sub-second precision. See Inode 14962306a36Sopenharmony_ci Timestamps section. 15062306a36Sopenharmony_ci * - 0x88 15162306a36Sopenharmony_ci - __le32 15262306a36Sopenharmony_ci - i_mtime_extra 15362306a36Sopenharmony_ci - Extra modification time bits. This provides sub-second precision. 15462306a36Sopenharmony_ci * - 0x8C 15562306a36Sopenharmony_ci - __le32 15662306a36Sopenharmony_ci - i_atime_extra 15762306a36Sopenharmony_ci - Extra access time bits. This provides sub-second precision. 15862306a36Sopenharmony_ci * - 0x90 15962306a36Sopenharmony_ci - __le32 16062306a36Sopenharmony_ci - i_crtime 16162306a36Sopenharmony_ci - File creation time, in seconds since the epoch. 16262306a36Sopenharmony_ci * - 0x94 16362306a36Sopenharmony_ci - __le32 16462306a36Sopenharmony_ci - i_crtime_extra 16562306a36Sopenharmony_ci - Extra file creation time bits. This provides sub-second precision. 16662306a36Sopenharmony_ci * - 0x98 16762306a36Sopenharmony_ci - __le32 16862306a36Sopenharmony_ci - i_version_hi 16962306a36Sopenharmony_ci - Upper 32-bits for version number. 17062306a36Sopenharmony_ci * - 0x9C 17162306a36Sopenharmony_ci - __le32 17262306a36Sopenharmony_ci - i_projid 17362306a36Sopenharmony_ci - Project ID. 17462306a36Sopenharmony_ci 17562306a36Sopenharmony_ci.. _i_mode: 17662306a36Sopenharmony_ci 17762306a36Sopenharmony_ciThe ``i_mode`` value is a combination of the following flags: 17862306a36Sopenharmony_ci 17962306a36Sopenharmony_ci.. list-table:: 18062306a36Sopenharmony_ci :widths: 16 64 18162306a36Sopenharmony_ci :header-rows: 1 18262306a36Sopenharmony_ci 18362306a36Sopenharmony_ci * - Value 18462306a36Sopenharmony_ci - Description 18562306a36Sopenharmony_ci * - 0x1 18662306a36Sopenharmony_ci - S_IXOTH (Others may execute) 18762306a36Sopenharmony_ci * - 0x2 18862306a36Sopenharmony_ci - S_IWOTH (Others may write) 18962306a36Sopenharmony_ci * - 0x4 19062306a36Sopenharmony_ci - S_IROTH (Others may read) 19162306a36Sopenharmony_ci * - 0x8 19262306a36Sopenharmony_ci - S_IXGRP (Group members may execute) 19362306a36Sopenharmony_ci * - 0x10 19462306a36Sopenharmony_ci - S_IWGRP (Group members may write) 19562306a36Sopenharmony_ci * - 0x20 19662306a36Sopenharmony_ci - S_IRGRP (Group members may read) 19762306a36Sopenharmony_ci * - 0x40 19862306a36Sopenharmony_ci - S_IXUSR (Owner may execute) 19962306a36Sopenharmony_ci * - 0x80 20062306a36Sopenharmony_ci - S_IWUSR (Owner may write) 20162306a36Sopenharmony_ci * - 0x100 20262306a36Sopenharmony_ci - S_IRUSR (Owner may read) 20362306a36Sopenharmony_ci * - 0x200 20462306a36Sopenharmony_ci - S_ISVTX (Sticky bit) 20562306a36Sopenharmony_ci * - 0x400 20662306a36Sopenharmony_ci - S_ISGID (Set GID) 20762306a36Sopenharmony_ci * - 0x800 20862306a36Sopenharmony_ci - S_ISUID (Set UID) 20962306a36Sopenharmony_ci * - 21062306a36Sopenharmony_ci - These are mutually-exclusive file types: 21162306a36Sopenharmony_ci * - 0x1000 21262306a36Sopenharmony_ci - S_IFIFO (FIFO) 21362306a36Sopenharmony_ci * - 0x2000 21462306a36Sopenharmony_ci - S_IFCHR (Character device) 21562306a36Sopenharmony_ci * - 0x4000 21662306a36Sopenharmony_ci - S_IFDIR (Directory) 21762306a36Sopenharmony_ci * - 0x6000 21862306a36Sopenharmony_ci - S_IFBLK (Block device) 21962306a36Sopenharmony_ci * - 0x8000 22062306a36Sopenharmony_ci - S_IFREG (Regular file) 22162306a36Sopenharmony_ci * - 0xA000 22262306a36Sopenharmony_ci - S_IFLNK (Symbolic link) 22362306a36Sopenharmony_ci * - 0xC000 22462306a36Sopenharmony_ci - S_IFSOCK (Socket) 22562306a36Sopenharmony_ci 22662306a36Sopenharmony_ci.. _i_flags: 22762306a36Sopenharmony_ci 22862306a36Sopenharmony_ciThe ``i_flags`` field is a combination of these values: 22962306a36Sopenharmony_ci 23062306a36Sopenharmony_ci.. list-table:: 23162306a36Sopenharmony_ci :widths: 16 64 23262306a36Sopenharmony_ci :header-rows: 1 23362306a36Sopenharmony_ci 23462306a36Sopenharmony_ci * - Value 23562306a36Sopenharmony_ci - Description 23662306a36Sopenharmony_ci * - 0x1 23762306a36Sopenharmony_ci - This file requires secure deletion (EXT4_SECRM_FL). (not implemented) 23862306a36Sopenharmony_ci * - 0x2 23962306a36Sopenharmony_ci - This file should be preserved, should undeletion be desired 24062306a36Sopenharmony_ci (EXT4_UNRM_FL). (not implemented) 24162306a36Sopenharmony_ci * - 0x4 24262306a36Sopenharmony_ci - File is compressed (EXT4_COMPR_FL). (not really implemented) 24362306a36Sopenharmony_ci * - 0x8 24462306a36Sopenharmony_ci - All writes to the file must be synchronous (EXT4_SYNC_FL). 24562306a36Sopenharmony_ci * - 0x10 24662306a36Sopenharmony_ci - File is immutable (EXT4_IMMUTABLE_FL). 24762306a36Sopenharmony_ci * - 0x20 24862306a36Sopenharmony_ci - File can only be appended (EXT4_APPEND_FL). 24962306a36Sopenharmony_ci * - 0x40 25062306a36Sopenharmony_ci - The dump(1) utility should not dump this file (EXT4_NODUMP_FL). 25162306a36Sopenharmony_ci * - 0x80 25262306a36Sopenharmony_ci - Do not update access time (EXT4_NOATIME_FL). 25362306a36Sopenharmony_ci * - 0x100 25462306a36Sopenharmony_ci - Dirty compressed file (EXT4_DIRTY_FL). (not used) 25562306a36Sopenharmony_ci * - 0x200 25662306a36Sopenharmony_ci - File has one or more compressed clusters (EXT4_COMPRBLK_FL). (not used) 25762306a36Sopenharmony_ci * - 0x400 25862306a36Sopenharmony_ci - Do not compress file (EXT4_NOCOMPR_FL). (not used) 25962306a36Sopenharmony_ci * - 0x800 26062306a36Sopenharmony_ci - Encrypted inode (EXT4_ENCRYPT_FL). This bit value previously was 26162306a36Sopenharmony_ci EXT4_ECOMPR_FL (compression error), which was never used. 26262306a36Sopenharmony_ci * - 0x1000 26362306a36Sopenharmony_ci - Directory has hashed indexes (EXT4_INDEX_FL). 26462306a36Sopenharmony_ci * - 0x2000 26562306a36Sopenharmony_ci - AFS magic directory (EXT4_IMAGIC_FL). 26662306a36Sopenharmony_ci * - 0x4000 26762306a36Sopenharmony_ci - File data must always be written through the journal 26862306a36Sopenharmony_ci (EXT4_JOURNAL_DATA_FL). 26962306a36Sopenharmony_ci * - 0x8000 27062306a36Sopenharmony_ci - File tail should not be merged (EXT4_NOTAIL_FL). (not used by ext4) 27162306a36Sopenharmony_ci * - 0x10000 27262306a36Sopenharmony_ci - All directory entry data should be written synchronously (see 27362306a36Sopenharmony_ci ``dirsync``) (EXT4_DIRSYNC_FL). 27462306a36Sopenharmony_ci * - 0x20000 27562306a36Sopenharmony_ci - Top of directory hierarchy (EXT4_TOPDIR_FL). 27662306a36Sopenharmony_ci * - 0x40000 27762306a36Sopenharmony_ci - This is a huge file (EXT4_HUGE_FILE_FL). 27862306a36Sopenharmony_ci * - 0x80000 27962306a36Sopenharmony_ci - Inode uses extents (EXT4_EXTENTS_FL). 28062306a36Sopenharmony_ci * - 0x100000 28162306a36Sopenharmony_ci - Verity protected file (EXT4_VERITY_FL). 28262306a36Sopenharmony_ci * - 0x200000 28362306a36Sopenharmony_ci - Inode stores a large extended attribute value in its data blocks 28462306a36Sopenharmony_ci (EXT4_EA_INODE_FL). 28562306a36Sopenharmony_ci * - 0x400000 28662306a36Sopenharmony_ci - This file has blocks allocated past EOF (EXT4_EOFBLOCKS_FL). 28762306a36Sopenharmony_ci (deprecated) 28862306a36Sopenharmony_ci * - 0x01000000 28962306a36Sopenharmony_ci - Inode is a snapshot (``EXT4_SNAPFILE_FL``). (not in mainline) 29062306a36Sopenharmony_ci * - 0x04000000 29162306a36Sopenharmony_ci - Snapshot is being deleted (``EXT4_SNAPFILE_DELETED_FL``). (not in 29262306a36Sopenharmony_ci mainline) 29362306a36Sopenharmony_ci * - 0x08000000 29462306a36Sopenharmony_ci - Snapshot shrink has completed (``EXT4_SNAPFILE_SHRUNK_FL``). (not in 29562306a36Sopenharmony_ci mainline) 29662306a36Sopenharmony_ci * - 0x10000000 29762306a36Sopenharmony_ci - Inode has inline data (EXT4_INLINE_DATA_FL). 29862306a36Sopenharmony_ci * - 0x20000000 29962306a36Sopenharmony_ci - Create children with the same project ID (EXT4_PROJINHERIT_FL). 30062306a36Sopenharmony_ci * - 0x80000000 30162306a36Sopenharmony_ci - Reserved for ext4 library (EXT4_RESERVED_FL). 30262306a36Sopenharmony_ci * - 30362306a36Sopenharmony_ci - Aggregate flags: 30462306a36Sopenharmony_ci * - 0x705BDFFF 30562306a36Sopenharmony_ci - User-visible flags. 30662306a36Sopenharmony_ci * - 0x604BC0FF 30762306a36Sopenharmony_ci - User-modifiable flags. Note that while EXT4_JOURNAL_DATA_FL and 30862306a36Sopenharmony_ci EXT4_EXTENTS_FL can be set with setattr, they are not in the kernel's 30962306a36Sopenharmony_ci EXT4_FL_USER_MODIFIABLE mask, since it needs to handle the setting of 31062306a36Sopenharmony_ci these flags in a special manner and they are masked out of the set of 31162306a36Sopenharmony_ci flags that are saved directly to i_flags. 31262306a36Sopenharmony_ci 31362306a36Sopenharmony_ci.. _i_osd1: 31462306a36Sopenharmony_ci 31562306a36Sopenharmony_ciThe ``osd1`` field has multiple meanings depending on the creator: 31662306a36Sopenharmony_ci 31762306a36Sopenharmony_ciLinux: 31862306a36Sopenharmony_ci 31962306a36Sopenharmony_ci.. list-table:: 32062306a36Sopenharmony_ci :widths: 8 8 24 40 32162306a36Sopenharmony_ci :header-rows: 1 32262306a36Sopenharmony_ci 32362306a36Sopenharmony_ci * - Offset 32462306a36Sopenharmony_ci - Size 32562306a36Sopenharmony_ci - Name 32662306a36Sopenharmony_ci - Description 32762306a36Sopenharmony_ci * - 0x0 32862306a36Sopenharmony_ci - __le32 32962306a36Sopenharmony_ci - l_i_version 33062306a36Sopenharmony_ci - Inode version. However, if the EA_INODE inode flag is set, this inode 33162306a36Sopenharmony_ci stores an extended attribute value and this field contains the upper 32 33262306a36Sopenharmony_ci bits of the attribute value's reference count. 33362306a36Sopenharmony_ci 33462306a36Sopenharmony_ciHurd: 33562306a36Sopenharmony_ci 33662306a36Sopenharmony_ci.. list-table:: 33762306a36Sopenharmony_ci :widths: 8 8 24 40 33862306a36Sopenharmony_ci :header-rows: 1 33962306a36Sopenharmony_ci 34062306a36Sopenharmony_ci * - Offset 34162306a36Sopenharmony_ci - Size 34262306a36Sopenharmony_ci - Name 34362306a36Sopenharmony_ci - Description 34462306a36Sopenharmony_ci * - 0x0 34562306a36Sopenharmony_ci - __le32 34662306a36Sopenharmony_ci - h_i_translator 34762306a36Sopenharmony_ci - ?? 34862306a36Sopenharmony_ci 34962306a36Sopenharmony_ciMasix: 35062306a36Sopenharmony_ci 35162306a36Sopenharmony_ci.. list-table:: 35262306a36Sopenharmony_ci :widths: 8 8 24 40 35362306a36Sopenharmony_ci :header-rows: 1 35462306a36Sopenharmony_ci 35562306a36Sopenharmony_ci * - Offset 35662306a36Sopenharmony_ci - Size 35762306a36Sopenharmony_ci - Name 35862306a36Sopenharmony_ci - Description 35962306a36Sopenharmony_ci * - 0x0 36062306a36Sopenharmony_ci - __le32 36162306a36Sopenharmony_ci - m_i_reserved 36262306a36Sopenharmony_ci - ?? 36362306a36Sopenharmony_ci 36462306a36Sopenharmony_ci.. _i_osd2: 36562306a36Sopenharmony_ci 36662306a36Sopenharmony_ciThe ``osd2`` field has multiple meanings depending on the filesystem creator: 36762306a36Sopenharmony_ci 36862306a36Sopenharmony_ciLinux: 36962306a36Sopenharmony_ci 37062306a36Sopenharmony_ci.. list-table:: 37162306a36Sopenharmony_ci :widths: 8 8 24 40 37262306a36Sopenharmony_ci :header-rows: 1 37362306a36Sopenharmony_ci 37462306a36Sopenharmony_ci * - Offset 37562306a36Sopenharmony_ci - Size 37662306a36Sopenharmony_ci - Name 37762306a36Sopenharmony_ci - Description 37862306a36Sopenharmony_ci * - 0x0 37962306a36Sopenharmony_ci - __le16 38062306a36Sopenharmony_ci - l_i_blocks_high 38162306a36Sopenharmony_ci - Upper 16-bits of the block count. Please see the note attached to 38262306a36Sopenharmony_ci i_blocks_lo. 38362306a36Sopenharmony_ci * - 0x2 38462306a36Sopenharmony_ci - __le16 38562306a36Sopenharmony_ci - l_i_file_acl_high 38662306a36Sopenharmony_ci - Upper 16-bits of the extended attribute block (historically, the file 38762306a36Sopenharmony_ci ACL location). See the Extended Attributes section below. 38862306a36Sopenharmony_ci * - 0x4 38962306a36Sopenharmony_ci - __le16 39062306a36Sopenharmony_ci - l_i_uid_high 39162306a36Sopenharmony_ci - Upper 16-bits of the Owner UID. 39262306a36Sopenharmony_ci * - 0x6 39362306a36Sopenharmony_ci - __le16 39462306a36Sopenharmony_ci - l_i_gid_high 39562306a36Sopenharmony_ci - Upper 16-bits of the GID. 39662306a36Sopenharmony_ci * - 0x8 39762306a36Sopenharmony_ci - __le16 39862306a36Sopenharmony_ci - l_i_checksum_lo 39962306a36Sopenharmony_ci - Lower 16-bits of the inode checksum. 40062306a36Sopenharmony_ci * - 0xA 40162306a36Sopenharmony_ci - __le16 40262306a36Sopenharmony_ci - l_i_reserved 40362306a36Sopenharmony_ci - Unused. 40462306a36Sopenharmony_ci 40562306a36Sopenharmony_ciHurd: 40662306a36Sopenharmony_ci 40762306a36Sopenharmony_ci.. list-table:: 40862306a36Sopenharmony_ci :widths: 8 8 24 40 40962306a36Sopenharmony_ci :header-rows: 1 41062306a36Sopenharmony_ci 41162306a36Sopenharmony_ci * - Offset 41262306a36Sopenharmony_ci - Size 41362306a36Sopenharmony_ci - Name 41462306a36Sopenharmony_ci - Description 41562306a36Sopenharmony_ci * - 0x0 41662306a36Sopenharmony_ci - __le16 41762306a36Sopenharmony_ci - h_i_reserved1 41862306a36Sopenharmony_ci - ?? 41962306a36Sopenharmony_ci * - 0x2 42062306a36Sopenharmony_ci - __u16 42162306a36Sopenharmony_ci - h_i_mode_high 42262306a36Sopenharmony_ci - Upper 16-bits of the file mode. 42362306a36Sopenharmony_ci * - 0x4 42462306a36Sopenharmony_ci - __le16 42562306a36Sopenharmony_ci - h_i_uid_high 42662306a36Sopenharmony_ci - Upper 16-bits of the Owner UID. 42762306a36Sopenharmony_ci * - 0x6 42862306a36Sopenharmony_ci - __le16 42962306a36Sopenharmony_ci - h_i_gid_high 43062306a36Sopenharmony_ci - Upper 16-bits of the GID. 43162306a36Sopenharmony_ci * - 0x8 43262306a36Sopenharmony_ci - __u32 43362306a36Sopenharmony_ci - h_i_author 43462306a36Sopenharmony_ci - Author code? 43562306a36Sopenharmony_ci 43662306a36Sopenharmony_ciMasix: 43762306a36Sopenharmony_ci 43862306a36Sopenharmony_ci.. list-table:: 43962306a36Sopenharmony_ci :widths: 8 8 24 40 44062306a36Sopenharmony_ci :header-rows: 1 44162306a36Sopenharmony_ci 44262306a36Sopenharmony_ci * - Offset 44362306a36Sopenharmony_ci - Size 44462306a36Sopenharmony_ci - Name 44562306a36Sopenharmony_ci - Description 44662306a36Sopenharmony_ci * - 0x0 44762306a36Sopenharmony_ci - __le16 44862306a36Sopenharmony_ci - h_i_reserved1 44962306a36Sopenharmony_ci - ?? 45062306a36Sopenharmony_ci * - 0x2 45162306a36Sopenharmony_ci - __u16 45262306a36Sopenharmony_ci - m_i_file_acl_high 45362306a36Sopenharmony_ci - Upper 16-bits of the extended attribute block (historically, the file 45462306a36Sopenharmony_ci ACL location). 45562306a36Sopenharmony_ci * - 0x4 45662306a36Sopenharmony_ci - __u32 45762306a36Sopenharmony_ci - m_i_reserved2[2] 45862306a36Sopenharmony_ci - ?? 45962306a36Sopenharmony_ci 46062306a36Sopenharmony_ciInode Size 46162306a36Sopenharmony_ci~~~~~~~~~~ 46262306a36Sopenharmony_ci 46362306a36Sopenharmony_ciIn ext2 and ext3, the inode structure size was fixed at 128 bytes 46462306a36Sopenharmony_ci(``EXT2_GOOD_OLD_INODE_SIZE``) and each inode had a disk record size of 46562306a36Sopenharmony_ci128 bytes. Starting with ext4, it is possible to allocate a larger 46662306a36Sopenharmony_cion-disk inode at format time for all inodes in the filesystem to provide 46762306a36Sopenharmony_cispace beyond the end of the original ext2 inode. The on-disk inode 46862306a36Sopenharmony_cirecord size is recorded in the superblock as ``s_inode_size``. The 46962306a36Sopenharmony_cinumber of bytes actually used by struct ext4_inode beyond the original 47062306a36Sopenharmony_ci128-byte ext2 inode is recorded in the ``i_extra_isize`` field for each 47162306a36Sopenharmony_ciinode, which allows struct ext4_inode to grow for a new kernel without 47262306a36Sopenharmony_cihaving to upgrade all of the on-disk inodes. Access to fields beyond 47362306a36Sopenharmony_ciEXT2_GOOD_OLD_INODE_SIZE should be verified to be within 47462306a36Sopenharmony_ci``i_extra_isize``. By default, ext4 inode records are 256 bytes, and (as 47562306a36Sopenharmony_ciof August 2019) the inode structure is 160 bytes 47662306a36Sopenharmony_ci(``i_extra_isize = 32``). The extra space between the end of the inode 47762306a36Sopenharmony_cistructure and the end of the inode record can be used to store extended 47862306a36Sopenharmony_ciattributes. Each inode record can be as large as the filesystem block 47962306a36Sopenharmony_cisize, though this is not terribly efficient. 48062306a36Sopenharmony_ci 48162306a36Sopenharmony_ciFinding an Inode 48262306a36Sopenharmony_ci~~~~~~~~~~~~~~~~ 48362306a36Sopenharmony_ci 48462306a36Sopenharmony_ciEach block group contains ``sb->s_inodes_per_group`` inodes. Because 48562306a36Sopenharmony_ciinode 0 is defined not to exist, this formula can be used to find the 48662306a36Sopenharmony_ciblock group that an inode lives in: 48762306a36Sopenharmony_ci``bg = (inode_num - 1) / sb->s_inodes_per_group``. The particular inode 48862306a36Sopenharmony_cican be found within the block group's inode table at 48962306a36Sopenharmony_ci``index = (inode_num - 1) % sb->s_inodes_per_group``. To get the byte 49062306a36Sopenharmony_ciaddress within the inode table, use 49162306a36Sopenharmony_ci``offset = index * sb->s_inode_size``. 49262306a36Sopenharmony_ci 49362306a36Sopenharmony_ciInode Timestamps 49462306a36Sopenharmony_ci~~~~~~~~~~~~~~~~ 49562306a36Sopenharmony_ci 49662306a36Sopenharmony_ciFour timestamps are recorded in the lower 128 bytes of the inode 49762306a36Sopenharmony_cistructure -- inode change time (ctime), access time (atime), data 49862306a36Sopenharmony_cimodification time (mtime), and deletion time (dtime). The four fields 49962306a36Sopenharmony_ciare 32-bit signed integers that represent seconds since the Unix epoch 50062306a36Sopenharmony_ci(1970-01-01 00:00:00 GMT), which means that the fields will overflow in 50162306a36Sopenharmony_ciJanuary 2038. If the filesystem does not have orphan_file feature, inodes 50262306a36Sopenharmony_cithat are not linked from any directory but are still open (orphan inodes) have 50362306a36Sopenharmony_cithe dtime field overloaded for use with the orphan list. The superblock field 50462306a36Sopenharmony_ci``s_last_orphan`` points to the first inode in the orphan list; dtime is then 50562306a36Sopenharmony_cithe number of the next orphaned inode, or zero if there are no more orphans. 50662306a36Sopenharmony_ci 50762306a36Sopenharmony_ciIf the inode structure size ``sb->s_inode_size`` is larger than 128 50862306a36Sopenharmony_cibytes and the ``i_inode_extra`` field is large enough to encompass the 50962306a36Sopenharmony_cirespective ``i_[cma]time_extra`` field, the ctime, atime, and mtime 51062306a36Sopenharmony_ciinode fields are widened to 64 bits. Within this “extra” 32-bit field, 51162306a36Sopenharmony_cithe lower two bits are used to extend the 32-bit seconds field to be 34 51262306a36Sopenharmony_cibit wide; the upper 30 bits are used to provide nanosecond timestamp 51362306a36Sopenharmony_ciaccuracy. Therefore, timestamps should not overflow until May 2446. 51462306a36Sopenharmony_cidtime was not widened. There is also a fifth timestamp to record inode 51562306a36Sopenharmony_cicreation time (crtime); this field is 64-bits wide and decoded in the 51662306a36Sopenharmony_cisame manner as 64-bit [cma]time. Neither crtime nor dtime are accessible 51762306a36Sopenharmony_cithrough the regular stat() interface, though debugfs will report them. 51862306a36Sopenharmony_ci 51962306a36Sopenharmony_ciWe use the 32-bit signed time value plus (2^32 * (extra epoch bits)). 52062306a36Sopenharmony_ciIn other words: 52162306a36Sopenharmony_ci 52262306a36Sopenharmony_ci.. list-table:: 52362306a36Sopenharmony_ci :widths: 20 20 20 20 20 52462306a36Sopenharmony_ci :header-rows: 1 52562306a36Sopenharmony_ci 52662306a36Sopenharmony_ci * - Extra epoch bits 52762306a36Sopenharmony_ci - MSB of 32-bit time 52862306a36Sopenharmony_ci - Adjustment for signed 32-bit to 64-bit tv_sec 52962306a36Sopenharmony_ci - Decoded 64-bit tv_sec 53062306a36Sopenharmony_ci - valid time range 53162306a36Sopenharmony_ci * - 0 0 53262306a36Sopenharmony_ci - 1 53362306a36Sopenharmony_ci - 0 53462306a36Sopenharmony_ci - ``-0x80000000 - -0x00000001`` 53562306a36Sopenharmony_ci - 1901-12-13 to 1969-12-31 53662306a36Sopenharmony_ci * - 0 0 53762306a36Sopenharmony_ci - 0 53862306a36Sopenharmony_ci - 0 53962306a36Sopenharmony_ci - ``0x000000000 - 0x07fffffff`` 54062306a36Sopenharmony_ci - 1970-01-01 to 2038-01-19 54162306a36Sopenharmony_ci * - 0 1 54262306a36Sopenharmony_ci - 1 54362306a36Sopenharmony_ci - 0x100000000 54462306a36Sopenharmony_ci - ``0x080000000 - 0x0ffffffff`` 54562306a36Sopenharmony_ci - 2038-01-19 to 2106-02-07 54662306a36Sopenharmony_ci * - 0 1 54762306a36Sopenharmony_ci - 0 54862306a36Sopenharmony_ci - 0x100000000 54962306a36Sopenharmony_ci - ``0x100000000 - 0x17fffffff`` 55062306a36Sopenharmony_ci - 2106-02-07 to 2174-02-25 55162306a36Sopenharmony_ci * - 1 0 55262306a36Sopenharmony_ci - 1 55362306a36Sopenharmony_ci - 0x200000000 55462306a36Sopenharmony_ci - ``0x180000000 - 0x1ffffffff`` 55562306a36Sopenharmony_ci - 2174-02-25 to 2242-03-16 55662306a36Sopenharmony_ci * - 1 0 55762306a36Sopenharmony_ci - 0 55862306a36Sopenharmony_ci - 0x200000000 55962306a36Sopenharmony_ci - ``0x200000000 - 0x27fffffff`` 56062306a36Sopenharmony_ci - 2242-03-16 to 2310-04-04 56162306a36Sopenharmony_ci * - 1 1 56262306a36Sopenharmony_ci - 1 56362306a36Sopenharmony_ci - 0x300000000 56462306a36Sopenharmony_ci - ``0x280000000 - 0x2ffffffff`` 56562306a36Sopenharmony_ci - 2310-04-04 to 2378-04-22 56662306a36Sopenharmony_ci * - 1 1 56762306a36Sopenharmony_ci - 0 56862306a36Sopenharmony_ci - 0x300000000 56962306a36Sopenharmony_ci - ``0x300000000 - 0x37fffffff`` 57062306a36Sopenharmony_ci - 2378-04-22 to 2446-05-10 57162306a36Sopenharmony_ci 57262306a36Sopenharmony_ciThis is a somewhat odd encoding since there are effectively seven times 57362306a36Sopenharmony_cias many positive values as negative values. There have also been 57462306a36Sopenharmony_cilong-standing bugs decoding and encoding dates beyond 2038, which don't 57562306a36Sopenharmony_ciseem to be fixed as of kernel 3.12 and e2fsprogs 1.42.8. 64-bit kernels 57662306a36Sopenharmony_ciincorrectly use the extra epoch bits 1,1 for dates between 1901 and 57762306a36Sopenharmony_ci1970. At some point the kernel will be fixed and e2fsck will fix this 57862306a36Sopenharmony_cisituation, assuming that it is run before 2310. 579