github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/sys/freebsd/posix_fs.txt (about)

     1  # Copyright 2017 syzkaller project authors. All rights reserved.
     2  # Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
     3  
     4  include <sys/types.h>
     5  include <sys/stat.h>
     6  include <sys/mount.h>
     7  include <sys/param.h>
     8  include <sys/ucred.h>
     9  include <fcntl.h>
    10  include <unistd.h>
    11  
    12  resource fd[int32]: 0xffffffffffffffff, AT_FDCWD
    13  resource fd_dir[fd]
    14  
    15  resource pid[int32]: 0, 0xffffffffffffffff
    16  resource uid[int32]: 0, 0xffffffffffffffff
    17  resource gid[int32]: 0, 0xffffffffffffffff
    18  
    19  open(file ptr[in, filename], flags flags[open_flags], mode flags[open_mode]) fd
    20  # Just so that we have something that creates fd_dir resources.
    21  open$dir(file ptr[in, filename], flags flags[open_flags], mode flags[open_mode]) fd_dir
    22  openat(fd fd_dir[opt], file ptr[in, filename], flags flags[open_flags], mode flags[open_mode]) fd
    23  close(fd fd)
    24  # Don't close fd ranges, tunfd ends up being closed as collateral damage.
    25  #close_range(fd fd, max_fd fd, flags flags[close_range_flags])
    26  #freebsd12_closefrom(fd fd)
    27  read(fd fd, buf buffer[out], count len[buf])
    28  readv(fd fd, vec ptr[in, array[iovec_out]], vlen len[vec])
    29  preadv(fd fd, vec ptr[in, array[iovec_out]], vlen len[vec], off fileoff)
    30  pread(fd fd, buf buffer[out], count len[buf], off fileoff)
    31  write(fd fd, buf buffer[in], count len[buf])
    32  writev(fd fd, vec ptr[in, array[iovec_in]], vlen len[vec])
    33  pwrite(fd fd, buf buffer[in], count len[buf], off fileoff)
    34  pwritev(fd fd, vec ptr[in, array[iovec_in]], vlen len[vec], off fileoff)
    35  lseek(fd fd, offset fileoff, whence flags[seek_whence])
    36  dup(oldfd fd) fd
    37  dup2(oldfd fd, newfd fd) fd
    38  pipe2(pipefd ptr[out, pipefd], flags flags[pipe_flags])
    39  freebsd10_pipe(pipefd ptr[out, pipefd])
    40  fstat(fd fd, statbuf ptr[out, stat])
    41  freebsd11_stat(file ptr[in, filename], statbuf ptr[out, freebsd11_stat])
    42  freebsd11_fstat(fd fd, statbuf ptr[out, freebsd11_stat])
    43  freebsd11_lstat(file ptr[in, filename], statbuf ptr[out, freebsd11_stat])
    44  fstatat(fd fd, path ptr[in, filename], statbuf ptr[out, stat], flag flags[fstatat_flags])
    45  freebsd11_fstatat(fd fd, path ptr[in, filename], statbuf ptr[out, freebsd11_stat], flag flags[fstatat_flags])
    46  freebsd11_getfsstat(buf ptr[out, freebsd11_statfs], size len[buf], mode flags[getfsstat_flags])
    47  getfsstat(buf ptr[out, statfs], size len[buf], mode flags[getfsstat_flags])
    48  posix_fallocate(fd fd, offset fileoff, len intptr)
    49  posix_fadvise(fd fd, offset fileoff, len intptr, advice flags[fadvise_advice])
    50  pathconf(file ptr[in, filename], name flags[conf_value])
    51  lpathconf(file ptr[in, filename], name flags[conf_value])
    52  fpathconf(fd fd, name flags[conf_value])
    53  unmount(path ptr[in, filename], flags flags[mount_flags])
    54  mount(type ptr[in, string[filesystem_types]], path ptr[in, filename], flags flags[mount_flags], data buffer[in])
    55  fspacectl(fd fd, cmd flags[spacectl_cmd], rgsr ptr[in, spacectl_range], flags flags[spacectl_flags], rmsr ptr[out, spacectl_range])
    56  getdirentries(fd fd_dir, buf buffer[out], nbytes len[buf], basep ptr[out, int64])
    57  
    58  pipefd {
    59  	rfd	fd
    60  	wfd	fd
    61  }
    62  
    63  iovec_in {
    64  	addr	buffer[in]
    65  	len	len[addr, intptr]
    66  }
    67  
    68  iovec_out {
    69  	addr	buffer[out]
    70  	len	len[addr, intptr]
    71  }
    72  
    73  freebsd11_stat {
    74  	dev	int32
    75  	ino	int32
    76  	mode	int16
    77  	nlink	int16
    78  	uid	uid
    79  	gid	gid
    80  	rdev	int32
    81  	atime	int64
    82  	ansec	int64
    83  	mtime	int64
    84  	mnsec	int64
    85  	ctime	int64
    86  	cnsec	int64
    87  	size	int64
    88  	blocks	int64
    89  	blksize	int32
    90  	flags	int32
    91  	gen	int32
    92  	__spare	const[0, int32]
    93  	btime	int64
    94  	bnsec	int64
    95  }
    96  
    97  stat {
    98  	dev	int64
    99  	ino	int64
   100  	nlink	int64
   101  	mode	int16
   102  	__pad0	const[0, int16]
   103  	uid	uid
   104  	gid	gid
   105  	__pad1	const[0, int32]
   106  	rdev	int64
   107  	atime	int64
   108  	ansec	int64
   109  	mtime	int64
   110  	mnsec	int64
   111  	ctime	int64
   112  	cnsec	int64
   113  	btime	int64
   114  	bnsec	int64
   115  	size	int64
   116  	blocks	int64
   117  	blksize	int32
   118  	flags	int32
   119  	gen	int64
   120  	__spare	array[int64, 10]
   121  }
   122  
   123  define MFSNAMELEN	16
   124  define MNAMELEN	1025
   125  define STATFS_VERSION	0x20140518
   126  
   127  statfs {
   128  	version		int32
   129  	type		int32
   130  	flags		flags[mount_flags, int64]
   131  	bsize		int64
   132  	iosize		int64
   133  	blocks		int64
   134  	bfree		int64
   135  	bavail		int64
   136  	files		int64
   137  	ffree		int64
   138  	syncwrites	int64
   139  	asyncwrites	int64
   140  	syncreads	int64
   141  	asyncreads	int64
   142  	spare		array[int64, 10]
   143  	namemax		int32
   144  	owner		uid
   145  	fsid		fsid
   146  	cspare		array[int8, 80]
   147  	fstype		array[int8, MFSNAMELEN]
   148  	mnton		array[int8, MNAMELEN]
   149  	mntfrom		array[int8, MNAMELEN]
   150  }
   151  
   152  define FREEBSD11_STATFS_VERSION	0x20030518
   153  
   154  freebsd11_statfs {
   155  	version		int32
   156  	type		int32
   157  	flags		flags[mount_flags, int64]
   158  	bsize		int64
   159  	iosize		int64
   160  	blocks		int64
   161  	bfree		int64
   162  	bavail		int64
   163  	files		int64
   164  	ffree		int64
   165  	syncwrites	int64
   166  	asyncwrites	int64
   167  	syncreads	int64
   168  	asyncreads	int64
   169  	spare		array[int64, 10]
   170  	namemax		int32
   171  	owner		uid
   172  	fsid		fsid
   173  	cspare		array[int8, 80]
   174  	fstype		array[int8, 16]
   175  	mnton		array[int8, 88]
   176  	mntfrom		array[int8, 88]
   177  }
   178  
   179  spacectl_range {
   180  	offset	int64
   181  	len	int64
   182  }
   183  
   184  filesystem_types = "apfs", "cd9660", "exfat", "ext2fs", "geli", "hammer", "hammer2", "hfsp", "msdosfs", "ntfs", "ufs", "zfs"
   185  open_flags = O_RDONLY, O_WRONLY, O_RDWR, O_APPEND, FASYNC, O_CLOEXEC, O_CREAT, O_DIRECT, O_DIRECTORY, O_EXCL, O_NOCTTY, O_NOFOLLOW, O_NONBLOCK, O_SYNC, O_TRUNC, O_EXEC, O_TTY_INIT, O_VERIFY, O_PATH, O_EMPTY_PATH
   186  open_mode = S_IRUSR, S_IWUSR, S_IXUSR, S_IRGRP, S_IWGRP, S_IXGRP, S_IROTH, S_IWOTH, S_IXOTH
   187  #close_range_flags = 0
   188  seek_whence = SEEK_SET, SEEK_CUR, SEEK_END, SEEK_DATA, SEEK_HOLE
   189  pipe_flags = O_NONBLOCK, O_CLOEXEC
   190  fadvise_advice = POSIX_FADV_NORMAL, POSIX_FADV_RANDOM, POSIX_FADV_SEQUENTIAL, POSIX_FADV_WILLNEED, POSIX_FADV_DONTNEED, POSIX_FADV_NOREUSE
   191  conf_value = _PC_LINK_MAX, _PC_MAX_CANON, _PC_MAX_INPUT, _PC_NAME_MAX, _PC_PATH_MAX, _PC_PIPE_BUF, _PC_CHOWN_RESTRICTED, _PC_NO_TRUNC, _PC_VDISABLE, _PC_ASYNC_IO, _PC_PRIO_IO, _PC_SYNC_IO, _PC_ALLOC_SIZE_MIN, _PC_FILESIZEBITS, _PC_REC_INCR_XFER_SIZE, _PC_REC_MAX_XFER_SIZE, _PC_REC_MIN_XFER_SIZE, _PC_REC_XFER_ALIGN, _PC_SYMLINK_MAX, _PC_ACL_EXTENDED, _PC_ACL_NFS4, _PC_ACL_PATH_MAX, _PC_CAP_PRESENT, _PC_INF_PRESENT, _PC_MAC_PRESENT, _PC_MIN_HOLE_SIZE
   192  fstatat_flags = AT_SYMLINK_NOFOLLOW, AT_EMPTY_PATH
   193  mount_flags = MNT_RDONLY, MNT_SYNCHRONOUS, MNT_NOEXEC, MNT_NOSUID, MNT_ASYNC, MNT_NOATIME, MNT_SNAPSHOT, MNT_SUIDDIR, MNT_FORCE, MNT_NOCLUSTERR, MNT_NOCLUSTERW, MNT_NFS4ACLS, MNT_SOFTDEP, MNT_NOSYMFOLLOW, MNT_GJOURNAL, MNT_MULTILABEL, MNT_ACLS, MNT_EXRDONLY, MNT_EXPORTED, MNT_DEFEXPORTED, MNT_EXPORTANON
   194  getfsstat_flags = MNT_WAIT, MNT_NOWAIT
   195  spacectl_flags = 0
   196  spacectl_cmd = SPACECTL_DEALLOC