2018-10-22 13:57:25 +02:00
|
|
|
#include "unistd.h"
|
2018-10-23 10:12:50 +02:00
|
|
|
#include "string.h"
|
2018-10-25 12:06:00 +02:00
|
|
|
#include "errno.h"
|
2018-10-22 13:57:25 +02:00
|
|
|
#include <Kernel/Syscall.h>
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
|
|
|
uid_t getuid()
|
|
|
|
{
|
|
|
|
return Syscall::invoke(Syscall::PosixGetuid);
|
|
|
|
}
|
|
|
|
|
2018-10-25 10:00:37 +02:00
|
|
|
gid_t getgid()
|
2018-10-22 13:57:25 +02:00
|
|
|
{
|
|
|
|
return Syscall::invoke(Syscall::PosixGetgid);
|
|
|
|
}
|
|
|
|
|
2018-10-25 10:00:37 +02:00
|
|
|
pid_t getpid()
|
2018-10-22 13:57:25 +02:00
|
|
|
{
|
|
|
|
return Syscall::invoke(Syscall::PosixGetpid);
|
|
|
|
}
|
|
|
|
|
2018-10-23 10:12:50 +02:00
|
|
|
int open(const char* path)
|
|
|
|
{
|
|
|
|
size_t length = strlen(path);
|
2018-10-25 12:06:00 +02:00
|
|
|
int rc = Syscall::invoke(Syscall::PosixOpen, (dword)path, (dword)length);
|
|
|
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
2018-10-23 10:12:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ssize_t read(int fd, void* buf, size_t count)
|
|
|
|
{
|
2018-10-25 12:06:00 +02:00
|
|
|
int rc = Syscall::invoke(Syscall::PosixRead, (dword)fd, (dword)buf, (dword)count);
|
|
|
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
2018-10-23 10:12:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int close(int fd)
|
|
|
|
{
|
2018-10-25 12:06:00 +02:00
|
|
|
int rc = Syscall::invoke(Syscall::PosixClose, fd);
|
|
|
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
2018-10-23 10:12:50 +02:00
|
|
|
}
|
|
|
|
|
2018-10-24 00:20:34 +02:00
|
|
|
pid_t waitpid(pid_t waitee)
|
|
|
|
{
|
2018-10-25 12:06:00 +02:00
|
|
|
int rc = Syscall::invoke(Syscall::PosixWaitpid, waitee);
|
|
|
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
2018-10-24 00:20:34 +02:00
|
|
|
}
|
|
|
|
|
2018-10-24 13:19:36 +02:00
|
|
|
int lstat(const char* path, stat* statbuf)
|
|
|
|
{
|
2018-10-25 12:06:00 +02:00
|
|
|
int rc = Syscall::invoke(Syscall::PosixLstat, (dword)path, (dword)statbuf);
|
|
|
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
2018-10-24 13:19:36 +02:00
|
|
|
}
|
|
|
|
|
2018-10-24 14:28:22 +02:00
|
|
|
char* getcwd(char* buffer, size_t size)
|
|
|
|
{
|
|
|
|
int rc = Syscall::invoke(Syscall::PosixGetcwd, (dword)buffer, (dword)size);
|
2018-10-25 12:06:00 +02:00
|
|
|
__RETURN_WITH_ERRNO(rc, buffer, nullptr);
|
2018-10-24 14:28:22 +02:00
|
|
|
}
|
|
|
|
|
2018-10-25 13:53:49 +02:00
|
|
|
int sleep(unsigned seconds)
|
|
|
|
{
|
|
|
|
return Syscall::invoke(Syscall::Sleep, (dword)seconds);
|
|
|
|
}
|
|
|
|
|
2018-10-22 13:57:25 +02:00
|
|
|
}
|
|
|
|
|