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