github.com/SagerNet/gvisor@v0.0.0-20210707092255-7731c139d75c/pkg/sentry/fsimpl/ext/disklayout/superblock_old.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 // SuperBlockOld implements SuperBlock and represents the old version of the 18 // superblock struct. Should be used only if RevLevel = OldRev. 19 // 20 // +marshal 21 type SuperBlockOld struct { 22 InodesCountRaw uint32 23 BlocksCountLo uint32 24 ReservedBlocksCount uint32 25 FreeBlocksCountLo uint32 26 FreeInodesCountRaw uint32 27 FirstDataBlockRaw uint32 28 LogBlockSize uint32 29 LogClusterSize uint32 30 BlocksPerGroupRaw uint32 31 ClustersPerGroupRaw uint32 32 InodesPerGroupRaw uint32 33 Mtime uint32 34 Wtime uint32 35 MountCountRaw uint16 36 MaxMountCountRaw uint16 37 MagicRaw uint16 38 State uint16 39 Errors uint16 40 MinorRevLevel uint16 41 LastCheck uint32 42 CheckInterval uint32 43 CreatorOS uint32 44 RevLevel uint32 45 DefResUID uint16 46 DefResGID uint16 47 } 48 49 // Compiles only if SuperBlockOld implements SuperBlock. 50 var _ SuperBlock = (*SuperBlockOld)(nil) 51 52 // InodesCount implements SuperBlock.InodesCount. 53 func (sb *SuperBlockOld) InodesCount() uint32 { return sb.InodesCountRaw } 54 55 // BlocksCount implements SuperBlock.BlocksCount. 56 func (sb *SuperBlockOld) BlocksCount() uint64 { return uint64(sb.BlocksCountLo) } 57 58 // FreeBlocksCount implements SuperBlock.FreeBlocksCount. 59 func (sb *SuperBlockOld) FreeBlocksCount() uint64 { return uint64(sb.FreeBlocksCountLo) } 60 61 // FreeInodesCount implements SuperBlock.FreeInodesCount. 62 func (sb *SuperBlockOld) FreeInodesCount() uint32 { return sb.FreeInodesCountRaw } 63 64 // MountCount implements SuperBlock.MountCount. 65 func (sb *SuperBlockOld) MountCount() uint16 { return sb.MountCountRaw } 66 67 // MaxMountCount implements SuperBlock.MaxMountCount. 68 func (sb *SuperBlockOld) MaxMountCount() uint16 { return sb.MaxMountCountRaw } 69 70 // FirstDataBlock implements SuperBlock.FirstDataBlock. 71 func (sb *SuperBlockOld) FirstDataBlock() uint32 { return sb.FirstDataBlockRaw } 72 73 // BlockSize implements SuperBlock.BlockSize. 74 func (sb *SuperBlockOld) BlockSize() uint64 { return 1 << (10 + sb.LogBlockSize) } 75 76 // BlocksPerGroup implements SuperBlock.BlocksPerGroup. 77 func (sb *SuperBlockOld) BlocksPerGroup() uint32 { return sb.BlocksPerGroupRaw } 78 79 // ClusterSize implements SuperBlock.ClusterSize. 80 func (sb *SuperBlockOld) ClusterSize() uint64 { return 1 << (10 + sb.LogClusterSize) } 81 82 // ClustersPerGroup implements SuperBlock.ClustersPerGroup. 83 func (sb *SuperBlockOld) ClustersPerGroup() uint32 { return sb.ClustersPerGroupRaw } 84 85 // InodeSize implements SuperBlock.InodeSize. 86 func (sb *SuperBlockOld) InodeSize() uint16 { return OldInodeSize } 87 88 // InodesPerGroup implements SuperBlock.InodesPerGroup. 89 func (sb *SuperBlockOld) InodesPerGroup() uint32 { return sb.InodesPerGroupRaw } 90 91 // BgDescSize implements SuperBlock.BgDescSize. 92 func (sb *SuperBlockOld) BgDescSize() uint16 { return 32 } 93 94 // CompatibleFeatures implements SuperBlock.CompatibleFeatures. 95 func (sb *SuperBlockOld) CompatibleFeatures() CompatFeatures { return CompatFeatures{} } 96 97 // IncompatibleFeatures implements SuperBlock.IncompatibleFeatures. 98 func (sb *SuperBlockOld) IncompatibleFeatures() IncompatFeatures { return IncompatFeatures{} } 99 100 // ReadOnlyCompatibleFeatures implements SuperBlock.ReadOnlyCompatibleFeatures. 101 func (sb *SuperBlockOld) ReadOnlyCompatibleFeatures() RoCompatFeatures { return RoCompatFeatures{} } 102 103 // Magic implements SuperBlock.Magic. 104 func (sb *SuperBlockOld) Magic() uint16 { return sb.MagicRaw } 105 106 // Revision implements SuperBlock.Revision. 107 func (sb *SuperBlockOld) Revision() SbRevision { return SbRevision(sb.RevLevel) }