From 888b7005ca03316ac930ad762fa86b04d9f28a5a Mon Sep 17 00:00:00 2001 From: Ilya Dryomov Date: Fri, 3 Feb 2012 21:02:30 +0200 Subject: Btrfs-progs: add 'balance' command group infrastructure Add balance command group under both 'btrfs' and 'btrfs filesystem'. Preserve the old 'btrfs filesystem balance ' behaviour. Signed-off-by: Ilya Dryomov --- cmds-filesystem.c | 38 +------------------------------------- 1 file changed, 1 insertion(+), 37 deletions(-) (limited to 'cmds-filesystem.c') diff --git a/cmds-filesystem.c b/cmds-filesystem.c index 828ca0c7..a2efb938 100644 --- a/cmds-filesystem.c +++ b/cmds-filesystem.c @@ -453,42 +453,6 @@ static int cmd_defrag(int argc, char **argv) return errors + 20; } -static const char * const cmd_balance_usage[] = { - "btrfs filesystem balance ", - "Balance the chunks across the device", - NULL -}; - -static int cmd_balance(int argc, char **argv) -{ - int fdmnt, ret=0, e; - struct btrfs_ioctl_vol_args args; - char *path; - - if (check_argc_exact(argc, 2)) - usage(cmd_balance_usage); - - path = argv[1]; - - fdmnt = open_file_or_dir(path); - if (fdmnt < 0) { - fprintf(stderr, "ERROR: can't access to '%s'\n", path); - return 12; - } - - memset(&args, 0, sizeof(args)); - ret = ioctl(fdmnt, BTRFS_IOC_BALANCE, &args); - e = errno; - close(fdmnt); - if(ret<0){ - fprintf(stderr, "ERROR: error during balancing '%s' - %s\n", - path, strerror(e)); - - return 19; - } - return 0; -} - static const char * const cmd_resize_usage[] = { "btrfs filesystem resize [+/-][gkm]|max ", "Resize a filesystem", @@ -559,7 +523,7 @@ const struct cmd_group filesystem_cmd_group = { { "show", cmd_show, cmd_show_usage, NULL, 0 }, { "sync", cmd_sync, cmd_sync_usage, NULL, 0 }, { "defragment", cmd_defrag, cmd_defrag_usage, NULL, 0 }, - { "balance", cmd_balance, cmd_balance_usage, NULL, 0 }, + { "balance", cmd_balance, NULL, &balance_cmd_group, 1 }, { "resize", cmd_resize, cmd_resize_usage, NULL, 0 }, { "label", cmd_label, cmd_label_usage, NULL, 0 }, { 0, 0, 0, 0, 0 }, -- cgit v1.2.3