Skip to content

Commit f263fea

Browse files
committed
Remove file_create and add file_mkdir.
Besides being a slight simplification (the only current use of `file_create` is creating directories), if we add ways to create other kinds of filesystem objects in the future, it's desirable to create separate functions for them. WASI has two levels of capabilities -- static and dynamic. The static capabilities are the imports. By using separate functions for separate file types, we can distinguish between the capabilities to create different types of filesystem objects statically. And, users won't often need to specify what type of thing to create dynamicaly. For example, the POSIX interface just has `mkdir`.
1 parent 73ec778 commit f263fea

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

expected/wasm32-wasi/undefined-symbols.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ __wasi_fd_sync
3939
__wasi_fd_write
4040
__wasi_file_advise
4141
__wasi_file_allocate
42-
__wasi_file_create
4342
__wasi_file_link
43+
__wasi_file_mkdir
4444
__wasi_file_open
4545
__wasi_file_readdir
4646
__wasi_file_readlink

libc-bottom-half/cloudlibc/src/libc/sys/stat/mkdirat.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@ int mkdirat(int fd, const char *path, ...) {
1515
#else
1616
int mkdirat(int fd, const char *path, mode_t mode) {
1717
#endif
18+
#ifdef __wasilibc_unmodified_upstream // __wasi_file_mkdir
1819
__wasi_errno_t error = __wasi_file_create(
1920
fd, path, strlen(path), __WASI_FILETYPE_DIRECTORY);
21+
#else
22+
__wasi_errno_t error = __wasi_file_mkdir(
23+
fd, path, strlen(path));
24+
#endif
2025
if (error != 0) {
2126
errno = errno_fixup_directory(fd, error);
2227
return -1;

libc-bottom-half/headers/public/wasi.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -639,12 +639,11 @@ __wasi_errno_t __wasi_file_allocate(
639639
__wasi_filesize_t len
640640
) __WASI_SYSCALL_NAME(file_allocate) __attribute__((__warn_unused_result__));
641641

642-
__wasi_errno_t __wasi_file_create(
642+
__wasi_errno_t __wasi_file_mkdir(
643643
__wasi_fd_t fd,
644644
const char *path,
645-
size_t path_len,
646-
__wasi_filetype_t type
647-
) __WASI_SYSCALL_NAME(file_create) __attribute__((__warn_unused_result__));
645+
size_t path_len
646+
) __WASI_SYSCALL_NAME(file_mkdir) __attribute__((__warn_unused_result__));
648647

649648
__wasi_errno_t __wasi_file_link(
650649
__wasi_fd_t old_fd,

0 commit comments

Comments
 (0)