forked from Mirrors/btrfs-progs
btrfs-progs: improve troubleshooting avoid duplicate error strings
my troubleshooting experience says have unique error string per module. In the below eg, its one additional step to know error line, cat -n cmds-device.c | egrep "error removing the device" 185 "ERROR: error removing the device '%s' - %s\n", 190 "ERROR: error removing the device '%s' - %s\n", which is completely avoidable. Signed-off-by: Anand Jain <anand.jain@oracle.com> [merged the two messages into one] Signed-off-by: David Sterba <dsterba@suse.cz>master
parent
672076d4b7
commit
32ca2fa502
|
@ -180,15 +180,16 @@ static int cmd_rm_dev(int argc, char **argv)
|
||||||
strncpy_null(arg.name, argv[i]);
|
strncpy_null(arg.name, argv[i]);
|
||||||
res = ioctl(fdmnt, BTRFS_IOC_RM_DEV, &arg);
|
res = ioctl(fdmnt, BTRFS_IOC_RM_DEV, &arg);
|
||||||
e = errno;
|
e = errno;
|
||||||
if (res > 0) {
|
if (res) {
|
||||||
|
const char *msg;
|
||||||
|
|
||||||
|
if (ret > 0)
|
||||||
|
msg = btrfs_err_str(res);
|
||||||
|
else
|
||||||
|
msg = strerror(e);
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"ERROR: error removing the device '%s' - %s\n",
|
"ERROR: error removing the device '%s' - %s\n",
|
||||||
argv[i], btrfs_err_str(res));
|
argv[i], msg);
|
||||||
ret++;
|
|
||||||
} else if (res < 0) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"ERROR: error removing the device '%s' - %s\n",
|
|
||||||
argv[i], strerror(e));
|
|
||||||
ret++;
|
ret++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue