diff --git a/kernel/src/fs/VFS.h b/kernel/src/fs/VFS.h index 7dcee9d5..3dc369fb 100644 --- a/kernel/src/fs/VFS.h +++ b/kernel/src/fs/VFS.h @@ -17,6 +17,7 @@ namespace VFS BlockDevice, Symlink, FIFO, + Socket, }; class Inode; diff --git a/kernel/src/sys/open.cpp b/kernel/src/sys/open.cpp index ce160a19..0a3de817 100644 --- a/kernel/src/sys/open.cpp +++ b/kernel/src/sys/open.cpp @@ -55,6 +55,8 @@ Result sys_openat(Registers*, SyscallArgs args) // 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::Socket) return err(ENXIO); + if (flags & O_TMPFILE) { if (inode->type() != VFS::InodeType::Directory) return err(EINVAL); diff --git a/kernel/src/sys/stat.cpp b/kernel/src/sys/stat.cpp index 85c534cd..55e35699 100644 --- a/kernel/src/sys/stat.cpp +++ b/kernel/src/sys/stat.cpp @@ -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::Symlink: result |= S_IFLNK; break; case VFS::InodeType::FIFO: result |= S_IFIFO; break; + case VFS::InodeType::Socket: result |= S_IFSOCK; break; default: break; } diff --git a/libc/include/bits/modes.h b/libc/include/bits/modes.h index 6f567339..b46df7c2 100644 --- a/libc/include/bits/modes.h +++ b/libc/include/bits/modes.h @@ -10,6 +10,7 @@ #define S_IFBLK 030000 #define S_IFDIR 040000 #define S_IFCHR 050000 +#define S_IFSOCK 060000 #define __CHECK_TYPE(mode, type) (((mode)&S_IFMT) == type) @@ -19,6 +20,7 @@ #define S_ISBLK(mode) __CHECK_TYPE(mode, S_IFBLK) #define S_ISLNK(mode) __CHECK_TYPE(mode, S_IFLNK) #define S_ISFIFO(mode) __CHECK_TYPE(mode, S_IFIFO) +#define S_ISSOCK(mode) __CHECK_TYPE(mode, S_IFSOCK) #define S_IRWXU 0700 #define S_IRUSR 0400 diff --git a/libos/src/Mode.cpp b/libos/src/Mode.cpp index 2c6e6cbb..1b3d3c86 100644 --- a/libos/src/Mode.cpp +++ b/libos/src/Mode.cpp @@ -21,6 +21,7 @@ namespace os if (S_ISBLK(mode)) return 'b'; if (S_ISLNK(mode)) return 'l'; if (S_ISFIFO(mode)) return 'p'; + if (S_ISSOCK(mode)) return 's'; return '?'; }