Files
David ea7ea289d2 refactor(libSceLibcInternal): share the statvfs layout and its conversion
fstatvfs kept the guest struct statvfs and the sfs2svfs conversion from
the kernel's statfs to itself. Both move to include/Statvfs.hpp so that
statvfs can convert a volume the same way without opening the path.
Nothing changes for fstatvfs.
2026-10-16 07:24:08 +04:00

23 lines
751 B
C++

#include "prx/libc/include/general/VabiMacros.hpp"
#include "prx/libSceLibcInternal/include/Statvfs.hpp"
#include <cstring>
extern "C" int APS5_VABI _fstatfs_nid_postfix(int, KernelStatfs*);
extern "C" int* APS5_VABI __error_nid_postfix();
extern "C" int APS5_VABI fstatvfs_nid_postfix(int descriptor, LibcStatvfs* output) {
int* const error = __error_nid_postfix();
const int saved = *error;
KernelStatfs volume{};
const int status = _fstatfs_nid_postfix(descriptor, &volume);
if (status != 0) return status;
if (output == nullptr) {
*error = 14;
return -1;
}
const LibcStatvfs result = StatvfsFromStatfs(volume);
std::memcpy(output, &result, sizeof(result));
*error = saved;
return 0;
}