2023-07-13 12:33:17 +02:00
|
|
|
#include "orbis-config.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_shm_open(Thread *thread, ptr<const char> path,
|
|
|
|
|
sint flags, mode_t mode) {
|
2023-07-13 12:33:17 +02:00
|
|
|
char _name[256];
|
|
|
|
|
if (auto result = ureadString(_name, sizeof(_name), path);
|
|
|
|
|
result != ErrorCode{}) {
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-29 21:46:28 +02:00
|
|
|
if (auto shm_open = thread->tproc->ops->shm_open) {
|
|
|
|
|
Ref<File> file;
|
|
|
|
|
auto result = shm_open(thread, path, flags, mode, &file);
|
|
|
|
|
if (result.isError()) {
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
thread->retval[0] = thread->tproc->fileDescriptors.insert(file);
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
return ErrorCode::NOSYS;
|
2023-07-06 18:16:25 +02:00
|
|
|
}
|
2023-07-29 21:46:28 +02:00
|
|
|
|
2023-07-06 18:16:25 +02:00
|
|
|
orbis::SysResult orbis::sys_shm_unlink(Thread *thread, ptr<const char> path) {
|
2023-07-23 16:40:01 +02:00
|
|
|
char _name[256];
|
|
|
|
|
if (auto result = ureadString(_name, sizeof(_name), path);
|
|
|
|
|
result != ErrorCode{}) {
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-29 21:46:28 +02:00
|
|
|
if (auto shm_unlink = thread->tproc->ops->shm_unlink) {
|
|
|
|
|
Ref<File> file;
|
|
|
|
|
auto result = shm_unlink(thread, path);
|
|
|
|
|
if (result.isError()) {
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
thread->retval[0] = thread->tproc->fileDescriptors.insert(file);
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ErrorCode::NOSYS;
|
2023-07-06 18:16:25 +02:00
|
|
|
}
|