improvements in sceSaveDataMount2 , scesavedataunmount , sceMKKernel

This commit is contained in:
georgemoralis 2024-04-28 07:12:01 +03:00
parent 3a4986b726
commit 85dae9d3c9
3 changed files with 19 additions and 16 deletions

View File

@ -156,7 +156,7 @@ int PS4_SYSV_ABI sceKernelMkdir(const char* path, u16 mode) {
}
auto* mnt = Common::Singleton<Core::FileSys::MntPoints>::Instance();
std::string dir_name = mnt->GetHostFile(path);
if (std::filesystem::is_directory(dir_name)) {
if (std::filesystem::exists(dir_name)) {
return SCE_KERNEL_ERROR_EEXIST;
}
@ -164,7 +164,7 @@ int PS4_SYSV_ABI sceKernelMkdir(const char* path, u16 mode) {
return SCE_KERNEL_ERROR_EIO;
}
if (!std::filesystem::is_directory(dir_name)) {
if (!std::filesystem::exists(dir_name)) {
return SCE_KERNEL_ERROR_ENOENT;
}
return ORBIS_OK;

View File

@ -3,5 +3,6 @@
#pragma once
constexpr int ORBIS_SAVE_DATA_ERROR_PARAMETER = 0x809f0000;
constexpr int ORBIS_SAVE_DATA_ERROR_NOT_FOUND = 0x809f0008; // save data doesn't exist
constexpr int ORBIS_SAVE_DATA_ERROR_EXISTS = 0x809f0007; // save data directory,same name exists

View File

@ -341,18 +341,12 @@ s32 PS4_SYSV_ABI sceSaveDataMount2(const OrbisSaveDataMount2* mount,
LOG_INFO(Lib_SaveData, "called user_id = {} dir_name = {} blocks = {} mount_mode = {}",
mount->user_id, mount->dir_name->data, mount->blocks, mount->mount_mode);
bool rdonly = (mount->mount_mode & ORBIS_SAVE_DATA_MOUNT_MODE_RDONLY) != 0;
bool rdwr = (mount->mount_mode & ORBIS_SAVE_DATA_MOUNT_MODE_RDWR) != 0;
bool create = (mount->mount_mode & ORBIS_SAVE_DATA_MOUNT_MODE_CREATE) != 0;
bool destruct_off = (mount->mount_mode & ORBIS_SAVE_DATA_MOUNT_MODE_DESTRUCT_OFF) != 0;
bool copy_icon = (mount->mount_mode & ORBIS_SAVE_DATA_MOUNT_MODE_COPY_ICON) != 0;
bool create2 = (mount->mount_mode & ORBIS_SAVE_DATA_MOUNT_MODE_CREATE2) != 0;
const auto& mount_dir = Common::FS::GetUserPath(Common::FS::PathType::SaveDataDir) /
std::string(mount->dir_name->data);
if (rdonly) {
if (!std::filesystem::is_directory(mount_dir)) {
switch (mount->mount_mode) {
case ORBIS_SAVE_DATA_MOUNT_MODE_RDONLY:
case ORBIS_SAVE_DATA_MOUNT_MODE_RDWR: {
if (!std::filesystem::exists(mount_dir)) {
return ORBIS_SAVE_DATA_ERROR_NOT_FOUND;
}
auto* mnt = Common::Singleton<Core::FileSys::MntPoints>::Instance();
@ -360,9 +354,11 @@ s32 PS4_SYSV_ABI sceSaveDataMount2(const OrbisSaveDataMount2* mount,
mount_result->mount_status = 0;
strncpy(mount_result->mount_point.data, g_mount_point.c_str(), 16);
}
if (create) {
if (std::filesystem::is_directory(mount_dir)) {
} break;
case ORBIS_SAVE_DATA_MOUNT_MODE_CREATE | ORBIS_SAVE_DATA_MOUNT_MODE_RDWR:
case ORBIS_SAVE_DATA_MOUNT_MODE_CREATE | ORBIS_SAVE_DATA_MOUNT_MODE_RDWR |
ORBIS_SAVE_DATA_MOUNT_MODE_COPY_ICON: {
if (std::filesystem::exists(mount_dir)) {
return ORBIS_SAVE_DATA_ERROR_EXISTS;
}
std::filesystem::create_directories(mount_dir);
@ -372,6 +368,9 @@ s32 PS4_SYSV_ABI sceSaveDataMount2(const OrbisSaveDataMount2* mount,
mount_result->mount_status = 1;
strncpy(mount_result->mount_point.data, g_mount_point.c_str(), 16);
} break;
default:
UNREACHABLE();
}
mount_result->required_blocks = 0;
@ -499,7 +498,10 @@ int PS4_SYSV_ABI sceSaveDataTransferringMount() {
}
int PS4_SYSV_ABI sceSaveDataUmount(const OrbisSaveDataMountPoint* mountPoint) {
LOG_ERROR(Lib_SaveData, "mountPoint {}",std::string(mountPoint->data));
LOG_INFO(Lib_SaveData, "mountPoint = {}", std::string(mountPoint->data));
if (std::string(mountPoint->data).empty()) {
return ORBIS_SAVE_DATA_ERROR_PARAMETER;
}
auto* mnt = Common::Singleton<Core::FileSys::MntPoints>::Instance();
mnt->Unmount(std::string(mountPoint->data));
return ORBIS_OK;