#include "libbcachefs/opts.h"
#include "cmds.h"
-
-static inline int printf_pad(unsigned pad, const char * fmt, ...)
-{
- va_list args;
- int ret;
-
- va_start(args, fmt);
- ret = vprintf(fmt, args);
- va_end(args);
-
- while (ret++ < pad)
- putchar(' ');
-
- return ret;
-}
+#include "libbcachefs.h"
static void print_fs_usage(const char *path, enum units units)
{
- unsigned i, j, nr_devices = 4;
- struct bcache_handle fs = bcache_fs_open(path);
- struct bch_ioctl_usage *u = NULL;
+ unsigned i, j;
char uuid[40];
- while (1) {
- u = xrealloc(u, sizeof(*u) + sizeof(u->devs[0]) * nr_devices);
- u->nr_devices = nr_devices;
-
- if (!ioctl(fs.ioctl_fd, BCH_IOCTL_USAGE, u))
- break;
- if (errno != ENOSPC)
- die("BCH_IOCTL_USAGE error: %m");
- nr_devices *= 2;
- }
+ struct bchfs_handle fs = bcache_fs_open(path);
+ struct bch_ioctl_usage *u = bchu_usage(fs);
uuid_unparse(fs.uuid.b, uuid);
printf("Filesystem %s:\n", uuid);
int cmd_fs_usage(int argc, char *argv[])
{
enum units units = BYTES;
- unsigned i;
+ char *fs;
int opt;
while ((opt = getopt(argc, argv, "h")) != -1)
units = HUMAN_READABLE;
break;
}
+ args_shift(optind);
- if (argc - optind < 1) {
+ if (!argc) {
print_fs_usage(".", units);
} else {
- for (i = optind; i < argc; i++)
- print_fs_usage(argv[i], units);
+ while ((fs = arg_pop()))
+ print_fs_usage(fs, units);
}
return 0;