Add Unix domain sockets for local IPC #37

Merged
apio merged 16 commits from unix-sockets into main 2023-07-30 09:49:38 +00:00
5 changed files with 7 additions and 0 deletions
Showing only changes of commit 200bb6c240 - Show all commits

View File

@ -17,6 +17,7 @@ namespace VFS
BlockDevice,
Symlink,
FIFO,
Socket,
};
class Inode;

View File

@ -55,6 +55,8 @@ Result<u64> 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);

View File

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

View File

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

View File

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