===================================================================
@@ -87,9 +87,10 @@
"Show the info of a btrfs filesystem. If no <uuid> or <label>\n"
"is passed, info of all the btrfs filesystem are shown."
},
- { do_df_filesystem, 1,
- "filesystem df", "<path>\n"
+ { do_df_filesystem, -1,
+ "filesystem df", "[-r|-b|-i] <path>\n"
"Show space usage information for a mount point\n."
+ "-r, -b, -i for raw (bytes), binary or ISO sizes."
},
{ do_balance, 1,
"filesystem balance", "<path>\n"
===================================================================
@@ -841,7 +841,36 @@
u64 count = 0, i;
int ret;
int fd;
- char *path = argv[1];
+ char *path;
+ int format = PRETTY_SIZE_BINARY;
+
+ optind = 1;
+ while(1) {
+ int c = getopt(nargs, argv, "rbi");
+ if (c < 0)
+ break;
+ switch(c) {
+ case 'r':
+ format = PRETTY_SIZE_RAW;
+ break;
+ case 'b':
+ format = PRETTY_SIZE_BINARY;
+ break;
+ case 'i':
+ format = PRETTY_SIZE_ISO;
+ break;
+ default:
+ fprintf(stderr, "Invalid arguments for df\n");
+ free(argv);
+ return 1;
+ }
+ }
+ if (nargs - optind != 1) {
+ fprintf(stderr, "No path given for df\n");
+ free(argv);
+ return 1;
+ }
+ path = argv[optind];
fd = open_file_or_dir(path);
if (fd < 0) {
@@ -914,10 +943,8 @@
written += 8;
}
- total_bytes = pretty_sizes(sargs->spaces[i].total_bytes,
- PRETTY_SIZE_BINARY);
- used_bytes = pretty_sizes(sargs->spaces[i].used_bytes,
- PRETTY_SIZE_BINARY);
+ total_bytes = pretty_sizes(sargs->spaces[i].total_bytes, format);
+ used_bytes = pretty_sizes(sargs->spaces[i].used_bytes, format);
printf("%s: total=%s, used=%s\n", description, total_bytes,
used_bytes);
}