X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/1375eb51603466b723ab7dd1ca4194ee5d662f75..b60166b327a9108b07e3069fa6568a451529ffd9:/lunaix-os/kernel/fs/vfs.c?ds=sidebyside diff --git a/lunaix-os/kernel/fs/vfs.c b/lunaix-os/kernel/fs/vfs.c index 490b4df..c59584a 100644 --- a/lunaix-os/kernel/fs/vfs.c +++ b/lunaix-os/kernel/fs/vfs.c @@ -860,7 +860,7 @@ vfs_readlink(struct v_dnode* dnode, char* buf, size_t size) int vfs_get_dtype(int itype) { - if ((itype & VFS_IFSYMLINK)) { + if ((itype & VFS_IFSYMLINK) == VFS_IFSYMLINK) { return DT_SYMLINK; } else if (!(itype & VFS_IFFILE)) { return DT_DIR; @@ -1003,6 +1003,11 @@ __DEFINE_LXSYSCALL1(int, mkdir, const char*, path) goto done; } + if (!(errno = vfs_walk(parent, name_value, &dir, NULL, 0))) { + errno = EEXIST; + goto done; + } + if ((errno = vfs_check_writable(parent))) { goto done; } @@ -1235,14 +1240,19 @@ void vfs_ref_dnode(struct v_dnode* dnode) { atomic_fetch_add(&dnode->ref_count, 1); - mnt_mkbusy(dnode->mnt); + + if (dnode->mnt) { + mnt_mkbusy(dnode->mnt); + } } void vfs_unref_dnode(struct v_dnode* dnode) { atomic_fetch_sub(&dnode->ref_count, 1); - mnt_chillax(dnode->mnt); + if (dnode->mnt) { + mnt_chillax(dnode->mnt); + } } int @@ -1327,7 +1337,7 @@ __DEFINE_LXSYSCALL2(char*, getcwd, char*, buf, size_t, size) ret_ptr = buf; done: - __current->k_status = errno; + syscall_result(errno); return ret_ptr; } @@ -1448,7 +1458,7 @@ __DEFINE_LXSYSCALL2(int, fstat, int, fd, struct file_stat*, stat) .st_blksize = vino->sb->blksize}; if (VFS_DEVFILE(vino->itype)) { - struct device* rdev = (struct device*)vino->data; + struct device* rdev = resolve_device(vino->data); if (!rdev || rdev->magic != DEV_STRUCT_MAGIC) { errno = EINVAL; goto done;