diff options
Diffstat (limited to 'Userland/Libraries/LibCore/System.cpp')
-rw-r--r-- | Userland/Libraries/LibCore/System.cpp | 17 |
1 files changed, 17 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 +} + } |