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