diff options
author | Ilya Dryomov <idryomov@gmail.com> | 2012-02-03 21:02:30 +0200 |
---|---|---|
committer | Ilya Dryomov <idryomov@gmail.com> | 2012-02-03 21:02:30 +0200 |
commit | 888b7005ca03316ac930ad762fa86b04d9f28a5a (patch) | |
tree | 1bc67199f0e6d224c272885b4e3dc4cd31024bca /cmds-filesystem.c | |
parent | 4f3a15d09a4172f7c82ad943a944d86328fa504c (diff) | |
download | btrfs-progs-888b7005ca03316ac930ad762fa86b04d9f28a5a.tar.gz |
Btrfs-progs: add 'balance' command group infrastructure
Add balance command group under both 'btrfs' and 'btrfs filesystem'.
Preserve the old 'btrfs filesystem balance <path>' behaviour.
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Diffstat (limited to 'cmds-filesystem.c')
-rw-r--r-- | cmds-filesystem.c | 38 |
1 files changed, 1 insertions, 37 deletions
diff --git a/cmds-filesystem.c b/cmds-filesystem.c index 828ca0c..a2efb93 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 <path>", - "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 [+/-]<newsize>[gkm]|max <path>", "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 }, |