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