Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions core/libs/prx/libkernel/System/src/SystemConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,10 @@ int APS5_VABI sysctlbyname_nid_postfix(const char* name, void* oldValue, std::si
static constexpr int mib[] = {1, 14, 12};
return sysctl_nid_postfix(mib, 3, oldValue, oldLength, newValue, newLength);
}
if (std::strcmp(name, "kern.proc.proc") == 0) {
static constexpr int mib[] = {1, 14, 8};
return sysctl_nid_postfix(mib, 3, oldValue, oldLength, newValue, newLength);
}
if (std::strcmp(name, "kern.boottime") == 0) {
static constexpr int mib[] = {1, 21};
return sysctl_nid_postfix(mib, 2, oldValue, oldLength, newValue, newLength);
Expand Down Expand Up @@ -803,6 +807,7 @@ int APS5_VABI sysctlnametomib_nid_postfix(const char* name, int* mib, std::size_
{"kern.maxfilesperproc", {1, 27}, 2},
{"kern.maxproc", {1, 6}, 2},
{"kern.proc.pathname", {1, 14, 12}, 3},
{"kern.proc.proc", {1, 14, 8}, 3},
{"kern.ps_strings", {1, 32}, 2},
{"kern.rng_pseudo", {1, 50}, 2},
{"vm.loadavg", {2, 2}, 2},
Expand Down
17 changes: 17 additions & 0 deletions core/libs/tests/GuestSystemConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,11 +352,20 @@ static void CheckProcessListSysctl() {
const int mib[] = {1, 14, 8};
std::size_t length = 0;
Require(sysctl_nid_postfix(mib, 3, nullptr, &length, nullptr, 0) == 0);
const std::size_t size = length;
*__error_nid_postfix() = 13;
length = 0;
Require(sysctlbyname_nid_postfix("kern.proc.proc", nullptr, &length, nullptr, 0) == 0 && length == size && *__error_nid_postfix() == 13);

unsigned char buffer[1100];
std::memset(buffer, 0xaa, sizeof(buffer));
length = sizeof(buffer);
Require(sysctl_nid_postfix(mib, 3, buffer, &length, nullptr, 0) == 0 && length == 1088);
unsigned char named[1100];
std::memset(named, 0xaa, sizeof(named));
length = sizeof(named);
Require(sysctlbyname_nid_postfix("kern.proc.proc", named, &length, nullptr, 0) == 0 && length == 1088 && *__error_nid_postfix() == 13);
Require(std::memcmp(named, buffer, sizeof(buffer)) == 0);
std::int32_t structSize = 0;
std::int32_t pid = 0;
std::memcpy(&structSize, buffer, sizeof(structSize));
Expand All @@ -377,6 +386,13 @@ static void CheckProcessListSysctl() {

length = sizeof(buffer);
Require(sysctl_nid_postfix(mib, 3, buffer, &length, buffer, sizeof(buffer)) == -1 && *__error_nid_postfix() == 1);

*__error_nid_postfix() = 13;
length = 100;
Require(sysctlbyname_nid_postfix("kern.proc.proc", buffer, &length, nullptr, 0) == -1 && *__error_nid_postfix() == 12 && length == 100);
*__error_nid_postfix() = 13;
length = sizeof(buffer);
Require(sysctlbyname_nid_postfix("kern.proc.proc", buffer, &length, buffer, sizeof(buffer)) == -1 && *__error_nid_postfix() == 1);
}
struct SystemString {
int mib[2];
Expand Down Expand Up @@ -970,6 +986,7 @@ static void CheckNameToMib() {
{"kern.boottime", {1, 21}, 2},
{"kern.rng_pseudo", {1, 50}, 2},
{"kern.proc.pathname", {1, 14, 12}, 3},
{"kern.proc.proc", {1, 14, 8}, 3},
};
*__error_nid_postfix() = 13;
for (const auto& entry : expected) {
Expand Down
Loading