...

Source file src/github.com/Microsoft/hcsshim/ext4/internal/format/format.go

Documentation: github.com/Microsoft/hcsshim/ext4/internal/format

     1  package format
     2  
     3  type SuperBlock struct {
     4  	InodesCount          uint32
     5  	BlocksCountLow       uint32
     6  	RootBlocksCountLow   uint32
     7  	FreeBlocksCountLow   uint32
     8  	FreeInodesCount      uint32
     9  	FirstDataBlock       uint32
    10  	LogBlockSize         uint32
    11  	LogClusterSize       uint32
    12  	BlocksPerGroup       uint32
    13  	ClustersPerGroup     uint32
    14  	InodesPerGroup       uint32
    15  	Mtime                uint32
    16  	Wtime                uint32
    17  	MountCount           uint16
    18  	MaxMountCount        uint16
    19  	Magic                uint16
    20  	State                uint16
    21  	Errors               uint16
    22  	MinorRevisionLevel   uint16
    23  	LastCheck            uint32
    24  	CheckInterval        uint32
    25  	CreatorOS            uint32
    26  	RevisionLevel        uint32
    27  	DefaultReservedUid   uint16
    28  	DefaultReservedGid   uint16
    29  	FirstInode           uint32
    30  	InodeSize            uint16
    31  	BlockGroupNr         uint16
    32  	FeatureCompat        CompatFeature
    33  	FeatureIncompat      IncompatFeature
    34  	FeatureRoCompat      RoCompatFeature
    35  	UUID                 [16]uint8
    36  	VolumeName           [16]byte
    37  	LastMounted          [64]byte
    38  	AlgorithmUsageBitmap uint32
    39  	PreallocBlocks       uint8
    40  	PreallocDirBlocks    uint8
    41  	ReservedGdtBlocks    uint16
    42  	JournalUUID          [16]uint8
    43  	JournalInum          uint32
    44  	JournalDev           uint32
    45  	LastOrphan           uint32
    46  	HashSeed             [4]uint32
    47  	DefHashVersion       uint8
    48  	JournalBackupType    uint8
    49  	DescSize             uint16
    50  	DefaultMountOpts     uint32
    51  	FirstMetaBg          uint32
    52  	MkfsTime             uint32
    53  	JournalBlocks        [17]uint32
    54  	BlocksCountHigh      uint32
    55  	RBlocksCountHigh     uint32
    56  	FreeBlocksCountHigh  uint32
    57  	MinExtraIsize        uint16
    58  	WantExtraIsize       uint16
    59  	Flags                uint32
    60  	RaidStride           uint16
    61  	MmpInterval          uint16
    62  	MmpBlock             uint64
    63  	RaidStripeWidth      uint32
    64  	LogGroupsPerFlex     uint8
    65  	ChecksumType         uint8
    66  	ReservedPad          uint16
    67  	KbytesWritten        uint64
    68  	SnapshotInum         uint32
    69  	SnapshotID           uint32
    70  	SnapshotRBlocksCount uint64
    71  	SnapshotList         uint32
    72  	ErrorCount           uint32
    73  	FirstErrorTime       uint32
    74  	FirstErrorInode      uint32
    75  	FirstErrorBlock      uint64
    76  	FirstErrorFunc       [32]uint8
    77  	FirstErrorLine       uint32
    78  	LastErrorTime        uint32
    79  	LastErrorInode       uint32
    80  	LastErrorLine        uint32
    81  	LastErrorBlock       uint64
    82  	LastErrorFunc        [32]uint8
    83  	MountOpts            [64]uint8
    84  	UserQuotaInum        uint32
    85  	GroupQuotaInum       uint32
    86  	OverheadBlocks       uint32
    87  	BackupBgs            [2]uint32
    88  	EncryptAlgos         [4]uint8
    89  	EncryptPwSalt        [16]uint8
    90  	LpfInode             uint32
    91  	ProjectQuotaInum     uint32
    92  	ChecksumSeed         uint32
    93  	WtimeHigh            uint8
    94  	MtimeHigh            uint8
    95  	MkfsTimeHigh         uint8
    96  	LastcheckHigh        uint8
    97  	FirstErrorTimeHigh   uint8
    98  	LastErrorTimeHigh    uint8
    99  	Pad                  [2]uint8
   100  	Reserved             [96]uint32
   101  	Checksum             uint32
   102  }
   103  
   104  const SuperBlockMagic uint16 = 0xef53
   105  
   106  type CompatFeature uint32
   107  type IncompatFeature uint32
   108  type RoCompatFeature uint32
   109  
   110  const (
   111  	CompatDirPrealloc   CompatFeature = 0x1
   112  	CompatImagicInodes  CompatFeature = 0x2
   113  	CompatHasJournal    CompatFeature = 0x4
   114  	CompatExtAttr       CompatFeature = 0x8
   115  	CompatResizeInode   CompatFeature = 0x10
   116  	CompatDirIndex      CompatFeature = 0x20
   117  	CompatLazyBg        CompatFeature = 0x40
   118  	CompatExcludeInode  CompatFeature = 0x80
   119  	CompatExcludeBitmap CompatFeature = 0x100
   120  	CompatSparseSuper2  CompatFeature = 0x200
   121  
   122  	IncompatCompression IncompatFeature = 0x1
   123  	IncompatFiletype    IncompatFeature = 0x2
   124  	IncompatRecover     IncompatFeature = 0x4
   125  	IncompatJournalDev  IncompatFeature = 0x8
   126  	IncompatMetaBg      IncompatFeature = 0x10
   127  	IncompatExtents     IncompatFeature = 0x40
   128  	Incompat_64Bit      IncompatFeature = 0x80
   129  	IncompatMmp         IncompatFeature = 0x100
   130  	IncompatFlexBg      IncompatFeature = 0x200
   131  	IncompatEaInode     IncompatFeature = 0x400
   132  	IncompatDirdata     IncompatFeature = 0x1000
   133  	IncompatCsumSeed    IncompatFeature = 0x2000
   134  	IncompatLargedir    IncompatFeature = 0x4000
   135  	IncompatInlineData  IncompatFeature = 0x8000
   136  	IncompatEncrypt     IncompatFeature = 0x10000
   137  
   138  	RoCompatSparseSuper  RoCompatFeature = 0x1
   139  	RoCompatLargeFile    RoCompatFeature = 0x2
   140  	RoCompatBtreeDir     RoCompatFeature = 0x4
   141  	RoCompatHugeFile     RoCompatFeature = 0x8
   142  	RoCompatGdtCsum      RoCompatFeature = 0x10
   143  	RoCompatDirNlink     RoCompatFeature = 0x20
   144  	RoCompatExtraIsize   RoCompatFeature = 0x40
   145  	RoCompatHasSnapshot  RoCompatFeature = 0x80
   146  	RoCompatQuota        RoCompatFeature = 0x100
   147  	RoCompatBigalloc     RoCompatFeature = 0x200
   148  	RoCompatMetadataCsum RoCompatFeature = 0x400
   149  	RoCompatReplica      RoCompatFeature = 0x800
   150  	RoCompatReadonly     RoCompatFeature = 0x1000
   151  	RoCompatProject      RoCompatFeature = 0x2000
   152  )
   153  
   154  type BlockGroupFlag uint16
   155  
   156  const (
   157  	BlockGroupInodeUninit BlockGroupFlag = 0x1
   158  	BlockGroupBlockUninit BlockGroupFlag = 0x2
   159  	BlockGroupInodeZeroed BlockGroupFlag = 0x4
   160  )
   161  
   162  type GroupDescriptor struct {
   163  	BlockBitmapLow     uint32
   164  	InodeBitmapLow     uint32
   165  	InodeTableLow      uint32
   166  	FreeBlocksCountLow uint16
   167  	FreeInodesCountLow uint16
   168  	UsedDirsCountLow   uint16
   169  	Flags              BlockGroupFlag
   170  	ExcludeBitmapLow   uint32
   171  	BlockBitmapCsumLow uint16
   172  	InodeBitmapCsumLow uint16
   173  	ItableUnusedLow    uint16
   174  	Checksum           uint16
   175  }
   176  
   177  type GroupDescriptor64 struct {
   178  	GroupDescriptor
   179  	BlockBitmapHigh     uint32
   180  	InodeBitmapHigh     uint32
   181  	InodeTableHigh      uint32
   182  	FreeBlocksCountHigh uint16
   183  	FreeInodesCountHigh uint16
   184  	UsedDirsCountHigh   uint16
   185  	ItableUnusedHigh    uint16
   186  	ExcludeBitmapHigh   uint32
   187  	BlockBitmapCsumHigh uint16
   188  	InodeBitmapCsumHigh uint16
   189  	Reserved            uint32
   190  }
   191  
   192  const (
   193  	S_IXOTH  = 0x1
   194  	S_IWOTH  = 0x2
   195  	S_IROTH  = 0x4
   196  	S_IXGRP  = 0x8
   197  	S_IWGRP  = 0x10
   198  	S_IRGRP  = 0x20
   199  	S_IXUSR  = 0x40
   200  	S_IWUSR  = 0x80
   201  	S_IRUSR  = 0x100
   202  	S_ISVTX  = 0x200
   203  	S_ISGID  = 0x400
   204  	S_ISUID  = 0x800
   205  	S_IFIFO  = 0x1000
   206  	S_IFCHR  = 0x2000
   207  	S_IFDIR  = 0x4000
   208  	S_IFBLK  = 0x6000
   209  	S_IFREG  = 0x8000
   210  	S_IFLNK  = 0xA000
   211  	S_IFSOCK = 0xC000
   212  
   213  	TypeMask uint16 = 0xF000
   214  )
   215  
   216  type InodeNumber uint32
   217  
   218  const (
   219  	InodeRoot = 2
   220  )
   221  
   222  type Inode struct {
   223  	Mode                 uint16
   224  	Uid                  uint16
   225  	SizeLow              uint32
   226  	Atime                uint32
   227  	Ctime                uint32
   228  	Mtime                uint32
   229  	Dtime                uint32
   230  	Gid                  uint16
   231  	LinksCount           uint16
   232  	BlocksLow            uint32
   233  	Flags                InodeFlag
   234  	Version              uint32
   235  	Block                [60]byte
   236  	Generation           uint32
   237  	XattrBlockLow        uint32
   238  	SizeHigh             uint32
   239  	ObsoleteFragmentAddr uint32
   240  	BlocksHigh           uint16
   241  	XattrBlockHigh       uint16
   242  	UidHigh              uint16
   243  	GidHigh              uint16
   244  	ChecksumLow          uint16
   245  	Reserved             uint16
   246  	ExtraIsize           uint16
   247  	ChecksumHigh         uint16
   248  	CtimeExtra           uint32
   249  	MtimeExtra           uint32
   250  	AtimeExtra           uint32
   251  	Crtime               uint32
   252  	CrtimeExtra          uint32
   253  	VersionHigh          uint32
   254  	Projid               uint32
   255  }
   256  
   257  type InodeFlag uint32
   258  
   259  const (
   260  	InodeFlagSecRm              InodeFlag = 0x1
   261  	InodeFlagUnRm               InodeFlag = 0x2
   262  	InodeFlagCompressed         InodeFlag = 0x4
   263  	InodeFlagSync               InodeFlag = 0x8
   264  	InodeFlagImmutable          InodeFlag = 0x10
   265  	InodeFlagAppend             InodeFlag = 0x20
   266  	InodeFlagNoDump             InodeFlag = 0x40
   267  	InodeFlagNoAtime            InodeFlag = 0x80
   268  	InodeFlagDirtyCompressed    InodeFlag = 0x100
   269  	InodeFlagCompressedClusters InodeFlag = 0x200
   270  	InodeFlagNoCompress         InodeFlag = 0x400
   271  	InodeFlagEncrypted          InodeFlag = 0x800
   272  	InodeFlagHashedIndex        InodeFlag = 0x1000
   273  	InodeFlagMagic              InodeFlag = 0x2000
   274  	InodeFlagJournalData        InodeFlag = 0x4000
   275  	InodeFlagNoTail             InodeFlag = 0x8000
   276  	InodeFlagDirSync            InodeFlag = 0x10000
   277  	InodeFlagTopDir             InodeFlag = 0x20000
   278  	InodeFlagHugeFile           InodeFlag = 0x40000
   279  	InodeFlagExtents            InodeFlag = 0x80000
   280  	InodeFlagEaInode            InodeFlag = 0x200000
   281  	InodeFlagEOFBlocks          InodeFlag = 0x400000
   282  	InodeFlagSnapfile           InodeFlag = 0x01000000
   283  	InodeFlagSnapfileDeleted    InodeFlag = 0x04000000
   284  	InodeFlagSnapfileShrunk     InodeFlag = 0x08000000
   285  	InodeFlagInlineData         InodeFlag = 0x10000000
   286  	InodeFlagProjectIDInherit   InodeFlag = 0x20000000
   287  	InodeFlagReserved           InodeFlag = 0x80000000
   288  )
   289  
   290  const (
   291  	MaxLinks = 65000
   292  )
   293  
   294  type ExtentHeader struct {
   295  	Magic      uint16
   296  	Entries    uint16
   297  	Max        uint16
   298  	Depth      uint16
   299  	Generation uint32
   300  }
   301  
   302  const ExtentHeaderMagic uint16 = 0xf30a
   303  
   304  type ExtentIndexNode struct {
   305  	Block    uint32
   306  	LeafLow  uint32
   307  	LeafHigh uint16
   308  	Unused   uint16
   309  }
   310  
   311  type ExtentLeafNode struct {
   312  	Block     uint32
   313  	Length    uint16
   314  	StartHigh uint16
   315  	StartLow  uint32
   316  }
   317  
   318  type ExtentTail struct {
   319  	Checksum uint32
   320  }
   321  
   322  type DirectoryEntry struct {
   323  	Inode        InodeNumber
   324  	RecordLength uint16
   325  	NameLength   uint8
   326  	FileType     FileType
   327  	//Name         []byte
   328  }
   329  
   330  type FileType uint8
   331  
   332  const (
   333  	FileTypeUnknown      FileType = 0x0
   334  	FileTypeRegular      FileType = 0x1
   335  	FileTypeDirectory    FileType = 0x2
   336  	FileTypeCharacter    FileType = 0x3
   337  	FileTypeBlock        FileType = 0x4
   338  	FileTypeFIFO         FileType = 0x5
   339  	FileTypeSocket       FileType = 0x6
   340  	FileTypeSymbolicLink FileType = 0x7
   341  )
   342  
   343  type DirectoryEntryTail struct {
   344  	ReservedZero1 uint32
   345  	RecordLength  uint16
   346  	ReservedZero2 uint8
   347  	FileType      uint8
   348  	Checksum      uint32
   349  }
   350  
   351  type DirectoryTreeRoot struct {
   352  	Dot            DirectoryEntry
   353  	DotName        [4]byte
   354  	DotDot         DirectoryEntry
   355  	DotDotName     [4]byte
   356  	ReservedZero   uint32
   357  	HashVersion    uint8
   358  	InfoLength     uint8
   359  	IndirectLevels uint8
   360  	UnusedFlags    uint8
   361  	Limit          uint16
   362  	Count          uint16
   363  	Block          uint32
   364  	//Entries        []DirectoryTreeEntry
   365  }
   366  
   367  type DirectoryTreeNode struct {
   368  	FakeInode        uint32
   369  	FakeRecordLength uint16
   370  	NameLength       uint8
   371  	FileType         uint8
   372  	Limit            uint16
   373  	Count            uint16
   374  	Block            uint32
   375  	//Entries          []DirectoryTreeEntry
   376  }
   377  
   378  type DirectoryTreeEntry struct {
   379  	Hash  uint32
   380  	Block uint32
   381  }
   382  
   383  type DirectoryTreeTail struct {
   384  	Reserved uint32
   385  	Checksum uint32
   386  }
   387  
   388  type XAttrInodeBodyHeader struct {
   389  	Magic uint32
   390  }
   391  
   392  type XAttrHeader struct {
   393  	Magic          uint32
   394  	ReferenceCount uint32
   395  	Blocks         uint32
   396  	Hash           uint32
   397  	Checksum       uint32
   398  	Reserved       [3]uint32
   399  }
   400  
   401  const XAttrHeaderMagic uint32 = 0xea020000
   402  
   403  type XAttrEntry struct {
   404  	NameLength  uint8
   405  	NameIndex   uint8
   406  	ValueOffset uint16
   407  	ValueInum   uint32
   408  	ValueSize   uint32
   409  	Hash        uint32
   410  	//Name        []byte
   411  }
   412  

View as plain text