aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2023-01-24 12:47:32 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2023-01-24 12:47:32 +0100
commitc2739e11dee92770839ac9b2dbf020459baec7b9 (patch)
treee0bffef46052206f0f04d2b7aeee2e826c92b45e
parent1040f78176c7dad57aadbbd023e8ac094606ac25 (diff)
downloadbusybox-w32-c2739e11dee92770839ac9b2dbf020459baec7b9.tar.gz
busybox-w32-c2739e11dee92770839ac9b2dbf020459baec7b9.tar.bz2
busybox-w32-c2739e11dee92770839ac9b2dbf020459baec7b9.zip
nmeter: increase maximum /proc file size (needed for large machines)
function old new delta get_file 185 201 +16 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--procps/nmeter.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/procps/nmeter.c b/procps/nmeter.c
index 68e6f3325..e52c868df 100644
--- a/procps/nmeter.c
+++ b/procps/nmeter.c
@@ -59,9 +59,9 @@
59 59
60typedef unsigned long long ullong; 60typedef unsigned long long ullong;
61 61
62enum { /* Preferably use powers of 2 */ 62enum {
63 PROC_MIN_FILE_SIZE = 256, 63 PROC_MIN_FILE_SIZE = 256,
64 PROC_MAX_FILE_SIZE = 16 * 1024, 64 PROC_MAX_FILE_SIZE = 64 * 1024, /* 16k was a bit too small for a 128-CPU machine */
65}; 65};
66 66
67typedef struct proc_file { 67typedef struct proc_file {
@@ -176,7 +176,10 @@ static void readfile_z(proc_file *pf, const char* fname)
176 close(fd); 176 close(fd);
177 if (rdsz > 0) { 177 if (rdsz > 0) {
178 if (rdsz == sz-1 && sz < PROC_MAX_FILE_SIZE) { 178 if (rdsz == sz-1 && sz < PROC_MAX_FILE_SIZE) {
179 sz *= 2; 179 if (sz < 4 * 1024)
180 sz *= 2;
181 else
182 sz += 4 * 1024;
180 buf = xrealloc(buf, sz); 183 buf = xrealloc(buf, sz);
181 goto again; 184 goto again;
182 } 185 }