github.com/SagerNet/gvisor@v0.0.0-20210707092255-7731c139d75c/pkg/sentry/fsimpl/ext/disklayout/superblock_64.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  // SuperBlock64Bit implements SuperBlock and represents the 64-bit version of
    18  // the ext4_super_block struct in fs/ext4/ext4.h. This sums up to be exactly
    19  // 1024 bytes (smallest possible block size) and hence the superblock always
    20  // fits in no more than one data block. Should only be used when the 64-bit
    21  // feature is set.
    22  //
    23  // +marshal
    24  type SuperBlock64Bit struct {
    25  	// We embed the 32-bit struct here because 64-bit version is just an extension
    26  	// of the 32-bit version.
    27  	SuperBlock32Bit
    28  
    29  	BlocksCountHi           uint32
    30  	ReservedBlocksCountHi   uint32
    31  	FreeBlocksCountHi       uint32
    32  	MinInodeSize            uint16
    33  	WantInodeSize           uint16
    34  	Flags                   uint32
    35  	RaidStride              uint16
    36  	MmpInterval             uint16
    37  	MmpBlock                uint64
    38  	RaidStripeWidth         uint32
    39  	LogGroupsPerFlex        uint8
    40  	ChecksumType            uint8
    41  	_                       uint16
    42  	KbytesWritten           uint64
    43  	SnapshotInum            uint32
    44  	SnapshotID              uint32
    45  	SnapshotRsrvBlocksCount uint64
    46  	SnapshotList            uint32
    47  	ErrorCount              uint32
    48  	FirstErrorTime          uint32
    49  	FirstErrorInode         uint32
    50  	FirstErrorBlock         uint64
    51  	FirstErrorFunction      [32]byte
    52  	FirstErrorLine          uint32
    53  	LastErrorTime           uint32
    54  	LastErrorInode          uint32
    55  	LastErrorLine           uint32
    56  	LastErrorBlock          uint64
    57  	LastErrorFunction       [32]byte
    58  	MountOpts               [64]byte
    59  	UserQuotaInum           uint32
    60  	GroupQuotaInum          uint32
    61  	OverheadBlocks          uint32
    62  	BackupBgs               [2]uint32
    63  	EncryptAlgos            [4]uint8
    64  	EncryptPwSalt           [16]uint8
    65  	LostFoundInode          uint32
    66  	ProjectQuotaInode       uint32
    67  	ChecksumSeed            uint32
    68  	WtimeHi                 uint8
    69  	MtimeHi                 uint8
    70  	MkfsTimeHi              uint8
    71  	LastCheckHi             uint8
    72  	FirstErrorTimeHi        uint8
    73  	LastErrorTimeHi         uint8
    74  	_                       [2]uint8
    75  	Encoding                uint16
    76  	EncodingFlags           uint16
    77  	_                       [95]uint32
    78  	Checksum                uint32
    79  }
    80  
    81  // Compiles only if SuperBlock64Bit implements SuperBlock.
    82  var _ SuperBlock = (*SuperBlock64Bit)(nil)
    83  
    84  // Only override methods which change based on the 64-bit feature.
    85  
    86  // BlocksCount implements SuperBlock.BlocksCount.
    87  func (sb *SuperBlock64Bit) BlocksCount() uint64 {
    88  	return (uint64(sb.BlocksCountHi) << 32) | uint64(sb.BlocksCountLo)
    89  }
    90  
    91  // FreeBlocksCount implements SuperBlock.FreeBlocksCount.
    92  func (sb *SuperBlock64Bit) FreeBlocksCount() uint64 {
    93  	return (uint64(sb.FreeBlocksCountHi) << 32) | uint64(sb.FreeBlocksCountLo)
    94  }
    95  
    96  // BgDescSize implements SuperBlock.BgDescSize.
    97  func (sb *SuperBlock64Bit) BgDescSize() uint16 { return sb.BgDescSizeRaw }