inet.af/netstack@v0.0.0-20220214151720-7585b01ddccf/abi/linux/fs.go (about)

     1  // Copyright 2018 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 linux
    16  
    17  // Filesystem types used in statfs(2).
    18  //
    19  // See linux/magic.h.
    20  const (
    21  	ANON_INODE_FS_MAGIC   = 0x09041934
    22  	CGROUP_SUPER_MAGIC    = 0x27e0eb
    23  	DEVPTS_SUPER_MAGIC    = 0x00001cd1
    24  	EXT_SUPER_MAGIC       = 0xef53
    25  	FUSE_SUPER_MAGIC      = 0x65735546
    26  	MQUEUE_MAGIC          = 0x19800202
    27  	OVERLAYFS_SUPER_MAGIC = 0x794c7630
    28  	PIPEFS_MAGIC          = 0x50495045
    29  	PROC_SUPER_MAGIC      = 0x9fa0
    30  	RAMFS_MAGIC           = 0x09041934
    31  	SOCKFS_MAGIC          = 0x534F434B
    32  	SYSFS_MAGIC           = 0x62656572
    33  	TMPFS_MAGIC           = 0x01021994
    34  	V9FS_MAGIC            = 0x01021997
    35  )
    36  
    37  // Filesystem path limits, from uapi/linux/limits.h.
    38  const (
    39  	NAME_MAX = 255
    40  	PATH_MAX = 4096
    41  )
    42  
    43  // Statfs is struct statfs, from uapi/asm-generic/statfs.h.
    44  //
    45  // +marshal
    46  type Statfs struct {
    47  	// Type is one of the filesystem magic values, defined above.
    48  	Type uint64
    49  
    50  	// BlockSize is the optimal transfer block size in bytes.
    51  	BlockSize int64
    52  
    53  	// Blocks is the maximum number of data blocks the filesystem may store, in
    54  	// units of BlockSize.
    55  	Blocks uint64
    56  
    57  	// BlocksFree is the number of free data blocks, in units of BlockSize.
    58  	BlocksFree uint64
    59  
    60  	// BlocksAvailable is the number of data blocks free for use by
    61  	// unprivileged users, in units of BlockSize.
    62  	BlocksAvailable uint64
    63  
    64  	// Files is the number of used file nodes on the filesystem.
    65  	Files uint64
    66  
    67  	// FileFress is the number of free file nodes on the filesystem.
    68  	FilesFree uint64
    69  
    70  	// FSID is the filesystem ID.
    71  	FSID [2]int32
    72  
    73  	// NameLength is the maximum file name length.
    74  	NameLength uint64
    75  
    76  	// FragmentSize is equivalent to BlockSize.
    77  	FragmentSize int64
    78  
    79  	// Flags is the set of filesystem mount flags.
    80  	Flags uint64
    81  
    82  	// Spare is unused.
    83  	Spare [4]uint64
    84  }
    85  
    86  // Whence argument to lseek(2), from include/uapi/linux/fs.h.
    87  const (
    88  	SEEK_SET  = 0
    89  	SEEK_CUR  = 1
    90  	SEEK_END  = 2
    91  	SEEK_DATA = 3
    92  	SEEK_HOLE = 4
    93  )
    94  
    95  // Sync_file_range flags, from include/uapi/linux/fs.h
    96  const (
    97  	SYNC_FILE_RANGE_WAIT_BEFORE = 1
    98  	SYNC_FILE_RANGE_WRITE       = 2
    99  	SYNC_FILE_RANGE_WAIT_AFTER  = 4
   100  )
   101  
   102  // Flag argument to renameat2(2), from include/uapi/linux/fs.h.
   103  const (
   104  	RENAME_NOREPLACE = (1 << 0) // Don't overwrite target.
   105  	RENAME_EXCHANGE  = (1 << 1) // Exchange src and dst.
   106  	RENAME_WHITEOUT  = (1 << 2) // Whiteout src.
   107  )