forked from tetratelabs/wazero
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rights.go
148 lines (117 loc) · 4.31 KB
/
rights.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
package wasip1
// See https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#-rights-flagsu64
const (
// RIGHT_FD_DATASYNC is the right to invoke fd_datasync. If RIGHT_PATH_OPEN
// is set, includes the right to invoke path_open with FD_DSYNC.
RIGHT_FD_DATASYNC uint32 = 1 << iota //nolint
// RIGHT_FD_READ is he right to invoke fd_read and sock_recv. If
// RIGHT_FD_SYNC is set, includes the right to invoke fd_pread.
RIGHT_FD_READ
// RIGHT_FD_SEEK is the right to invoke fd_seek. This flag implies
// RIGHT_FD_TELL.
RIGHT_FD_SEEK
// RIGHT_FDSTAT_SET_FLAGS is the right to invoke fd_fdstat_set_flags.
RIGHT_FDSTAT_SET_FLAGS
// RIGHT_FD_SYNC The right to invoke fd_sync. If path_open is set, includes
// the right to invoke path_open with FD_RSYNC and FD_DSYNC.
RIGHT_FD_SYNC
// RIGHT_FD_TELL is the right to invoke fd_seek in such a way that the file
// offset remains unaltered (i.e., whence::cur with offset zero), or to
// invoke fd_tell.
RIGHT_FD_TELL
// RIGHT_FD_WRITE is the right to invoke fd_write and sock_send. If
// RIGHT_FD_SEEK is set, includes the right to invoke fd_pwrite.
RIGHT_FD_WRITE
// RIGHT_FD_ADVISE is the right to invoke fd_advise.
RIGHT_FD_ADVISE
// RIGHT_FD_ALLOCATE is the right to invoke fd_allocate.
RIGHT_FD_ALLOCATE
// RIGHT_PATH_CREATE_DIRECTORY is the right to invoke
// path_create_directory.
RIGHT_PATH_CREATE_DIRECTORY
// RIGHT_PATH_CREATE_FILE when RIGHT_PATH_OPEN is set, the right to invoke
// path_open with O_CREAT.
RIGHT_PATH_CREATE_FILE
// RIGHT_PATH_LINK_SOURCE is the right to invoke path_link with the file
// descriptor as the source directory.
RIGHT_PATH_LINK_SOURCE
// RIGHT_PATH_LINK_TARGET is the right to invoke path_link with the file
// descriptor as the target directory.
RIGHT_PATH_LINK_TARGET
// RIGHT_PATH_OPEN is the right to invoke path_open.
RIGHT_PATH_OPEN
// RIGHT_FD_READDIR is the right to invoke fd_readdir.
RIGHT_FD_READDIR
// RIGHT_PATH_READLINK is the right to invoke path_readlink.
RIGHT_PATH_READLINK
// RIGHT_PATH_RENAME_SOURCE is the right to invoke path_rename with the
// file descriptor as the source directory.
RIGHT_PATH_RENAME_SOURCE
// RIGHT_PATH_RENAME_TARGET is the right to invoke path_rename with the
// file descriptor as the target directory.
RIGHT_PATH_RENAME_TARGET
// RIGHT_PATH_FILESTAT_GET is the right to invoke path_filestat_get.
RIGHT_PATH_FILESTAT_GET
// RIGHT_PATH_FILESTAT_SET_SIZE is the right to change a file's size (there
// is no path_filestat_set_size). If RIGHT_PATH_OPEN is set, includes the
// right to invoke path_open with O_TRUNC.
RIGHT_PATH_FILESTAT_SET_SIZE
// RIGHT_PATH_FILESTAT_SET_TIMES is the right to invoke
// path_filestat_set_times.
RIGHT_PATH_FILESTAT_SET_TIMES
// RIGHT_FD_FILESTAT_GET is the right to invoke fd_filestat_get.
RIGHT_FD_FILESTAT_GET
// RIGHT_FD_FILESTAT_SET_SIZE is the right to invoke fd_filestat_set_size.
RIGHT_FD_FILESTAT_SET_SIZE
// RIGHT_FD_FILESTAT_SET_TIMES is the right to invoke
// fd_filestat_set_times.
RIGHT_FD_FILESTAT_SET_TIMES
// RIGHT_PATH_SYMLINK is the right to invoke path_symlink.
RIGHT_PATH_SYMLINK
// RIGHT_PATH_REMOVE_DIRECTORY is the right to invoke
// path_remove_directory.
RIGHT_PATH_REMOVE_DIRECTORY
// RIGHT_PATH_UNLINK_FILE is the right to invoke path_unlink_file.
RIGHT_PATH_UNLINK_FILE
// RIGHT_POLL_FD_READWRITE when RIGHT_FD_READ is set, includes the right to
// invoke poll_oneoff to subscribe to eventtype::fd_read. If RIGHT_FD_WRITE
// is set, includes the right to invoke poll_oneoff to subscribe to
// eventtype::fd_write.
RIGHT_POLL_FD_READWRITE
// RIGHT_SOCK_SHUTDOWN is the right to invoke sock_shutdown.
RIGHT_SOCK_SHUTDOWN
)
func RightsString(rights int) string {
return flagsString(rightNames[:], rights)
}
var rightNames = [...]string{
"FD_DATASYNC",
"FD_READ",
"FD_SEEK",
"FDSTAT_SET_FLAGS",
"FD_SYNC",
"FD_TELL",
"FD_WRITE",
"FD_ADVISE",
"FD_ALLOCATE",
"PATH_CREATE_DIRECTORY",
"PATH_CREATE_FILE",
"PATH_LINK_SOURCE",
"PATH_LINK_TARGET",
"PATH_OPEN",
"FD_READDIR",
"PATH_READLINK",
"PATH_RENAME_SOURCE",
"PATH_RENAME_TARGET",
"PATH_FILESTAT_GET",
"PATH_FILESTAT_SET_SIZE",
"PATH_FILESTAT_SET_TIMES",
"FD_FILESTAT_GET",
"FD_FILESTAT_SET_SIZE",
"FD_FILESTAT_SET_TIMES",
"PATH_SYMLINK",
"PATH_REMOVE_DIRECTORY",
"PATH_UNLINK_FILE",
"POLL_FD_READWRITE",
"SOCK_SHUTDOWN",
}