@@ -382,6 +382,7 @@ long long now(void)
382382char * path = NULL ;
383383char * fstype = "" ;
384384char * device = "" ;
385+ off_t device_size = 0 ;
385386
386387int fd ;
387388void * buf ;
@@ -901,13 +902,9 @@ int main (int argc, char **argv)
901902 if (fd < 0 )
902903 err (2 , "failed to open \"%s\"" , path );
903904
904- st . st_size = get_device_size (fd , & st );
905-
905+ device_size = get_device_size (fd , & st );
906+ st . st_size = device_size ;
906907 fstype = "device" ;
907- device = malloc (32 );
908- if (!device )
909- err (2 , "no mem" );
910- snprintf (device , 32 , "%.1f Gb" , (double )st .st_size /(1ll <<30 ));
911908 } else {
912909 errx (2 , "unsupported destination: \"%s\"" , path );
913910 }
@@ -1008,8 +1005,10 @@ int main (int argc, char **argv)
10081005
10091006 if (!quiet ) {
10101007 print_size (ret_size );
1011- printf (" from %s (%s %s): request=%d time=" ,
1012- path , fstype , device , request );
1008+ printf (" from %s (%s %s" , path , fstype , device );
1009+ if (device_size )
1010+ print_size (device_size );
1011+ printf ("): request=%d time=" , request );
10131012 print_time (this_time );
10141013 printf ("\n" );
10151014 }
@@ -1079,8 +1078,10 @@ int main (int argc, char **argv)
10791078 time_min , time_avg ,
10801079 time_max , time_mdev );
10811080 } else if (!quiet || (!period_time && !period_request )) {
1082- printf ("\n--- %s (%s %s) ioping statistics ---\n" ,
1083- path , fstype , device );
1081+ printf ("\n--- %s (%s %s" , path , fstype , device );
1082+ if (device_size )
1083+ print_size (device_size );
1084+ printf (") ioping statistics ---\n" );
10841085 print_int (request );
10851086 printf (" requests completed in " );
10861087 print_time (time_total );
0 commit comments