xref: /aosp_15_r20/external/okio/okio-wasifilesystem/src/wasmWasiMain/kotlin/okio/internal/preview1/Rights.kt (revision f9742813c14b702d71392179818a9e591da8620c)
1 // Copyright 2019-2023 the Contributors to the WASI Specification
2 // This file is adapted from the WASI preview1 spec here:
3 // https://github.com/WebAssembly/WASI/blob/main/legacy/preview1/docs.md
4 package okio.internal.preview1
5 
6 /** `rights: Record`. */
7 typealias rights = Long
8 
9 /**
10  * The right to invoke [`fd_datasync`](#fd_datasync)0
11  * If [`path_open`](#path_open) is set, includes the right to invoke
12  * [`path_open`](#path_open) with [`fdflags::dsync`](#fdflags.dsync).
13  */
14 val right_fd_datasync = 1L shl 0
15 
16 /**
17  * The right to invoke [`fd_read`](#fd_read) and [`sock_recv`](#sock_recv).
18  * If [`rights::fd_seek`](#rights.fd_seek) is set, includes the right to invoke [`fd_pread`](#fd_pread).
19  */
20 val right_fd_read = 1L shl 1
21 
22 /** The right to invoke [`fd_seek`](#fd_seek). This flag implies [`rights::fd_tell`](#rights.fd_tell). */
23 val right_fd_seek = 1L shl 2
24 
25 /** The right to invoke [`fd_fdstat_set_flags`](#fd_fdstat_set_flags). */
26 val right_fd_fdstat_set_flags = 1L shl 3
27 
28 /**
29  * The right to invoke [`fd_sync`](#fd_sync).
30  * If [`path_open`](#path_open) is set, includes the right to invoke
31  * [`path_open`](#path_open) with [`fdflags::rsync`](#fdflags.rsync) and [`fdflags::dsync`](#fdflags.dsync).
32  */
33 val right_fd_sync = 1L shl 4
34 
35 /**
36  * The right to invoke [`fd_seek`](#fd_seek) in such a way that the file offset
37  * remains unaltered (i.e., [`whence::cur`](#whence.cur) with offset zero), or to
38  * invoke [`fd_tell`](#fd_tell).
39  */
40 val right_fd_tell = 1L shl 5
41 
42 /**
43  * The right to invoke [`fd_write`](#fd_write) and [`sock_send`](#sock_send).
44  * If [`rights::fd_seek`](#rights.fd_seek) is set, includes the right to invoke [`fd_pwrite`](#fd_pwrite).
45  */
46 val right_fd_write = 1L shl 6
47 
48 /** The right to invoke [`fd_advise`](#fd_advise). */
49 val right_fd_advise = 1L shl 7
50 
51 /** The right to invoke [`fd_allocate`](#fd_allocate). */
52 val right_fd_allocate = 1L shl 8
53 
54 /** The right to invoke [`path_create_directory`](#path_create_directory). */
55 val right_path_create_directory = 1L shl 9
56 
57 /** If [`path_open`](#path_open) is set, the right to invoke [`path_open`](#path_open) with [`oflags::creat`](#oflags.creat). */
58 val right_path_create_file = 1L shl 10
59 
60 /**
61  * The right to invoke [`path_link`](#path_link) with the file descriptor as the
62  * source directory.
63  */
64 val right_path_link_source = 1L shl 11
65 
66 /** The right to invoke [`path_link`](#path_link) with the file descriptor as the target directory.
67  */
68 val right_path_link_target = 1L shl 12
69 
70 /** The right to invoke [`path_open`](#path_open). */
71 val right_path_open = 1L shl 13
72 
73 /** The right to invoke [`fd_readdir`](#fd_readdir). */
74 val right_fd_readdir = 1L shl 14
75 
76 /** The right to invoke [`path_readlink`](#path_readlink). */
77 val right_path_readlink = 1L shl 15
78 
79 /** The right to invoke [`path_rename`](#path_rename) with the file descriptor as the source directory. */
80 val right_path_rename_source = 1L shl 16
81 
82 /** The right to invoke [`path_rename`](#path_rename) with the file descriptor as the target directory. */
83 val right_path_rename_target = 1L shl 17
84 
85 /** The right to invoke [`path_filestat_get`](#path_filestat_get). */
86 val right_path_filestat_get = 1L shl 18
87 
88 /**
89  * The right to change a file's size.
90  * If [`path_open`](#path_open) is set, includes the right to invoke [`path_open`](#path_open) with [`oflags::trunc`](#oflags.trunc).
91  * Note: there is no function named `path_filestat_set_size`. This follows POSIX design,
92  * which only has `ftruncate` and does not provide `ftruncateat`.
93  * While such function would be desirable from the API design perspective, there are virtually
94  * no use cases for it since no code written for POSIX systems would use it.
95  * Moreover, implementing it would require multiple syscalls, leading to inferior performance.
96  */
97 val right_path_filestat_set_size = 1L shl 19
98 
99 /** The right to invoke [`path_filestat_set_times`](#path_filestat_set_times). */
100 val right_path_filestat_set_times = 1L shl 20
101 
102 /** The right to invoke [`fd_filestat_get`](#fd_filestat_get). */
103 val right_fd_filestat_get = 1L shl 21
104 
105 /** The right to invoke [`fd_filestat_set_size`](#fd_filestat_set_size). */
106 val right_fd_filestat_set_size = 1L shl 22
107 
108 /** The right to invoke [`fd_filestat_set_times`](#fd_filestat_set_times). */
109 val right_fd_filestat_set_times = 1L shl 23
110 
111 /** The right to invoke [`path_symlink`](#path_symlink). */
112 val right_path_symlink = 1L shl 24
113 
114 /** The right to invoke [`path_remove_directory`](#path_remove_directory). */
115 val right_path_remove_directory = 1L shl 25
116 
117 /** The right to invoke [`path_unlink_file`](#path_unlink_file). */
118 val right_path_unlink_file = 1L shl 26
119 
120 /**
121  * If [`rights::fd_read`](#rights.fd_read) is set, includes the right to invoke [`poll_oneoff`](#poll_oneoff) to subscribe to [`eventtype::fd_read`](#eventtype.fd_read).
122  * If [`rights::fd_write`](#rights.fd_write) is set, includes the right to invoke [`poll_oneoff`](#poll_oneoff) to subscribe to [`eventtype::fd_write`](#eventtype.fd_write).
123  */
124 val right_poll_fd_readwrite = 1L shl 27
125 
126 /** The right to invoke [`sock_shutdown`](#sock_shutdown). */
127 val right_sock_shutdown = 1L shl 28
128 
129 /** The right to invoke [`sock_accept`](#sock_accept). */
130 val right_sock_accept = 1L shl 29
131