X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=diskutil.c;h=cb285cffb31d3137421518dbba6c5c42e14e1bbf;hb=111558579a2f1965ff3f6a67ecb8ee4b596a4f88;hp=d97c5ca15e183c364d58bbac94a880396d67bb8a;hpb=a3b4cf7dcae447729f0f4a4ea122f605b909ed70;p=fio.git diff --git a/diskutil.c b/diskutil.c index d97c5ca1..cb285cff 100644 --- a/diskutil.c +++ b/diskutil.c @@ -6,6 +6,7 @@ #include #include #include +#include #include "fio.h" #include "smalloc.h" @@ -299,7 +300,7 @@ static struct disk_util *disk_util_add(struct thread_data *td, int majdev, 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; @@ -686,12 +687,15 @@ void show_disk_util(int terse, struct json_object *parent) 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);