diff options
author | dzwdz | 2024-08-15 20:29:46 +0200 |
---|---|---|
committer | dzwdz | 2024-08-15 20:29:46 +0200 |
commit | 4f8bb6643aa097008341b044e67991e3ec039f38 (patch) | |
tree | e357d5324d556cd5dda01f64af793afea14790cf /src/cmd/ext2fs | |
parent | 27b8676963d5d69353f44fde7faaa9a4dfe1567b (diff) |
ext2fs: don't create files unless OPEN_CREATE is set
Diffstat (limited to 'src/cmd/ext2fs')
-rw-r--r-- | src/cmd/ext2fs/main.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/cmd/ext2fs/main.c b/src/cmd/ext2fs/main.c index 1099df6..f45f75c 100644 --- a/src/cmd/ext2fs/main.c +++ b/src/cmd/ext2fs/main.c @@ -56,11 +56,17 @@ do_open(struct ext2 *fs, hid_t reqh, struct ufs_request *req, char *buf) { bool is_dir = req->len == 0 || buf[req->len-1] == '/'; uint32_t n = ext2c_walk(fs, buf, req->len); - if (n == 0) { + if (n == 0) { /* didn't find anything */ + if ((req->flags & OPEN_CREATE) == 0) { + _sys_fs_respond(reqh, NULL, -ENOENT, 0); + return; + } if (is_dir) { + // TODO support creating directories _sys_fs_respond(reqh, NULL, -ENOSYS, 0); return; } + /* buf[0] == '/', strrchr != NULL */ char *name = strrchr(buf, '/') + 1; uint32_t dir_n = ext2c_walk(fs, buf, name - buf); |