[orbis-kernel] Dummy sys_stat implementation

Ignore shm_open
Correct Stat argument for syscalls
This commit is contained in:
DH 2023-07-13 13:33:17 +03:00
parent 9482bd6704
commit dd9351843b
4 changed files with 45 additions and 16 deletions

View file

@ -15,7 +15,7 @@ struct ModuleInfo;
struct ModuleInfoEx;
struct KEvent;
struct timespec;
struct Stat;
struct stack_t;
SysResult nosys(Thread *thread);
@ -173,9 +173,9 @@ SysResult sys_ntp_adjtime(Thread *thread, ptr<struct timex> tp);
SysResult sys_setgid(Thread *thread, gid_t gid);
SysResult sys_setegid(Thread *thread, gid_t egid);
SysResult sys_seteuid(Thread *thread, uid_t euid);
SysResult sys_stat(Thread *thread, ptr<char> path, ptr<struct stat> ub);
SysResult sys_fstat(Thread *thread, sint fd, ptr<struct stat> ub);
SysResult sys_lstat(Thread *thread, ptr<char> path, ptr<struct stat> ub);
SysResult sys_stat(Thread *thread, ptr<char> path, ptr<Stat> ub);
SysResult sys_fstat(Thread *thread, sint fd, ptr<Stat> ub);
SysResult sys_lstat(Thread *thread, ptr<char> path, ptr<Stat> ub);
SysResult sys_pathconf(Thread *thread, ptr<char> path, sint name);
SysResult sys_fpathconf(Thread *thread, sint fd, sint name);
SysResult sys_getrlimit(Thread *thread, uint which, ptr<struct rlimit> rlp);
@ -255,7 +255,7 @@ SysResult sys_pwritev(Thread *thread, sint fd, ptr<struct iovec> iovp,
SysResult sys_fhopen(Thread *thread, ptr<const struct fhandle> u_fhp,
sint flags);
SysResult sys_fhstat(Thread *thread, ptr<const struct fhandle> u_fhp,
ptr<struct stat> sb);
ptr<Stat> sb);
SysResult sys_modnext(Thread *thread, sint modid);
SysResult sys_modstat(Thread *thread, sint modid, ptr<struct module_stat> stat);
SysResult sys_modfnext(Thread *thread, sint modid);
@ -535,8 +535,8 @@ SysResult sys_fchownat(Thread *thread, sint fd, ptr<char> path, uid_t uid,
gid_t gid, sint flag);
SysResult sys_fexecve(Thread *thread, sint fd, ptr<ptr<char>> argv,
ptr<ptr<char>> envv);
SysResult sys_fstatat(Thread *thread, sint fd, ptr<char> path,
ptr<struct stat> buf, sint flag);
SysResult sys_fstatat(Thread *thread, sint fd, ptr<char> path, ptr<Stat> buf,
sint flag);
SysResult sys_futimesat(Thread *thread, sint fd, ptr<char> path,
ptr<struct timeval> times);
SysResult sys_linkat(Thread *thread, sint fd1, ptr<char> path1, sint fd2,

View file

@ -23,8 +23,7 @@ orbis::SysResult orbis::sys_close(Thread *thread, sint fd) {
orbis::SysResult orbis::sys_closefrom(Thread *thread, sint lowfd) {
return ErrorCode::NOSYS;
}
orbis::SysResult orbis::sys_fstat(Thread *thread, sint fd,
ptr<struct stat> ub) {
orbis::SysResult orbis::sys_fstat(Thread *thread, sint fd, ptr<Stat> ub) {
return ErrorCode::NOSYS;
}
orbis::SysResult orbis::sys_nfstat(Thread *thread, sint fd,

View file

@ -1,8 +1,17 @@
#include "orbis-config.hpp"
#include "sys/sysproto.hpp"
#include "utils/Logs.hpp"
orbis::SysResult orbis::sys_shm_open(Thread *thread, ptr<const char> path,
sint flags, mode_t mode) {
return ErrorCode::NOSYS;
char _name[256];
if (auto result = ureadString(_name, sizeof(_name), path);
result != ErrorCode{}) {
return result;
}
ORBIS_LOG_TODO(__FUNCTION__, _name, flags, mode);
return {};
}
orbis::SysResult orbis::sys_shm_unlink(Thread *thread, ptr<const char> path) {
return ErrorCode::NOSYS;

View file

@ -1,3 +1,4 @@
#include "stat.hpp"
#include "sys/sysproto.hpp"
#include "utils/Logs.hpp"
@ -103,16 +104,36 @@ orbis::SysResult orbis::sys_eaccess(Thread *thread, ptr<char> path,
sint flags) {
return ErrorCode::NOSYS;
}
orbis::SysResult orbis::sys_stat(Thread *thread, ptr<char> path,
ptr<struct stat> ub) {
return ErrorCode::NOSYS;
orbis::SysResult orbis::sys_stat(Thread *thread, ptr<char> path, ptr<Stat> ub) {
ORBIS_LOG_TODO(__FUNCTION__, path, ub);
auto result = sys_open(thread, path, 0, 0);
if (result.isError()) {
return result;
}
auto fd = thread->retval[0];
result = sys_lseek(thread, fd, 0, SEEK_END);
if (result.isError()) {
sys_close(thread, fd);
return result;
}
auto len = thread->retval[0];
*ub = {};
ub->size = len;
ub->blksize = 1;
ub->blocks = len;
ub->mode = 0777;
sys_close(thread, fd);
thread->retval[0] = 0;
return {};
}
orbis::SysResult orbis::sys_fstatat(Thread *thread, sint fd, ptr<char> path,
ptr<struct stat> buf, sint flag) {
ptr<Stat> buf, sint flag) {
return ErrorCode::NOSYS;
}
orbis::SysResult orbis::sys_lstat(Thread *thread, ptr<char> path,
ptr<struct stat> ub) {
ptr<Stat> ub) {
return ErrorCode::NOSYS;
}
orbis::SysResult orbis::sys_nstat(Thread *thread, ptr<char> path,
@ -257,7 +278,7 @@ orbis::sys_fhopen(Thread *thread, ptr<const struct fhandle> u_fhp, sint flags) {
}
orbis::SysResult orbis::sys_fhstat(Thread *thread,
ptr<const struct fhandle> u_fhp,
ptr<struct stat> sb) {
ptr<Stat> sb) {
return ErrorCode::NOSYS;
}
orbis::SysResult orbis::sys_fhstatfs(Thread *thread,