RFC: "file" magic for ext4
This seems to work fine; any comments, either about the logic, or the text descriptions, or the various options I've shown/not shown?
To test, copy your "magic" file somewhere local, replace the ext2/3 section with the following, and do something like:
# file -C -m magic; file -m ./magic -s /dev/sda1
-Eric
# ext2/ext3 filesystems - Andreas Dilger <[email protected]> 0x438 leshort 0xEF53 Linux
Quoted 2 lines
0x44c lelong x rev %d 0x43e leshort x \b.%d
# No journal? ext2
Quoted 2 lines
0x45c lelong ^0x0000004 ext2 filesystem data >0x43a leshort ^0x0000001 (mounted or unclean)
# Has a journal? ext3 or ext4
Quoted 1 line
0x45clelong &0x0000004
# and small INCOMPAT?
Quoted 1 line
Quoted 1 line
0x460lelong <0x0000040
# and small RO_COMPAT?
Quoted 1 line
Quoted 1 line
Quoted 1 line
0x464lelong <0x0000008ext3 filesystem data
# else large RO_COMPAT?
Quoted 1 line
Quoted 1 line
Quoted 1 line
0x464lelong >0x0000007 ext4 filesystem data
# else large INCOMPAT?
Quoted 1 line
Quoted 1 line
0x460lelong >0x000003f ext4 filesystem data
# General flags for any ext* fs
Quoted 2 lines
0x460 lelong &0x0000004 (needs journal recovery) 0x43a leshort &0x0000002 (errors)
# INCOMPAT flags
Quoted 1 line
0x460lelong &0x0000001 (compressed)
#>0x460 lelong &0x0000002 (filetype) #>0x460 lelong &0x0000010 (meta bg) >0x460 lelong &0x0000040 (extents) >0x460 lelong &0x0000080 (64bit) #>0x460 lelong &0x0000100 (mmp) #>0x460 lelong &0x0000200 (flex bg) # RO_INCOMPAT flags #>0x464 lelong &0x0000001 (sparse super) >0x464 lelong &0x0000002 (large files) >0x464 lelong &0x0000008 (huge files) #>0x464 lelong &0x0000010 (gdt checksum) #>0x464 lelong &0x0000020 (many subdirs) #>0x463 lelong &0x0000040 (extra isize)
Quoted 8 lines · Eric Sandeen
This seems to work fine; any comments, either about the logic, or the text descriptions, or the various options I've shown/not shown?
To test, copy your "magic" file somewhere local, replace the ext2/3 section with the following, and do something like:
Quoted 5 lines
# file -C -m magic; file -m ./magic -s /dev/sda1-Eric
# ext2/ext3 filesystems - Andreas Dilger <[email protected]>
Lol, you may as well fix up the email.... [email protected] will probably be the least transient.
Quoted 21 lines
0x438 leshort 0xEF53 Linux >0x44c lelong x rev %d >0x43e leshort x \b.%d# No journal? ext2
Quoted 2 lines
0x45c lelong ^0x0000004 ext2 filesystem data >0x43a leshort ^0x0000001 (mounted or unclean)# Has a journal? ext3 or ext4
Quoted 1 line
0x45clelong &0x0000004# and small INCOMPAT?
Quoted 1 line
Quoted 1 line
0x460lelong <0x0000040# and small
RO_COMPAT?Quoted 1 line
Quoted 1 line
Quoted 1 line
0x464lelong <0x0000008ext3 filesystem data# else large
RO_COMPAT?Quoted 1 line
Quoted 1 line
Quoted 1 line
0x464lelong >0x0000007 ext4 filesystem data# else large INCOMPAT?
Quoted 1 line
Quoted 1 line
0x460lelong >0x000003f ext4 filesystem data# General flags for any ext* fs
Quoted 2 lines
0x460 lelong &0x0000004 (needs journal recovery) 0x43a leshort &0x0000002 (errors)# INCOMPAT flags
Quoted 1 line
0x460lelong &0x0000001 (compressed)
Quoted 13 lines
#>0x460 lelong &0x0000002 (filetype) #>0x460 lelong &0x0000010 (meta bg) >0x460 lelong &0x0000040 (extents) >0x460 lelong &0x0000080 (64bit) #>0x460 lelong &0x0000100 (mmp) #>0x460 lelong &0x0000200 (flex bg) # RO_INCOMPAT flags #>0x464 lelong &0x0000001 (sparse super) >0x464 lelong &0x0000002 (large files) >0x464 lelong &0x0000008 (huge files) #>0x464 lelong &0x0000010 (gdt checksum) #>0x464 lelong &0x0000020 (many subdirs) #>0x463 lelong &0x0000040 (extra isize)
Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.