Fix accessing the /vol/save directories

This commit is contained in:
Maschell 2024-04-28 15:20:42 +02:00
parent 3e1d862aff
commit ec1101e82f
2 changed files with 31 additions and 1 deletions

View File

@ -183,6 +183,18 @@ int IOAbstraction::stat (const char *path, struct stat *sbuf)
auto r = ::stat (convertedPath.c_str (), sbuf); auto r = ::stat (convertedPath.c_str (), sbuf);
if (r < 0) if (r < 0)
{ {
if (errno == EPERM)
{
auto *dir = ::opendir (convertedPath.c_str ());
if (dir)
{
*sbuf = {};
// TODO: init other values?
sbuf->st_mode = _IFDIR;
::closedir (dir);
return 0;
}
}
if (sVirtualDirs.contains (convertedPath)) if (sVirtualDirs.contains (convertedPath))
{ {
*sbuf = {}; *sbuf = {};

View File

@ -28,6 +28,7 @@
#include <mocha/mocha.h> #include <mocha/mocha.h>
#include <nn/ac.h> #include <nn/ac.h>
#include <nn/act.h>
#include <thread> #include <thread>
#include <coreinit/thread.h> #include <coreinit/thread.h>
@ -159,6 +160,8 @@ void start_server ()
virtualDirsInRoot.emplace_back ("storage_usb"); virtualDirsInRoot.emplace_back ("storage_usb");
IOAbstraction::addVirtualPath ("storage_usb:/", {}); IOAbstraction::addVirtualPath ("storage_usb:/", {});
} }
sMochaPathsWereMounted = true;
} }
virtualDirsInRoot.emplace_back ("fs"); virtualDirsInRoot.emplace_back ("fs");
IOAbstraction::addVirtualPath (":/", virtualDirsInRoot); IOAbstraction::addVirtualPath (":/", virtualDirsInRoot);
@ -167,7 +170,22 @@ void start_server ()
"fs:/vol", std::vector<std::string>{"external01", "content", "save"}); "fs:/vol", std::vector<std::string>{"external01", "content", "save"});
IOAbstraction::addVirtualPath ("fs:/vol/content", {}); IOAbstraction::addVirtualPath ("fs:/vol/content", {});
sMochaPathsWereMounted = true;
std::vector<std::string> virtualDirsInSave;
virtualDirsInSave.emplace_back ("common");
nn::act::Initialize ();
for (int32_t i = 0; i < 13; i++)
{
if (!nn::act::IsSlotOccupied (i))
{
continue;
}
char buffer[9];
snprintf (buffer, sizeof (buffer), "%08X", nn::act::GetPersistentIdEx (i));
virtualDirsInSave.emplace_back (buffer);
}
nn::act::Finalize ();
IOAbstraction::addVirtualPath ("fs:/vol/save", virtualDirsInSave);
} }
else else
{ {