mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-28 00:35:47 +00:00
Merge pull request #9008 from verusferro/feat/libkernel-sys-fstat
feat(libkernel_sys): implement fstat
This commit is contained in:
3 files changed
+15
-5
No files matched your search
@@ -98,11 +98,6 @@ int APS5_VABI fchownat_nid_postfix(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI fstat_nid_postfix(void) {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI futimesat_nid_postfix(void) {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
|
||||
@@ -274,6 +274,12 @@ int APS5_VABI fstatfs_nid_postfix(int d, void* buf) {
|
||||
return _fstatfs_nid_postfix(d, buf);
|
||||
}
|
||||
|
||||
std::int64_t APS5_VABI _fstat_nid_postfix(int d, FileStat* sb);
|
||||
|
||||
int APS5_VABI fstat_nid_postfix(int d, FileStat* sb) {
|
||||
return static_cast<int>(_fstat_nid_postfix(d, sb));
|
||||
}
|
||||
|
||||
std::int64_t APS5_VABI readlink_nid_postfix(const char* path, char* buffer, std::size_t size) {
|
||||
if (size > static_cast<std::size_t>(std::numeric_limits<std::int64_t>::max())) return Fail(GuestEinval);
|
||||
if (path == nullptr) return Fail(GuestEfault);
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
extern "C" {
|
||||
int APS5_VABI fstatfs_nid_postfix(int, void*);
|
||||
int APS5_VABI _fstatfs_nid_postfix(int, void*);
|
||||
int APS5_VABI fstat_nid_postfix(int, FileStat*);
|
||||
std::int64_t APS5_VABI _fstat_nid_postfix(int, FileStat*);
|
||||
int APS5_VABI open_nid_postfix(const char*, int, int);
|
||||
int APS5_VABI close_nid_postfix(int);
|
||||
int APS5_VABI pipe_nid_postfix(int*);
|
||||
@@ -286,8 +288,15 @@ int main() {
|
||||
Require(std::memcmp(viaPublic, viaSyscall, 4) == 0 && std::memcmp(viaPublic + 16, viaSyscall + 16, 8) == 0);
|
||||
Require(std::memcmp(viaPublic + 280, viaSyscall + 280, 16) == 0);
|
||||
Require(fstatfs_nid_postfix(descriptor, nullptr) == -1 && Error() == 14);
|
||||
FileStat viaFstat{};
|
||||
FileStat viaUnderscore{};
|
||||
Require(fstat_nid_postfix(descriptor, &viaFstat) == 0 && _fstat_nid_postfix(descriptor, &viaUnderscore) == 0);
|
||||
Require(std::memcmp(&viaFstat, &viaUnderscore, sizeof(FileStat)) == 0 && viaFstat.st_size == 1);
|
||||
Require(fstat_nid_postfix(descriptor, nullptr) == -1 && Error() == 14);
|
||||
Require(close_nid_postfix(descriptor) == 0);
|
||||
Require(fstatfs_nid_postfix(-1, viaPublic) == -1 && Error() == 9);
|
||||
Require(fstat_nid_postfix(descriptor, &viaFstat) == -1 && Error() == 9);
|
||||
Require(fstat_nid_postfix(-1, &viaFstat) == -1 && Error() == 9);
|
||||
char buffer[64];
|
||||
for (const auto& component : {std::string("missing"), std::string("file.txt")}) {
|
||||
const auto prefix = root.generic_string() + "/" + component + "/../";
|
||||
|
||||
Reference in new issue
Block a user