From 4f8bb6643aa097008341b044e67991e3ec039f38 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Thu, 15 Aug 2024 20:29:46 +0200 Subject: ext2fs: don't create files unless OPEN_CREATE is set --- src/cmd/ext2fs/main.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/cmd/ext2fs/main.c') 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); -- cgit v1.2.3