mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2026-04-26 21:05:15 -06:00
unified int to s32
This commit is contained in:
parent
4949f16268
commit
9e12eec072
@ -26,7 +26,7 @@ public:
|
||||
// Conversion helpers
|
||||
//
|
||||
|
||||
static constexpr int ToPOSIXSeekOrigin(QuasiFS::SeekOrigin origin) {
|
||||
static constexpr s32 ToPOSIXSeekOrigin(QuasiFS::SeekOrigin origin) {
|
||||
switch (origin) {
|
||||
case QuasiFS::SeekOrigin::ORIGIN:
|
||||
return SEEK_SET;
|
||||
@ -39,8 +39,8 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
static constexpr int ToPOSIXOpenFlags(int quasi_flags) {
|
||||
int flags = 0;
|
||||
static constexpr s32 ToPOSIXOpenFlags(int quasi_flags) {
|
||||
s32 flags = 0;
|
||||
if (quasi_flags & QUASI_O_RDONLY)
|
||||
flags |= O_RDONLY;
|
||||
if (quasi_flags & QUASI_O_WRONLY)
|
||||
@ -79,36 +79,36 @@ public:
|
||||
// POSIX Functions
|
||||
//
|
||||
|
||||
s32 Open(const fs::path& path, int flags, u16 mode = 0755) override;
|
||||
s32 Open(const fs::path& path, s32 flags, u16 mode = 0755) override;
|
||||
s32 Creat(const fs::path& path, u16 mode = 0755) override;
|
||||
s32 Close(const int fd) override;
|
||||
s32 Close(const s32 fd) override;
|
||||
|
||||
s32 Link(const fs::path& src, const fs::path& dst) override;
|
||||
s32 Unlink(const fs::path& path) override;
|
||||
s32 LinkSymbolic(const fs::path& src, const fs::path& dst) override;
|
||||
|
||||
s32 Flush(const int fd) override;
|
||||
s32 FSync(const int fd) override;
|
||||
s64 LSeek(const int fd, u64 offset, QuasiFS::SeekOrigin origin) override;
|
||||
s64 Tell(const int fd) override;
|
||||
s32 Flush(const s32 fd) override;
|
||||
s32 FSync(const s32 fd) override;
|
||||
s64 LSeek(const s32 fd, u64 offset, QuasiFS::SeekOrigin origin) override;
|
||||
s64 Tell(const s32 fd) override;
|
||||
|
||||
s32 Truncate(const fs::path& path, u64 size) override;
|
||||
s32 FTruncate(const int fd, u64 size) override;
|
||||
s32 FTruncate(const s32 fd, u64 size) override;
|
||||
|
||||
s64 Write(const int fd, const void* buf, u64 count) override;
|
||||
s64 Read(const int fd, void* buf, u64 count) override;
|
||||
s64 Write(const s32 fd, const void* buf, u64 count) override;
|
||||
s64 Read(const s32 fd, void* buf, u64 count) override;
|
||||
|
||||
s64 PWrite(const int fd, const void* buf, u64 count, u64 offset) override;
|
||||
s64 PRead(const int fd, void* buf, u64 count, u64 offset) override;
|
||||
s64 PWrite(const s32 fd, const void* buf, u64 count, u64 offset) override;
|
||||
s64 PRead(const s32 fd, void* buf, u64 count, u64 offset) override;
|
||||
|
||||
s32 MKDir(const fs::path& path, u16 mode = 0755) override;
|
||||
s32 RMDir(const fs::path& path) override;
|
||||
|
||||
s32 Stat(const fs::path& path, Libraries::Kernel::OrbisKernelStat* statbuf) override;
|
||||
s32 FStat(const int fd, Libraries::Kernel::OrbisKernelStat* statbuf) override;
|
||||
s32 FStat(const s32 fd, Libraries::Kernel::OrbisKernelStat* statbuf) override;
|
||||
|
||||
s32 Chmod(const fs::path& path, u16 mode) override;
|
||||
s32 FChmod(const int fd, u16 mode) override;
|
||||
s32 FChmod(const s32 fd, u16 mode) override;
|
||||
};
|
||||
} // namespace HostIODriver
|
||||
|
||||
|
||||
@ -45,36 +45,36 @@ public:
|
||||
* This function doesn't return numeric fd
|
||||
* The only outputs are 0 and -errno!
|
||||
*/
|
||||
s32 Open(const fs::path& path, int flags, u16 mode = 0755) override;
|
||||
s32 Open(const fs::path& path, s32 flags, u16 mode = 0755) override;
|
||||
s32 Creat(const fs::path& path, u16 mode = 0755) override;
|
||||
s32 Close(const int fd) override;
|
||||
s32 Close(const s32 fd) override;
|
||||
|
||||
s32 Link(const fs::path& src, const fs::path& dst) override;
|
||||
s32 Unlink(const fs::path& path) override;
|
||||
s32 LinkSymbolic(const fs::path& src, const fs::path& dst) override;
|
||||
|
||||
s32 Flush(const int fd) override;
|
||||
s32 FSync(const int fd) override;
|
||||
s64 LSeek(const int fd, u64 offset, QuasiFS::SeekOrigin origin) override;
|
||||
s64 Tell(const int fd) override;
|
||||
s32 Flush(const s32 fd) override;
|
||||
s32 FSync(const s32 fd) override;
|
||||
s64 LSeek(const s32 fd, u64 offset, QuasiFS::SeekOrigin origin) override;
|
||||
s64 Tell(const s32 fd) override;
|
||||
|
||||
s32 Truncate(const fs::path& path, u64 size) override;
|
||||
s32 FTruncate(const int fd, u64 size) override;
|
||||
s32 FTruncate(const s32 fd, u64 size) override;
|
||||
|
||||
s64 Write(const int fd, const void* buf, u64 count) override;
|
||||
s64 Read(const int fd, void* buf, u64 count) override;
|
||||
s64 Write(const s32 fd, const void* buf, u64 count) override;
|
||||
s64 Read(const s32 fd, void* buf, u64 count) override;
|
||||
|
||||
s64 PWrite(const int fd, const void* buf, u64 count, u64 offset) override;
|
||||
s64 PRead(const int fd, void* buf, u64 count, u64 offset) override;
|
||||
s64 PWrite(const s32 fd, const void* buf, u64 count, u64 offset) override;
|
||||
s64 PRead(const s32 fd, void* buf, u64 count, u64 offset) override;
|
||||
|
||||
s32 MKDir(const fs::path& path, u16 mode = 0755) override;
|
||||
s32 RMDir(const fs::path& path) override;
|
||||
|
||||
s32 Stat(const fs::path& path, Libraries::Kernel::OrbisKernelStat* statbuf) override;
|
||||
s32 FStat(const int fd, Libraries::Kernel::OrbisKernelStat* statbuf) override;
|
||||
s32 FStat(const s32 fd, Libraries::Kernel::OrbisKernelStat* statbuf) override;
|
||||
|
||||
s32 Chmod(const fs::path& path, u16 mode) override;
|
||||
s32 FChmod(const int fd, u16 mode) override;
|
||||
s32 FChmod(const s32 fd, u16 mode) override;
|
||||
|
||||
//
|
||||
// Derived, complex functions are to be handled by main FS class
|
||||
|
||||
@ -8,52 +8,103 @@
|
||||
|
||||
#include <cstdint>
|
||||
#include <unordered_map>
|
||||
#include <fcntl.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include "core/file_sys/quasifs/quasi_sys_fcntl.h"
|
||||
#include "src/host_io_base.h"
|
||||
|
||||
namespace HostIODriver {
|
||||
|
||||
class HostIO_Win32 final : public HostIO_Base {
|
||||
private:
|
||||
// well, *dows keeps raw handles in a different way than we want them to be
|
||||
// filesystem-wise, this is an oddball so we'll just hack it around POSIX 'till it works
|
||||
std::unordered_map<int, HANDLE> fd_mapping{};
|
||||
|
||||
public:
|
||||
//
|
||||
// Conversion helpers
|
||||
//
|
||||
|
||||
static constexpr s32 ToWIN32SeekOrigin(QuasiFS::SeekOrigin origin) {
|
||||
switch (origin) {
|
||||
case QuasiFS::SeekOrigin::ORIGIN:
|
||||
return SEEK_SET;
|
||||
case QuasiFS::SeekOrigin::CURRENT:
|
||||
return SEEK_CUR;
|
||||
case QuasiFS::SeekOrigin::END:
|
||||
return SEEK_END;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static constexpr s32 ToWIN32OpenFlags(int quasi_flags) {
|
||||
s32 flags = 0;
|
||||
if (quasi_flags & QUASI_O_RDONLY)
|
||||
flags |= _O_RDONLY;
|
||||
if (quasi_flags & QUASI_O_WRONLY)
|
||||
flags |= _O_WRONLY;
|
||||
if (quasi_flags & QUASI_O_RDWR)
|
||||
flags |= _O_RDWR;
|
||||
if (quasi_flags & QUASI_O_CREAT)
|
||||
flags |= _O_CREAT;
|
||||
if (quasi_flags & QUASI_O_EXCL)
|
||||
flags |= _O_EXCL;
|
||||
if (quasi_flags & QUASI_O_TRUNC)
|
||||
flags |= _O_TRUNC;
|
||||
if (quasi_flags & QUASI_O_APPEND)
|
||||
flags |= _O_APPEND;
|
||||
|
||||
// No info, maybe there are some equivalents
|
||||
// if (quasi_flags & QUASI_O_NONBLOCK)
|
||||
// flags |= _O_NONBLOCK;
|
||||
// if (quasi_flags & QUASI_O_SYNC)
|
||||
// flags |= _O_SYNC;
|
||||
// if (quasi_flags & QUASI_O_FSYNC)
|
||||
// flags |= _O_FSYNC;
|
||||
|
||||
if (quasi_flags & QUASI_O_DIRECTORY)
|
||||
flags |= _O_OBTAIN_DIR; // I don't like how this one looks
|
||||
|
||||
// if (quasi_flags & QUASI_O_DIRECT)
|
||||
// flags |= _O_DIRECT;
|
||||
// if (quasi_flags & QUASI_O_DSYNC)
|
||||
// flags |= _O_DSYNC;
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
HostIO_Win32();
|
||||
~HostIO_Win32();
|
||||
|
||||
s32 Open(const fs::path& path, int flags, u16 mode = 0755) override;
|
||||
s32 Open(const fs::path& path, s32 flags, u16 mode = 0755) override;
|
||||
s32 Creat(const fs::path& path, u16 mode = 0755) override;
|
||||
s32 Close(const int fd) override;
|
||||
s32 Close(const s32 fd) override;
|
||||
|
||||
s32 Link(const fs::path& src, const fs::path& dst) override;
|
||||
s32 Unlink(const fs::path& path) override;
|
||||
s32 LinkSymbolic(const fs::path& src, const fs::path& dst) override;
|
||||
// s32 Link(const fs::path& src, const fs::path& dst) override;
|
||||
// s32 Unlink(const fs::path& path) override;
|
||||
// s32 LinkSymbolic(const fs::path& src, const fs::path& dst) override;
|
||||
|
||||
s32 Flush(const int fd) override;
|
||||
s32 FSync(const int fd) override;
|
||||
// s64 LSeek(const int fd, u64 offset, QuasiFS::SeekOrigin origin) override;
|
||||
// s64 Tell(const int fd) override;
|
||||
s32 Flush(const s32 fd) override;
|
||||
s32 FSync(const s32 fd) override;
|
||||
s64 LSeek(const s32 fd, u64 offset, QuasiFS::SeekOrigin origin) override;
|
||||
s64 Tell(const s32 fd) override;
|
||||
|
||||
s32 Truncate(const fs::path& path, u64 size) override;
|
||||
s32 FTruncate(const int fd, u64 size) override;
|
||||
s32 FTruncate(const s32 fd, u64 size) override;
|
||||
|
||||
// s64 Write(const int fd, const void* buf, u64 count) override;
|
||||
// s64 Read(const int fd, void* buf, u64 count) override;
|
||||
// s64 Write(const s32 fd, const void* buf, u64 count) override;
|
||||
// s64 Read(const s32 fd, void* buf, u64 count) override;
|
||||
|
||||
// s64 PWrite(const int fd, const void* buf, u64 count, u64 offset) override;
|
||||
// s64 PRead(const int fd, void* buf, u64 count, u64 offset) override;
|
||||
// s64 PWrite(const s32 fd, const void* buf, u64 count, u64 offset) override;
|
||||
// s64 PRead(const s32 fd, void* buf, u64 count, u64 offset) override;
|
||||
|
||||
s32 MKDir(const fs::path& path, u16 mode = 0755) override;
|
||||
s32 RMDir(const fs::path& path) override;
|
||||
// s32 MKDir(const fs::path& path, u16 mode = 0755) override;
|
||||
// s32 RMDir(const fs::path& path) override;
|
||||
|
||||
s32 Stat(const fs::path& path, Libraries::Kernel::OrbisKernelStat* statbuf) override;
|
||||
s32 FStat(const int fd, Libraries::Kernel::OrbisKernelStat* statbuf) override;
|
||||
// s32 Stat(const fs::path& path, Libraries::Kernel::OrbisKernelStat* statbuf) override;
|
||||
// s32 FStat(const s32 fd, Libraries::Kernel::OrbisKernelStat* statbuf) override;
|
||||
|
||||
s32 Chmod(const fs::path& path, u16 mode) override;
|
||||
s32 FChmod(const int fd, u16 mode) override;
|
||||
// s32 Chmod(const fs::path& path, u16 mode) override;
|
||||
// s32 FChmod(const s32 fd, u16 mode) override;
|
||||
};
|
||||
|
||||
} // namespace HostIODriver
|
||||
|
||||
@ -20,108 +20,108 @@
|
||||
|
||||
namespace HostIODriver {
|
||||
|
||||
s32 HostIO_POSIX::Open(const fs::path& path, int flags, u16 mode) {
|
||||
s32 HostIO_POSIX::Open(const fs::path& path, s32 flags, u16 mode) {
|
||||
errno = 0;
|
||||
int status = open(path.c_str(), ToPOSIXOpenFlags(flags), ToPOSIXOpenMode(mode));
|
||||
s32 status = open(path.c_str(), ToPOSIXOpenFlags(flags), mode);
|
||||
return status >= 0 ? status : -errno;
|
||||
}
|
||||
|
||||
s32 HostIO_POSIX::Creat(const fs::path& path, u16 mode) {
|
||||
errno = 0;
|
||||
int status = creat(path.c_str(), ToPOSIXOpenMode(mode));
|
||||
s32 status = creat(path.c_str(), mode);
|
||||
return status >= 0 ? status : -errno;
|
||||
}
|
||||
|
||||
s32 HostIO_POSIX::Close(const int fd) {
|
||||
s32 HostIO_POSIX::Close(const s32 fd) {
|
||||
errno = 0;
|
||||
int status = close(fd);
|
||||
s32 status = close(fd);
|
||||
return 0 == status ? status : -errno;
|
||||
}
|
||||
|
||||
s32 HostIO_POSIX::Link(const fs::path& src, const fs::path& dst) {
|
||||
errno = 0;
|
||||
int status = link(src.c_str(), dst.c_str());
|
||||
s32 status = link(src.c_str(), dst.c_str());
|
||||
return 0 == status ? status : -errno;
|
||||
}
|
||||
|
||||
s32 HostIO_POSIX::Unlink(const fs::path& path) {
|
||||
errno = 0;
|
||||
int status = unlink(path.c_str());
|
||||
s32 status = unlink(path.c_str());
|
||||
return 0 == status ? status : -errno;
|
||||
}
|
||||
|
||||
s32 HostIO_POSIX::LinkSymbolic(const fs::path& src, const fs::path& dst) {
|
||||
errno = 0;
|
||||
int status = symlink(src.c_str(), dst.c_str());
|
||||
s32 status = symlink(src.c_str(), dst.c_str());
|
||||
return 0 == status ? status : -errno;
|
||||
}
|
||||
|
||||
s32 HostIO_POSIX::Flush(const int fd) {
|
||||
s32 HostIO_POSIX::Flush(const s32 fd) {
|
||||
errno = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 HostIO_POSIX::FSync(const int fd) {
|
||||
s32 HostIO_POSIX::FSync(const s32 fd) {
|
||||
errno = 0;
|
||||
int status = fsync(fd);
|
||||
s32 status = fsync(fd);
|
||||
return 0 == status ? status : -errno;
|
||||
}
|
||||
|
||||
s64 HostIO_POSIX::LSeek(const int fd, u64 offset, QuasiFS::SeekOrigin origin) {
|
||||
s64 HostIO_POSIX::LSeek(const s32 fd, u64 offset, QuasiFS::SeekOrigin origin) {
|
||||
errno = 0;
|
||||
int status = lseek(fd, offset, ToPOSIXSeekOrigin(origin));
|
||||
s32 status = lseek(fd, offset, ToPOSIXSeekOrigin(origin));
|
||||
return status >= 0 ? status : -errno;
|
||||
}
|
||||
|
||||
s64 HostIO_POSIX::Tell(const int fd) {
|
||||
s64 HostIO_POSIX::Tell(const s32 fd) {
|
||||
return LSeek(fd, 0, SeekOrigin::CURRENT);
|
||||
}
|
||||
|
||||
s32 HostIO_POSIX::Truncate(const fs::path& path, u64 size) {
|
||||
errno = 0;
|
||||
int status = truncate(path.c_str(), size);
|
||||
s32 status = truncate(path.c_str(), size);
|
||||
return status >= 0 ? status : -errno;
|
||||
}
|
||||
|
||||
s32 HostIO_POSIX::FTruncate(const int fd, u64 size) {
|
||||
s32 HostIO_POSIX::FTruncate(const s32 fd, u64 size) {
|
||||
errno = 0;
|
||||
int status = ftruncate(fd, size);
|
||||
s32 status = ftruncate(fd, size);
|
||||
return status >= 0 ? status : -errno;
|
||||
}
|
||||
|
||||
s64 HostIO_POSIX::Write(const int fd, const void* buf, u64 count) {
|
||||
s64 HostIO_POSIX::Write(const s32 fd, const void* buf, u64 count) {
|
||||
errno = 0;
|
||||
int status = write(fd, buf, count);
|
||||
s32 status = write(fd, buf, count);
|
||||
return status >= 0 ? status : -errno;
|
||||
}
|
||||
|
||||
s64 HostIO_POSIX::Read(const int fd, void* buf, u64 count) {
|
||||
s64 HostIO_POSIX::Read(const s32 fd, void* buf, u64 count) {
|
||||
errno = 0;
|
||||
int status = read(fd, buf, count);
|
||||
s32 status = read(fd, buf, count);
|
||||
return status >= 0 ? status : -errno;
|
||||
}
|
||||
|
||||
s64 HostIO_POSIX::PWrite(const int fd, const void* buf, u64 count, u64 offset) {
|
||||
s64 HostIO_POSIX::PWrite(const s32 fd, const void* buf, u64 count, u64 offset) {
|
||||
errno = 0;
|
||||
int status = pwrite(fd, buf, count, offset);
|
||||
s32 status = pwrite(fd, buf, count, offset);
|
||||
return status >= 0 ? status : -errno;
|
||||
}
|
||||
|
||||
s64 HostIO_POSIX::PRead(const int fd, void* buf, u64 count, u64 offset) {
|
||||
s64 HostIO_POSIX::PRead(const s32 fd, void* buf, u64 count, u64 offset) {
|
||||
errno = 0;
|
||||
int status = pread(fd, buf, count, offset);
|
||||
s32 status = pread(fd, buf, count, offset);
|
||||
return status >= 0 ? status : -errno;
|
||||
}
|
||||
|
||||
s32 HostIO_POSIX::MKDir(const fs::path& path, u16 mode) {
|
||||
errno = 0;
|
||||
int status = mkdir(path.c_str(), mode);
|
||||
s32 status = mkdir(path.c_str(), mode);
|
||||
return 0 == status ? status : -errno;
|
||||
}
|
||||
|
||||
s32 HostIO_POSIX::RMDir(const fs::path& path) {
|
||||
errno = 0;
|
||||
int status = rmdir(path.c_str());
|
||||
s32 status = rmdir(path.c_str());
|
||||
return 0 == status ? status : -errno;
|
||||
}
|
||||
|
||||
@ -159,7 +159,7 @@ s32 HostIO_POSIX::Stat(const fs::path& path, Libraries::Kernel::OrbisKernelStat*
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 HostIO_POSIX::FStat(const int fd, Libraries::Kernel::OrbisKernelStat* statbuf) {
|
||||
s32 HostIO_POSIX::FStat(const s32 fd, Libraries::Kernel::OrbisKernelStat* statbuf) {
|
||||
errno = 0;
|
||||
|
||||
struct stat st;
|
||||
@ -189,13 +189,13 @@ s32 HostIO_POSIX::FStat(const int fd, Libraries::Kernel::OrbisKernelStat* statbu
|
||||
|
||||
s32 HostIO_POSIX::Chmod(const fs::path& path, u16 mode) {
|
||||
errno = 0;
|
||||
int status = chmod(path.c_str(), mode);
|
||||
s32 status = chmod(path.c_str(), mode);
|
||||
return 0 == status ? status : -errno;
|
||||
}
|
||||
|
||||
s32 HostIO_POSIX::FChmod(const int fd, u16 mode) {
|
||||
s32 HostIO_POSIX::FChmod(const s32 fd, u16 mode) {
|
||||
errno = 0;
|
||||
int status = fchmod(fd, mode);
|
||||
s32 status = fchmod(fd, mode);
|
||||
return 0 == status ? status : -errno;
|
||||
}
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ namespace HostIODriver {
|
||||
HostIO_Virtual::HostIO_Virtual() = default;
|
||||
HostIO_Virtual::~HostIO_Virtual() = default;
|
||||
|
||||
s32 HostIO_Virtual::Open(const fs::path& path, int flags, u16 mode) {
|
||||
s32 HostIO_Virtual::Open(const fs::path& path, s32 flags, u16 mode) {
|
||||
if (nullptr == this->res)
|
||||
return -QUASI_EINVAL;
|
||||
|
||||
@ -73,18 +73,10 @@ s32 HostIO_Virtual::Open(const fs::path& path, int flags, u16 mode) {
|
||||
}
|
||||
|
||||
s32 HostIO_Virtual::Creat(const fs::path& path, u16 mode) {
|
||||
if (nullptr == this->res)
|
||||
return -QUASI_EINVAL;
|
||||
if (!this->res->node->is_dir())
|
||||
return -QUASI_ENOTDIR;
|
||||
|
||||
dir_ptr parent = std::static_pointer_cast<Directory>(this->res->node);
|
||||
file_ptr new_file =
|
||||
this->host_bound ? QuasiFile::Create<RegularFile>() : QuasiFile::Create<VirtualFile>();
|
||||
return this->res->mountpoint->touch(parent, path.filename().string(), new_file);
|
||||
return Open(path, QUASI_O_CREAT | QUASI_O_TRUNC | QUASI_O_WRONLY);
|
||||
}
|
||||
|
||||
s32 HostIO_Virtual::Close(const int fd) {
|
||||
s32 HostIO_Virtual::Close(const s32 fd) {
|
||||
// N/A
|
||||
return 0;
|
||||
}
|
||||
@ -135,12 +127,12 @@ s32 HostIO_Virtual::LinkSymbolic(const fs::path& src, const fs::path& dst) {
|
||||
return this->res->mountpoint->touch(this->res->parent, dst.filename().string(), sym);
|
||||
}
|
||||
|
||||
s32 HostIO_Virtual::Flush(const int fd) {
|
||||
s32 HostIO_Virtual::Flush(const s32 fd) {
|
||||
// not applicable
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 HostIO_Virtual::FSync(const int fd) {
|
||||
s32 HostIO_Virtual::FSync(const s32 fd) {
|
||||
if (nullptr == handle)
|
||||
return -QUASI_EINVAL;
|
||||
|
||||
@ -152,7 +144,7 @@ s32 HostIO_Virtual::FSync(const int fd) {
|
||||
return handle->node->fsync();
|
||||
}
|
||||
|
||||
s64 HostIO_Virtual::LSeek(const int fd, u64 offset, QuasiFS::SeekOrigin origin) {
|
||||
s64 HostIO_Virtual::LSeek(const s32 fd, u64 offset, QuasiFS::SeekOrigin origin) {
|
||||
if (nullptr == handle)
|
||||
return -QUASI_EINVAL;
|
||||
|
||||
@ -174,7 +166,7 @@ s64 HostIO_Virtual::LSeek(const int fd, u64 offset, QuasiFS::SeekOrigin origin)
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
s64 HostIO_Virtual::Tell(const int fd) {
|
||||
s64 HostIO_Virtual::Tell(const s32 fd) {
|
||||
return LSeek(fd, 0, SeekOrigin::CURRENT);
|
||||
}
|
||||
|
||||
@ -196,7 +188,7 @@ s32 HostIO_Virtual::Truncate(const fs::path& path, u64 size) {
|
||||
return node->ftruncate(size);
|
||||
}
|
||||
|
||||
s32 HostIO_Virtual::FTruncate(const int fd, u64 size) {
|
||||
s32 HostIO_Virtual::FTruncate(const s32 fd, u64 size) {
|
||||
if (nullptr == handle)
|
||||
return -QUASI_EINVAL;
|
||||
|
||||
@ -214,7 +206,7 @@ s32 HostIO_Virtual::FTruncate(const int fd, u64 size) {
|
||||
return handle->node->ftruncate(size);
|
||||
}
|
||||
|
||||
s64 HostIO_Virtual::Write(const int fd, const void* buf, u64 count) {
|
||||
s64 HostIO_Virtual::Write(const s32 fd, const void* buf, u64 count) {
|
||||
s64 bw = this->PWrite(fd, buf, count, handle->pos);
|
||||
|
||||
if (bw > 0)
|
||||
@ -223,7 +215,7 @@ s64 HostIO_Virtual::Write(const int fd, const void* buf, u64 count) {
|
||||
return bw;
|
||||
}
|
||||
|
||||
s64 HostIO_Virtual::Read(const int fd, void* buf, u64 count) {
|
||||
s64 HostIO_Virtual::Read(const s32 fd, void* buf, u64 count) {
|
||||
s64 br = PRead(fd, buf, count, handle->pos);
|
||||
|
||||
if (br > 0)
|
||||
@ -232,7 +224,7 @@ s64 HostIO_Virtual::Read(const int fd, void* buf, u64 count) {
|
||||
return br;
|
||||
}
|
||||
|
||||
s64 HostIO_Virtual::PWrite(const int fd, const void* buf, u64 count, u64 offset) {
|
||||
s64 HostIO_Virtual::PWrite(const s32 fd, const void* buf, u64 count, u64 offset) {
|
||||
if (nullptr == handle)
|
||||
return -QUASI_EBADF;
|
||||
|
||||
@ -247,7 +239,7 @@ s64 HostIO_Virtual::PWrite(const int fd, const void* buf, u64 count, u64 offset)
|
||||
return node->pwrite(buf, count, offset);
|
||||
}
|
||||
|
||||
s64 HostIO_Virtual::PRead(const int fd, void* buf, u64 count, u64 offset) {
|
||||
s64 HostIO_Virtual::PRead(const s32 fd, void* buf, u64 count, u64 offset) {
|
||||
if (nullptr == handle)
|
||||
return -QUASI_EINVAL;
|
||||
|
||||
@ -305,7 +297,7 @@ s32 HostIO_Virtual::Stat(const fs::path& path, Libraries::Kernel::OrbisKernelSta
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 HostIO_Virtual::FStat(const int fd, Libraries::Kernel::OrbisKernelStat* statbuf) {
|
||||
s32 HostIO_Virtual::FStat(const s32 fd, Libraries::Kernel::OrbisKernelStat* statbuf) {
|
||||
if (nullptr == this->handle)
|
||||
return -QUASI_EINVAL;
|
||||
|
||||
@ -331,7 +323,7 @@ s32 HostIO_Virtual::Chmod(const fs::path& path, u16 mode) {
|
||||
return Partition::chmod(node, mode);
|
||||
}
|
||||
|
||||
s32 HostIO_Virtual::FChmod(const int fd, u16 mode) {
|
||||
s32 HostIO_Virtual::FChmod(const s32 fd, u16 mode) {
|
||||
if (nullptr == this->handle)
|
||||
return -QUASI_EINVAL;
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
// INAA License @marecl 2025
|
||||
|
||||
#include <errno.h>
|
||||
#include <io.h>
|
||||
|
||||
#include "common/logging/log.h"
|
||||
#include "src/core/file_sys/hostio/host_io_win32.h"
|
||||
|
||||
@ -8,17 +11,77 @@ namespace HostIODriver {
|
||||
HostIO_Win32::HostIO_Win32() = default;
|
||||
HostIO_Win32::~HostIO_Win32() = default;
|
||||
|
||||
s32 HostIO_Win32::Open(const fs::path& path, s32 flags, u16 mode) {
|
||||
errno = 0;
|
||||
s32 status = _wopen(path.c_str(), ToWIN32OpenFlags(flags), mode);
|
||||
return status >= 0 ? status : -errno;
|
||||
}
|
||||
|
||||
s32 HostIO_Win32::Creat(const fs::path& path, u16 mode) {
|
||||
LOG_ERROR(Kernel_Fs, "Stub called in HostIO_Base: {}:{}", __FILE__, __LINE__);
|
||||
return -38;
|
||||
errno = 0;
|
||||
s32 status = _wcreat(path.c_str(), mode);
|
||||
return status >= 0 ? status : -errno;
|
||||
}
|
||||
s32 HostIO_Win32::Open(const fs::path& path, int flags, u16 mode) {
|
||||
LOG_ERROR(Kernel_Fs, "Stub called in HostIO_Base: {}:{}", __FILE__, __LINE__);
|
||||
return -38;
|
||||
|
||||
s32 HostIO_Win32::Close(const s32 fd) {
|
||||
errno = 0;
|
||||
s32 status = _close(fd);
|
||||
return 0 == status ? 0 : -errno;
|
||||
}
|
||||
s32 HostIO_Win32::Close(const int fd) {
|
||||
LOG_ERROR(Kernel_Fs, "Stub called in HostIO_Base: {}:{}", __FILE__, __LINE__);
|
||||
return -38;
|
||||
|
||||
// s32 HostIO_Win32::Link(const fs::path& src, const fs::path& dst) {
|
||||
// // errno = 0;
|
||||
// // s32 status = link(src.c_str(), dst.c_str());
|
||||
// // return 0 == status ? 0 : -errno;
|
||||
// }
|
||||
|
||||
// s32 HostIO_Win32::Unlink(const fs::path& path) {
|
||||
// // errno = 0;
|
||||
// // s32 status = unlink(path.c_str());
|
||||
// // return 0 == status ? 0 : -errno;
|
||||
// }
|
||||
|
||||
// s32 HostIO_Win32::LinkSymbolic(const fs::path& src, const fs:
|
||||
// // errno = 0;
|
||||
// // s32 status = symlink(src.c_str(), dst.c_str());
|
||||
// // return 0 == status ? 0 : -errno;
|
||||
// }
|
||||
|
||||
s32 HostIO_Win32::Flush(const s32 fd) {
|
||||
errno = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 HostIO_Win32::FSync(const s32 fd) {
|
||||
errno = 0;
|
||||
s32 status = _commit(fd);
|
||||
return 0 == status ? 0 : -errno;
|
||||
}
|
||||
|
||||
s64 HostIO_Win32::LSeek(const s32 fd, u64 offset, QuasiFS::SeekOrigin origin) {
|
||||
errno = 0;
|
||||
s32 status = _lseeki64(fd, offset, ToWIN32SeekOrigin(origin));
|
||||
return status >= 0 ? status : -errno;
|
||||
}
|
||||
|
||||
s64 HostIO_Win32::Tell(const s32 fd) {
|
||||
return LSeek(fd, 0, SeekOrigin::CURRENT);
|
||||
}
|
||||
|
||||
int HostIO_Win32::Truncate(const fs::path& path, u64 size) {
|
||||
errno = 0;
|
||||
s32 fd = _wopen(path.c_str(), _O_RDONLY);
|
||||
if (fd < 0)
|
||||
return -errno;
|
||||
s32 status = _chsize_s(fd, size);
|
||||
_close(fd);
|
||||
return status >= 0 ? status : -errno;
|
||||
}
|
||||
|
||||
int HostIO_Win32::FTruncate(const s32 fd, u64 size) {
|
||||
errno = 0;
|
||||
s32 status = _chsize_s(fd, size);
|
||||
return status >= 0 ? status : -errno;
|
||||
}
|
||||
|
||||
} // namespace HostIODriver
|
||||
@ -551,7 +551,6 @@ static s64 GetDents(s32 fd, char* buf, u64 nbytes, s64* basep) {
|
||||
}
|
||||
|
||||
s32 result = f->node->getdents(buf, nbytes, basep);
|
||||
LOG_TRACE(Lib_Kernel, "ioctl: fd = {:X} cmd = {:X} result = {}", fd, cmd, result);
|
||||
if (result < 0) {
|
||||
ErrSceToPosix(result);
|
||||
return -1;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user