btrfs-progs: fi usage: print ratio of used/total for each chunk type

This is based on idea from Stanislaw Gruszka to print the ratio,
originally suggested for the 'fi df', but we don't want to add new
things there and let people use 'fi us' instead. The new output fits
there and is printed by default without options:

Example output:

  $ btrfs fi us /mnt
  [...]

  Data,single: Size:339.00GiB, Used:172.05GiB (50.75%)

  Metadata,single: Size:7.00GiB, Used:3.41GiB (48.70%)

  System,single: Size:32.00MiB, Used:64.00KiB (0.20%)

Signed-off-by: David Sterba <dsterba@suse.com>
master
David Sterba 2019-11-19 19:06:55 +01:00
parent a855c63625
commit ca210687f8
1 changed files with 4 additions and 2 deletions

View File

@ -932,8 +932,10 @@ static void _cmd_filesystem_usage_linear(unsigned unit_mode,
r_mode,
pretty_size_mode(sargs->spaces[i].total_bytes,
unit_mode));
printf("Used:%s\n",
pretty_size_mode(sargs->spaces[i].used_bytes, unit_mode));
printf("Used:%s (%.2f%%)\n",
pretty_size_mode(sargs->spaces[i].used_bytes, unit_mode),
100.0f * sargs->spaces[i].used_bytes /
(sargs->spaces[i].total_bytes + 1));
print_chunk_device(flags, info_ptr, info_count,
device_info_ptr, device_info_count, unit_mode);
printf("\n");