From 6f611e23dd958d08e412fa26000b823b6df652cc Mon Sep 17 00:00:00 2001 From: DH Date: Sun, 9 Nov 2025 21:47:23 +0300 Subject: [PATCH] orbis: add stat and statfs to IoDevice cleanup debug code --- kernel/orbis/include/orbis/IoDevice.hpp | 10 ++++++ kernel/orbis/include/orbis/stat.hpp | 7 +++++ kernel/orbis/include/orbis/sys/sysproto.hpp | 9 +++--- kernel/orbis/src/sys/sys_vfs.cpp | 35 +++++---------------- 4 files changed, 29 insertions(+), 32 deletions(-) diff --git a/kernel/orbis/include/orbis/IoDevice.hpp b/kernel/orbis/include/orbis/IoDevice.hpp index 10a4ebaa7..114bdbf6b 100644 --- a/kernel/orbis/include/orbis/IoDevice.hpp +++ b/kernel/orbis/include/orbis/IoDevice.hpp @@ -31,11 +31,21 @@ enum OpenFlags { struct File; struct Thread; struct Process; +struct Stat; +struct StatFs; struct IoDevice : rx::RcBase { virtual ErrorCode open(rx::Ref *file, const char *path, std::uint32_t flags, std::uint32_t mode, Thread *thread) = 0; + virtual ErrorCode statfs(const char *path, StatFs *sb, Thread *thread) { + return ErrorCode::NOTSUP; + } + + virtual ErrorCode stat(const char *path, Stat *sb, Thread *thread) { + return ErrorCode::NOTSUP; + } + virtual ErrorCode unlink(const char *path, bool recursive, Thread *thread) { return ErrorCode::NOTSUP; } diff --git a/kernel/orbis/include/orbis/stat.hpp b/kernel/orbis/include/orbis/stat.hpp index c99c522c2..2b6eff3b3 100644 --- a/kernel/orbis/include/orbis/stat.hpp +++ b/kernel/orbis/include/orbis/stat.hpp @@ -24,6 +24,13 @@ struct Stat { timespec birthtim; // time of file creation }; +struct StatFs { + char pad[0x118]; + char f_fstypename[16]; // filesystem type name + char f_mntfromname[88]; // mounted filesystem + char f_mntonname[88]; // directory on which mounted +}; + struct Dirent { uint32_t fileno; uint16_t reclen; diff --git a/kernel/orbis/include/orbis/sys/sysproto.hpp b/kernel/orbis/include/orbis/sys/sysproto.hpp index 200d17abb..6925c6185 100644 --- a/kernel/orbis/include/orbis/sys/sysproto.hpp +++ b/kernel/orbis/include/orbis/sys/sysproto.hpp @@ -27,6 +27,7 @@ struct timesec; struct timezone; struct timeval; struct Stat; +struct StatFs; struct stack_t; struct IoVec; struct BatchMapEntry; @@ -393,12 +394,12 @@ SysResult sys_sendfile(Thread *thread, sint fd, sint s, off_t offset, ptr sbytes, sint flags); SysResult sys_mac_syscall(Thread *thread, ptr policy, sint call, ptr arg); -SysResult sys_getfsstat(Thread *thread, ptr buf, slong bufsize, +SysResult sys_getfsstat(Thread *thread, ptr buf, slong bufsize, sint flags); -SysResult sys_statfs(Thread *thread, ptr path, ptr buf); -SysResult sys_fstatfs(Thread *thread, sint fd, ptr buf); +SysResult sys_statfs(Thread *thread, ptr path, ptr buf); +SysResult sys_fstatfs(Thread *thread, sint fd, ptr buf); SysResult sys_fhstatfs(Thread *thread, ptr u_fhp, - ptr buf); + ptr buf); SysResult sys_ksem_close(Thread *thread, semid_t id); SysResult sys_ksem_post(Thread *thread, semid_t id); SysResult sys_ksem_wait(Thread *thread, semid_t id); diff --git a/kernel/orbis/src/sys/sys_vfs.cpp b/kernel/orbis/src/sys/sys_vfs.cpp index be5942613..1da50ac8b 100644 --- a/kernel/orbis/src/sys/sys_vfs.cpp +++ b/kernel/orbis/src/sys/sys_vfs.cpp @@ -13,22 +13,14 @@ orbis::SysResult orbis::sys_quotactl(Thread *thread, ptr path, sint cmd, return ErrorCode::NOSYS; } -namespace orbis { -struct statfs { - char pad[0x118]; - char f_fstypename[16]; /* filesystem type name */ - char f_mntfromname[88]; /* mounted filesystem */ - char f_mntonname[88]; /* directory on which mounted */ -}; -} // namespace orbis - orbis::SysResult orbis::sys_statfs(Thread *thread, ptr path, - ptr buf) { + ptr buf) { if (buf == 0) { thread->retval[0] = 1; return {}; } + // FIXME: use statfs std::strncpy(buf->f_fstypename, "unionfs", sizeof(buf->f_fstypename)); std::strncpy(buf->f_mntfromname, "/dev/super-hdd", sizeof(buf->f_mntfromname)); @@ -37,13 +29,13 @@ orbis::SysResult orbis::sys_statfs(Thread *thread, ptr path, thread->retval[0] = 1; return {}; } -orbis::SysResult orbis::sys_fstatfs(Thread *thread, sint fd, - ptr buf) { +orbis::SysResult orbis::sys_fstatfs(Thread *thread, sint fd, ptr buf) { if (buf == 0) { thread->retval[0] = 1; return {}; } + // FIXME: use statfs std::strncpy(buf->f_fstypename, "unionfs", sizeof(buf->f_fstypename)); std::strncpy(buf->f_mntfromname, "/dev/super-hdd", sizeof(buf->f_mntfromname)); @@ -52,7 +44,7 @@ orbis::SysResult orbis::sys_fstatfs(Thread *thread, sint fd, thread->retval[0] = 1; return {}; } -orbis::SysResult orbis::sys_getfsstat(Thread *thread, ptr buf, +orbis::SysResult orbis::sys_getfsstat(Thread *thread, ptr buf, slong bufsize, sint flags) { return ErrorCode::NOSYS; } @@ -70,7 +62,6 @@ orbis::SysResult orbis::sys_chroot(Thread *thread, ptr path) { return {}; } -// volatile bool debuggerPresent = false; orbis::SysResult orbis::sys_open(Thread *thread, ptr path, sint flags, sint mode) { if (auto open = thread->tproc->ops->open) { @@ -82,24 +73,12 @@ orbis::SysResult orbis::sys_open(Thread *thread, ptr path, auto fd = thread->tproc->fileDescriptors.insert(file); thread->retval[0] = fd; - // if (path == - // std::string_view{"/app0/psm/Application/resource/Sce.Vsh.ShellUI.SystemMessage.rco"}) - // { - ORBIS_LOG_SUCCESS(__FUNCTION__, thread->tid, path, flags, mode, fd); - if (path == std::string_view{"/app0/wave/wave1.fbxd"}) { - thread->where(); - } - - // while (debuggerPresent == false) { - // std::this_thread::sleep_for(std::chrono::seconds(1)); - // } - // // thread->where(); - // } return {}; } return ErrorCode::NOSYS; } + orbis::SysResult orbis::sys_openat(Thread *thread, sint fd, ptr path, sint flag, mode_t mode) { ORBIS_LOG_WARNING(__FUNCTION__, fd, path, flag, mode); @@ -485,7 +464,7 @@ orbis::SysResult orbis::sys_fhstat(Thread *thread, } orbis::SysResult orbis::sys_fhstatfs(Thread *thread, ptr u_fhp, - ptr buf) { + ptr buf) { return ErrorCode::NOSYS; } orbis::SysResult orbis::sys_posix_fallocate(Thread *thread, sint fd,