Fix device name parsing for diskio variables.
[monky] / src / diskio.c
index de49f1d..d9b2f3f 100644 (file)
@@ -10,7 +10,7 @@
  * Please see COPYING for details
  *
  * Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
- * Copyright (c) 2005-2009 Brenden Matthews, Philip Kovacs, et. al.
+ * Copyright (c) 2005-2010 Brenden Matthews, Philip Kovacs, et. al.
  * (see AUTHORS)
  * All rights reserved.
  *
@@ -76,12 +76,6 @@ struct diskio_stat *prepare_diskio_stat(const char *s)
        if (!s)
                return &stats;
 
-#if defined(__FreeBSD__)
-       if (strncmp(s, "/dev/", 5) == 0) {
-               // supplied a /dev/device arg, so cut off the /dev part
-               strncpy(device_name, s + 5, text_buffer_size);
-       } else
-#endif
        strncpy(device_name, s, text_buffer_size);
 
        snprintf(stat_name, text_buffer_size, "/dev/%s", device_name);
@@ -129,7 +123,7 @@ static void print_diskio_dir(struct text_object *obj, int dir, char *p, int p_ma
 
        if (dir < 0)
                val = diskio->current_read;
-       if (dir == 0)
+       else if (dir == 0)
                val = diskio->current;
        else
                val = diskio->current_write;
@@ -214,7 +208,7 @@ void update_diskio_values(struct diskio_stat *ds,
                ds->last_read = reads;
                ds->last_write = writes;
        }
-       /* since the values in /proc/diskstats are absolute, we have to substract
+       /* since the values in /proc/diskstats are absolute, we have to subtract
         * our last reading. The numbers stand for "sectors read", and we therefore
         * have to divide by two to get KB */
        ds->sample_read[0] = (reads - ds->last_read) / 2;