summaryrefslogtreecommitdiff
path: root/utils.c
diff options
context:
space:
mode:
authorGoffredo Baroncelli <kreijack@libero.it>2010-12-20 20:06:19 +0000
committerChris Mason <chris.mason@oracle.com>2011-10-25 09:18:31 -0400
commit17cf679fb3622a9e3452777d07fcf3a346266ff1 (patch)
tree50b0745e40f8102f1e6e3b26eec3c5a865d3d42d /utils.c
parent0646719841433c015d849c197cd13be6f2cb31a3 (diff)
Improve error handling in the btrfs command
Hi Chris, below is enclosed a trivial patch, which has the aim to improve the error reporting of the "btrfs" command. You can pull from http://cassiopea.homelinux.net/git/btrfs-progs-unstable.git branch strerror I changed every printf("some-error") to something like: e = errno; fprintf(stderr, "ERROR: .... - %s", strerror(e)); so: 1) all the error are reported to standard error 2) At the end of the message is printed the error as returned by the system. The change is quite simple, I replaced every printf("some-error") to the line above. I don't touched anything other. I also integrated a missing "printf" on the basis of the Ben patch. This patch leads the btrfs command to be more "user friendly" :-) Regards G.Baroncelli btrfs-list.c | 40 ++++++++++++++++++++++-------- btrfs_cmds.c | 77 ++++++++++++++++++++++++++++++++++++++++----------------- utils.c | 6 ++++ 3 files changed, 89 insertions(+), 34 deletions(-) Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/utils.c b/utils.c
index d8c3dcc9..2a15d866 100644
--- a/utils.c
+++ b/utils.c
@@ -821,6 +821,7 @@ void btrfs_register_one_device(char *fname)
struct btrfs_ioctl_vol_args args;
int fd;
int ret;
+ int e;
fd = open("/dev/btrfs-control", O_RDONLY);
if (fd < 0) {
@@ -830,6 +831,11 @@ void btrfs_register_one_device(char *fname)
}
strncpy(args.name, fname, BTRFS_PATH_NAME_MAX);
ret = ioctl(fd, BTRFS_IOC_SCAN_DEV, &args);
+ e = errno;
+ if(ret<0){
+ fprintf(stderr, "ERROR: unable to scan the device '%s' - %s\n",
+ fname, strerror(e));
+ }
close(fd);
}