Filesystem errors and Base Array Layers (#280)
* Filesystem errors and Base Array Layers * Fixed build for POSIX * forgot 1 file
This commit is contained in:
parent
59be090c83
commit
989f88837d
|
@ -167,7 +167,7 @@ IOFile& IOFile::operator=(IOFile&& other) noexcept {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IOFile::Open(const fs::path& path, FileAccessMode mode, FileType type, FileShareFlag flag) {
|
int IOFile::Open(const fs::path& path, FileAccessMode mode, FileType type, FileShareFlag flag) {
|
||||||
Close();
|
Close();
|
||||||
|
|
||||||
file_path = path;
|
file_path = path;
|
||||||
|
@ -175,21 +175,26 @@ void IOFile::Open(const fs::path& path, FileAccessMode mode, FileType type, File
|
||||||
file_type = type;
|
file_type = type;
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (flag != FileShareFlag::ShareNone) {
|
if (flag != FileShareFlag::ShareNone) {
|
||||||
file = _wfsopen(path.c_str(), AccessModeToWStr(mode, type), ToWindowsFileShareFlag(flag));
|
file = _wfsopen(path.c_str(), AccessModeToWStr(mode, type), ToWindowsFileShareFlag(flag));
|
||||||
|
result = errno;
|
||||||
} else {
|
} else {
|
||||||
_wfopen_s(&file, path.c_str(), AccessModeToWStr(mode, type));
|
result = _wfopen_s(&file, path.c_str(), AccessModeToWStr(mode, type));
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
file = std::fopen(path.c_str(), AccessModeToStr(mode, type));
|
file = std::fopen(path.c_str(), AccessModeToStr(mode, type));
|
||||||
|
result = errno;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!IsOpen()) {
|
if (!IsOpen()) {
|
||||||
LOG_ERROR(Common_Filesystem, "Failed to open the file at path={}",
|
LOG_ERROR(Common_Filesystem, "Failed to open the file at path={}",
|
||||||
PathToUTF8String(file_path));
|
PathToUTF8String(file_path));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IOFile::Close() {
|
void IOFile::Close() {
|
||||||
|
|
|
@ -102,7 +102,7 @@ public:
|
||||||
|
|
||||||
uintptr_t GetFileMapping();
|
uintptr_t GetFileMapping();
|
||||||
|
|
||||||
void Open(const std::filesystem::path& path, FileAccessMode mode,
|
int Open(const std::filesystem::path& path, FileAccessMode mode,
|
||||||
FileType type = FileType::BinaryFile,
|
FileType type = FileType::BinaryFile,
|
||||||
FileShareFlag flag = FileShareFlag::ShareReadOnly);
|
FileShareFlag flag = FileShareFlag::ShareReadOnly);
|
||||||
void Close();
|
void Close();
|
||||||
|
|
|
@ -73,28 +73,25 @@ int PS4_SYSV_ABI sceKernelOpen(const char* path, int flags, u16 mode) {
|
||||||
} else {
|
} else {
|
||||||
file->m_guest_name = path;
|
file->m_guest_name = path;
|
||||||
file->m_host_name = mnt->GetHostFile(file->m_guest_name);
|
file->m_host_name = mnt->GetHostFile(file->m_guest_name);
|
||||||
|
int e = 0;
|
||||||
if (read) {
|
if (read) {
|
||||||
file->f.Open(file->m_host_name, Common::FS::FileAccessMode::Read);
|
e = file->f.Open(file->m_host_name, Common::FS::FileAccessMode::Read);
|
||||||
} else if (write && create) {
|
} else if (write && (create || truncate)) {
|
||||||
file->f.Open(file->m_host_name, Common::FS::FileAccessMode::Write);
|
e = file->f.Open(file->m_host_name, Common::FS::FileAccessMode::Write);
|
||||||
} else if (write && create && append) { // CUSA04729 (appends app0/shaderlist.txt)
|
} else if (write && create && append) { // CUSA04729 (appends app0/shaderlist.txt)
|
||||||
file->f.Open(file->m_host_name, Common::FS::FileAccessMode::Append);
|
e = file->f.Open(file->m_host_name, Common::FS::FileAccessMode::Append);
|
||||||
} else if (rdwr) {
|
} else if (rdwr) {
|
||||||
if (create) { // Create an empty file first.
|
if (create) { // Create an empty file first.
|
||||||
Common::FS::IOFile out(file->m_host_name, Common::FS::FileAccessMode::Write);
|
Common::FS::IOFile out(file->m_host_name, Common::FS::FileAccessMode::Write);
|
||||||
}
|
}
|
||||||
// RW, then scekernelWrite is called and savedata is written just fine now.
|
// RW, then scekernelWrite is called and savedata is written just fine now.
|
||||||
file->f.Open(file->m_host_name, Common::FS::FileAccessMode::ReadWrite);
|
e = file->f.Open(file->m_host_name, Common::FS::FileAccessMode::ReadWrite);
|
||||||
} else {
|
} else {
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
if (!file->f.IsOpen()) {
|
if (e != 0) {
|
||||||
h->DeleteHandle(handle);
|
h->DeleteHandle(handle);
|
||||||
if (create) {
|
return ErrnoToSceKernelError(e);
|
||||||
return ORBIS_KERNEL_ERROR_EACCES;
|
|
||||||
} else {
|
|
||||||
return ORBIS_KERNEL_ERROR_ENOENT;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file->is_opened = true;
|
file->is_opened = true;
|
||||||
|
|
|
@ -106,12 +106,17 @@ int* PS4_SYSV_ABI __Error() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ErrSceToPosix(int result) {
|
void ErrSceToPosix(int result) {
|
||||||
int rt = result > SCE_KERNEL_ERROR_UNKNOWN && result <= SCE_KERNEL_ERROR_ESTOP
|
const int rt = result > SCE_KERNEL_ERROR_UNKNOWN && result <= SCE_KERNEL_ERROR_ESTOP
|
||||||
? result + -SCE_KERNEL_ERROR_UNKNOWN
|
? result + -SCE_KERNEL_ERROR_UNKNOWN
|
||||||
: POSIX_EOTHER;
|
: POSIX_EOTHER;
|
||||||
g_posix_errno = rt;
|
g_posix_errno = rt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ErrnoToSceKernelError(int e) {
|
||||||
|
const auto res = SCE_KERNEL_ERROR_UNKNOWN + e;
|
||||||
|
return res > SCE_KERNEL_ERROR_ESTOP ? SCE_KERNEL_ERROR_UNKNOWN : res;
|
||||||
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceKernelMmap(void* addr, u64 len, int prot, int flags, int fd, size_t offset,
|
int PS4_SYSV_ABI sceKernelMmap(void* addr, u64 len, int prot, int flags, int fd, size_t offset,
|
||||||
void** res) {
|
void** res) {
|
||||||
LOG_INFO(Kernel_Vmm, "called addr = {}, len = {}, prot = {}, flags = {}, fd = {}, offset = {}",
|
LOG_INFO(Kernel_Vmm, "called addr = {}, len = {}, prot = {}, flags = {}, fd = {}, offset = {}",
|
||||||
|
|
|
@ -13,6 +13,7 @@ class SymbolsResolver;
|
||||||
namespace Libraries::Kernel {
|
namespace Libraries::Kernel {
|
||||||
|
|
||||||
void ErrSceToPosix(int result);
|
void ErrSceToPosix(int result);
|
||||||
|
int ErrnoToSceKernelError(int e);
|
||||||
|
|
||||||
struct OrbisTimesec {
|
struct OrbisTimesec {
|
||||||
time_t t;
|
time_t t;
|
||||||
|
|
|
@ -50,8 +50,8 @@ ImageViewInfo::ImageViewInfo(const AmdGpu::Image& image, bool is_storage) noexce
|
||||||
: is_storage{is_storage} {
|
: is_storage{is_storage} {
|
||||||
type = ConvertImageViewType(image.GetType());
|
type = ConvertImageViewType(image.GetType());
|
||||||
format = Vulkan::LiverpoolToVK::SurfaceFormat(image.GetDataFmt(), image.GetNumberFmt());
|
format = Vulkan::LiverpoolToVK::SurfaceFormat(image.GetDataFmt(), image.GetNumberFmt());
|
||||||
range.base.level = 0;
|
range.base.level = static_cast<u32>(image.base_level);
|
||||||
range.base.layer = 0;
|
range.base.layer = static_cast<u32>(image.base_array);
|
||||||
range.extent.levels = image.NumLevels();
|
range.extent.levels = image.NumLevels();
|
||||||
range.extent.layers = image.NumLayers();
|
range.extent.layers = image.NumLayers();
|
||||||
if (!is_storage) {
|
if (!is_storage) {
|
||||||
|
@ -95,7 +95,7 @@ ImageView::ImageView(const Vulkan::Instance& instance, const ImageViewInfo& info
|
||||||
.aspectMask = aspect,
|
.aspectMask = aspect,
|
||||||
.baseMipLevel = 0U,
|
.baseMipLevel = 0U,
|
||||||
.levelCount = 1,
|
.levelCount = 1,
|
||||||
.baseArrayLayer = 0,
|
.baseArrayLayer = info_.range.base.layer,
|
||||||
.layerCount = image.info.IsBlockCoded() ? 1 : VK_REMAINING_ARRAY_LAYERS,
|
.layerCount = image.info.IsBlockCoded() ? 1 : VK_REMAINING_ARRAY_LAYERS,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -45,15 +45,15 @@ struct SubresourceLayers {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SubresourceBase {
|
struct SubresourceBase {
|
||||||
s32 level = 0;
|
u32 level = 0;
|
||||||
s32 layer = 0;
|
u32 layer = 0;
|
||||||
|
|
||||||
auto operator<=>(const SubresourceBase&) const = default;
|
auto operator<=>(const SubresourceBase&) const = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SubresourceExtent {
|
struct SubresourceExtent {
|
||||||
s32 levels = 1;
|
u32 levels = 1;
|
||||||
s32 layers = 1;
|
u32 layers = 1;
|
||||||
|
|
||||||
auto operator<=>(const SubresourceExtent&) const = default;
|
auto operator<=>(const SubresourceExtent&) const = default;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue