rpcsx/orbis-kernel/src/sys/sys_descrip.cpp

64 lines
1.7 KiB
C++
Raw Normal View History

#include "orbis/utils/Logs.hpp"
#include "stat.hpp"
2023-07-03 13:10:16 +02:00
#include "sys/sysproto.hpp"
2023-07-06 18:16:25 +02:00
orbis::SysResult orbis::sys_getdtablesize(Thread *thread) {
return ErrorCode::NOSYS;
}
orbis::SysResult orbis::sys_dup2(Thread *thread, uint from, uint to) {
return ErrorCode::NOSYS;
}
orbis::SysResult orbis::sys_dup(Thread *thread, uint fd) {
return ErrorCode::NOSYS;
}
orbis::SysResult orbis::sys_fcntl(Thread *thread, sint fd, sint cmd,
slong arg) {
return ErrorCode::NOSYS;
}
2023-07-03 13:10:16 +02:00
orbis::SysResult orbis::sys_close(Thread *thread, sint fd) {
ORBIS_LOG_NOTICE(__FUNCTION__, fd);
if (thread->tproc->fileDescriptors.close(fd)) {
return {};
}
return ErrorCode::BADF;
2023-07-03 13:10:16 +02:00
}
2023-07-06 18:16:25 +02:00
orbis::SysResult orbis::sys_closefrom(Thread *thread, sint lowfd) {
return ErrorCode::NOSYS;
}
orbis::SysResult orbis::sys_fstat(Thread *thread, sint fd, ptr<Stat> ub) {
Ref<File> file = thread->tproc->fileDescriptors.get(fd);
if (file == nullptr) {
return ErrorCode::BADF;
2023-07-21 18:51:15 +02:00
}
auto stat = file->ops->stat;
if (stat == nullptr) {
return ErrorCode::NOTSUP;
2023-07-21 18:51:15 +02:00
}
std::lock_guard lock(file->mtx);
Stat _ub;
auto result = uread(_ub, ub);
if (result != ErrorCode{}) {
2023-07-21 18:51:15 +02:00
return result;
}
result = stat(file.get(), &_ub, thread);
if (result != ErrorCode{}) {
2023-07-21 18:51:15 +02:00
return result;
}
return uwrite(ub, _ub);
2023-07-06 18:16:25 +02:00
}
orbis::SysResult orbis::sys_nfstat(Thread *thread, sint fd,
ptr<struct nstat> sb) {
return ErrorCode::NOSYS;
}
orbis::SysResult orbis::sys_fpathconf(Thread *thread, sint fd, sint name) {
return ErrorCode::NOSYS;
}
orbis::SysResult orbis::sys_flock(Thread *thread, sint fd, sint how) {
return ErrorCode::NOSYS;
}