diff --git a/fs/vfs/inode.c b/fs/vfs/inode.c index 4d847b0..c7d4e83 100644 --- a/fs/vfs/inode.c +++ b/fs/vfs/inode.c @@ -79,7 +79,7 @@ int inode_find_dirent_locked(inode_t *inode, const char *name, dirent_t **out) int inode_find_dirent(inode_t *inode, const char *name, dirent_t **out) { - if (inode->mode != INODE_DIRECTORY) + if ((inode->mode & S_IFMT) != S_IFDIR) return -ENOTDIR; read_lock(&inode->rwlock); diff --git a/fs/vfs/vfs.c b/fs/vfs/vfs.c index 7926d16..f7428b1 100644 --- a/fs/vfs/vfs.c +++ b/fs/vfs/vfs.c @@ -177,12 +177,12 @@ int vfs_creat(dirent_t *parent, const char *name, u64 mode, int flags, dirent_t if (len > 255) return -ENAMETOOLONG; - if (ino->mode != INODE_DIRECTORY) + if ((ino->mode & S_IFMT) != S_IFDIR) return -ENOTDIR; write_lock(&ino->rwlock); - if (ino->mode != INODE_DIRECTORY) { + if ((ino->mode &S_IFMT) != S_IFDIR) { write_unlock(&ino->rwlock); return -ENOTDIR; } @@ -231,7 +231,7 @@ int vfs_unlink(dirent_t *parent, const char *name) write_lock(&ino->rwlock); - if (ino->mode != INODE_DIRECTORY) { + if ((ino->mode & S_IFMT)!= S_IFDIR) { write_unlock(&ino->rwlock); return -ENOTDIR; } diff --git a/include/fs/inode.h b/include/fs/inode.h index a78ade7..07e7c37 100644 --- a/include/fs/inode.h +++ b/include/fs/inode.h @@ -20,15 +20,6 @@ #define DIRENT_TYPE(dirent) ((dirent)->flags & 0x7) -#define INODE_UNKNOWN 0x0 -#define INODE_REGULAR 0x1 -#define INODE_DIRECTORY 0x2 -#define INODE_CHRDEV 0x3 -#define INODE_BLKDEV 0x4 -#define INODE_FIFO 0x5 -#define INODE_SOCKET 0x6 -#define INODE_SYMLINK 0x7 - typedef struct _inode inode_t; typedef struct _dirent dirent_t; typedef struct _fs fs_t;