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
4include <sys/types.h>
5include <sys/stat.h>
6include <fcntl.h>
7include <unistd.h>
8
9resource fd[int32]: 0xffffffffffffffff, AT_FDCWD
10resource fd_dir[fd]
11
12resource pid[int32]: 0, 0xffffffffffffffff
13resource uid[int32]: 0, 0xffffffffffffffff
14resource gid[int32]: 0, 0xffffffffffffffff
15
16open(file ptr[in, filename], flags flags[open_flags], mode flags[open_mode]) fd
17# Just so that we have something that creates fd_dir resources.
18open$dir(file ptr[in, filename], flags flags[open_flags], mode flags[open_mode]) fd_dir
19openat(fd fd_dir[opt], file ptr[in, filename], flags flags[open_flags], mode flags[open_mode]) fd
20close(fd fd)
21read(fd fd, buf buffer[out], count len[buf])
22readv(fd fd, vec ptr[in, array[iovec_out]], vlen len[vec])
23preadv(fd fd, vec ptr[in, array[iovec_out]], vlen len[vec], off fileoff)
24write(fd fd, buf buffer[in], count len[buf])
25writev(fd fd, vec ptr[in, array[iovec_in]], vlen len[vec])
26pwritev(fd fd, vec ptr[in, array[iovec_in]], vlen len[vec], off fileoff)
27lseek(fd fd, offset fileoff, whence flags[seek_whence])
28dup(oldfd fd) fd
29dup2(oldfd fd, newfd fd) fd
30pipe2(pipefd ptr[out, pipefd], flags flags[pipe_flags])
31
32pipefd {
33	rfd	fd
34	wfd	fd
35}
36
37iovec_in {
38	addr	buffer[in]
39	len	len[addr, intptr]
40}
41
42iovec_out {
43	addr	buffer[out]
44	len	len[addr, intptr]
45}
46
47stat {
48	dev	int64
49	ino	int64
50	mode	int32
51	nlink	int32
52	rdev	int64
53	size	int64
54	blksize	int32
55	blocks	int64
56	atime	int64
57	ansec	int64
58	mtime	int64
59	mnsec	int64
60	ctime	int64
61	cnsec	int64
62	pad1	int32
63	pad2	int32
64}
65
66open_flags = O_RDONLY, O_WRONLY, O_RDWR, O_APPEND, O_CREAT, O_TRUNC, O_EXCL, O_SHLOCK, O_EXLOCK, O_NOFOLLOW, O_CLOEXEC, O_NOSIGPIPE, O_DSYNC, O_SYNC, O_RSYNC, O_ALT_IO, O_NOCTTY, O_DIRECT, O_DIRECTORY, O_ASYNC
67open_mode = S_IRUSR, S_IWUSR, S_IXUSR, S_IRGRP, S_IWGRP, S_IXGRP, S_IROTH, S_IWOTH, S_IXOTH
68seek_whence = SEEK_SET, SEEK_CUR, SEEK_END
69pipe_flags = O_NONBLOCK, O_CLOEXEC, O_NOSIGPIPE
70