vfs: add S_IFMT mask

Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
Michael Shaw 2026-07-06 19:40:59 +02:00
commit f24cd3ef74
3 changed files with 4 additions and 13 deletions

View file

@ -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);

View file

@ -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;
}