From 797f70268fc2aa8acb01a105afc5cb51af7777e1 Mon Sep 17 00:00:00 2001 From: DH Date: Sat, 31 Aug 2024 23:24:52 +0300 Subject: [PATCH] vfs: allow subdirectory creation in /dev --- rpcsx-os/vfs.cpp | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/rpcsx-os/vfs.cpp b/rpcsx-os/vfs.cpp index 083a12d51..361f46c5a 100644 --- a/rpcsx-os/vfs.cpp +++ b/rpcsx-os/vfs.cpp @@ -8,16 +8,14 @@ #include #include - static orbis::ErrorCode devfs_stat(orbis::File *file, orbis::Stat *sb, - orbis::Thread *thread) { + orbis::Thread *thread) { *sb = {}; // TODO return {}; } - static orbis::FileOps devfs_ops = { - .stat = devfs_stat, + .stat = devfs_stat, }; struct DevFs : IoDevice { @@ -39,21 +37,12 @@ struct DevFs : IoDevice { result->ops = &devfs_ops; *file = result; - return{}; + return {}; } - std::string_view devPath = path; - if (auto pos = devPath.find('/'); pos != std::string_view::npos) { - auto deviceName = devPath.substr(0, pos); - devPath.remove_prefix(pos + 1); - if (auto it = devices.find(deviceName); it != devices.end()) { - return it->second->open(file, std::string(devPath).c_str(), flags, mode, - thread); - } - } else { - if (auto it = devices.find(devPath); it != devices.end()) { - return it->second->open(file, "", flags, mode, thread); - } + std::string_view devPath = path; + if (auto it = devices.find(devPath); it != devices.end()) { + return it->second->open(file, "", flags, mode, thread); } std::fprintf(stderr, "device %s not exists\n", path); @@ -115,7 +104,6 @@ rx::vfs::get(const std::filesystem::path &guestPath) { std::string normalPath = std::filesystem::path(guestPath).lexically_normal(); std::string_view path = normalPath; orbis::Ref device; - std::string_view prefix; std::lock_guard lock(gMountMtx); @@ -129,7 +117,7 @@ rx::vfs::get(const std::filesystem::path &guestPath) { path = {}; } - return { gDevFs, std::string(path) }; + return {gDevFs, std::string(path)}; } }