2018-10-22 13:57:25 +02:00
|
|
|
#include "unistd.h"
|
2018-10-23 10:12:50 +02:00
|
|
|
#include "string.h"
|
2018-10-22 13:57:25 +02:00
|
|
|
#include <Kernel/Syscall.h>
|
|
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
|
|
|
|
|
uid_t getuid()
|
|
|
|
|
{
|
|
|
|
|
return Syscall::invoke(Syscall::PosixGetuid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uid_t getgid()
|
|
|
|
|
{
|
|
|
|
|
return Syscall::invoke(Syscall::PosixGetgid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uid_t getpid()
|
|
|
|
|
{
|
|
|
|
|
return Syscall::invoke(Syscall::PosixGetpid);
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-23 10:12:50 +02:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-24 00:20:34 +02:00
|
|
|
pid_t waitpid(pid_t waitee)
|
|
|
|
|
{
|
|
|
|
|
return Syscall::invoke(Syscall::PosixWaitpid, waitee);
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-24 13:19:36 +02:00
|
|
|
int lstat(const char* path, stat* statbuf)
|
|
|
|
|
{
|
|
|
|
|
return Syscall::invoke(Syscall::PosixLstat, (dword)path, (dword)statbuf);
|
|
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
|
|
if (rc != 0)
|
|
|
|
|
return nullptr;
|
|
|
|
|
return buffer;
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-22 13:57:25 +02:00
|
|
|
}
|
|
|
|
|
|