summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cmd/ext2fs/main.c8
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);