diff --git a/README.md b/README.md index 9f9457a..b1e7ec3 100644 --- a/README.md +++ b/README.md @@ -1870,6 +1870,10 @@ Possible values: The file refers to a symbolic link inode. +- **`UVWASI_FILETYPE_FIFO`** + + The file descriptor or file refers to a FIFO. + ### `uvwasi_fstflags_t` (`uint16_t` bitfield) Which file time attributes to adjust. diff --git a/include/wasi_types.h b/include/wasi_types.h index ffa3614..ab3cc69 100644 --- a/include/wasi_types.h +++ b/include/wasi_types.h @@ -141,6 +141,7 @@ typedef uint8_t uvwasi_filetype_t; #define UVWASI_FILETYPE_SOCKET_DGRAM 5 #define UVWASI_FILETYPE_SOCKET_STREAM 6 #define UVWASI_FILETYPE_SYMBOLIC_LINK 7 +#define UVWASI_FILETYPE_FIFO 8 typedef uint16_t uvwasi_fstflags_t; /* Bitfield */ #define UVWASI_FILESTAT_SET_ATIM (1 << 0) diff --git a/src/uv_mapping.c b/src/uv_mapping.c index a0963b2..9314855 100644 --- a/src/uv_mapping.c +++ b/src/uv_mapping.c @@ -134,7 +134,7 @@ uvwasi_filetype_t uvwasi__stat_to_filetype(const uv_stat_t* stat) { #ifdef S_ISFIFO if (S_ISFIFO(mode)) - return UVWASI_FILETYPE_SOCKET_STREAM; + return UVWASI_FILETYPE_FIFO; #endif /* S_ISFIFO */ #ifdef S_ISBLK diff --git a/src/uvwasi.c b/src/uvwasi.c index 74d0c46..acda64f 100644 --- a/src/uvwasi.c +++ b/src/uvwasi.c @@ -1460,6 +1460,8 @@ uvwasi_errno_t uvwasi_fd_readdir(uvwasi_t* uvwasi, dirent.d_type = UVWASI_FILETYPE_BLOCK_DEVICE; break; case UV_DIRENT_FIFO: + dirent.d_type = UVWASI_FILETYPE_FIFO; + break; case UV_DIRENT_UNKNOWN: default: dirent.d_type = UVWASI_FILETYPE_UNKNOWN; diff --git a/src/wasi_rights.c b/src/wasi_rights.c index 79d0338..a44919e 100644 --- a/src/wasi_rights.c +++ b/src/wasi_rights.c @@ -45,6 +45,11 @@ uvwasi_errno_t uvwasi__get_rights(uv_file fd, *rights_inheriting = UVWASI__RIGHTS_BLOCK_DEVICE_INHERITING; break; + case UVWASI_FILETYPE_FIFO: + *rights_base = UVWASI__RIGHTS_FIFO_BASE; + *rights_inheriting = UVWASI__RIGHTS_FIFO_INHERITING; + break; + default: *rights_base = 0; *rights_inheriting = 0; diff --git a/src/wasi_rights.h b/src/wasi_rights.h index fb19bd0..6510bdf 100644 --- a/src/wasi_rights.h +++ b/src/wasi_rights.h @@ -93,6 +93,13 @@ UVWASI_RIGHT_POLL_FD_READWRITE) #define UVWASI__RIGHTS_TTY_INHERITING 0 +#define UVWASI__RIGHTS_FIFO_BASE (UVWASI_RIGHT_FD_READ | \ + UVWASI_RIGHT_FD_FDSTAT_SET_FLAGS | \ + UVWASI_RIGHT_FD_WRITE | \ + UVWASI_RIGHT_FD_FILESTAT_GET | \ + UVWASI_RIGHT_POLL_FD_READWRITE) +#define UVWASI__RIGHTS_FIFO_INHERITING UVWASI__RIGHTS_ALL + uvwasi_errno_t uvwasi__get_rights(uv_file fd, int flags,