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

Comparing projects/libstatgrab/src/libstatgrab/disk_stats.c (file contents):
Revision 1.80 by tdb, Thu Feb 24 12:34:45 2005 UTC vs.
Revision 1.81 by ats, Wed Apr 13 11:50:31 2005 UTC

# Line 338 | Line 338 | sg_disk_io_stats *sg_get_disk_io_stats(int *entries){
338          int i, n;
339          time_t now;
340          const char *format;
341 +        static regex_t not_part_re, part_re;
342 +        static int re_compiled = 0;
343   #endif
344   #if defined(FREEBSD) || defined(DFBSD)
345          static struct statinfo stats;
# Line 699 | Line 701 | sg_disk_io_stats *sg_get_disk_io_stats(int *entries){
701          if (f == NULL) goto out;
702          now = time(NULL);
703  
704 +        if (!re_compiled) {
705 +                if (regcomp(&part_re, "^(.*/)?[^/]*[0-9]$", REG_EXTENDED | REG_NOSUB) != 0) {
706 +                        sg_set_error(SG_ERROR_PARSE, NULL);
707 +                        goto out;
708 +                }
709 +                if (regcomp(&not_part_re, "^(.*/)?[^/0-9]+[0-9]+d[0-9]+$", REG_EXTENDED | REG_NOSUB) != 0) {
710 +                        sg_set_error(SG_ERROR_PARSE, NULL);
711 +                        goto out;
712 +                }
713 +                re_compiled = 1;
714 +        }
715 +
716          while ((line_ptr = sg_f_read_line(f, "")) != NULL) {
717                  char name[100];
704                char *s;
718                  long long rsect, wsect;
719  
720                  int nr = sscanf(line_ptr, format,
# Line 709 | Line 722 | sg_disk_io_stats *sg_get_disk_io_stats(int *entries){
722                  if (nr < 3) continue;
723  
724                  /* Skip device names ending in numbers, since they're
725 <                   partitions. */
726 <                s = name;
727 <                while (*s != '\0') s++;
728 <                --s;
729 <                if (*s >= '0' && *s <= '9') continue;
725 >                   partitions, unless they match the c0d0 pattern that some
726 >                   RAID devices use. */
727 >                /* FIXME: For 2.6+, we should probably be using sysfs to detect
728 >                   this... */
729 >                if ((regexec(&part_re, name, 0, NULL, 0) == 0)
730 >                    && (regexec(&not_part_re, name, 0, NULL, 0) != 0)) {
731 >                        continue;
732 >                }
733  
734                  if (nr < 5) {
735                          has_pp_stats = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines