1/2 migrating linux/unix errno to freebsd

This commit is contained in:
Marek Ledworowski 2025-11-21 00:29:17 +01:00
parent 204e8f72b0
commit beafd04eaa
23 changed files with 221 additions and 362 deletions

View File

@ -11,7 +11,7 @@
#define DEVICE_STUB() \
{ \
LOG_ERROR(Kernel_Fs, "(STUBBED) called"); \
return -QUASI_ENOSYS; \
return -POSIX_ENOSYS; \
}
namespace Core::Devices {

View File

@ -11,7 +11,7 @@
#define DEVICE_STUB() \
{ \
LOG_ERROR(Kernel_Fs, "(STUBBED) called"); \
return -QUASI_ENOSYS; \
return -POSIX_ENOSYS; \
}
namespace Core::Devices {

View File

@ -14,7 +14,7 @@
#define DEVICE_STUB() \
{ \
LOG_ERROR(Kernel_Fs, "(STUBBED) called"); \
return -QUASI_ENOSYS; \
return -POSIX_ENOSYS; \
}
namespace Core::Devices {

View File

@ -10,7 +10,7 @@
#define DEVICE_STUB() \
{ \
LOG_ERROR(Kernel_Fs, "(STUBBED) called"); \
return -QUASI_ENOSYS; \
return -POSIX_ENOSYS; \
}
namespace Core::Devices {

View File

@ -10,7 +10,7 @@
#define DEVICE_STUB() \
{ \
LOG_ERROR(Kernel_Fs, "(STUBBED) called"); \
return -QUASI_ENOSYS; \
return -POSIX_ENOSYS; \
}
namespace Core::Devices {

View File

@ -10,7 +10,7 @@
#define DEVICE_STUB() \
{ \
LOG_ERROR(Kernel_Fs, "(STUBBED) called"); \
return -QUASI_ENOSYS; \
return -POSIX_ENOSYS; \
}
namespace Core::Devices {

View File

@ -10,7 +10,7 @@
#define DEVICE_STUB() \
{ \
LOG_ERROR(Kernel_Fs, "(STUBBED) called"); \
return -QUASI_ENOSYS; \
return -POSIX_ENOSYS; \
}
namespace Core::Devices {

View File

@ -10,7 +10,7 @@
#define DEVICE_STUB() \
{ \
LOG_ERROR(Kernel_Fs, "(STUBBED) called"); \
return -QUASI_ENOSYS; \
return -POSIX_ENOSYS; \
}
namespace Core::Devices {

View File

@ -0,0 +1,14 @@
#include <fcntl.h>
#include "common/assert.h"
#include "core/libraries/kernel/posix_error.h"
// Convert linux/unix errno to FreeBSD errno
// They differ in higher errno numbers, which may throw Orbis off quite a bit
s32 posix2bsd(s32 id) {
switch (id) {
default:
UNREACHABLE_MSG("Unknown POSIX errno");
}
}

View File

@ -18,6 +18,7 @@
#include "core/file_sys/quasifs/quasifs_partition.h"
#include "host_io_base.h"
#include "host_io_linux2bsd.h"
namespace HostIODriver {
@ -259,6 +260,6 @@ s32 HostIO_POSIX::FChmod(const s32 fd, u16 mode) {
return 0 == status ? status : -errno;
}
// s32 HostIO_POSIX::GetDents(void* buf, u32 count, s64* basep) { return -QUASI_ENOSYS; }
// s32 HostIO_POSIX::GetDents(void* buf, u32 count, s64* basep) { return -POSIX_ENOSYS; }
} // namespace HostIODriver

View File

@ -10,8 +10,8 @@
#include "core/file_sys/quasifs/quasifs_inode_quasi_file.h"
#include "core/file_sys/quasifs/quasifs_inode_symlink.h"
#include "core/file_sys/quasifs/quasifs_partition.h"
#include "core/libraries/kernel/posix_error.h"
#include "src/core/file_sys/hostio/host_io_virtual.h"
#include "src/core/file_sys/quasifs/quasi_errno.h"
#include "src/core/file_sys/quasifs/quasi_sys_fcntl.h"
#include "src/core/file_sys/quasifs/quasi_types.h"
#include "src/core/file_sys/quasifs/quasifs_inode_quasi_file_virtual.h"
@ -28,7 +28,7 @@ s32 HostIO_Virtual::Open(const fs::path& path, s32 flags, u16 mode) {
LOG_WARNING(Kernel_Fs, "open() received unknown flags: {:x}", remainder);
if (nullptr == this->res)
return -QUASI_EINVAL;
return -POSIX_EINVAL;
partition_ptr part = this->res->mountpoint;
dir_ptr parent = this->res->parent;
@ -37,17 +37,17 @@ s32 HostIO_Virtual::Open(const fs::path& path, s32 flags, u16 mode) {
bool exists = this->res->node != nullptr;
if (exists && (flags & QUASI_O_EXCL) && (flags & QUASI_O_CREAT))
return -QUASI_EEXIST;
return -POSIX_EEXIST;
if (!exists) {
if ((flags & QUASI_O_CREAT) == 0)
return -QUASI_ENOENT;
return -POSIX_ENOENT;
target = this->host_bound ? RegularFile::Create() : VirtualFile::Create();
target->chmod(mode);
if (0 != part->touch(parent, this->res->leaf, target))
// touch failed in target directory, issue with resolve() is most likely
return -QUASI_EFAULT;
return -POSIX_EFAULT;
this->res->node = target;
}
@ -61,11 +61,11 @@ s32 HostIO_Virtual::Open(const fs::path& path, s32 flags, u16 mode) {
// if exists and is a directory, can't be opened with any kind of write
if (exists && (target->is_dir() || (flags & QUASI_O_DIRECTORY)) &&
(flags & (QUASI_O_TRUNC | QUASI_O_RDWR | QUASI_O_WRONLY)))
return -QUASI_EISDIR;
return -POSIX_EISDIR;
if ((flags & QUASI_O_DIRECTORY) && !target->is_dir())
// opening dirs isn't supported yet
return -QUASI_ENOTDIR;
return -POSIX_ENOTDIR;
if (flags & (QUASI_O_NONBLOCK | QUASI_O_SYNC | QUASI_O_DIRECT | QUASI_O_DSYNC)) {
// unused, not affecting file manip per-se
@ -85,7 +85,7 @@ s32 HostIO_Virtual::Close(const s32 fd) {
s32 HostIO_Virtual::Link(const fs::path& src, const fs::path& dst) {
if (nullptr == this->res)
return -QUASI_EINVAL;
return -POSIX_EINVAL;
partition_ptr part = this->res->mountpoint;
inode_ptr src_node = this->res->node;
@ -98,7 +98,7 @@ s32 HostIO_Virtual::Link(const fs::path& src, const fs::path& dst) {
return res_status;
if (!dst_res.node->is_dir())
return -QUASI_ENOTDIR;
return -POSIX_ENOTDIR;
dir_ptr dst_parent = std::static_pointer_cast<Directory>(dst_res.node);
return part->link(src_node, dst_parent, dst_name);
@ -106,12 +106,12 @@ s32 HostIO_Virtual::Link(const fs::path& src, const fs::path& dst) {
s32 HostIO_Virtual::Unlink(const fs::path& path) {
if (nullptr == this->res)
return -QUASI_EINVAL;
return -POSIX_EINVAL;
if ("." == this->res->leaf)
return -QUASI_EINVAL;
return -POSIX_EINVAL;
if (nullptr == this->res->node)
return -QUASI_ENOENT;
return -POSIX_ENOENT;
partition_ptr part = this->res->mountpoint;
dir_ptr parent = this->res->parent;
@ -120,7 +120,7 @@ s32 HostIO_Virtual::Unlink(const fs::path& path) {
s32 HostIO_Virtual::LinkSymbolic(const fs::path& src, const fs::path& dst) {
if (nullptr == this->res)
return -QUASI_EINVAL;
return -POSIX_EINVAL;
symlink_ptr sym = Symlink::Create(src);
// symlink counter is never increased
@ -136,29 +136,29 @@ s32 HostIO_Virtual::Flush(const s32 fd) {
s32 HostIO_Virtual::FSync(const s32 fd) {
if (nullptr == handle)
return -QUASI_EINVAL;
return -POSIX_EINVAL;
inode_ptr node = handle->node;
if (nullptr == node)
return -QUASI_EBADF;
return -POSIX_EBADF;
return handle->node->fsync();
}
s64 HostIO_Virtual::LSeek(const s32 fd, s64 offset, s32 whence) {
if (nullptr == handle)
return -QUASI_EINVAL;
return -POSIX_EINVAL;
inode_ptr node = handle->node;
if (nullptr == node)
return -QUASI_EBADF;
return -POSIX_EBADF;
s64 new_position = node->lseek(handle->pos, offset, whence);
if (new_position < 0)
return -QUASI_EINVAL;
return -POSIX_EINVAL;
handle->pos = new_position;
return handle->pos;
@ -170,30 +170,30 @@ s64 HostIO_Virtual::Tell(const s32 fd) {
s32 HostIO_Virtual::Truncate(const fs::path& path, u64 size) {
if (nullptr == this->res)
return -QUASI_EINVAL;
return -POSIX_EINVAL;
inode_ptr node = this->res->node;
if (nullptr == node)
return -QUASI_EBADF;
return -POSIX_EBADF;
if (node->is_dir())
return -QUASI_EISDIR;
return -POSIX_EISDIR;
if (!node->is_file())
return -QUASI_EINVAL;
return -POSIX_EINVAL;
return node->ftruncate(size);
}
s32 HostIO_Virtual::FTruncate(const s32 fd, u64 size) {
if (nullptr == handle)
return -QUASI_EINVAL;
return -POSIX_EINVAL;
inode_ptr node = handle->node;
if (nullptr == node)
return -QUASI_EBADF;
return -POSIX_EBADF;
return handle->node->ftruncate(size);
}
@ -209,12 +209,12 @@ s64 HostIO_Virtual::Read(const s32 fd, void* buf, u64 count) {
s64 HostIO_Virtual::PRead(const s32 fd, void* buf, u64 count, s64 offset) {
if (nullptr == handle)
return -QUASI_EINVAL;
return -POSIX_EINVAL;
inode_ptr node = handle->node;
if (nullptr == node)
return -QUASI_EBADF;
return -POSIX_EBADF;
return node->pread(buf, count, offset);
}
@ -230,12 +230,12 @@ s64 HostIO_Virtual::ReadV(const s32 fd, OrbisKernelIovec* iov, u32 iovcnt) {
s64 HostIO_Virtual::PReadV(const s32 fd, OrbisKernelIovec* iov, u32 iovcnt, s64 offset) {
if (nullptr == handle)
return -QUASI_EBADF;
return -POSIX_EBADF;
inode_ptr node = handle->node;
if (nullptr == node)
return -QUASI_EBADF;
return -POSIX_EBADF;
if (handle->append)
offset = node->st.st_size;
@ -254,12 +254,12 @@ s64 HostIO_Virtual::Write(const s32 fd, const void* buf, u64 count) {
s64 HostIO_Virtual::PWrite(const s32 fd, const void* buf, u64 count, s64 offset) {
if (nullptr == handle)
return -QUASI_EBADF;
return -POSIX_EBADF;
inode_ptr node = handle->node;
if (nullptr == node)
return -QUASI_EBADF;
return -POSIX_EBADF;
if (handle->append)
offset = node->st.st_size;
@ -278,12 +278,12 @@ s64 HostIO_Virtual::WriteV(const s32 fd, const OrbisKernelIovec* iov, u32 iovcnt
s64 HostIO_Virtual::PWriteV(const s32 fd, const OrbisKernelIovec* iov, u32 iovcnt, s64 offset) {
if (nullptr == handle)
return -QUASI_EBADF;
return -POSIX_EBADF;
inode_ptr node = handle->node;
if (nullptr == node)
return -QUASI_EBADF;
return -POSIX_EBADF;
if (handle->append)
offset = node->st.st_size;
@ -293,14 +293,14 @@ s64 HostIO_Virtual::PWriteV(const s32 fd, const OrbisKernelIovec* iov, u32 iovcn
s32 HostIO_Virtual::MKDir(const fs::path& path, u16 mode) {
if (nullptr == this->res)
return -QUASI_EINVAL;
return -POSIX_EINVAL;
return this->res->mountpoint->mkdir(this->res->parent, this->res->leaf);
}
s32 HostIO_Virtual::RMDir(const fs::path& path) {
if (nullptr == this->res)
return -QUASI_EINVAL;
return -POSIX_EINVAL;
// EINVAL on . as last element
@ -308,7 +308,7 @@ s32 HostIO_Virtual::RMDir(const fs::path& path) {
dir_ptr parent = this->res->parent;
if (parent->mounted_root)
return -QUASI_EBUSY;
return -POSIX_EBUSY;
if (int unlink_status = res->mountpoint->rmdir(parent, this->res->leaf); unlink_status != 0)
return unlink_status;
@ -316,7 +316,7 @@ s32 HostIO_Virtual::RMDir(const fs::path& path) {
auto target_nlink = res->node->st.st_nlink;
if (target_nlink != 0) {
LOG_ERROR(Kernel_Fs, "RMDir'd directory nlink is not 0!", "(is ", target_nlink, ")");
return -QUASI_ENOTEMPTY;
return -POSIX_ENOTEMPTY;
}
return 0;
@ -324,12 +324,12 @@ s32 HostIO_Virtual::RMDir(const fs::path& path) {
s32 HostIO_Virtual::Stat(const fs::path& path, OrbisKernelStat* statbuf) {
if (nullptr == this->res)
return -QUASI_EINVAL;
return -POSIX_EINVAL;
inode_ptr node = this->res->node;
if (nullptr == node)
return -QUASI_ENOENT;
return -POSIX_ENOENT;
memcpy(statbuf, &node->st, sizeof(OrbisKernelStat));
@ -338,12 +338,12 @@ s32 HostIO_Virtual::Stat(const fs::path& path, OrbisKernelStat* statbuf) {
s32 HostIO_Virtual::FStat(const s32 fd, OrbisKernelStat* statbuf) {
if (nullptr == this->handle)
return -QUASI_EINVAL;
return -POSIX_EINVAL;
inode_ptr node = this->handle->node;
if (nullptr == node)
return -QUASI_EBADF;
return -POSIX_EBADF;
memcpy(statbuf, &node->st, sizeof(OrbisKernelStat));
@ -352,36 +352,36 @@ s32 HostIO_Virtual::FStat(const s32 fd, OrbisKernelStat* statbuf) {
s32 HostIO_Virtual::Chmod(const fs::path& path, u16 mode) {
if (nullptr == this->res)
return -QUASI_EINVAL;
return -POSIX_EINVAL;
inode_ptr node = this->res->node;
if (nullptr == node)
return -QUASI_ENOENT;
return -POSIX_ENOENT;
return Partition::chmod(node, mode);
}
s32 HostIO_Virtual::FChmod(const s32 fd, u16 mode) {
if (nullptr == this->handle)
return -QUASI_EINVAL;
return -POSIX_EINVAL;
inode_ptr node = this->handle->node;
if (nullptr == node)
return -QUASI_EBADF;
return -POSIX_EBADF;
return Partition::chmod(node, mode);
}
s64 HostIO_Virtual::GetDents(const s32 fd, void* buf, u64 count, s64* basep) {
if (nullptr == this->handle)
return -QUASI_EINVAL;
return -POSIX_EINVAL;
inode_ptr node = this->handle->node;
if (nullptr == node)
return -QUASI_EBADF;
return -POSIX_EBADF;
// GetDents must have read size equal to or greater than block size for that FS
// In most cases it's 512 bytes
@ -389,7 +389,7 @@ s64 HostIO_Virtual::GetDents(const s32 fd, void* buf, u64 count, s64* basep) {
if (count < 512) {
LOG_ERROR(Kernel_Fs,
"(Partial STUB) check for block size associated. Read size must be greater");
return -QUASI_EINVAL;
return -POSIX_EINVAL;
}
s64 br = node->getdents(buf, count, handle->pos, basep);

View File

@ -1,156 +0,0 @@
// INAA License @marecl 2025
#pragma once
#include <cstdint>
#define QUASI_EPERM 1 /* Operation not permitted */
#define QUASI_ENOENT 2 /* No such file or directory */
#define QUASI_ESRCH 3 /* No such process */
#define QUASI_EINTR 4 /* Interrupted system call */
#define QUASI_EIO 5 /* I/O error */
#define QUASI_ENXIO 6 /* No such device or address */
#define QUASI_E2BIG 7 /* Argument list too long */
#define QUASI_ENOEXEC 8 /* Exec format error */
#define QUASI_EBADF 9 /* Bad file number */
#define QUASI_ECHILD 10 /* No child processes */
#define QUASI_EAGAIN 11 /* Try again */
#define QUASI_ENOMEM 12 /* Out of memory */
#define QUASI_EACCES 13 /* Permission denied */
#define QUASI_EFAULT 14 /* Bad address */
#define QUASI_ENOTBLK 15 /* Block device required */
#define QUASI_EBUSY 16 /* Device or resource busy */
#define QUASI_EEXIST 17 /* File exists */
#define QUASI_EXDEV 18 /* Cross-device link */
#define QUASI_ENODEV 19 /* No such device */
#define QUASI_ENOTDIR 20 /* Not a directory */
#define QUASI_EISDIR 21 /* Is a directory */
#define QUASI_EINVAL 22 /* Invalid argument */
#define QUASI_ENFILE 23 /* File table overflow */
#define QUASI_EMFILE 24 /* Too many open files */
#define QUASI_ENOTTY 25 /* Not a typewriter */
#define QUASI_ETXTBSY 26 /* Text file busy */
#define QUASI_EFBIG 27 /* File too large */
#define QUASI_ENOSPC 28 /* No space left on device */
#define QUASI_ESPIPE 29 /* Illegal seek */
#define QUASI_EROFS 30 /* Read-only file system */
#define QUASI_EMLINK 31 /* Too many links */
#define QUASI_EPIPE 32 /* Broken pipe */
#define QUASI_EDOM 33 /* Math argument out of domain of func */
#define QUASI_ERANGE 34 /* Math result not representable */
#define QUASI_EDEADLK 35 /* Resource deadlock would occur */
#define QUASI_ENAMETOOLONG 36 /* File name too long */
#define QUASI_ENOLCK 37 /* No record locks available */
/*
* This error code is special: arch syscall entry code will return
* -ENOSYS if users try to call a syscall that doesn't exist. To keep
* failures of syscalls that really do exist distinguishable from
* failures due to attempts to use a nonexistent syscall, syscall
* implementations should refrain from returning -ENOSYS.
*/
#define QUASI_ENOSYS 38 /* Invalid system call number */
#define QUASI_ENOTEMPTY 39 /* Directory not empty */
#define QUASI_ELOOP 40 /* Too many symbolic links encountered */
#define QUASI_EWOULDBLOCK EAGAIN /* Operation would block */
#define QUASI_ENOMSG 42 /* No message of desired type */
#define QUASI_EIDRM 43 /* Identifier removed */
#define QUASI_ECHRNG 44 /* Channel number out of range */
#define QUASI_EL2NSYNC 45 /* Level 2 not synchronized */
#define QUASI_EL3HLT 46 /* Level 3 halted */
#define QUASI_EL3RST 47 /* Level 3 reset */
#define QUASI_ELNRNG 48 /* Link number out of range */
#define QUASI_EUNATCH 49 /* Protocol driver not attached */
#define QUASI_ENOCSI 50 /* No CSI structure available */
#define QUASI_EL2HLT 51 /* Level 2 halted */
#define QUASI_EBADE 52 /* Invalid exchange */
#define QUASI_EBADR 53 /* Invalid request descriptor */
#define QUASI_EXFULL 54 /* Exchange full */
#define QUASI_ENOANO 55 /* No anode */
#define QUASI_EBADRQC 56 /* Invalid request code */
#define QUASI_EBADSLT 57 /* Invalid slot */
#define QUASI_EDEADLOCK QUASI_EDEADLK
#define QUASI_EBFONT 59 /* Bad font file format */
#define QUASI_ENOSTR 60 /* Device not a stream */
#define QUASI_ENODATA 61 /* No data available */
#define QUASI_ETIME 62 /* Timer expired */
#define QUASI_ENOSR 63 /* Out of streams resources */
#define QUASI_ENONET 64 /* Machine is not on the network */
#define QUASI_ENOPKG 65 /* Package not installed */
#define QUASI_EREMOTE 66 /* Object is remote */
#define QUASI_ENOLINK 67 /* Link has been severed */
#define QUASI_EADV 68 /* Advertise error */
#define QUASI_ESRMNT 69 /* Srmount error */
#define QUASI_ECOMM 70 /* Communication error on send */
#define QUASI_EPROTO 71 /* Protocol error */
#define QUASI_EMULTIHOP 72 /* Multihop attempted */
#define QUASI_EDOTDOT 73 /* RFS specific error */
#define QUASI_EBADMSG 74 /* Not a data message */
#define QUASI_EOVERFLOW 75 /* Value too large for defined data type */
#define QUASI_ENOTUNIQ 76 /* Name not unique on network */
#define QUASI_EBADFD 77 /* File descriptor in bad state */
#define QUASI_EREMCHG 78 /* Remote address changed */
#define QUASI_ELIBACC 79 /* Can not access a needed shared library */
#define QUASI_ELIBBAD 80 /* Accessing a corrupted shared library */
#define QUASI_ELIBSCN 81 /* .lib section in a.out corrupted */
#define QUASI_ELIBMAX 82 /* Attempting to link in too many shared libraries */
#define QUASI_ELIBEXEC 83 /* Cannot exec a shared library directly */
#define QUASI_EILSEQ 84 /* Illegal byte sequence */
#define QUASI_ERESTART 85 /* Interrupted system call should be restarted */
#define QUASI_ESTRPIPE 86 /* Streams pipe error */
#define QUASI_EUSERS 87 /* Too many users */
#define QUASI_ENOTSOCK 88 /* Socket operation on non-socket */
#define QUASI_EDESTADDRREQ 89 /* Destination address required */
#define QUASI_EMSGSIZE 90 /* Message too long */
#define QUASI_EPROTOTYPE 91 /* Protocol wrong type for socket */
#define QUASI_ENOPROTOOPT 92 /* Protocol not available */
#define QUASI_EPROTONOSUPPORT 93 /* Protocol not supported */
#define QUASI_ESOCKTNOSUPPORT 94 /* Socket type not supported */
#define QUASI_EOPNOTSUPP 95 /* Operation not supported on transport endpoint */
#define QUASI_EPFNOSUPPORT 96 /* Protocol family not supported */
#define QUASI_EAFNOSUPPORT 97 /* Address family not supported by protocol */
#define QUASI_EADDRINUSE 98 /* Address already in use */
#define QUASI_EADDRNOTAVAIL 99 /* Cannot assign requested address */
#define QUASI_ENETDOWN 100 /* Network is down */
#define QUASI_ENETUNREACH 101 /* Network is unreachable */
#define QUASI_ENETRESET 102 /* Network dropped connection because of reset */
#define QUASI_ECONNABORTED 103 /* Software caused connection abort */
#define QUASI_ECONNRESET 104 /* Connection reset by peer */
#define QUASI_ENOBUFS 105 /* No buffer space available */
#define QUASI_EISCONN 106 /* Transport endpoint is already connected */
#define QUASI_ENOTCONN 107 /* Transport endpoint is not connected */
#define QUASI_ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */
#define QUASI_ETOOMANYREFS 109 /* Too many references: cannot splice */
#define QUASI_ETIMEDOUT 110 /* Connection timed out */
#define QUASI_ECONNREFUSED 111 /* Connection refused */
#define QUASI_EHOSTDOWN 112 /* Host is down */
#define QUASI_EHOSTUNREACH 113 /* No route to host */
#define QUASI_EALREADY 114 /* Operation already in progress */
#define QUASI_EINPROGRESS 115 /* Operation now in progress */
#define QUASI_ESTALE 116 /* Stale file handle */
#define QUASI_EUCLEAN 117 /* Structure needs cleaning */
#define QUASI_ENOTNAM 118 /* Not a XENIX named type file */
#define QUASI_ENAVAIL 119 /* No XENIX semaphores available */
#define QUASI_EISNAM 120 /* Is a named type file */
#define QUASI_EREMOTEIO 121 /* Remote I/O error */
#define QUASI_EDQUOT 122 /* Quota exceeded */
#define QUASI_ENOMEDIUM 123 /* No medium found */
#define QUASI_EMEDIUMTYPE 124 /* Wrong medium type */
#define QUASI_ECANCELED 125 /* Operation Canceled */
#define QUASI_ENOKEY 126 /* Required key not available */
#define QUASI_EKEYEXPIRED 127 /* Key has expired */
#define QUASI_EKEYREVOKED 128 /* Key has been revoked */
#define QUASI_EKEYREJECTED 129 /* Key was rejected by service */
/* for robust mutexes */
#define QUASI_EOWNERDEAD 130 /* Owner died */
#define QUASI_ENOTRECOVERABLE 131 /* State not recoverable */
#define QUASI_ERFKILL 132 /* Operation not possible due to RF-kill */
#define QUASI_EHWPOISON 133 /* Memory page has hardware error */

View File

@ -6,9 +6,9 @@
#include <unordered_map>
#include "common/types.h"
#include "core/libraries/kernel/posix_error.h"
#include "src/core/file_sys/hostio/host_io.h"
#include "quasi_errno.h"
#include "quasi_types.h"
#include "quasifs_inode.h"
@ -188,22 +188,22 @@ public:
//
int64_t GetSize(const fs::path& path) {
return -QUASI_EINVAL;
return -POSIX_EINVAL;
};
int64_t GetSize(const fs::path& path, std::error_code& ec) noexcept {
return -QUASI_EINVAL;
return -POSIX_EINVAL;
};
bool Exists(const fs::path& path) {
return -QUASI_EINVAL;
return -POSIX_EINVAL;
};
bool Exists(const fs::path& path, std::error_code& ec) noexcept {
return -QUASI_EINVAL;
return -POSIX_EINVAL;
};
bool IsDirectory(const fs::path& path) {
return -QUASI_EINVAL;
return -POSIX_EINVAL;
};
bool IsDirectory(const fs::path& path, std::error_code& ec) noexcept {
return -QUASI_EINVAL;
return -POSIX_EINVAL;
};
fs::path AbsolutePath(const fs::path& path) {
return "";
@ -212,10 +212,10 @@ public:
return "";
};
bool Remove(const fs::path& path) {
return -QUASI_EINVAL;
return -POSIX_EINVAL;
};
bool Remove(const fs::path& path, std::error_code& ec) noexcept {
return -QUASI_EINVAL;
return -POSIX_EINVAL;
};
uint64_t RemoveAll(const fs::path& path) = delete;
uint64_t RemoveAll(const fs::path& path, std::error_code& ec) noexcept = delete;
@ -231,20 +231,20 @@ public:
// 0777 to mimic default C++ mode (std::filesystem::perms::all)
bool CreateDirectory(const fs::path& path, int mode = 0777) {
return -QUASI_EINVAL;
return -POSIX_EINVAL;
};
bool CreateDirectory(const fs::path& path, std::error_code& ec, int mode = 0777) noexcept {
return -QUASI_EINVAL;
return -POSIX_EINVAL;
};
bool CreateDirectory(const fs::path& path, const fs::path& existing_path,
int mode = 0777) = delete;
bool CreateDirectory(const fs::path& path, const fs::path& existing_path, std::error_code& ec,
int mode = 0777) noexcept = delete;
bool CreateDirectories(const fs::path& path, int mode = 0777) {
return -QUASI_EINVAL;
return -POSIX_EINVAL;
};
bool CreateDirectories(const fs::path& path, std::error_code& ec, int mode = 0777) noexcept {
return -QUASI_EINVAL;
return -POSIX_EINVAL;
};
fd_handle_ptr GetHandle(s32 fd);

View File

@ -9,8 +9,8 @@
#include "common/types.h"
#include "common/va_ctx.h"
#include "core/libraries/kernel/file_system.h"
#include "core/libraries/kernel/posix_error.h"
#include "quasi_errno.h"
#include "quasi_sys_stat.h"
#include "quasi_types.h"
@ -39,15 +39,15 @@ public:
virtual ~Inode() = default;
virtual s32 ioctl(u64 cmd, Common::VaCtx* args) {
return -QUASI_ENOTTY;
return -POSIX_ENOTTY;
}
virtual s64 pread(void* buf, u64 count, s64 offset) {
return -QUASI_EBADF;
return -POSIX_EBADF;
}
virtual s64 pwrite(const void* buf, u64 count, s64 offset) {
return -QUASI_EBADF;
return -POSIX_EBADF;
}
virtual s64 preadv(const Libraries::Kernel::OrbisKernelIovec* iov, u32 iovcnt, s64 offset) {
@ -84,15 +84,15 @@ public:
}
virtual s32 fsync() {
return -QUASI_EBADF;
return -POSIX_EBADF;
}
virtual s32 ftruncate(s64 length) {
return -QUASI_EINVAL;
return -POSIX_EINVAL;
}
virtual s64 getdents(void* buf, u32 count, s64 offset, s64* basep) {
return -QUASI_EINVAL;
return -POSIX_EINVAL;
}
// type helpers

View File

@ -4,7 +4,6 @@
#include "common/logging/log.h"
#include "core/file_sys/quasifs/quasi_errno.h"
#include "core/file_sys/quasifs/quasi_types.h"
#include "core/file_sys/quasifs/quasifs.h"
#include "core/file_sys/quasifs/quasifs_inode_quasi_directory.h"
@ -13,6 +12,7 @@
#include "core/file_sys/quasifs/quasifs_inode_quasi_file_virtual.h"
#include "core/file_sys/quasifs/quasifs_inode_symlink.h"
#include "core/file_sys/quasifs/quasifs_partition.h"
#include "core/libraries/kernel/posix_error.h"
namespace QuasiFS {
std::string file_mode(u16 mode) {
@ -140,10 +140,10 @@ int QFS::SyncHost(fs::path path) {
int status = Resolve(path, res);
if (0 != status)
return -QUASI_ENOENT;
return -POSIX_ENOENT;
if (nullptr == res.mountpoint)
return -QUASI_ENOMEDIUM;
return -POSIX_ENODEV;
SyncHostImpl(res.mountpoint);
@ -159,14 +159,14 @@ int QFS::Mount(const fs::path& path, partition_ptr fs, unsigned int options) {
return status;
if (!res.node->is_dir())
return -QUASI_ENOTDIR;
return -POSIX_ENOTDIR;
mount_t* existing_fs_options = GetPartitionInfo(fs);
if (options & MountOptions::MOUNT_REMOUNT) {
if (nullptr == existing_fs_options) {
LOG_ERROR(Kernel_Fs, "Can't remount {}: Not mounted", path.string());
return -QUASI_EINVAL;
return -POSIX_EINVAL;
}
auto curopt = &existing_fs_options->options;
@ -178,7 +178,7 @@ int QFS::Mount(const fs::path& path, partition_ptr fs, unsigned int options) {
if (nullptr != existing_fs_options || dir->mounted_root) {
// fs_options exists or there's something (else?) mounted there already
LOG_ERROR(Kernel_Fs, "Can't mount {}: Already mounted", path.string());
return -QUASI_EEXIST;
return -POSIX_EEXIST;
}
if (options & MountOptions::MOUNT_BIND)
@ -209,7 +209,7 @@ int QFS::Unmount(const fs::path& path) {
mount_t* part_opts = GetPartitionInfo(part);
if (nullptr == part_opts)
return -QUASI_EINVAL;
return -POSIX_EINVAL;
dir_ptr options_parentdir = part_opts->parentdir;
dir_ptr res_parentdir = res.parent;
@ -221,7 +221,7 @@ int QFS::Unmount(const fs::path& path) {
if (nullptr == res_rootdir)
// mounted but rootdir disappeared O.o
return -QUASI_EINVAL;
return -POSIX_EINVAL;
options_parentdir->mounted_root = nullptr;
this->block_devices.erase(part);
@ -236,7 +236,7 @@ int QFS::ForceInsert(const fs::path& path, const std::string& name, inode_ptr no
if (0 != resolve_status)
return resolve_status;
if (!res.node->is_dir())
return -QUASI_ENOTDIR;
return -POSIX_ENOTDIR;
return res.mountpoint->touch(std::static_pointer_cast<Directory>(res.node), name, node);
}
@ -244,9 +244,9 @@ int QFS::ForceInsert(const fs::path& path, const std::string& name, inode_ptr no
// Debugging it is a royal PITA
int QFS::Resolve(const fs::path& path, Resolved& res) {
if (path.empty() || !path.string().starts_with("/"))
return -QUASI_EINVAL;
return -POSIX_EINVAL;
// if (path.is_relative())
// return -QUASI_EINVAL;
// return -POSIX_EINVAL;
// on return:
// node - last element of the path (if exists)
@ -312,7 +312,7 @@ int QFS::Resolve(const fs::path& path, Resolved& res) {
if (nullptr == mounted_partition) {
res.mountpoint = nullptr;
return -QUASI_ENOENT;
return -POSIX_ENOENT;
}
res.mountpoint = mounted_partition;
@ -331,7 +331,7 @@ int QFS::Resolve(const fs::path& path, Resolved& res) {
} while (--safety_counter > 0);
if (0 == safety_counter)
return -QUASI_ELOOP;
return -POSIX_ELOOP;
return 0;
}
@ -355,23 +355,23 @@ bool QFS::IsOpen(const s32 fd) noexcept {
int QFS::SetSize(const s32 fd, uint64_t size) noexcept {
fd_handle_ptr fh = this->GetHandle(fd);
if (nullptr == fh)
return -QUASI_EBADF;
return -POSIX_EBADF;
return this->Operation.FTruncate(fd, size);
}
s64 QFS::GetSize(const s32 fd) noexcept {
fd_handle_ptr fh = this->GetHandle(fd);
if (nullptr == fh)
return -QUASI_EBADF;
return -POSIX_EBADF;
if (nullptr == fh->node)
return -QUASI_EBADF;
return -POSIX_EBADF;
return fh->node->st.st_size;
};
s64 QFS::GetDirectorySize(const fs::path& path) noexcept {
UNIMPLEMENTED();
return -QUASI_ENOSYS;
return -POSIX_ENOSYS;
};
//
@ -489,7 +489,7 @@ partition_ptr QFS::GetPartitionByParent(const dir_ptr dir) {
int QFS::IsPartitionRO(partition_ptr part) {
mount_t* part_info = GetPartitionInfo(part);
if (nullptr == part_info)
return -QUASI_ENODEV;
return -POSIX_ENODEV;
if (part_info->options & MountOptions::MOUNT_RW)
return 0;
return 1;

View File

@ -16,11 +16,11 @@ Device::Device() {
Device::~Device() = default;
s64 Device::read(void* buf, u64 count) {
return -QUASI_EBADF;
return -POSIX_EBADF;
}
s64 Device::write(const void* buf, u64 count) {
return -QUASI_EBADF;
return -POSIX_EBADF;
}
s64 Device::pread(void* buf, u64 count, s64 offset) {

View File

@ -4,8 +4,8 @@
#include <string>
#include "common/alignment.h"
#include "core/file_sys/quasifs/quasi_errno.h"
#include "core/file_sys/quasifs/quasifs_inode_quasi_directory.h"
#include "core/libraries/kernel/posix_error.h"
namespace QuasiFS {
@ -37,7 +37,7 @@ s32 QuasiDirectory::fstat(Libraries::Kernel::OrbisKernelStat* sb) {
}
s32 QuasiDirectory::ftruncate(s64 length) {
return -QUASI_EISDIR;
return -POSIX_EISDIR;
}
s64 QuasiDirectory::getdents(void* buf, u32 count, s64 offset, s64* basep) {
@ -77,9 +77,9 @@ inode_ptr QuasiDirectory::lookup(const std::string& name) {
int QuasiDirectory::link(const std::string& name, inode_ptr child) {
if (name.empty())
return -QUASI_ENOENT;
return -POSIX_ENOENT;
if (entries.count(name))
return -QUASI_EEXIST;
return -POSIX_EEXIST;
entries[name] = child;
if (!child->is_link())
child->st.st_nlink++;
@ -90,7 +90,7 @@ int QuasiDirectory::link(const std::string& name, inode_ptr child) {
int QuasiDirectory::unlink(const std::string& name) {
auto it = entries.find(name);
if (it == entries.end())
return -QUASI_ENOENT;
return -POSIX_ENOENT;
inode_ptr target = it->second;
// if directory and not empty -> EBUSY or ENOTEMPTY
@ -100,7 +100,7 @@ int QuasiDirectory::unlink(const std::string& name) {
children.erase(std::remove(children.begin(), children.end(), "."), children.end());
children.erase(std::remove(children.begin(), children.end(), ".."), children.end());
if (!children.empty())
return -QUASI_ENOTEMPTY;
return -POSIX_ENOTEMPTY;
// parent loses reference from subdir [ .. ]
this->st.st_nlink--;

View File

@ -4,8 +4,8 @@
#include <string>
#include "common/alignment.h"
#include "core/file_sys/quasifs/quasi_errno.h"
#include "core/file_sys/quasifs/quasifs_inode_quasi_directory_pfs.h"
#include "core/libraries/kernel/posix_error.h"
// PFS is a bit different from regular dirents, see comments below
// Although it's pretty simple, every tested game (sample size: 1) reads it exclusively with

View File

@ -2,8 +2,8 @@
#include <vector>
#include "core/file_sys/quasifs/quasi_errno.h"
#include "core/file_sys/quasifs/quasifs_inode_quasi_file.h"
#include "core/libraries/kernel/posix_error.h"
namespace QuasiFS {
@ -27,7 +27,7 @@ s64 QuasiFile::pwrite(const void* buf, size_t count, s64 offset) {
s32 QuasiFile::ftruncate(s64 length) {
if (length < 0)
return -QUASI_EINVAL;
return -POSIX_EINVAL;
this->st.st_size = length;
st.st_mtim.tv_sec = time(0);
return 0;

View File

@ -2,8 +2,8 @@
#include <vector>
#include "core/file_sys/quasifs/quasi_errno.h"
#include "core/file_sys/quasifs/quasifs_inode_quasi_file_virtual.h"
#include "core/libraries/kernel/posix_error.h"
namespace QuasiFS {
@ -40,7 +40,7 @@ s64 VirtualFile::pwrite(const void* buf, size_t count, s64 offset) {
s32 VirtualFile::ftruncate(s64 length) {
if (length < 0)
return -QUASI_EINVAL;
return -POSIX_EINVAL;
this->data.resize(length, 0);
this->st.st_size = length;
st.st_mtim.tv_sec = time(0);

View File

@ -2,13 +2,13 @@
#include "common/logging/log.h"
#include "core/file_sys/quasifs/quasi_errno.h"
#include "core/file_sys/quasifs/quasi_types.h"
#include "core/file_sys/quasifs/quasifs_inode_quasi_directory.h"
#include "core/file_sys/quasifs/quasifs_inode_quasi_directory_pfs.h"
#include "core/file_sys/quasifs/quasifs_inode_quasi_file.h"
#include "core/file_sys/quasifs/quasifs_inode_symlink.h"
#include "core/file_sys/quasifs/quasifs_partition.h"
#include "core/libraries/kernel/posix_error.h"
namespace QuasiFS {
@ -39,17 +39,17 @@ fs::path Partition::SanitizePath(const fs::path& path) {
int Partition::GetHostPath(fs::path& output_path, const fs::path& local_path) {
if (this->host_root.empty())
return -QUASI_ENODEV;
return -POSIX_ENODEV;
// must be relative to root, otherwise lvalue is overwritten
fs::path host_path_target = (this->host_root / local_path.lexically_relative("/"));
if (host_path_target.empty())
return -QUASI_EINVAL;
return -POSIX_EINVAL;
fs::path host_path_target_sanitized = SanitizePath(host_path_target);
if (host_path_target_sanitized.empty()) {
LOG_ERROR(Kernel_Fs, "Malicious path detected: {}", host_path_target.string());
return -QUASI_EACCES;
return -POSIX_EACCES;
}
output_path = host_path_target_sanitized;
@ -88,13 +88,13 @@ inode_ptr Partition::GetInodeByFileno(fileno_t fileno) {
// Debugging it is a royal PITA
int Partition::Resolve(fs::path& path, Resolved& res) {
if (path.empty() || !path.string().starts_with("/"))
return -QUASI_EINVAL;
return -POSIX_EINVAL;
// if (path.is_relative())
// return -QUASI_EBADF;
// return -POSIX_EBADF;
if (path.string().size() >= 256)
return -QUASI_ENAMETOOLONG;
return -POSIX_ENAMETOOLONG;
res.mountpoint = shared_from_this();
res.local_path = "/";
@ -129,21 +129,21 @@ int Partition::Resolve(fs::path& path, Resolved& res) {
if (!(current->is_link() || current->is_dir()))
// trailing slash after a file
return -QUASI_ENOTDIR;
return -POSIX_ENOTDIR;
return 0;
}
if (!(current->is_link() || current->is_dir()) && !is_final) {
// path elements must be a dir or a symlink
return -QUASI_ENOTDIR;
return -POSIX_ENOTDIR;
}
//
if (current->is_dir()) {
if (!current->CanRead())
return -QUASI_EACCES;
return -POSIX_EACCES;
dir_ptr dir = std::static_pointer_cast<Directory>(current);
parent = dir;
@ -165,7 +165,7 @@ int Partition::Resolve(fs::path& path, Resolved& res) {
res.node = nullptr;
res.parent = nullptr;
}
return -QUASI_ENOENT;
return -POSIX_ENOENT;
}
//
@ -223,7 +223,7 @@ int Partition::Resolve(fs::path& path, Resolved& res) {
int Partition::touch(dir_ptr parent, const std::string& name, inode_ptr child) {
if (nullptr == parent)
return -QUASI_EINVAL;
return -POSIX_EINVAL;
auto ret = parent->link(name, child);
if (ret == 0)
@ -233,7 +233,7 @@ int Partition::touch(dir_ptr parent, const std::string& name, inode_ptr child) {
int Partition::mkdir(dir_ptr parent, const std::string& name) {
if (nullptr == parent)
return -QUASI_ENOENT;
return -POSIX_ENOENT;
dir_ptr real_parent = parent->mounted_root ? parent->mounted_root : parent;
dir_ptr child = real_parent->Spawn();
@ -251,16 +251,16 @@ int Partition::mkdir(dir_ptr parent, const std::string& name) {
int Partition::rmdir(dir_ptr parent, const std::string& name) {
if (nullptr == parent)
return -QUASI_ENOENT;
return -POSIX_ENOENT;
if (name.empty())
return -QUASI_EINVAL;
return -POSIX_EINVAL;
inode_ptr target = parent->lookup(name);
if (nullptr == target)
return -QUASI_ENOENT;
return -POSIX_ENOENT;
if (!target->is_dir())
return -QUASI_ENOTDIR;
return -POSIX_ENOTDIR;
int status = parent->unlink(name);
if (0 != status)
@ -271,29 +271,29 @@ int Partition::rmdir(dir_ptr parent, const std::string& name) {
int Partition::link(inode_ptr source, dir_ptr destination_parent, const std::string& name) {
if (nullptr == source || nullptr == destination_parent)
return -QUASI_ENOENT;
return -POSIX_ENOENT;
if (name.empty())
return -QUASI_EINVAL;
return -POSIX_EINVAL;
if (destination_parent->lookup(name) != nullptr)
return -QUASI_EEXIST;
return -POSIX_EEXIST;
if (source->is_dir())
return -QUASI_EPERM;
return -POSIX_EPERM;
return destination_parent->link(name, source);
}
int Partition::unlink(dir_ptr parent, const std::string& name) {
if (nullptr == parent)
return -QUASI_ENOENT;
return -POSIX_ENOENT;
if (name.empty())
return -QUASI_EINVAL;
return -POSIX_EINVAL;
inode_ptr target = parent->lookup(name);
if (nullptr == target)
return -QUASI_ENOENT;
return -POSIX_ENOENT;
if (target->is_dir())
return -QUASI_EISDIR;
return -POSIX_EISDIR;
int status = parent->unlink(name);
if (0 != status)
@ -304,7 +304,7 @@ int Partition::unlink(dir_ptr parent, const std::string& name) {
int Partition::chmod(inode_ptr target, u16 mode) {
if (nullptr == target)
return -QUASI_EINVAL;
return -POSIX_EINVAL;
return target->chmod(mode);
}
@ -312,20 +312,20 @@ int Partition::chmod(inode_ptr target, u16 mode) {
int Partition::rmInode(fileno_t fileno) {
inode_ptr target = GetInodeByFileno(fileno);
if (nullptr == target)
return -QUASI_EINVAL;
return -POSIX_EINVAL;
return rmInode(target);
}
int Partition::rmInode(inode_ptr node) {
if (nullptr == node)
return -QUASI_EINVAL;
return -POSIX_EINVAL;
// truly remove if there are no hardlinks
if (node->st.st_nlink > 0)
return 0;
// TODO: check for open file handles, return -QUASI_EEBUSY
// TODO: check for open file handles, return -POSIX_EEBUSY
this->inode_table.erase(node->GetFileno());
return 0;

View File

@ -4,7 +4,6 @@
#include "common/logging/log.h"
#include "core/file_sys/quasifs/quasi_errno.h"
#include "core/file_sys/quasifs/quasi_sys_fcntl.h"
#include "core/file_sys/quasifs/quasi_types.h"
#include "core/file_sys/quasifs/quasifs.h"
@ -12,6 +11,7 @@
#include "core/file_sys/quasifs/quasifs_inode_quasi_file.h"
#include "core/file_sys/quasifs/quasifs_inode_symlink.h"
#include "core/file_sys/quasifs/quasifs_partition.h"
#include "core/libraries/kernel/posix_error.h"
namespace QuasiFS {
@ -21,9 +21,9 @@ s32 QFS::OperationImpl::Open(const fs::path& path, int flags, u16 mode) {
int resolve_status = qfs.Resolve(path, res);
// enoent on last element in the path is good
if (-QUASI_ENOENT == resolve_status) {
if (-POSIX_ENOENT == resolve_status) {
if (nullptr == res.parent)
return -QUASI_ENOENT;
return -POSIX_ENOENT;
} else if (0 != resolve_status)
return resolve_status;
@ -41,26 +41,26 @@ s32 QFS::OperationImpl::Open(const fs::path& path, int flags, u16 mode) {
//
if ((flags & (QUASI_O_WRONLY | QUASI_O_RDWR)) == (QUASI_O_WRONLY | QUASI_O_RDWR))
return -QUASI_EINVAL;
return -POSIX_EINVAL;
// if it doesn't exist, check the parent
inode_ptr checked_node = nullptr == res.node ? parent_node : res.node;
if ((request_read && !checked_node->CanRead()) || (request_write && !checked_node->CanWrite()))
return -QUASI_EACCES;
return -POSIX_EACCES;
if ((request_write || request_append) && qfs.IsPartitionRO(part))
return -QUASI_EROFS;
return -POSIX_EROFS;
if (flags & QUASI_O_DIRECTORY && flags & QUASI_O_CREAT)
return -QUASI_ENOTDIR;
return -POSIX_ENOTDIR;
// O_TRUNC | O_RDONLY - throw einval but touch a file
// TODO: find out what happens when can't create file before throwing einval
if ((flags & (QUASI_O_TRUNC | QUASI_O_WRONLY | QUASI_O_RDWR)) == QUASI_O_TRUNC) {
if (int status = this->Close(this->Creat(path, mode)); status != 0)
return status;
return -QUASI_ENOENT;
return -POSIX_ENOENT;
}
//
@ -124,11 +124,11 @@ s32 QFS::OperationImpl::Creat(const fs::path& path, u16 mode) {
s32 QFS::OperationImpl::Close(s32 fd) {
if (fd < 0)
return -QUASI_EBADF;
return -POSIX_EBADF;
fd_handle_ptr handle = qfs.GetHandle(fd);
if (nullptr == handle)
return -QUASI_EBADF;
return -POSIX_EBADF;
if (fd <= 2)
LOG_ERROR(Kernel_Fs, "Closing std stream, this will have consequences fd={}", fd);
@ -164,16 +164,16 @@ s32 QFS::OperationImpl::LinkSymbolic(const fs::path& src, const fs::path& dst) {
// source may not exist and can point wherever it wants, so we skip checks for it
if (0 == status_where)
return -QUASI_EEXIST;
return -POSIX_EEXIST;
// destination parent directory must exist though
if (0 != status_where && nullptr == dst_res.parent)
return -QUASI_ENOENT;
return -POSIX_ENOENT;
partition_ptr src_part = src_res.mountpoint;
partition_ptr dst_part = dst_res.mountpoint;
if (qfs.IsPartitionRO(dst_part))
return -QUASI_EROFS;
return -POSIX_EROFS;
bool host_used = false;
int hio_status = 0;
@ -184,7 +184,7 @@ s32 QFS::OperationImpl::LinkSymbolic(const fs::path& src, const fs::path& dst) {
if (src_part->IsHostMounted() && dst_part->IsHostMounted()) {
// if target partition doesn't exist or is not mounted, we can'tqfs.Resolve host path
if (nullptr == src_part)
return -QUASI_ENOENT;
return -POSIX_ENOENT;
fs::path host_path_src{};
fs::path host_path_dst{};
@ -203,7 +203,7 @@ s32 QFS::OperationImpl::LinkSymbolic(const fs::path& src, const fs::path& dst) {
} else if (dst_part->IsHostMounted() ^ src_part->IsHostMounted()) {
LOG_ERROR(Kernel_Fs,
"Symlinks can be only created on the same type of partition (virtual/host)");
return -QUASI_ENOSYS;
return -POSIX_ENOSYS;
}
{
@ -230,11 +230,11 @@ s32 QFS::OperationImpl::Link(const fs::path& src, const fs::path& dst) {
if (0 != status_what)
return status_what;
if (0 == status_where)
return -QUASI_EEXIST;
return -POSIX_EEXIST;
// cross-partition linking is not supported
if (src_res.mountpoint != dst_res.mountpoint)
return -QUASI_EXDEV;
return -POSIX_EXDEV;
partition_ptr src_part = src_res.mountpoint;
partition_ptr dst_part = dst_res.mountpoint;
@ -242,11 +242,11 @@ s32 QFS::OperationImpl::Link(const fs::path& src, const fs::path& dst) {
if (src_part != dst_part) {
LOG_ERROR(Kernel_Fs, "Hard links can only be created within one partition");
// I think this is the right error
return -QUASI_ENOSYS;
return -POSIX_ENOSYS;
}
if (qfs.IsPartitionRO(dst_part))
return -QUASI_EROFS;
return -POSIX_EROFS;
bool host_used = false;
int hio_status = 0;
@ -298,17 +298,17 @@ s32 QFS::OperationImpl::Unlink(const fs::path& path) {
return resolve_status;
if (!res.node->is_dir())
return -QUASI_ENOTDIR;
return -POSIX_ENOTDIR;
partition_ptr part = res.mountpoint;
if (qfs.IsPartitionRO(part))
return -QUASI_EROFS;
return -POSIX_EROFS;
dir_ptr parent = std::static_pointer_cast<Directory>(res.node);
inode_ptr target = parent->lookup(leaf);
if (nullptr == target)
return -QUASI_ENOENT;
return -POSIX_ENOENT;
// fix upqfs.Resolve result for VIO
res.parent = parent;
@ -348,14 +348,14 @@ s32 QFS::OperationImpl::Unlink(const fs::path& path) {
s32 QFS::OperationImpl::Flush(const s32 fd) {
if (fd < 0)
return -QUASI_EBADF;
return -POSIX_EBADF;
fd_handle_ptr handle = qfs.GetHandle(fd);
if (nullptr == handle)
return -QUASI_EBADF;
return -POSIX_EBADF;
if (!handle->read)
return -QUASI_EBADF;
return -POSIX_EBADF;
bool host_used = false;
int hio_status = 0;
@ -385,11 +385,11 @@ s32 QFS::OperationImpl::Flush(const s32 fd) {
s32 QFS::OperationImpl::FSync(const s32 fd) {
if (fd < 0)
return -QUASI_EBADF;
return -POSIX_EBADF;
fd_handle_ptr handle = qfs.GetHandle(fd);
if (nullptr == handle)
return -QUASI_EBADF;
return -POSIX_EBADF;
bool host_used = false;
int hio_status = 0;
@ -426,7 +426,7 @@ s32 QFS::OperationImpl::Truncate(const fs::path& path, u64 length) {
partition_ptr part = res.mountpoint;
if (qfs.IsPartitionRO(part))
return -QUASI_EROFS;
return -POSIX_EROFS;
bool host_used = false;
int hio_status = 0;
@ -459,14 +459,14 @@ s32 QFS::OperationImpl::Truncate(const fs::path& path, u64 length) {
s32 QFS::OperationImpl::FTruncate(const s32 fd, u64 length) {
if (fd < 0)
return -QUASI_EBADF;
return -POSIX_EBADF;
fd_handle_ptr handle = qfs.GetHandle(fd);
if (nullptr == handle)
return -QUASI_EBADF;
return -POSIX_EBADF;
if (!handle->write)
return -QUASI_EBADF;
return -POSIX_EBADF;
// EROFS is guarded by Open()
@ -498,11 +498,11 @@ s32 QFS::OperationImpl::FTruncate(const s32 fd, u64 length) {
s64 QFS::OperationImpl::LSeek(const s32 fd, s64 offset, s32 whence) {
if (fd < 0)
return -QUASI_EBADF;
return -POSIX_EBADF;
fd_handle_ptr handle = qfs.GetHandle(fd);
if (nullptr == handle)
return -QUASI_EBADF;
return -POSIX_EBADF;
bool host_used = false;
int hio_status = 0;
@ -546,14 +546,14 @@ void UpdateStatFromHost(Libraries::Kernel::OrbisKernelStat* vfs,
s64 QFS::OperationImpl::Read(const s32 fd, void* buf, u64 count) {
if (fd < 0)
return -QUASI_EBADF;
return -POSIX_EBADF;
fd_handle_ptr handle = qfs.GetHandle(fd);
if (nullptr == handle)
return -QUASI_EBADF;
return -POSIX_EBADF;
if (!handle->read)
return -QUASI_EBADF;
return -POSIX_EBADF;
bool host_used = false;
int hio_status = 0;
@ -583,14 +583,14 @@ s64 QFS::OperationImpl::Read(const s32 fd, void* buf, u64 count) {
s64 QFS::OperationImpl::PRead(const s32 fd, void* buf, u64 count, s64 offset) {
if (fd < 0)
return -QUASI_EBADF;
return -POSIX_EBADF;
fd_handle_ptr handle = qfs.GetHandle(fd);
if (nullptr == handle)
return -QUASI_EBADF;
return -POSIX_EBADF;
if (!handle->read)
return -QUASI_EBADF;
return -POSIX_EBADF;
bool host_used = false;
int hio_status = 0;
@ -620,14 +620,14 @@ s64 QFS::OperationImpl::PRead(const s32 fd, void* buf, u64 count, s64 offset) {
s64 QFS::OperationImpl::ReadV(const s32 fd, Libraries::Kernel::OrbisKernelIovec* iov, u32 iovcnt) {
if (fd < 0)
return -QUASI_EBADF;
return -POSIX_EBADF;
fd_handle_ptr handle = qfs.GetHandle(fd);
if (nullptr == handle)
return -QUASI_EBADF;
return -POSIX_EBADF;
if (!handle->read)
return -QUASI_EBADF;
return -POSIX_EBADF;
bool host_used = false;
int hio_status = 0;
@ -658,14 +658,14 @@ s64 QFS::OperationImpl::ReadV(const s32 fd, Libraries::Kernel::OrbisKernelIovec*
s64 QFS::OperationImpl::PReadV(const s32 fd, Libraries::Kernel::OrbisKernelIovec* iov, u32 iovcnt,
s64 offset) {
if (fd < 0)
return -QUASI_EBADF;
return -POSIX_EBADF;
fd_handle_ptr handle = qfs.GetHandle(fd);
if (nullptr == handle)
return -QUASI_EBADF;
return -POSIX_EBADF;
if (!handle->read)
return -QUASI_EBADF;
return -POSIX_EBADF;
bool host_used = false;
int hio_status = 0;
@ -695,14 +695,14 @@ s64 QFS::OperationImpl::PReadV(const s32 fd, Libraries::Kernel::OrbisKernelIovec
s64 QFS::OperationImpl::Write(const s32 fd, const void* buf, u64 count) {
if (fd < 0)
return -QUASI_EBADF;
return -POSIX_EBADF;
fd_handle_ptr handle = qfs.GetHandle(fd);
if (nullptr == handle)
return -QUASI_EBADF;
return -POSIX_EBADF;
if (!handle->write)
return -QUASI_EBADF;
return -POSIX_EBADF;
bool host_used = false;
int hio_status = 0;
@ -732,14 +732,14 @@ s64 QFS::OperationImpl::Write(const s32 fd, const void* buf, u64 count) {
s64 QFS::OperationImpl::PWrite(const s32 fd, const void* buf, u64 count, s64 offset) {
if (fd < 0)
return -QUASI_EBADF;
return -POSIX_EBADF;
fd_handle_ptr handle = qfs.GetHandle(fd);
if (nullptr == handle)
return -QUASI_EBADF;
return -POSIX_EBADF;
if (!handle->write)
return -QUASI_EBADF;
return -POSIX_EBADF;
bool host_used = false;
int hio_status = 0;
@ -770,14 +770,14 @@ s64 QFS::OperationImpl::PWrite(const s32 fd, const void* buf, u64 count, s64 off
s64 QFS::OperationImpl::WriteV(const s32 fd, const Libraries::Kernel::OrbisKernelIovec* iov,
u32 iovcnt) {
if (fd < 0)
return -QUASI_EBADF;
return -POSIX_EBADF;
fd_handle_ptr handle = qfs.GetHandle(fd);
if (nullptr == handle)
return -QUASI_EBADF;
return -POSIX_EBADF;
if (!handle->write)
return -QUASI_EBADF;
return -POSIX_EBADF;
bool host_used = false;
int hio_status = 0;
@ -808,14 +808,14 @@ s64 QFS::OperationImpl::WriteV(const s32 fd, const Libraries::Kernel::OrbisKerne
s64 QFS::OperationImpl::PWriteV(const s32 fd, const Libraries::Kernel::OrbisKernelIovec* iov,
u32 iovcnt, s64 offset) {
if (fd < 0)
return -QUASI_EBADF;
return -POSIX_EBADF;
fd_handle_ptr handle = qfs.GetHandle(fd);
if (nullptr == handle)
return -QUASI_EBADF;
return -POSIX_EBADF;
if (!handle->write)
return -QUASI_EBADF;
return -POSIX_EBADF;
bool host_used = false;
int hio_status = 0;
@ -848,18 +848,18 @@ s32 QFS::OperationImpl::MKDir(const fs::path& path, u16 mode) {
int resolve_status = qfs.Resolve(path, res);
if (0 == resolve_status)
return -QUASI_EEXIST;
return -POSIX_EEXIST;
if (-QUASI_ENOENT == resolve_status) {
if (-POSIX_ENOENT == resolve_status) {
if (nullptr == res.parent)
return -QUASI_ENOENT;
return -POSIX_ENOENT;
} else if (0 != resolve_status)
return resolve_status;
partition_ptr part = res.mountpoint;
if (qfs.IsPartitionRO(part))
return -QUASI_EROFS;
return -POSIX_EROFS;
bool host_used = false;
int hio_status = 0;
@ -949,11 +949,11 @@ s32 QFS::OperationImpl::Stat(const fs::path& path, Libraries::Kernel::OrbisKerne
s32 QFS::OperationImpl::FStat(const s32 fd, Libraries::Kernel::OrbisKernelStat* statbuf) {
if (fd < 0)
return -QUASI_EBADF;
return -POSIX_EBADF;
fd_handle_ptr handle = qfs.GetHandle(fd);
if (nullptr == handle)
return -QUASI_EBADF;
return -POSIX_EBADF;
// too short to justify a separate block
std::lock_guard<std::mutex> lock(c_mutex);
@ -984,14 +984,14 @@ s32 QFS::OperationImpl::Chmod(const fs::path& path, u16 mode) {
s32 QFS::OperationImpl::FChmod(const s32 fd, u16 mode) {
if (fd < 0)
return -QUASI_EBADF;
return -POSIX_EBADF;
fd_handle_ptr handle = qfs.GetHandle(fd);
if (nullptr == handle)
return -QUASI_EBADF;
return -POSIX_EBADF;
if (!handle->read)
return -QUASI_EBADF;
return -POSIX_EBADF;
// too short to justify a separate block
std::lock_guard<std::mutex> lock(c_mutex);
@ -1004,14 +1004,14 @@ s32 QFS::OperationImpl::FChmod(const s32 fd, u16 mode) {
s64 QFS::OperationImpl::GetDents(const s32 fd, void* buf, u64 count, s64* basep) {
if (fd < 0)
return -QUASI_EBADF;
return -POSIX_EBADF;
fd_handle_ptr handle = qfs.GetHandle(fd);
if (nullptr == handle)
return -QUASI_EBADF;
return -POSIX_EBADF;
if (!handle->read)
return -QUASI_EBADF;
return -POSIX_EBADF;
// too short to justify a separate block
std::lock_guard<std::mutex> lock(c_mutex);

View File

@ -15,9 +15,9 @@
#include "core/debug_state.h"
#include "core/debugger.h"
#include "core/libraries/audio/audioout.h"
#include "core/libraries/usbd/usbd.h"
#include "input/input_handler.h"
#include "sdl_window.h"
#include "src/core/libraries/usbd/usbd.h"
#include "video_core/renderer_vulkan/vk_presenter.h"
extern std::unique_ptr<Vulkan::Presenter> presenter;