From b8e23d4fb268152447761a9855d0afc75065215f Mon Sep 17 00:00:00 2001 From: Anand Jain Date: Mon, 15 Jul 2013 13:30:53 +0800 Subject: btrfs-progs: device delete to get errors from the kernel when user runs command btrfs dev del the raid requisite error if any goes to the /var/log/messages, its not good idea to clutter messages with these user (knowledge) errors, further user don't have to review the system messages to know problem with the cli it should be dropped to the user as part of the cli return. to bring this feature created a set of the ERROR defined BTRFS_ERROR_DEV* error codes and created their error string. I expect this enum to be added with other error which we might want to communicate to the user land Signed-off-by: Anand Jain Signed-off-by: David Sterba Signed-off-by: Chris Mason --- cmds-device.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'cmds-device.c') diff --git a/cmds-device.c b/cmds-device.c index c1dc363a..be2aaff3 100644 --- a/cmds-device.c +++ b/cmds-device.c @@ -165,8 +165,14 @@ static int cmd_rm_dev(int argc, char **argv) strncpy_null(arg.name, argv[i]); res = ioctl(fdmnt, BTRFS_IOC_RM_DEV, &arg); e = errno; - if(res<0){ - fprintf(stderr, "ERROR: error removing the device '%s' - %s\n", + if (res > 0) { + fprintf(stderr, + "ERROR: error removing the device '%s' - %s\n", + argv[i], btrfs_err_str(res)); + ret++; + } else if (res < 0) { + fprintf(stderr, + "ERROR: error removing the device '%s' - %s\n", argv[i], strerror(e)); ret++; } -- cgit v1.2.3