diff options
author | Benny Baumann <BenBE@geshi.org> | 2024-03-10 17:13:01 +0100 |
---|---|---|
committer | cgzones <cgzones@googlemail.com> | 2024-03-27 20:06:42 +0100 |
commit | e50b33d53795a5c8d95849347802e860deea55a6 (patch) | |
tree | f09b4c5be7747eb8b1b20882e90fab84293921b7 /linux | |
parent | 78c6aacfb50e602ea59db51fc19fe7c4cf370d7c (diff) |
Avoid glibc FILE API for number of open files
Diffstat (limited to 'linux')
-rw-r--r-- | linux/Platform.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/linux/Platform.c b/linux/Platform.c index a47918fe..59fe7056 100644 --- a/linux/Platform.c +++ b/linux/Platform.c @@ -589,21 +589,21 @@ void Platform_getPressureStall(const char* file, bool some, double* ten, double* } void Platform_getFileDescriptors(double* used, double* max) { + char buffer[128] = {0}; + *used = NAN; *max = 65536; - FILE* fd = fopen(PROCDIR "/sys/fs/file-nr", "r"); - if (!fd) + ssize_t fdread = xReadfile(PROCDIR "/sys/fs/file-nr", buffer, sizeof(buffer)); + if (fdread < 1) return; unsigned long long v1, v2, v3; - int total = fscanf(fd, "%llu %llu %llu", &v1, &v2, &v3); + int total = sscanf(buffer, "%llu %llu %llu", &v1, &v2, &v3); if (total == 3) { *used = v1; *max = v3; } - - fclose(fd); } bool Platform_getDiskIO(DiskIOData* data) { |