vfs: add S_IFMT mask
Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
parent
260ed8a013
commit
f24cd3ef74
3 changed files with 4 additions and 13 deletions
|
|
@ -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)
|
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;
|
return -ENOTDIR;
|
||||||
|
|
||||||
read_lock(&inode->rwlock);
|
read_lock(&inode->rwlock);
|
||||||
|
|
|
||||||
|
|
@ -177,12 +177,12 @@ int vfs_creat(dirent_t *parent, const char *name, u64 mode, int flags, dirent_t
|
||||||
if (len > 255)
|
if (len > 255)
|
||||||
return -ENAMETOOLONG;
|
return -ENAMETOOLONG;
|
||||||
|
|
||||||
if (ino->mode != INODE_DIRECTORY)
|
if ((ino->mode & S_IFMT) != S_IFDIR)
|
||||||
return -ENOTDIR;
|
return -ENOTDIR;
|
||||||
|
|
||||||
write_lock(&ino->rwlock);
|
write_lock(&ino->rwlock);
|
||||||
|
|
||||||
if (ino->mode != INODE_DIRECTORY) {
|
if ((ino->mode &S_IFMT) != S_IFDIR) {
|
||||||
write_unlock(&ino->rwlock);
|
write_unlock(&ino->rwlock);
|
||||||
return -ENOTDIR;
|
return -ENOTDIR;
|
||||||
}
|
}
|
||||||
|
|
@ -231,7 +231,7 @@ int vfs_unlink(dirent_t *parent, const char *name)
|
||||||
|
|
||||||
write_lock(&ino->rwlock);
|
write_lock(&ino->rwlock);
|
||||||
|
|
||||||
if (ino->mode != INODE_DIRECTORY) {
|
if ((ino->mode & S_IFMT)!= S_IFDIR) {
|
||||||
write_unlock(&ino->rwlock);
|
write_unlock(&ino->rwlock);
|
||||||
return -ENOTDIR;
|
return -ENOTDIR;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,15 +20,6 @@
|
||||||
|
|
||||||
#define DIRENT_TYPE(dirent) ((dirent)->flags & 0x7)
|
#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 _inode inode_t;
|
||||||
typedef struct _dirent dirent_t;
|
typedef struct _dirent dirent_t;
|
||||||
typedef struct _fs fs_t;
|
typedef struct _fs fs_t;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue