feat: capability list to enable greater flexibility of devices
[lunaix-os.git] / lunaix-os / kernel / fs / vfs.c
index 80d2036b88ab8657e48fa45ab96ab566d3b7f256..28cede5e5a2ad44e2dc90487acb3dad79c98e93e 100644 (file)
@@ -708,7 +708,7 @@ __DEFINE_LXSYSCALL3(int, read, int, fd, void*, buf, size_t, count)
     file->inode->atime = clock_unixtime();
 
     if ((file->inode->itype & VFS_IFSEQDEV) || (fd_s->flags & FO_DIRECT)) {
-        errno = file->ops->read(file->inode, buf, count, file->f_pos);
+    errno = file->ops->read(file->inode, buf, count, file->f_pos);
     } else {
         errno = pcache_read(file->inode, buf, count, file->f_pos);
     }
@@ -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;
     }