src/collectd.h: Use `#pragma GCC poison' to disable evil functions.
[collectd.git] / src / disk.c
index d2e9f98..536c511 100644 (file)
@@ -164,8 +164,8 @@ static void disk_submit (const char *plugin_instance,
        vl.values = values;
        vl.values_len = 2;
        vl.time = time (NULL);
-       strcpy (vl.host, hostname_g);
-       strcpy (vl.plugin, "disk");
+       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+       sstrncpy (vl.plugin, "disk", sizeof (vl.plugin));
        strncpy (vl.plugin_instance, plugin_instance,
                        sizeof (vl.plugin_instance));
 
@@ -403,7 +403,7 @@ static int disk_read (void)
                major = atoll (fields[0]);
                minor = atoll (fields[1]);
 
-               disk_name = fields[2];
+               disk_name = fields[2 + fieldshift];
 
                for (ds = disklist, pre_ds = disklist; ds != NULL; pre_ds = ds, ds = ds->next)
                        if (strcmp (disk_name, ds->name) == 0)
@@ -562,9 +562,8 @@ static int disk_read (void)
 
                if (is_disk)
                {
-                       if ((read_merged != -1LL) || (write_merged != -1LL))
-                               disk_submit (disk_name, "disk_merged",
-                                               read_merged, write_merged);
+                       disk_submit (disk_name, "disk_merged",
+                                       read_merged, write_merged);
                } /* if (is_disk) */
        } /* while (fgets (buffer, sizeof (buffer), fh) != NULL) */