#include <dirent.h>
#include <libgen.h>
#include <math.h>
+#include <assert.h>
#include "fio.h"
#include "smalloc.h"
sfree(du);
return NULL;
}
- strncpy((char *) du->dus.name, basename(path) - 1, FIO_DU_NAME_SZ);
+ strncpy((char *) du->dus.name, basename(path), FIO_DU_NAME_SZ - 1);
du->sysfs_root = path;
du->major = majdev;
du->minor = mindev;
return;
}
- if (!terse && !parent)
+ if (output_format == FIO_OUTPUT_JSON)
+ assert(parent);
+
+ if (!terse && output_format != FIO_OUTPUT_JSON)
log_info("\nDisk stats (read/write):\n");
- if (output_format == FIO_OUTPUT_JSON) {
+ if (output_format == FIO_OUTPUT_JSON)
json_object_add_disk_utils(parent, &disk_list);
- } else
+ else
flist_for_each(entry, &disk_list) {
du = flist_entry(entry, struct disk_util, list);