A Total Overhaul on the Lunaix's Virtual Memory Model (#26)
[lunaix-os.git] / lunaix-os / kernel / fs / vfs.c
index 80d2036b88ab8657e48fa45ab96ab566d3b7f256..eb4239639e84082ff89f13effb20da6a4e00e054 100644 (file)
@@ -47,7 +47,6 @@
 #include <lunaix/foptions.h>
 #include <lunaix/fs.h>
 #include <lunaix/mm/cake.h>
-#include <lunaix/mm/page.h>
 #include <lunaix/mm/valloc.h>
 #include <lunaix/process.h>
 #include <lunaix/spike.h>
@@ -860,7 +859,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 +1002,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;
     }
@@ -1332,7 +1336,7 @@ __DEFINE_LXSYSCALL2(char*, getcwd, char*, buf, size_t, size)
     ret_ptr = buf;
 
 done:
-    __current->k_status = errno;
+    syscall_result(errno);
     return ret_ptr;
 }
 
@@ -1449,7 +1453,7 @@ __DEFINE_LXSYSCALL2(int, fstat, int, fd, struct file_stat*, stat)
                                .st_blocks = vino->lb_usage,
                                .st_size = vino->fsize,
                                .mode = vino->itype,
-                               .st_ioblksize = PG_SIZE,
+                               .st_ioblksize = PAGE_SIZE,
                                .st_blksize = vino->sb->blksize};
 
     if (VFS_DEVFILE(vino->itype)) {