mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2026-04-26 04:35:24 -06:00
Compiles on *dows
This commit is contained in:
parent
60a32ab723
commit
2b03e9d925
@ -696,10 +696,14 @@ set(QUASIFS src/core/file_sys/quasifs/src/quasifs.cpp
|
||||
|
||||
set(HOSTIO src/core/file_sys/hostio/src/host_io_base.cpp
|
||||
src/core/file_sys/hostio/src/host_io_virtual.cpp
|
||||
src/core/file_sys/hostio/src/host_io_posix.cpp
|
||||
src/core/file_sys/hostio/src/host_io_win32.cpp
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND HOSTIO src/core/file_sys/hostio/src/host_io_win32.cpp)
|
||||
elseif(UNIX AND (NOT APPLE))
|
||||
list(APPEND HOSTIO src/core/file_sys/hostio/src/host_io_posix.cpp)
|
||||
endif()
|
||||
|
||||
set(COMMON src/common/logging/backend.cpp
|
||||
src/common/logging/backend.h
|
||||
src/common/logging/filter.cpp
|
||||
|
||||
@ -1,12 +0,0 @@
|
||||
# Host IO
|
||||
add_library(host_io_lib
|
||||
src/host_io_base.cpp
|
||||
src/host_io_virtual.cpp
|
||||
src/host_io_posix.cpp
|
||||
src/host_io_win32.cpp
|
||||
)
|
||||
|
||||
target_include_directories(host_io_lib
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
)
|
||||
@ -17,7 +17,7 @@ using HostVIO = HostIODriver::HostIO_Virtual;
|
||||
#ifdef __linux__
|
||||
using HostIO = HostIODriver::HostIO_POSIX;
|
||||
#elif _WIN32
|
||||
#error Contributors needed
|
||||
//#error Contributors needed
|
||||
using HostIO = HostIODriver::HostIO_Win32;
|
||||
#else
|
||||
#warning This architecture isn't supported by HostIO
|
||||
|
||||
@ -4,9 +4,9 @@
|
||||
|
||||
#ifdef __linux__
|
||||
|
||||
#include "core/file_sys/quasifs/quasi_types.h"
|
||||
|
||||
#include <sys/fcntl.h>
|
||||
|
||||
#include "core/file_sys/quasifs/quasi_types.h"
|
||||
#include "core/file_sys/quasifs/quasi_sys_fcntl.h"
|
||||
#include "core/libraries/kernel/file_system.h"
|
||||
#include "src/host_io_base.h"
|
||||
@ -19,7 +19,7 @@ namespace HostIODriver {
|
||||
* However there is no indication that the function executed (because it doesn't have to)
|
||||
*/
|
||||
|
||||
class HostIO_POSIX : public HostIO_Base {
|
||||
class HostIO_POSIX final : public HostIO_Base {
|
||||
|
||||
public:
|
||||
//
|
||||
@ -83,19 +83,24 @@ public:
|
||||
int Creat(const fs::path& path, u16 mode = 0755) override;
|
||||
int Close(const int fd) override;
|
||||
|
||||
int LinkSymbolic(const fs::path& src, const fs::path& dst) override;
|
||||
int Link(const fs::path& src, const fs::path& dst) override;
|
||||
int Unlink(const fs::path& path) override;
|
||||
int LinkSymbolic(const fs::path& src, const fs::path& dst) override;
|
||||
|
||||
int Flush(const int fd) override;
|
||||
int FSync(const int fd) override;
|
||||
int Truncate(const fs::path& path, u64 size) override;
|
||||
int FTruncate(const int fd, u64 size) override;
|
||||
u64 LSeek(const int fd, u64 offset, QuasiFS::SeekOrigin origin) override;
|
||||
s64 Tell(const int fd) override;
|
||||
|
||||
int Truncate(const fs::path& path, u64 size) override;
|
||||
int FTruncate(const int fd, u64 size) override;
|
||||
|
||||
s64 Write(const int fd, const void* buf, u64 count) override;
|
||||
s64 PWrite(const int fd, const void* buf, u64 count, u64 offset) override;
|
||||
s64 Read(const int 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;
|
||||
|
||||
int MKDir(const fs::path& path, u16 mode = 0755) override;
|
||||
int RMDir(const fs::path& path) override;
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
#include "src/host_io_base.h"
|
||||
|
||||
namespace HostIODriver {
|
||||
class HostIO_Virtual : public HostIO_Base {
|
||||
class HostIO_Virtual final : public HostIO_Base {
|
||||
protected:
|
||||
Resolved* res{nullptr};
|
||||
fd_handle_ptr handle{nullptr};
|
||||
@ -51,19 +51,24 @@ public:
|
||||
int Creat(const fs::path& path, u16 mode = 0755) override;
|
||||
int Close(const int fd) override;
|
||||
|
||||
int LinkSymbolic(const fs::path& src, const fs::path& dst) override;
|
||||
int Link(const fs::path& src, const fs::path& dst) override;
|
||||
int Unlink(const fs::path& path) override;
|
||||
int LinkSymbolic(const fs::path& src, const fs::path& dst) override;
|
||||
|
||||
int Flush(const int fd) override;
|
||||
int FSync(const int fd) override;
|
||||
int Truncate(const fs::path& path, u64 size) override;
|
||||
int FTruncate(const int fd, u64 size) override;
|
||||
u64 LSeek(const int fd, u64 offset, QuasiFS::SeekOrigin origin) override;
|
||||
s64 Tell(const int fd) override;
|
||||
|
||||
int Truncate(const fs::path& path, u64 size) override;
|
||||
int FTruncate(const int fd, u64 size) override;
|
||||
|
||||
s64 Write(const int fd, const void* buf, u64 count) override;
|
||||
s64 PWrite(const int fd, const void* buf, u64 count, u64 offset) override;
|
||||
s64 Read(const int 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;
|
||||
|
||||
int MKDir(const fs::path& path, u16 mode = 0755) override;
|
||||
int RMDir(const fs::path& path) override;
|
||||
|
||||
|
||||
@ -7,10 +7,48 @@
|
||||
// #error unimplemented
|
||||
|
||||
#include <cstdint>
|
||||
#include "host_io_base.h"
|
||||
|
||||
#include "src/host_io_base.h"
|
||||
|
||||
namespace HostIODriver {
|
||||
class HostIO_Win32 {};
|
||||
} // namespace HostIODriver
|
||||
|
||||
class HostIO_Win32 final : public HostIO_Base {
|
||||
|
||||
public:
|
||||
HostIO_Win32();
|
||||
~HostIO_Win32();
|
||||
|
||||
int Open(const fs::path& path, int flags, u16 mode = 0755) override;
|
||||
int Creat(const fs::path& path, u16 mode = 0755) override;
|
||||
int Close(const int fd) override;
|
||||
|
||||
// int Link(const fs::path& src, const fs::path& dst) override;
|
||||
// int Unlink(const fs::path& path) override;
|
||||
// int LinkSymbolic(const fs::path& src, const fs::path& dst) override;
|
||||
|
||||
// int Flush(const int fd) override;
|
||||
// int FSync(const int fd) override;
|
||||
// u64 LSeek(const int fd, u64 offset, QuasiFS::SeekOrigin origin) override;
|
||||
// s64 Tell(const int fd) override;
|
||||
|
||||
// int Truncate(const fs::path& path, u64 size) override;
|
||||
// int FTruncate(const int 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 PWrite(const int fd, const void* buf, u64 count, u64 offset) override;
|
||||
// s64 PRead(const int fd, void* buf, u64 count, u64 offset) override;
|
||||
|
||||
// int MKDir(const fs::path& path, u16 mode = 0755) override;
|
||||
// int RMDir(const fs::path& path) override;
|
||||
|
||||
// int Stat(const fs::path& path, Libraries::Kernel::OrbisKernelStat* statbuf) override;
|
||||
// int FStat(const int fd, Libraries::Kernel::OrbisKernelStat* statbuf) override;
|
||||
|
||||
// int Chmod(const fs::path& path, u16 mode) override;
|
||||
// int FChmod(const int fd, u16 mode) override;
|
||||
};
|
||||
|
||||
} // namespace HostIODriver
|
||||
#endif
|
||||
@ -19,23 +19,31 @@ HostIO_Base::~HostIO_Base() = default;
|
||||
int HostIO_Base::Open(const fs::path& path, int flags, u16 mode) { STUB(); }
|
||||
int HostIO_Base::Creat(const fs::path& path, u16 mode) { STUB() }
|
||||
int HostIO_Base::Close(const int fd) { STUB() }
|
||||
int HostIO_Base::LinkSymbolic(const fs::path& src, const fs::path& dst) { STUB() }
|
||||
|
||||
int HostIO_Base::Link(const fs::path& src, const fs::path& dst) { STUB() }
|
||||
int HostIO_Base::Unlink(const fs::path& path) { STUB() }
|
||||
int HostIO_Base::LinkSymbolic(const fs::path& src, const fs::path& dst) { STUB() }
|
||||
|
||||
int HostIO_Base::Flush(const int fd) { STUB() }
|
||||
int HostIO_Base::FSync(const int fd) { STUB() }
|
||||
int HostIO_Base::Truncate(const fs::path& path, u64 size) { STUB() }
|
||||
int HostIO_Base::FTruncate(const int fd, u64 size) { STUB() }
|
||||
u64 HostIO_Base::LSeek(const int fd, u64 offset, QuasiFS::SeekOrigin origin) { STUB() }
|
||||
s64 HostIO_Base::Tell(const int fd) { STUB() }
|
||||
|
||||
int HostIO_Base::Truncate(const fs::path& path, u64 size) { STUB() }
|
||||
int HostIO_Base::FTruncate(const int fd, u64 size) { STUB() }
|
||||
|
||||
s64 HostIO_Base::Write(const int fd, const void* buf, u64 count) { STUB() }
|
||||
s64 HostIO_Base::PWrite(const int fd, const void* buf, u64 count, u64 offset) { STUB() }
|
||||
s64 HostIO_Base::Read(const int fd, void* buf, u64 count) { STUB() }
|
||||
|
||||
s64 HostIO_Base::PWrite(const int fd, const void* buf, u64 count, u64 offset) { STUB() }
|
||||
s64 HostIO_Base::PRead(const int fd, void* buf, u64 count, u64 offset) { STUB() }
|
||||
|
||||
int HostIO_Base::MKDir(const fs::path& path, u16 mode) { STUB() }
|
||||
int HostIO_Base::RMDir(const fs::path& path) { STUB() }
|
||||
|
||||
int HostIO_Base::Stat(const fs::path& path, Libraries::Kernel::OrbisKernelStat* statbuf) { STUB() }
|
||||
int HostIO_Base::FStat(const int fd, Libraries::Kernel::OrbisKernelStat* statbuf) { STUB() }
|
||||
|
||||
int HostIO_Base::Chmod(const fs::path& path, u16 mode) { STUB() }
|
||||
int HostIO_Base::FChmod(const int fd, u16 mode) { STUB() }
|
||||
// clang-format on
|
||||
|
||||
@ -5,7 +5,6 @@
|
||||
#include <filesystem>
|
||||
#include <system_error>
|
||||
|
||||
#include <dirent.h>
|
||||
#include "core/libraries/kernel/file_system.h"
|
||||
|
||||
#include "../../quasifs/quasi_types.h"
|
||||
|
||||
@ -39,12 +39,6 @@ int HostIO_POSIX::Close(const int fd) {
|
||||
return 0 == status ? status : -errno;
|
||||
}
|
||||
|
||||
int HostIO_POSIX::LinkSymbolic(const fs::path& src, const fs::path& dst) {
|
||||
errno = 0;
|
||||
int status = symlink(src.c_str(), dst.c_str());
|
||||
return 0 == status ? status : -errno;
|
||||
}
|
||||
|
||||
int HostIO_POSIX::Link(const fs::path& src, const fs::path& dst) {
|
||||
errno = 0;
|
||||
int status = link(src.c_str(), dst.c_str());
|
||||
@ -57,6 +51,12 @@ int HostIO_POSIX::Unlink(const fs::path& path) {
|
||||
return 0 == status ? status : -errno;
|
||||
}
|
||||
|
||||
int HostIO_POSIX::LinkSymbolic(const fs::path& src, const fs::path& dst) {
|
||||
errno = 0;
|
||||
int status = symlink(src.c_str(), dst.c_str());
|
||||
return 0 == status ? status : -errno;
|
||||
}
|
||||
|
||||
int HostIO_POSIX::Flush(const int fd) {
|
||||
errno = 0;
|
||||
return 0;
|
||||
@ -68,6 +68,16 @@ int HostIO_POSIX::FSync(const int fd) {
|
||||
return 0 == status ? status : -errno;
|
||||
}
|
||||
|
||||
u64 HostIO_POSIX::LSeek(const int fd, u64 offset, QuasiFS::SeekOrigin origin) {
|
||||
errno = 0;
|
||||
int status = lseek(fd, offset, ToPOSIXSeekOrigin(origin));
|
||||
return status >= 0 ? status : -errno;
|
||||
}
|
||||
|
||||
s64 HostIO_POSIX::Tell(const int fd) {
|
||||
return LSeek(fd, 0, SeekOrigin::CURRENT);
|
||||
}
|
||||
|
||||
int HostIO_POSIX::Truncate(const fs::path& path, u64 size) {
|
||||
errno = 0;
|
||||
int status = truncate(path.c_str(), size);
|
||||
@ -80,34 +90,24 @@ int HostIO_POSIX::FTruncate(const int fd, u64 size) {
|
||||
return status >= 0 ? status : -errno;
|
||||
}
|
||||
|
||||
u64 HostIO_POSIX::LSeek(const int fd, u64 offset, QuasiFS::SeekOrigin origin) {
|
||||
errno = 0;
|
||||
int status = lseek(fd, offset, ToPOSIXSeekOrigin(origin));
|
||||
return status >= 0 ? status : -errno;
|
||||
}
|
||||
|
||||
s64 HostIO_POSIX::Tell(const int fd) {
|
||||
return LSeek(fd, 0, SeekOrigin::CURRENT);
|
||||
}
|
||||
|
||||
s64 HostIO_POSIX::Write(const int fd, const void* buf, u64 count) {
|
||||
errno = 0;
|
||||
int status = write(fd, buf, count);
|
||||
return status >= 0 ? status : -errno;
|
||||
}
|
||||
|
||||
s64 HostIO_POSIX::PWrite(const int fd, const void* buf, u64 count, u64 offset) {
|
||||
errno = 0;
|
||||
int status = pwrite(fd, buf, count, offset);
|
||||
return status >= 0 ? status : -errno;
|
||||
}
|
||||
|
||||
s64 HostIO_POSIX::Read(const int fd, void* buf, u64 count) {
|
||||
errno = 0;
|
||||
int status = read(fd, buf, count);
|
||||
return status >= 0 ? status : -errno;
|
||||
}
|
||||
|
||||
s64 HostIO_POSIX::PWrite(const int fd, const void* buf, u64 count, u64 offset) {
|
||||
errno = 0;
|
||||
int status = pwrite(fd, buf, count, offset);
|
||||
return status >= 0 ? status : -errno;
|
||||
}
|
||||
|
||||
s64 HostIO_POSIX::PRead(const int fd, void* buf, u64 count, u64 offset) {
|
||||
errno = 0;
|
||||
int status = pread(fd, buf, count, offset);
|
||||
|
||||
@ -4,21 +4,20 @@
|
||||
#include <filesystem>
|
||||
|
||||
#include "common/logging/log.h"
|
||||
#include "src/core/file_sys/hostio/host_io_virtual.h"
|
||||
#include "src/core/file_sys/quasifs/quasifs_inode_quasi_device.h"
|
||||
#include "src/core/file_sys/quasifs/quasifs_inode_quasi_directory.h"
|
||||
#include "src/core/file_sys/quasifs/quasifs_inode_quasi_file.h"
|
||||
#include "src/core/file_sys/quasifs/quasifs_inode_symlink.h"
|
||||
#include "src/core/file_sys/quasifs/quasifs_inode_virtualfile.h"
|
||||
#include "src/core/file_sys/quasifs/quasifs_partition.h"
|
||||
|
||||
#include "../../quasifs/quasi_errno.h"
|
||||
#include "../../quasifs/quasi_sys_fcntl.h"
|
||||
#include "../../quasifs/quasi_types.h"
|
||||
|
||||
#include "../../quasifs/quasifs_inode_quasi_device.h"
|
||||
#include "../../quasifs/quasifs_inode_quasi_directory.h"
|
||||
#include "../../quasifs/quasifs_inode_quasi_file.h"
|
||||
#include "../../quasifs/quasifs_inode_symlink.h"
|
||||
#include "../../quasifs/quasifs_inode_virtualfile.h"
|
||||
#include "../../quasifs/quasifs_partition.h"
|
||||
|
||||
#include "../host_io_virtual.h"
|
||||
#include "host_io_base.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"
|
||||
|
||||
namespace HostIODriver {
|
||||
|
||||
HostIO_Virtual::HostIO_Virtual() = default;
|
||||
@ -82,7 +81,7 @@ int HostIO_Virtual::Creat(const fs::path& path, u16 mode) {
|
||||
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(), new_file);
|
||||
return this->res->mountpoint->touch(parent, path.filename().string(), new_file);
|
||||
}
|
||||
|
||||
int HostIO_Virtual::Close(const int fd) {
|
||||
@ -90,17 +89,6 @@ int HostIO_Virtual::Close(const int fd) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int HostIO_Virtual::LinkSymbolic(const fs::path& src, const fs::path& dst) {
|
||||
if (nullptr == this->res)
|
||||
return -QUASI_EINVAL;
|
||||
|
||||
symlink_ptr sym = Symlink::Create(src);
|
||||
// symlink counter is never increased
|
||||
sym->st.st_nlink = 1;
|
||||
|
||||
return this->res->mountpoint->touch(this->res->parent, dst.filename(), sym);
|
||||
}
|
||||
|
||||
int HostIO_Virtual::Link(const fs::path& src, const fs::path& dst) {
|
||||
if (nullptr == this->res)
|
||||
return -QUASI_EINVAL;
|
||||
@ -110,7 +98,7 @@ int HostIO_Virtual::Link(const fs::path& src, const fs::path& dst) {
|
||||
|
||||
Resolved dst_res;
|
||||
fs::path dst_path = dst.parent_path();
|
||||
std::string dst_name = dst.filename();
|
||||
std::string dst_name = dst.filename().string();
|
||||
|
||||
if (int res_status = part->Resolve(dst_path, dst_res); res_status < 0)
|
||||
return res_status;
|
||||
@ -136,6 +124,17 @@ int HostIO_Virtual::Unlink(const fs::path& path) {
|
||||
return part->unlink(parent, this->res->leaf);
|
||||
}
|
||||
|
||||
int HostIO_Virtual::LinkSymbolic(const fs::path& src, const fs::path& dst) {
|
||||
if (nullptr == this->res)
|
||||
return -QUASI_EINVAL;
|
||||
|
||||
symlink_ptr sym = Symlink::Create(src);
|
||||
// symlink counter is never increased
|
||||
sym->st.st_nlink = 1;
|
||||
|
||||
return this->res->mountpoint->touch(this->res->parent, dst.filename().string(), sym);
|
||||
}
|
||||
|
||||
int HostIO_Virtual::Flush(const int fd) {
|
||||
// not applicable
|
||||
return 0;
|
||||
@ -153,6 +152,32 @@ int HostIO_Virtual::FSync(const int fd) {
|
||||
return handle->node->fsync();
|
||||
}
|
||||
|
||||
u64 HostIO_Virtual::LSeek(const int fd, u64 offset, QuasiFS::SeekOrigin origin) {
|
||||
if (nullptr == handle)
|
||||
return -QUASI_EINVAL;
|
||||
|
||||
inode_ptr node = handle->node;
|
||||
|
||||
if (nullptr == node)
|
||||
return -QUASI_EBADF;
|
||||
|
||||
auto ptr = &handle->pos;
|
||||
|
||||
u64 new_ptr = ((SeekOrigin::ORIGIN == origin) * offset) +
|
||||
((SeekOrigin::CURRENT == origin) * (*(ptr) + offset)) +
|
||||
((SeekOrigin::END == origin) * (node->st.st_size + offset));
|
||||
|
||||
if (new_ptr < 0)
|
||||
return -QUASI_EINVAL;
|
||||
|
||||
*ptr = new_ptr;
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
s64 HostIO_Virtual::Tell(const int fd) {
|
||||
return LSeek(fd, 0, SeekOrigin::CURRENT);
|
||||
}
|
||||
|
||||
int HostIO_Virtual::Truncate(const fs::path& path, u64 size) {
|
||||
if (nullptr == this->res)
|
||||
return -QUASI_EINVAL;
|
||||
@ -180,41 +205,15 @@ int HostIO_Virtual::FTruncate(const int fd, u64 size) {
|
||||
if (nullptr == node)
|
||||
return -QUASI_EBADF;
|
||||
|
||||
if (node->is_dir())
|
||||
return -QUASI_EISDIR;
|
||||
// if (node->is_dir())
|
||||
// return -QUASI_EISDIR;
|
||||
|
||||
if (!node->is_file())
|
||||
return -QUASI_EINVAL;
|
||||
// if (!node->is_file())
|
||||
// return -QUASI_EINVAL;
|
||||
|
||||
return handle->node->ftruncate(size);
|
||||
}
|
||||
|
||||
u64 HostIO_Virtual::LSeek(const int fd, u64 offset, QuasiFS::SeekOrigin origin) {
|
||||
if (nullptr == handle)
|
||||
return -QUASI_EINVAL;
|
||||
|
||||
inode_ptr node = handle->node;
|
||||
|
||||
if (nullptr == node)
|
||||
return -QUASI_EBADF;
|
||||
|
||||
auto ptr = &handle->pos;
|
||||
|
||||
u64 new_ptr = ((SeekOrigin::ORIGIN == origin) * offset) +
|
||||
((SeekOrigin::CURRENT == origin) * (*(ptr) + offset)) +
|
||||
((SeekOrigin::END == origin) * (node->st.st_size + offset));
|
||||
|
||||
if (new_ptr < 0)
|
||||
return -QUASI_EINVAL;
|
||||
|
||||
*ptr = new_ptr;
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
s64 HostIO_Virtual::Tell(const int fd) {
|
||||
return LSeek(fd, 0, SeekOrigin::CURRENT);
|
||||
}
|
||||
|
||||
s64 HostIO_Virtual::Write(const int fd, const void* buf, u64 count) {
|
||||
s64 bw = this->PWrite(fd, buf, count, handle->pos);
|
||||
|
||||
@ -224,6 +223,15 @@ 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 br = PRead(fd, buf, count, handle->pos);
|
||||
|
||||
if (br > 0)
|
||||
handle->pos += br;
|
||||
|
||||
return br;
|
||||
}
|
||||
|
||||
s64 HostIO_Virtual::PWrite(const int fd, const void* buf, u64 count, u64 offset) {
|
||||
if (nullptr == handle)
|
||||
return -QUASI_EBADF;
|
||||
@ -239,15 +247,6 @@ s64 HostIO_Virtual::PWrite(const int fd, const void* buf, u64 count, u64 offset)
|
||||
return node->pwrite(buf, count, offset);
|
||||
}
|
||||
|
||||
s64 HostIO_Virtual::Read(const int fd, void* buf, u64 count) {
|
||||
s64 br = PRead(fd, buf, count, handle->pos);
|
||||
|
||||
if (br > 0)
|
||||
handle->pos += br;
|
||||
|
||||
return br;
|
||||
}
|
||||
|
||||
s64 HostIO_Virtual::PRead(const int fd, void* buf, u64 count, u64 offset) {
|
||||
if (nullptr == handle)
|
||||
return -QUASI_EINVAL;
|
||||
|
||||
@ -1,3 +1,24 @@
|
||||
// INAA License @marecl 2025
|
||||
#include "common/logging/log.h"
|
||||
|
||||
#include "../host_io_win32.h"
|
||||
#include "../host_io_win32.h"
|
||||
|
||||
namespace HostIODriver {
|
||||
|
||||
HostIO_Win32::HostIO_Win32() = default;
|
||||
HostIO_Win32::~HostIO_Win32() = default;
|
||||
|
||||
int HostIO_Win32::Creat(const fs::path& path, u16 mode) {
|
||||
LOG_ERROR(Kernel_Fs, "Stub called in HostIO_Base: {}:{}", __FILE__, __LINE__);
|
||||
return -38;
|
||||
}
|
||||
int HostIO_Win32::Open(const fs::path& path, int flags, u16 mode) {
|
||||
LOG_ERROR(Kernel_Fs, "Stub called in HostIO_Base: {}:{}", __FILE__, __LINE__);
|
||||
return -38;
|
||||
}
|
||||
int HostIO_Win32::Close(const int fd) {
|
||||
LOG_ERROR(Kernel_Fs, "Stub called in HostIO_Base: {}:{}", __FILE__, __LINE__);
|
||||
return -38;
|
||||
}
|
||||
|
||||
} // namespace HostIODriver
|
||||
@ -5,13 +5,12 @@
|
||||
#include <unordered_map>
|
||||
|
||||
#include "common/types.h"
|
||||
#include "src/core/file_sys/hostio/host_io.h"
|
||||
|
||||
#include "quasi_errno.h"
|
||||
#include "quasi_types.h"
|
||||
#include "quasifs_inode.h"
|
||||
|
||||
#include "../hostio/host_io.h"
|
||||
|
||||
/**
|
||||
* Wrapper class
|
||||
* Basically a Partition object with a bit of extra functionality and single superblock
|
||||
@ -49,7 +48,7 @@ private:
|
||||
// when in doubt - man(2)
|
||||
//
|
||||
|
||||
class OperationImpl : public HostIO::HostIO_Base {
|
||||
class OperationImpl final : public HostIOBase {
|
||||
private:
|
||||
QFS& qfs;
|
||||
OperationImpl& operator=(const OperationImpl&) = delete;
|
||||
|
||||
@ -103,7 +103,7 @@ public:
|
||||
}
|
||||
|
||||
virtual s32 ftruncate(s64 length) {
|
||||
return -QUASI_EBADF;
|
||||
return -QUASI_EINVAL;
|
||||
}
|
||||
|
||||
virtual s32 getdents(void* buf, u32 nbytes, s64* basep) {
|
||||
|
||||
@ -102,7 +102,7 @@ public:
|
||||
int link(inode_ptr source, dir_ptr destination_parent, const std::string& name);
|
||||
int unlink(dir_ptr parent, const std::string& name);
|
||||
|
||||
static int chmod(inode_ptr target, mode_t mode);
|
||||
static int chmod(inode_ptr target, u16 mode);
|
||||
|
||||
private:
|
||||
int rmInode(fileno_t fileno);
|
||||
|
||||
@ -64,7 +64,7 @@ void _printTree(const inode_ptr& node, const std::string& name, int depth) {
|
||||
if (!name.empty()) {
|
||||
auto st = node->st;
|
||||
char timebuf[64];
|
||||
std::tm* t = std::localtime(&st.st_mtime);
|
||||
std::tm* t = std::localtime(&st.st_mtim.tv_sec);
|
||||
std::strftime(timebuf, sizeof(timebuf), "%EY-%m-%d %H:%M", t);
|
||||
|
||||
LOG_INFO(Kernel_Fs, "[ls -la] {} {:08} {:03d} {}:{} {:>08} {}\t{}{}\n",
|
||||
@ -386,7 +386,7 @@ void QFS::SyncHostImpl(partition_ptr part) {
|
||||
fs::path entry_path = entry->path();
|
||||
fs::path pp = "/" / slice_path(entry->path());
|
||||
fs::path parent_path = pp.parent_path();
|
||||
fs::path leaf = pp.filename();
|
||||
std::string leaf = pp.filename().string();
|
||||
|
||||
Resolved res;
|
||||
part->Resolve(parent_path, res);
|
||||
|
||||
@ -29,7 +29,7 @@ fs::path Partition::SanitizePath(const fs::path& path) {
|
||||
// lexically normal to resolve relative calls
|
||||
// avoids going OOB with malicious file names
|
||||
fs::path tmp = path.lexically_normal();
|
||||
if (tmp.string().find(this->host_root, 0) == 0)
|
||||
if (tmp.string().find(this->host_root.string(), 0) == 0)
|
||||
return tmp;
|
||||
|
||||
return {};
|
||||
@ -82,10 +82,11 @@ int Partition::Resolve(fs::path& path, Resolved& res) {
|
||||
|
||||
bool is_final = false;
|
||||
|
||||
for (auto part = path.begin(); part != path.end(); part++) {
|
||||
is_final = std::next(part) == path.end();
|
||||
for (auto _part = path.begin(); _part != path.end(); _part++) {
|
||||
std::string part = (*_part).string();
|
||||
is_final = std::next(_part) == path.end();
|
||||
|
||||
if ("/" == *part) {
|
||||
if ("/" == part) {
|
||||
res.local_path = "/";
|
||||
res.parent = res.parent;
|
||||
res.node = res.node;
|
||||
@ -94,7 +95,7 @@ int Partition::Resolve(fs::path& path, Resolved& res) {
|
||||
}
|
||||
|
||||
// empty means trailing / which is interpreted only when using dirs or symlinks
|
||||
if (part->empty()) {
|
||||
if (part.empty()) {
|
||||
if (!is_final)
|
||||
// something went wrong
|
||||
throw 666;
|
||||
@ -119,12 +120,12 @@ int Partition::Resolve(fs::path& path, Resolved& res) {
|
||||
|
||||
dir_ptr dir = std::static_pointer_cast<Directory>(current);
|
||||
parent = dir;
|
||||
current = dir->lookup(*part);
|
||||
current = dir->lookup(part);
|
||||
|
||||
res.local_path /= *part;
|
||||
res.local_path /= part;
|
||||
res.parent = parent;
|
||||
res.node = current;
|
||||
res.leaf = *part;
|
||||
res.leaf = part;
|
||||
}
|
||||
|
||||
// file not found in current directory, ENOENT
|
||||
@ -162,13 +163,13 @@ int Partition::Resolve(fs::path& path, Resolved& res) {
|
||||
// everything AFTER host's path since QFS holds mountpoint meta, its it's job to
|
||||
// resolve mounted root directory.
|
||||
fs::path remainder = "/";
|
||||
for (auto p = std::next(part); p != path.end(); p++)
|
||||
for (auto p = std::next(_part); p != path.end(); p++)
|
||||
remainder /= *p;
|
||||
path = remainder;
|
||||
|
||||
res.parent = current_dir; // no point, unused in this context
|
||||
res.node = current_dir->mounted_root;
|
||||
res.leaf = *part;
|
||||
res.leaf = part;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -179,13 +180,13 @@ int Partition::Resolve(fs::path& path, Resolved& res) {
|
||||
if (current->is_link()) {
|
||||
// just like with mountpoints, we discard everything up until the "next" element in path
|
||||
fs::path remainder = "";
|
||||
for (auto p = std::next(part); p != path.end(); p++)
|
||||
for (auto p = std::next(_part); p != path.end(); p++)
|
||||
remainder /= *p;
|
||||
path = remainder;
|
||||
|
||||
res.parent = parent;
|
||||
res.node = current;
|
||||
res.leaf = *part;
|
||||
res.leaf = part;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -295,7 +296,7 @@ int Partition::unlink(dir_ptr parent, const std::string& name) {
|
||||
return rmInode(target);
|
||||
}
|
||||
|
||||
int Partition::chmod(inode_ptr target, mode_t mode) {
|
||||
int Partition::chmod(inode_ptr target, u16 mode) {
|
||||
if (nullptr == target)
|
||||
return -QUASI_EINVAL;
|
||||
|
||||
|
||||
@ -260,7 +260,7 @@ int QFS::OperationImpl::Unlink(const fs::path& path) {
|
||||
// symlinks mess this whole thing up, so we need toqfs.Resolve parent and leaf independently
|
||||
|
||||
fs::path parent_path = path.parent_path();
|
||||
fs::path leaf = path.filename();
|
||||
std::string leaf = path.filename().string();
|
||||
|
||||
// parent, must pass
|
||||
resolve_status = qfs.Resolve(parent_path, res);
|
||||
|
||||
@ -48,7 +48,8 @@ bool AvPlayerSource::Init(const SceAvPlayerInitData& init_data, std::string_view
|
||||
auto qfs = Common::Singleton<QuasiFS::QFS>::Instance();
|
||||
std::filesystem::path filepath{};
|
||||
qfs->GetHostPath(filepath, path);
|
||||
if (AVPLAYER_IS_ERROR(avformat_open_input(&context, filepath.c_str(), nullptr, nullptr))) {
|
||||
// may get funky with char/wchar path on *dows
|
||||
if (AVPLAYER_IS_ERROR(avformat_open_input(&context, filepath.string().c_str(), nullptr, nullptr))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
#include "common/path_util.h"
|
||||
#include "common/singleton.h"
|
||||
#include "common/thread.h"
|
||||
#include "core/file_sys/quasifs/quasi_sys_fcntl.h"
|
||||
#include "core/file_sys/quasifs/quasifs.h"
|
||||
#include "core/libraries/system/msgdialog_ui.h"
|
||||
#include "save_instance.h"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user