diff --git a/wasi-filesystem.abi.md b/wasi-filesystem.abi.md index 3dc7f0c..ee310c1 100644 --- a/wasi-filesystem.abi.md +++ b/wasi-filesystem.abi.md @@ -26,25 +26,7 @@ Size: 8, Alignment: 8 Size: 8, Alignment: 8 -## `fd-info`: record - - Information associated with a descriptor. - - Note: This was called `fdstat` in earlier versions of WASI. - -Size: 2, Alignment: 1 - -### Record Fields - -- [`type`](#fd_info.type): [`type`](#type) - - The type of filesystem object referenced by a descriptor. - -- [`flags`](#fd_info.flags): [`flags`](#flags) - - Flags associated with a descriptor. - -## `type`: enum +## `descriptor-type`: enum The type of a filesystem object referenced by a descriptor. @@ -54,82 +36,82 @@ Size: 1, Alignment: 1 ### Enum Cases -- [`unknown`](#type.unknown) +- [`unknown`](#descriptor_type.unknown) The type of the descriptor or file is unknown or is different from any of the other types specified. -- [`block-device`](#type.block_device) +- [`block-device`](#descriptor_type.block_device) The descriptor refers to a block device inode. -- [`character-device`](#type.character_device) +- [`character-device`](#descriptor_type.character_device) The descriptor refers to a character device inode. -- [`directory`](#type.directory) +- [`directory`](#descriptor_type.directory) The descriptor refers to a directory inode. -- [`fifo`](#type.fifo) +- [`fifo`](#descriptor_type.fifo) The descriptor refers to a named pipe. -- [`symbolic-link`](#type.symbolic_link) +- [`symbolic-link`](#descriptor_type.symbolic_link) The file refers to a symbolic link inode. -- [`regular-file`](#type.regular_file) +- [`regular-file`](#descriptor_type.regular_file) The descriptor refers to a regular file inode. -- [`socket`](#type.socket) +- [`socket`](#descriptor_type.socket) The descriptor refers to a socket. -## `flags`: flags +## `descriptor-flags`: flags Descriptor flags. - Note: This was called `fd-flags` in earlier versions of WASI. + Note: This was called `fdflags` in earlier versions of WASI. Size: 1, Alignment: 1 ### Flags Fields -- [`read`](#flags.read) +- [`read`](#descriptor_flags.read) Read mode: Data can be read. Bit: 0 -- [`write`](#flags.write) +- [`write`](#descriptor_flags.write) Write mode: Data can be written to. Bit: 1 -- [`append`](#flags.append) +- [`append`](#descriptor_flags.append) Append mode: Data written to the file is always appended to the file's end. Bit: 2 -- [`dsync`](#flags.dsync) +- [`dsync`](#descriptor_flags.dsync) Write according to synchronized I/O data integrity completion. Only the data stored in the file is synchronized. Bit: 3 -- [`nonblock`](#flags.nonblock) +- [`nonblock`](#descriptor_flags.nonblock) Non-blocking mode. Bit: 4 -- [`rsync`](#flags.rsync) +- [`rsync`](#descriptor_flags.rsync) Synchronized read I/O operations. Bit: 5 -- [`sync`](#flags.sync) +- [`sync`](#descriptor_flags.sync) Write according to synchronized I/O file integrity completion. In addition to synchronizing the data stored in the file, the @@ -154,7 +136,7 @@ Size: 64, Alignment: 8 File serial number. -- [`type`](#stat.type): [`type`](#type) +- [`type`](#stat.type): [`descriptor-type`](#descriptor_type) File type. @@ -302,7 +284,7 @@ Size: 16, Alignment: 8 The length of the name of the directory entry. -- [`type`](#dirent.type): [`type`](#type) +- [`type`](#dirent.type): [`descriptor-type`](#descriptor_type) The type of the file referred to by this directory entry. @@ -347,7 +329,7 @@ Size: 1, Alignment: 1 - [`badf`](#errno.badf) - Bad file descriptor. + Bad descriptor. - [`badmsg`](#errno.badmsg) @@ -680,20 +662,58 @@ Size: 16, Alignment: 8 ---- -#### `descriptor::info` +#### `descriptor::flags` + + Get flags associated with a descriptor. + + Note: This returns similar flags to `fcntl(fd, F_GETFL)` in POSIX. + + Note: This returns the value that was the `fs_flags` value returned + from `fdstat_get` in earlier versions of WASI. +##### Params + +- `self`: handle +##### Results + +- result<[`descriptor-flags`](#descriptor_flags), [`errno`](#errno)> + +---- + +#### `descriptor::type` + + Get the dynamic type of a descriptor. + + Note: This returns the same value as the `type` field of the `fd-stat` + returned by `stat`, `stat-at` and similar. + + Note: This returns similar flags to the `st_mode & S_IFMT` value provided + by `fstat` in POSIX. + + Note: This returns the value that was the `fs_filetype` value returned + from `fdstat_get` in earlier versions of WASI. +##### Params + +- `self`: handle +##### Results + +- result<[`descriptor-type`](#descriptor_type), [`errno`](#errno)> + +---- + +#### `descriptor::set-flags` - Get information associated with a descriptor. + Set flags associated with a descriptor. - Note: This returns similar flags to `fcntl(fd, F_GETFL)` in POSIX, as well - as additional fields. + Note: This is similar to `fcntl(fd, F_SETFL, flags)` in POSIX. - Note: This was called `fdstat_get` in earlier versions of WASI. + Note: This was called `fd_fdstat_set_flags` in earlier versions of WASI. ##### Params -- `self`: handle +- `self`: handle +- `flags`: [`descriptor-flags`](#descriptor_flags) ##### Results -- result<[`fd-info`](#fd_info), [`errno`](#errno)> +- result<_, [`errno`](#errno)> ---- @@ -923,7 +943,7 @@ Size: 16, Alignment: 8 - `at-flags`: [`at-flags`](#at_flags) - `path`: `string` - `o-flags`: [`o-flags`](#o_flags) -- `flags`: [`flags`](#flags) +- `flags`: [`descriptor-flags`](#descriptor_flags) - `mode`: [`mode`](#mode) ##### Results diff --git a/wasi-filesystem.wit.md b/wasi-filesystem.wit.md index cedcd5d..08c3652 100644 --- a/wasi-filesystem.wit.md +++ b/wasi-filesystem.wit.md @@ -40,25 +40,12 @@ type filedelta = s64 type timestamp = u64 ``` -## `fd-info` -```wit -/// Information associated with a descriptor. -/// -/// Note: This was called `fdstat` in earlier versions of WASI. -record fd-info { - /// The type of filesystem object referenced by a descriptor. - %type: %type, - /// Flags associated with a descriptor. - %flags: %flags, -} -``` - -## `type` +## `descriptor-type` ```wit /// The type of a filesystem object referenced by a descriptor. /// /// Note: This was called `filetype` in earlier versions of WASI. -enum %type { +enum descriptor-type { /// The type of the descriptor or file is unknown or is different from /// any of the other types specified. unknown, @@ -79,12 +66,12 @@ enum %type { } ``` -## `flags` +## `descriptor-flags` ```wit /// Descriptor flags. /// -/// Note: This was called `fd-flags` in earlier versions of WASI. -flags %flags { +/// Note: This was called `fdflags` in earlier versions of WASI. +flags descriptor-flags { /// Read mode: Data can be read. read, /// Write mode: Data can be written to. @@ -117,7 +104,7 @@ record stat { /// File serial number. ino: inode, /// File type. - %type: %type, + %type: descriptor-type, /// Number of hard links to the file. nlink: linkcount, /// For regular files, the file size in bytes. For symbolic links, the length @@ -214,7 +201,7 @@ record dirent { /// The length of the name of the directory entry. namelen: size, /// The type of the file referred to by this directory entry. - %type: %type, + %type: descriptor-type, } ``` @@ -239,7 +226,7 @@ enum errno { again, /// Connection already in progress. already, - /// Bad file descriptor. + /// Bad descriptor. badf, /// Bad message. badmsg, @@ -429,15 +416,40 @@ fadvise: func( datasync: func() -> result<_, errno> ``` -## `info` +## `flags` +```wit +/// Get flags associated with a descriptor. +/// +/// Note: This returns similar flags to `fcntl(fd, F_GETFL)` in POSIX. +/// +/// Note: This returns the value that was the `fs_flags` value returned +/// from `fdstat_get` in earlier versions of WASI. +%flags: func() -> result +``` + +## `type` +```wit +/// Get the dynamic type of a descriptor. +/// +/// Note: This returns the same value as the `type` field of the `fd-stat` +/// returned by `stat`, `stat-at` and similar. +/// +/// Note: This returns similar flags to the `st_mode & S_IFMT` value provided +/// by `fstat` in POSIX. +/// +/// Note: This returns the value that was the `fs_filetype` value returned +/// from `fdstat_get` in earlier versions of WASI. +%type: func() -> result +``` + +## `set-flags` ```wit -/// Get information associated with a descriptor. +/// Set flags associated with a descriptor. /// -/// Note: This returns similar flags to `fcntl(fd, F_GETFL)` in POSIX, as well -/// as additional fields. +/// Note: This is similar to `fcntl(fd, F_SETFL, flags)` in POSIX. /// -/// Note: This was called `fdstat_get` in earlier versions of WASI. -info: func() -> result +/// Note: This was called `fd_fdstat_set_flags` in earlier versions of WASI. +set-flags: func(%flags: descriptor-flags) -> result<_, errno> ``` ## `set-size` @@ -623,7 +635,7 @@ open-at: func( /// The method by which to open the file. o-flags: o-flags, /// Flags to use for the resulting descriptor. - %flags: %flags, + %flags: descriptor-flags, /// Permissions to use when creating a new file. mode: mode ) -> result