Skip to content

Commit

Permalink
libwasi_littlefs: implement wasi_lfs_fd_close
Browse files Browse the repository at this point in the history
  • Loading branch information
yamt committed Feb 27, 2024
1 parent b808722 commit 4d5691e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion libwasi_littlefs/wasi_littlefs_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,18 @@ wasi_lfs_fd_futimes(struct wasi_fdinfo *fdinfo, const struct utimes_args *args)
int
wasi_lfs_fd_close(struct wasi_fdinfo *fdinfo)
{
return ENOTSUP;
struct wasi_vfs_lfs *vfs_lfs;
struct wasi_fdinfo_lfs *fdinfo_lfs;
fdinfo_to_lfs(fdinfo, &vfs_lfs, &fdinfo_lfs);
int ret;
if (fdinfo_lfs->type == WASI_LFS_TYPE_FILE) {
ret = lfs_file_close(&vfs_lfs->lfs, &fdinfo_lfs->u.file);
} else {
assert(fdinfo_lfs->type == WASI_LFS_TYPE_DIR);
ret = lfs_dir_close(&vfs_lfs->lfs, &fdinfo_lfs->u.dir);
}
fdinfo_lfs->type = WASI_LFS_TYPE_NONE;
return lfs_error_to_errno(ret);
}

int
Expand Down

0 comments on commit 4d5691e

Please sign in to comment.