mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-11 01:06:01 +03:00
LibCore: Add lstat() syscall wrapper
This commit is contained in:
parent
21acebd372
commit
1640445cb2
Notes:
sideshowbarker
2024-07-17 23:12:10 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/1640445cb2f
@ -175,6 +175,24 @@ ErrorOr<struct stat> stat(StringView path)
|
||||
#endif
|
||||
}
|
||||
|
||||
ErrorOr<struct stat> lstat(StringView path)
|
||||
{
|
||||
if (!path.characters_without_null_termination())
|
||||
return Error::from_syscall("lstat"sv, -EFAULT);
|
||||
|
||||
struct stat st = {};
|
||||
#ifdef __serenity__
|
||||
Syscall::SC_stat_params params { { path.characters_without_null_termination(), path.length() }, &st, AT_FDCWD, false };
|
||||
int rc = syscall(SC_stat, ¶ms);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("lstat"sv, rc, st);
|
||||
#else
|
||||
String path_string = path;
|
||||
if (::stat(path_string.characters(), &st) < 0)
|
||||
return Error::from_syscall("lstat"sv, -errno);
|
||||
return st;
|
||||
#endif
|
||||
}
|
||||
|
||||
ErrorOr<ssize_t> read(int fd, Bytes buffer)
|
||||
{
|
||||
ssize_t rc = ::read(fd, buffer.data(), buffer.size());
|
||||
|
@ -30,6 +30,7 @@ ErrorOr<int> open(StringView path, int options, ...);
|
||||
ErrorOr<void> close(int fd);
|
||||
ErrorOr<void> ftruncate(int fd, off_t length);
|
||||
ErrorOr<struct stat> stat(StringView path);
|
||||
ErrorOr<struct stat> lstat(StringView path);
|
||||
ErrorOr<ssize_t> read(int fd, Bytes buffer);
|
||||
ErrorOr<ssize_t> write(int fd, ReadonlyBytes buffer);
|
||||
ErrorOr<void> kill(pid_t, int signal);
|
||||
|
Loading…
Reference in New Issue
Block a user