github.com/SagerNet/gvisor@v0.0.0-20210707092255-7731c139d75c/pkg/sentry/fsimpl/ext/disklayout/superblock_32.go (about) 1 // Copyright 2019 The gVisor Authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package disklayout 16 17 // SuperBlock32Bit implements SuperBlock and represents the 32-bit version of 18 // the ext4_super_block struct in fs/ext4/ext4.h. Should be used only if 19 // RevLevel = DynamicRev and 64-bit feature is disabled. 20 // 21 // +marshal 22 type SuperBlock32Bit struct { 23 // We embed the old superblock struct here because the 32-bit version is just 24 // an extension of the old version. 25 SuperBlockOld 26 27 FirstInode uint32 28 InodeSizeRaw uint16 29 BlockGroupNumber uint16 30 FeatureCompat uint32 31 FeatureIncompat uint32 32 FeatureRoCompat uint32 33 UUID [16]byte 34 VolumeName [16]byte 35 LastMounted [64]byte 36 AlgoUsageBitmap uint32 37 PreallocBlocks uint8 38 PreallocDirBlocks uint8 39 ReservedGdtBlocks uint16 40 JournalUUID [16]byte 41 JournalInum uint32 42 JournalDev uint32 43 LastOrphan uint32 44 HashSeed [4]uint32 45 DefaultHashVersion uint8 46 JnlBackupType uint8 47 BgDescSizeRaw uint16 48 DefaultMountOpts uint32 49 FirstMetaBg uint32 50 MkfsTime uint32 51 JnlBlocks [17]uint32 52 } 53 54 // Compiles only if SuperBlock32Bit implements SuperBlock. 55 var _ SuperBlock = (*SuperBlock32Bit)(nil) 56 57 // Only override methods which change based on the additional fields above. 58 // Not overriding SuperBlock.BgDescSize because it would still return 32 here. 59 60 // InodeSize implements SuperBlock.InodeSize. 61 func (sb *SuperBlock32Bit) InodeSize() uint16 { 62 return sb.InodeSizeRaw 63 } 64 65 // CompatibleFeatures implements SuperBlock.CompatibleFeatures. 66 func (sb *SuperBlock32Bit) CompatibleFeatures() CompatFeatures { 67 return CompatFeaturesFromInt(sb.FeatureCompat) 68 } 69 70 // IncompatibleFeatures implements SuperBlock.IncompatibleFeatures. 71 func (sb *SuperBlock32Bit) IncompatibleFeatures() IncompatFeatures { 72 return IncompatFeaturesFromInt(sb.FeatureIncompat) 73 } 74 75 // ReadOnlyCompatibleFeatures implements SuperBlock.ReadOnlyCompatibleFeatures. 76 func (sb *SuperBlock32Bit) ReadOnlyCompatibleFeatures() RoCompatFeatures { 77 return RoCompatFeaturesFromInt(sb.FeatureRoCompat) 78 }