aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2025-09-06 14:52:34 +0100
committerRon Yorston <rmy@pobox.com>2025-09-06 14:52:34 +0100
commit01fbdbf4b48cedf0869e010ef5ccb817d6677e42 (patch)
treec7a7819b76621b206d3d3aaf0b7ceb08d02ca853 /libbb
parentd8086da8bfbf76b9910d04e3e7f646ebc7f4b593 (diff)
parent53b3854e8141f4fc5fad10f180fc4fac2feee954 (diff)
downloadbusybox-w32-01fbdbf4b48cedf0869e010ef5ccb817d6677e42.tar.gz
busybox-w32-01fbdbf4b48cedf0869e010ef5ccb817d6677e42.tar.bz2
busybox-w32-01fbdbf4b48cedf0869e010ef5ccb817d6677e42.zip
Merge branch 'busybox' into merge
Diffstat (limited to 'libbb')
-rw-r--r--libbb/procps.c37
1 files changed, 22 insertions, 15 deletions
diff --git a/libbb/procps.c b/libbb/procps.c
index c751100bc..dfea8af6b 100644
--- a/libbb/procps.c
+++ b/libbb/procps.c
@@ -196,7 +196,7 @@ static NOINLINE void procps_read_smaps(pid_t pid, procps_status_t *sp)
196 196
197 FILE *file; 197 FILE *file;
198 char filename[sizeof("/proc/%u/smaps") + sizeof(int)*3]; 198 char filename[sizeof("/proc/%u/smaps") + sizeof(int)*3];
199 char buf[PROCPS_BUFSIZE]; 199 char buf[PROCPS_BUFSIZE] ALIGN4;
200 200
201 sprintf(filename, "/proc/%u/smaps", (int)pid); 201 sprintf(filename, "/proc/%u/smaps", (int)pid);
202 202
@@ -212,27 +212,34 @@ static NOINLINE void procps_read_smaps(pid_t pid, procps_status_t *sp)
212 // ..... 212 // .....
213 213
214 char *tp; 214 char *tp;
215 215#define bytes4 *(uint32_t*)buf
216 if (buf[0] == 'S' || buf[0] == 'P') { 216#define Priv PACK32_BYTES('P','r','i','v')
217#define Shar PACK32_BYTES('S','h','a','r')
217#define SCAN(S, X) \ 218#define SCAN(S, X) \
218 if (memcmp(buf, S, sizeof(S)-1) == 0) { \ 219if (memcmp(buf+4, S, sizeof(S)-1) == 0) { \
219 tp = skip_whitespace(buf + sizeof(S)-1); \ 220 tp = skip_whitespace(buf+4 + sizeof(S)-1); \
220 sp->X += fast_strtoul_10(&tp); \ 221 sp->X += fast_strtoul_10(&tp); \
221 continue; \ 222 continue; \
222 } 223}
223 SCAN("Private_Dirty:", private_dirty) 224 if (bytes4 == Priv) {
224 SCAN("Private_Clean:", private_clean) 225 SCAN("ate_Dirty:", private_dirty)
225 SCAN("Shared_Dirty:" , shared_dirty ) 226 SCAN("ate_Clean:", private_clean)
226 SCAN("Shared_Clean:" , shared_clean ) 227 }
227#undef SCAN 228 if (bytes4 == Shar) {
229 SCAN("ed_Dirty:" , shared_dirty )
230 SCAN("ed_Clean:" , shared_clean )
228 } 231 }
232#undef bytes4
233#undef Priv
234#undef Shar
235#undef SCAN
229 tp = strchr(buf, '-'); 236 tp = strchr(buf, '-');
230 if (tp) { 237 if (tp) {
231 // We reached next mapping - the line of this form: 238 // We reached next mapping - the line of this form:
232 // f7d29000-f7d39000 rw-s FILEOFS M:m INODE FILENAME 239 // f7d29000-f7d39000 rw-s FILEOFS M:m INODE FILENAME
233 240
234 char *rwx; 241 char *rwx;
235 unsigned long sz; 242 unsigned long long sz;
236 243
237 *tp = ' '; 244 *tp = ' ';
238 tp = buf; 245 tp = buf;
@@ -579,7 +586,7 @@ int FAST_FUNC read_cmdline(char *buf, int col, unsigned pid, const char *comm)
579 */ 586 */
580 while (sz >= 0) { 587 while (sz >= 0) {
581 if ((unsigned char)(buf[sz]) < ' ') 588 if ((unsigned char)(buf[sz]) < ' ')
582 buf[sz] = ' '; 589 buf[sz] = (buf[sz] ? /*ctrl*/'?' : /*NUL*/' ');
583 sz--; 590 sz--;
584 } 591 }
585 592