diff options
-rw-r--r-- | Userland/Libraries/LibCore/System.cpp | 17 | ||||
-rw-r--r-- | Userland/Libraries/LibCore/System.h | 2 |
2 files changed, 19 insertions, 0 deletions
diff --git a/Userland/Libraries/LibCore/System.cpp b/Userland/Libraries/LibCore/System.cpp index 7b942b094d..3bb1c698fd 100644 --- a/Userland/Libraries/LibCore/System.cpp +++ b/Userland/Libraries/LibCore/System.cpp @@ -928,4 +928,21 @@ ErrorOr<Vector<gid_t>> getgroups() return groups; } +ErrorOr<void> mknod(StringView pathname, mode_t mode, dev_t dev) +{ + if (pathname.is_null()) + return Error::from_syscall("mknod"sv, -EFAULT); + +#ifdef __serenity__ + Syscall::SC_mknod_params params { { pathname.characters_without_null_termination(), pathname.length() }, mode, dev }; + int rc = syscall(SC_mknod, ¶ms); + HANDLE_SYSCALL_RETURN_VALUE("mknod"sv, rc, {}); +#else + String path_string = pathname; + if (::mknod(path_string.characters(), mode, dev) < 0) + return Error::from_syscall("mknod"sv, -errno); + return {}; +#endif +} + } diff --git a/Userland/Libraries/LibCore/System.h b/Userland/Libraries/LibCore/System.h index 0bba07f5bc..fb6ba508ed 100644 --- a/Userland/Libraries/LibCore/System.h +++ b/Userland/Libraries/LibCore/System.h @@ -135,4 +135,6 @@ ErrorOr<void> getsockname(int sockfd, struct sockaddr*, socklen_t*); ErrorOr<void> getpeername(int sockfd, struct sockaddr*, socklen_t*); ErrorOr<void> socketpair(int domain, int type, int protocol, int sv[2]); ErrorOr<Vector<gid_t>> getgroups(); +ErrorOr<void> mknod(StringView pathname, mode_t mode, dev_t dev); + } |