268 |
|
if (disk != NULL) { |
269 |
|
for (i = 0; i < n; i++) { |
270 |
|
/* FIXME it'd be nicer if libstatgrab did this */ |
271 |
< |
const char *name = disk[i].device_name, |
272 |
< |
*p = strrchr(name, '/'); |
273 |
< |
if (p != NULL) |
274 |
< |
name = p + 1; |
275 |
< |
if (*name == '\0') |
276 |
< |
name = "root"; |
277 |
< |
|
271 |
> |
char *buf, *name, *p; |
272 |
> |
const char *device = disk[i].device_name; |
273 |
> |
|
274 |
> |
if (strcmp(device, "/") == 0) |
275 |
> |
device = "root"; |
276 |
> |
|
277 |
> |
buf = strdup(device); |
278 |
> |
if (buf == NULL) |
279 |
> |
die("out of memory"); |
280 |
> |
|
281 |
> |
name = buf; |
282 |
> |
if (strncmp(name, "/dev/", 5) == 0) |
283 |
> |
name += 5; |
284 |
> |
while ((p = strchr(name, '/')) != NULL) |
285 |
> |
*p = '_'; |
286 |
> |
|
287 |
|
add_stat(STRING, &disk[i].device_name, |
288 |
|
"fs", name, "device_name", NULL); |
289 |
|
add_stat(STRING, &disk[i].fs_type, |
302 |
|
"fs", name, "used_inodes", NULL); |
303 |
|
add_stat(LONG_LONG, &disk[i].free_inodes, |
304 |
|
"fs", name, "free_inodes", NULL); |
305 |
+ |
|
306 |
+ |
free(buf); |
307 |
|
} |
308 |
|
} |
309 |
|
} |
369 |
|
if (page != NULL) { |
370 |
|
add_stat(LONG_LONG, &page->pages_pagein, "page", "in", NULL); |
371 |
|
add_stat(LONG_LONG, &page->pages_pageout, "page", "out", NULL); |
372 |
< |
add_stat(LONG_LONG, &page->systime, "page", "systime", NULL); |
372 |
> |
add_stat(TIME_T, &page->systime, "page", "systime", NULL); |
373 |
|
} |
374 |
|
} |
375 |
|
|
602 |
|
use_diffs = 1; |
603 |
|
|
604 |
|
select_interesting(argc - optind, &argv[optind]); |
605 |
+ |
|
606 |
+ |
/* We don't care if statgrab_init fails, because we can just display |
607 |
+ |
the statistics that can be read as non-root. */ |
608 |
+ |
statgrab_init(); |
609 |
+ |
#ifdef ALLBSD |
610 |
+ |
if (setegid(getgid()) != 0) |
611 |
+ |
die("Failed to lose effective group"); |
612 |
+ |
#endif |
613 |
|
|
614 |
|
switch (repeat_mode) { |
615 |
|
case REPEAT_NONE: |