LibCore: Add syscall wrapper for mkdir()

This commit is contained in:
Andreas Kling 2021-12-16 20:27:25 +01:00
parent f69bd3bd46
commit 01c2756e9a
Notes: sideshowbarker 2024-07-17 22:41:38 +09:00
2 changed files with 16 additions and 0 deletions

View file

@ -465,4 +465,19 @@ ErrorOr<void> symlink(StringView target, StringView link_path)
#endif
}
ErrorOr<void> mkdir(StringView path, mode_t mode)
{
if (path.is_null())
return Error::from_errno(EFAULT);
#ifdef __serenity__
int rc = syscall(SC_mkdir, path.characters_without_null_termination(), path.length(), mode);
HANDLE_SYSCALL_RETURN_VALUE("mkdir"sv, rc, {});
#else
String path_string = path;
if (::mkdir(path_string.characters(), mode) < 0)
return Error::from_syscall("mkdir"sv, -errno);
return {};
#endif
}
}

View file

@ -63,5 +63,6 @@ ErrorOr<void> setgid(gid_t);
ErrorOr<void> setegid(gid_t);
ErrorOr<bool> isatty(int fd);
ErrorOr<void> symlink(StringView target, StringView link_path);
ErrorOr<void> mkdir(StringView path, mode_t);
}