diff options
author | Anand Jain <anand.jain@oracle.com> | 2013-04-16 12:58:15 +0800 |
---|---|---|
committer | David Sterba <dsterba@suse.cz> | 2013-04-23 18:56:20 +0200 |
commit | 9b5a329c6cd9f89f0ed83300620581778b90d026 (patch) | |
tree | b861355fbd1a17f141f9779c19145ce55ea14374 | |
parent | 1c41ab9c4abff198806c4f54e0d3e3c30ee40188 (diff) |
btrfs-progs: no pending balance is not an error
Having no balance running/ paused/completed is a normal
situation, so the current output message should be positive
with return val zero.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
-rw-r--r-- | cmds-balance.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/cmds-balance.c b/cmds-balance.c index f5dc317f..cffa807a 100644 --- a/cmds-balance.c +++ b/cmds-balance.c @@ -616,6 +616,12 @@ static const char * const cmd_balance_status_usage[] = { NULL }; +/* Checks the status of the balance if any + * return codes: + * 2 : Error failed to know if there is any pending balance + * 1 : Successful to know status of a pending balance + * 0 : When there is no pending balance or completed + */ static int cmd_balance_status(int argc, char **argv) { struct btrfs_ioctl_balance_args args; @@ -654,7 +660,7 @@ static int cmd_balance_status(int argc, char **argv) fd = open_file_or_dir(path); if (fd < 0) { fprintf(stderr, "ERROR: can't access to '%s'\n", path); - return 12; + return 2; } ret = ioctl(fd, BTRFS_IOC_BALANCE_PROGRESS, &args); @@ -662,9 +668,13 @@ static int cmd_balance_status(int argc, char **argv) close(fd); if (ret < 0) { + if (e == ENOTCONN) { + printf("No balance found on '%s'\n", path); + return 0; + } fprintf(stderr, "ERROR: balance status on '%s' failed - %s\n", - path, (e == ENOTCONN) ? "Not in progress" : strerror(e)); - return 19; + path, strerror(e)); + return 2; } if (args.state & BTRFS_BALANCE_STATE_RUNNING) { @@ -688,7 +698,7 @@ static int cmd_balance_status(int argc, char **argv) if (verbose) dump_ioctl_balance_args(&args); - return 0; + return 1; } const struct cmd_group balance_cmd_group = { |