ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/src/statgrab/statgrab.c
(Generate patch)

Comparing projects/libstatgrab/src/statgrab/statgrab.c (file contents):
Revision 1.9 by ats, Sun Aug 31 13:23:19 2003 UTC vs.
Revision 1.13 by ats, Mon Nov 10 23:35:43 2003 UTC

# Line 268 | Line 268 | void populate_fs() {
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 (strlen(name) == 2 && name[1] == ':')
283 >                                name[1] = '\0';
284 >                        if (strncmp(name, "/dev/", 5) == 0)
285 >                                name += 5;
286 >                        while ((p = strchr(name, '/')) != NULL)
287 >                                *p = '_';
288 >
289                          add_stat(STRING, &disk[i].device_name,
290                                   "fs", name, "device_name", NULL);
291                          add_stat(STRING, &disk[i].fs_type,
# Line 293 | Line 304 | void populate_fs() {
304                                   "fs", name, "used_inodes", NULL);
305                          add_stat(LONG_LONG, &disk[i].free_inodes,
306                                   "fs", name, "free_inodes", NULL);
307 +
308 +                        free(buf);
309                  }
310          }
311   }
# Line 358 | Line 371 | void populate_page() {
371          if (page != NULL) {
372                  add_stat(LONG_LONG, &page->pages_pagein, "page", "in", NULL);
373                  add_stat(LONG_LONG, &page->pages_pageout, "page", "out", NULL);
374 <                add_stat(LONG_LONG, &page->systime, "page", "systime", NULL);
374 >                add_stat(TIME_T, &page->systime, "page", "systime", NULL);
375          }
376   }
377  
# Line 591 | Line 604 | int main(int argc, char **argv) {
604                  use_diffs = 1;
605  
606          select_interesting(argc - optind, &argv[optind]);
607 +
608 +        /* We don't care if statgrab_init fails, because we can just display
609 +           the statistics that can be read as non-root. */
610 +        statgrab_init();
611 + #ifdef ALLBSD
612 +        if (setegid(getgid()) != 0)
613 +                die("Failed to lose effective group");
614 + #endif
615  
616          switch (repeat_mode) {
617          case REPEAT_NONE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines