kernel+libc+libos: Add inode type for sockets
This commit is contained in:
parent
27fcdab85f
commit
48f5f6ea33
@ -17,6 +17,7 @@ namespace VFS
|
|||||||
BlockDevice,
|
BlockDevice,
|
||||||
Symlink,
|
Symlink,
|
||||||
FIFO,
|
FIFO,
|
||||||
|
Socket,
|
||||||
};
|
};
|
||||||
|
|
||||||
class Inode;
|
class Inode;
|
||||||
|
@ -55,6 +55,8 @@ Result<u64> sys_openat(Registers*, SyscallArgs args)
|
|||||||
// This should only be possible if O_NOFOLLOW was in flags.
|
// This should only be possible if O_NOFOLLOW was in flags.
|
||||||
if (inode->type() == VFS::InodeType::Symlink) return err(ELOOP);
|
if (inode->type() == VFS::InodeType::Symlink) return err(ELOOP);
|
||||||
|
|
||||||
|
if (inode->type() == VFS::InodeType::Socket) return err(ENXIO);
|
||||||
|
|
||||||
if (flags & O_TMPFILE)
|
if (flags & O_TMPFILE)
|
||||||
{
|
{
|
||||||
if (inode->type() != VFS::InodeType::Directory) return err(EINVAL);
|
if (inode->type() != VFS::InodeType::Directory) return err(EINVAL);
|
||||||
|
@ -18,6 +18,7 @@ static mode_t make_mode(mode_t mode, VFS::InodeType type)
|
|||||||
case VFS::InodeType::BlockDevice: result |= S_IFBLK; break;
|
case VFS::InodeType::BlockDevice: result |= S_IFBLK; break;
|
||||||
case VFS::InodeType::Symlink: result |= S_IFLNK; break;
|
case VFS::InodeType::Symlink: result |= S_IFLNK; break;
|
||||||
case VFS::InodeType::FIFO: result |= S_IFIFO; break;
|
case VFS::InodeType::FIFO: result |= S_IFIFO; break;
|
||||||
|
case VFS::InodeType::Socket: result |= S_IFSOCK; break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#define S_IFBLK 030000
|
#define S_IFBLK 030000
|
||||||
#define S_IFDIR 040000
|
#define S_IFDIR 040000
|
||||||
#define S_IFCHR 050000
|
#define S_IFCHR 050000
|
||||||
|
#define S_IFSOCK 060000
|
||||||
|
|
||||||
#define __CHECK_TYPE(mode, type) (((mode)&S_IFMT) == type)
|
#define __CHECK_TYPE(mode, type) (((mode)&S_IFMT) == type)
|
||||||
|
|
||||||
@ -19,6 +20,7 @@
|
|||||||
#define S_ISBLK(mode) __CHECK_TYPE(mode, S_IFBLK)
|
#define S_ISBLK(mode) __CHECK_TYPE(mode, S_IFBLK)
|
||||||
#define S_ISLNK(mode) __CHECK_TYPE(mode, S_IFLNK)
|
#define S_ISLNK(mode) __CHECK_TYPE(mode, S_IFLNK)
|
||||||
#define S_ISFIFO(mode) __CHECK_TYPE(mode, S_IFIFO)
|
#define S_ISFIFO(mode) __CHECK_TYPE(mode, S_IFIFO)
|
||||||
|
#define S_ISSOCK(mode) __CHECK_TYPE(mode, S_IFSOCK)
|
||||||
|
|
||||||
#define S_IRWXU 0700
|
#define S_IRWXU 0700
|
||||||
#define S_IRUSR 0400
|
#define S_IRUSR 0400
|
||||||
|
@ -21,6 +21,7 @@ namespace os
|
|||||||
if (S_ISBLK(mode)) return 'b';
|
if (S_ISBLK(mode)) return 'b';
|
||||||
if (S_ISLNK(mode)) return 'l';
|
if (S_ISLNK(mode)) return 'l';
|
||||||
if (S_ISFIFO(mode)) return 'p';
|
if (S_ISFIFO(mode)) return 'p';
|
||||||
|
if (S_ISSOCK(mode)) return 's';
|
||||||
|
|
||||||
return '?';
|
return '?';
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user