[orbis-kernel] implement unlink, nmount/unmount nullfs

This commit is contained in:
DH 2023-11-11 17:52:27 +03:00
parent 5a7d4dee1e
commit afc865cc69
8 changed files with 161 additions and 22 deletions

View file

@ -11,6 +11,7 @@ struct Module;
struct timespec;
struct File;
struct MemoryProtection;
struct IoVec;
struct ProcessOps {
SysResult (*mmap)(Thread *thread, caddr_t addr, size_t len, sint prot,
@ -40,6 +41,7 @@ struct ProcessOps {
Ref<File> *file);
SysResult (*shm_open)(Thread *thread, const char *path, sint flags, sint mode,
Ref<File> *file);
SysResult (*unlink)(Thread *thread, ptr<const char> path);
SysResult (*mkdir)(Thread *thread, ptr<const char> path, sint mode);
SysResult (*rmdir)(Thread *thread, ptr<const char> path);
SysResult (*rename)(Thread *thread, ptr<const char> from, ptr<const char> to);
@ -70,6 +72,9 @@ struct ProcessOps {
SysResult (*thr_wake)(Thread *thread, slong id);
SysResult (*thr_set_name)(Thread *thread, slong id, ptr<const char> name);
SysResult (*unmount)(Thread *thread, ptr<char> path, sint flags);
SysResult (*nmount)(Thread *thread, ptr<IoVec> iovp, uint iovcnt, sint flags);
SysResult (*fork)(Thread *thread, slong status);
SysResult (*execve)(Thread *thread, ptr<char> fname, ptr<ptr<char>> argv,
ptr<ptr<char>> envv);

View file

@ -84,6 +84,9 @@ orbis::SysResult orbis::sys_undelete(Thread *thread, ptr<char> path) {
return ErrorCode::NOSYS;
}
orbis::SysResult orbis::sys_unlink(Thread *thread, ptr<char> path) {
if (auto unlink = thread->tproc->ops->unlink) {
return unlink(thread, path);
}
return ErrorCode::NOSYS;
}
orbis::SysResult orbis::sys_unlinkat(Thread *thread, sint fd, ptr<char> path,

View file

@ -1,28 +1,24 @@
#include "sys/sysproto.hpp"
#include "uio.hpp"
#include "utils/Logs.hpp"
orbis::SysResult orbis::sys_mount(Thread *thread, ptr<char> type,
ptr<char> path, sint flags, caddr_t data) {
return ErrorCode::NOSYS;
}
orbis::SysResult orbis::sys_unmount(Thread *thread, ptr<char> path,
sint flags) {
if (auto unmount = thread->tproc->ops->unmount) {
return unmount(thread, path, flags);
}
return ErrorCode::NOSYS;
}
orbis::SysResult orbis::sys_nmount(Thread *thread, ptr<IoVec> iovp, uint iovcnt,
sint flags) {
ORBIS_LOG_ERROR(__FUNCTION__, iovp, iovcnt, flags);
for (auto it = iovp; it < iovp + iovcnt; it += 2) {
IoVec a{}, b{};
uread(a, it);
uread(b, it + 1);
std::string aSv((char *)a.base, a.len);
std::string bSv((char *)b.base, b.len);
std::fprintf(stderr, "%s: '%s':'%s'\n", __FUNCTION__, aSv.c_str(), bSv.c_str());
if (auto nmount = thread->tproc->ops->nmount) {
return nmount(thread, iovp, iovcnt, flags);
}
return {};
return ErrorCode::NOSYS;
}