mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:17:34 +00:00
LibCore: Add syscall wrapper for mount()
This commit is contained in:
parent
e923762afc
commit
f69bd3bd46
2 changed files with 36 additions and 0 deletions
|
@ -90,6 +90,22 @@ ErrorOr<void> setgroups(Span<gid_t const> gids)
|
||||||
return Error::from_syscall("setgroups"sv, -errno);
|
return Error::from_syscall("setgroups"sv, -errno);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ErrorOr<void> mount(int source_fd, StringView target, StringView fs_type, int flags)
|
||||||
|
{
|
||||||
|
if (target.is_null() || fs_type.is_null())
|
||||||
|
return Error::from_errno(EFAULT);
|
||||||
|
|
||||||
|
Syscall::SC_mount_params params {
|
||||||
|
{ target.characters_without_null_termination(), target.length() },
|
||||||
|
{ fs_type.characters_without_null_termination(), fs_type.length() },
|
||||||
|
source_fd,
|
||||||
|
flags
|
||||||
|
};
|
||||||
|
int rc = syscall(SC_mount, ¶ms);
|
||||||
|
HANDLE_SYSCALL_RETURN_VALUE("mount", rc, {});
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ErrorOr<void> sigaction(int signal, struct sigaction const* action, struct sigaction* old_action)
|
ErrorOr<void> sigaction(int signal, struct sigaction const* action, struct sigaction* old_action)
|
||||||
|
@ -431,4 +447,22 @@ ErrorOr<bool> isatty(int fd)
|
||||||
return rc == 1;
|
return rc == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ErrorOr<void> symlink(StringView target, StringView link_path)
|
||||||
|
{
|
||||||
|
#ifdef __serenity__
|
||||||
|
Syscall::SC_symlink_params params {
|
||||||
|
.target = { target.characters_without_null_termination(), target.length() },
|
||||||
|
.linkpath = { link_path.characters_without_null_termination(), link_path.length() },
|
||||||
|
};
|
||||||
|
int rc = syscall(SC_symlink, ¶ms);
|
||||||
|
HANDLE_SYSCALL_RETURN_VALUE("symlink"sv, rc, {});
|
||||||
|
#else
|
||||||
|
String target_string = target;
|
||||||
|
String link_path_string = link_path;
|
||||||
|
if (::symlink(target_string.characters(), link_path_string.characters()) < 0)
|
||||||
|
return Error::from_syscall("symlink"sv, -errno);
|
||||||
|
return {};
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ ErrorOr<void> sendfd(int sockfd, int fd);
|
||||||
ErrorOr<int> recvfd(int sockfd, int options);
|
ErrorOr<int> recvfd(int sockfd, int options);
|
||||||
ErrorOr<void> ptrace_peekbuf(pid_t tid, void const* tracee_addr, Bytes destination_buf);
|
ErrorOr<void> ptrace_peekbuf(pid_t tid, void const* tracee_addr, Bytes destination_buf);
|
||||||
ErrorOr<void> setgroups(Span<gid_t const>);
|
ErrorOr<void> setgroups(Span<gid_t const>);
|
||||||
|
ErrorOr<void> mount(int source_fd, StringView target, StringView fs_type, int flags);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ErrorOr<void> sigaction(int signal, struct sigaction const* action, struct sigaction* old_action);
|
ErrorOr<void> sigaction(int signal, struct sigaction const* action, struct sigaction* old_action);
|
||||||
|
@ -61,5 +62,6 @@ ErrorOr<void> seteuid(uid_t);
|
||||||
ErrorOr<void> setgid(gid_t);
|
ErrorOr<void> setgid(gid_t);
|
||||||
ErrorOr<void> setegid(gid_t);
|
ErrorOr<void> setegid(gid_t);
|
||||||
ErrorOr<bool> isatty(int fd);
|
ErrorOr<bool> isatty(int fd);
|
||||||
|
ErrorOr<void> symlink(StringView target, StringView link_path);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue