- if (!(errno = vfs_walk(NULL, path, fdir, &name, VFS_WALK_PARENT))) {
- errno = vfs_walk(*fdir, name.value, file, NULL, 0);
- if (errno == ENOENT && (options & FLOCATE_CREATE_EMPTY)) {
- struct v_dnode* file_new;
- file_new = vfs_d_alloc();
- file_new->name =
- HHSTR(valloc(VFS_NAME_MAXLEN), name.len, name.hash);
- strcpy(file_new->name.value, name_str);
- *file = file_new;
-
- llist_append(&(*fdir)->children, &file_new->siblings);
- }
+ if ((errno = vfs_walk(NULL, path, fdir, &name, VFS_WALK_PARENT))) {
+ return errno;
+ }
+
+ errno = vfs_walk(*fdir, name.value, file, NULL, 0);
+ if (errno != ENOENT || !(options & FLOCATE_CREATE_EMPTY)) {
+ return errno;
+ }
+
+ if (!(errno = (*fdir)->inode->ops.create((*fdir)->inode))) {
+ struct v_dnode* file_new;
+ file_new = vfs_d_alloc();
+ file_new->name = HHSTR(valloc(VFS_NAME_MAXLEN), name.len, name.hash);
+ strcpy(file_new->name.value, name_str);
+ *file = file_new;
+
+ llist_append(&(*fdir)->children, &file_new->siblings);