mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-26 03:02:27 -05:00
7a7956a595
We now make three VirtualConsoles at boot: tty0, tty1, and tty2. We launch an instance of /bin/sh in each one. You switch between them with Alt+1/2/3 How very very cool :^)
89 lines
2 KiB
C++
89 lines
2 KiB
C++
#include "unistd.h"
|
|
#include "string.h"
|
|
#include "errno.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, int options)
|
|
{
|
|
int rc = Syscall::invoke(Syscall::PosixOpen, (dword)path, (dword)options);
|
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
|
}
|
|
|
|
ssize_t read(int fd, void* buf, size_t count)
|
|
{
|
|
int rc = Syscall::invoke(Syscall::PosixRead, (dword)fd, (dword)buf, (dword)count);
|
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
|
}
|
|
|
|
ssize_t write(int fd, const void* buf, size_t count)
|
|
{
|
|
int rc = Syscall::invoke(Syscall::PosixWrite, (dword)fd, (dword)buf, (dword)count);
|
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
|
}
|
|
|
|
int close(int fd)
|
|
{
|
|
int rc = Syscall::invoke(Syscall::PosixClose, fd);
|
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
|
}
|
|
|
|
pid_t waitpid(pid_t waitee, int* wstatus, int options)
|
|
{
|
|
int rc = Syscall::invoke(Syscall::PosixWaitpid, waitee, (dword)wstatus);
|
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
|
}
|
|
|
|
int lstat(const char* path, stat* statbuf)
|
|
{
|
|
int rc = Syscall::invoke(Syscall::PosixLstat, (dword)path, (dword)statbuf);
|
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
|
}
|
|
|
|
int chdir(const char* path)
|
|
{
|
|
int rc = Syscall::invoke(Syscall::PosixChdir, (dword)path);
|
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
|
}
|
|
|
|
char* getcwd(char* buffer, size_t size)
|
|
{
|
|
int rc = Syscall::invoke(Syscall::PosixGetcwd, (dword)buffer, (dword)size);
|
|
__RETURN_WITH_ERRNO(rc, buffer, nullptr);
|
|
}
|
|
|
|
int sleep(unsigned seconds)
|
|
{
|
|
return Syscall::invoke(Syscall::Sleep, (dword)seconds);
|
|
}
|
|
|
|
int gethostname(char* buffer, size_t size)
|
|
{
|
|
int rc = Syscall::invoke(Syscall::PosixGethostname, (dword)buffer, (dword)size);
|
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
|
}
|
|
|
|
ssize_t readlink(const char* path, char* buffer, size_t size)
|
|
{
|
|
int rc = Syscall::invoke(Syscall::PosixReadlink, (dword)path, (dword)buffer, (dword)size);
|
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
|
}
|
|
|
|
}
|
|
|