diff --git a/wasi-filesystem.abi.md b/wasi-filesystem.abi.md index ee310c1..802cfc7 100644 --- a/wasi-filesystem.abi.md +++ b/wasi-filesystem.abi.md @@ -268,25 +268,30 @@ Size: 16, Alignment: 8 Set the timestamp to the given value. -## `dirent`: record +## `dir-entry`: record A directory entry. -Size: 16, Alignment: 8 +Size: 32, Alignment: 8 ### Record Fields -- [`ino`](#dirent.ino): [`inode`](#inode) +- [`ino`](#dir_entry.ino): option<[`inode`](#inode)> - The serial number of the file referred to by this directory entry. + The serial number of the object referred to by this directory entry. + May be none if the inode value is not known. + + When this is none, libc implementations might do an extra `stat-at` + call to retrieve the inode number to fill their `d_ino` fields, so + implementations which can set this to a non-none value should do so. -- [`namelen`](#dirent.namelen): [`size`](#size) +- [`type`](#dir_entry.type): [`descriptor-type`](#descriptor_type) - The length of the name of the directory entry. + The type of the file referred to by this directory entry. -- [`type`](#dirent.type): [`descriptor-type`](#descriptor_type) +- [`name`](#dir_entry.name): `string` - The type of the file referred to by this directory entry. + The name of the object. ## `errno`: enum @@ -787,22 +792,14 @@ Size: 16, Alignment: 8 Read directory entries from a directory. - When successful, the contents of the output buffer consist of a sequence of - directory entries. Each directory entry consists of a `dirent` object, - followed by `dirent::d_namlen` bytes holding the name of the directory - entry. - - This function fills the output buffer as much as possible, potentially - truncating the last directory entry. This allows the caller to grow its - read buffer size in case it's too small to fit a single large directory - entry, or skip the oversized directory entry. + This always returns a new stream which starts at the beginning of the + directory. ##### Params - `self`: handle -- `rewind`: `bool` ##### Results -- stream<`u8`, [`errno`](#errno)> +- stream<[`dir-entry`](#dir_entry), [`errno`](#errno)> ---- diff --git a/wasi-filesystem.wit.md b/wasi-filesystem.wit.md index 08c3652..11a6630 100644 --- a/wasi-filesystem.wit.md +++ b/wasi-filesystem.wit.md @@ -192,16 +192,23 @@ variant new-timestamp { } ``` -## `dirent` +## `dir-entry` ```wit /// A directory entry. -record dirent { - /// The serial number of the file referred to by this directory entry. - ino: inode, - /// The length of the name of the directory entry. - namelen: size, +record dir-entry { + /// The serial number of the object referred to by this directory entry. + /// May be none if the inode value is not known. + /// + /// When this is none, libc implementations might do an extra `stat-at` + /// call to retrieve the inode number to fill their `d_ino` fields, so + /// implementations which can set this to a non-none value should do so. + ino: option, + /// The type of the file referred to by this directory entry. %type: descriptor-type, + + /// The name of the object. + name: string, } ``` @@ -506,19 +513,9 @@ pwrite: func( ```wit /// Read directory entries from a directory. /// -/// When successful, the contents of the output buffer consist of a sequence of -/// directory entries. Each directory entry consists of a `dirent` object, -/// followed by `dirent::d_namlen` bytes holding the name of the directory -/// entry. -/// -/// This function fills the output buffer as much as possible, potentially -/// truncating the last directory entry. This allows the caller to grow its -/// read buffer size in case it's too small to fit a single large directory -/// entry, or skip the oversized directory entry. -readdir: func( - /// If true, rewind the current position to the beginning before reading. - rewind: bool -) -> stream +/// This always returns a new stream which starts at the beginning of the +/// directory. +readdir: func() -> stream ``` ## `seek`