mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:48:12 +00:00
57 lines
1 KiB
C++
57 lines
1 KiB
C++
#include "unistd.h"
|
|
#include "string.h"
|
|
#include <Kernel/Syscall.h>
|
|
|
|
extern "C" {
|
|
|
|
uid_t getuid()
|
|
{
|
|
return Syscall::invoke(Syscall::PosixGetuid);
|
|
}
|
|
|
|
gid_t getgid()
|
|
{
|
|
return Syscall::invoke(Syscall::PosixGetgid);
|
|
}
|
|
|
|
pid_t getpid()
|
|
{
|
|
return Syscall::invoke(Syscall::PosixGetpid);
|
|
}
|
|
|
|
int open(const char* path)
|
|
{
|
|
size_t length = strlen(path);
|
|
return Syscall::invoke(Syscall::PosixOpen, (dword)path, (dword)length);
|
|
}
|
|
|
|
ssize_t read(int fd, void* buf, size_t count)
|
|
{
|
|
return Syscall::invoke(Syscall::PosixRead, (dword)fd, (dword)buf, (dword)count);
|
|
}
|
|
|
|
int close(int fd)
|
|
{
|
|
return Syscall::invoke(Syscall::PosixClose, fd);
|
|
}
|
|
|
|
pid_t waitpid(pid_t waitee)
|
|
{
|
|
return Syscall::invoke(Syscall::PosixWaitpid, waitee);
|
|
}
|
|
|
|
int lstat(const char* path, stat* statbuf)
|
|
{
|
|
return Syscall::invoke(Syscall::PosixLstat, (dword)path, (dword)statbuf);
|
|
}
|
|
|
|
char* getcwd(char* buffer, size_t size)
|
|
{
|
|
int rc = Syscall::invoke(Syscall::PosixGetcwd, (dword)buffer, (dword)size);
|
|
if (rc != 0)
|
|
return nullptr;
|
|
return buffer;
|
|
}
|
|
|
|
}
|
|
|