add another parameter to the ioctl arg structure to carry the error string
Signed-off-by: Anand Jain <anand.jain@xxxxxxxxxx>
---
cmds-device.c | 13 +++++++++----
ioctl.h | 9 ++++++++-
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/cmds-device.c b/cmds-device.c
index 41e79d3..3cf96db 100644
--- a/cmds-device.c
+++ b/cmds-device.c
@@ -157,15 +157,20 @@ static int cmd_rm_dev(int argc, char **argv)
}
for(i=1 ; i < argc - 1; i++ ){
- struct btrfs_ioctl_vol_args arg;
+ struct btrfs_ioctl_dev_args arg;
int res;
+ memset(&arg, 0, sizeof(arg));
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",
- argv[i], strerror(e));
+ if (res < 0) {
+ if (strlen(arg.ret_err_str))
+ fprintf(stderr, "ERROR: error removing the device '%s' - %s\n",
+ argv[i], arg.ret_err_str);
+ else
+ fprintf(stderr, "ERROR: error removing the device '%s' - %s\n",
+ argv[i], strerror(e));
ret++;
}
}
diff --git a/ioctl.h b/ioctl.h
index 1ee631a..b55bcb7 100644
--- a/ioctl.h
+++ b/ioctl.h
@@ -36,6 +36,13 @@ struct btrfs_ioctl_vol_args {
char name[BTRFS_PATH_NAME_MAX + 1];
};
+#define BTRFS_IOCTL_ERR_LEN 256
+struct btrfs_ioctl_dev_args {
+ __s64 fd;
+ char name[BTRFS_PATH_NAME_MAX + 1];
+ char ret_err_str[BTRFS_IOCTL_ERR_LEN];
+};
+
#define BTRFS_DEVICE_PATH_NAME_MAX 1024
#define BTRFS_SUBVOL_CREATE_ASYNC (1ULL << 0)
@@ -467,7 +474,7 @@ struct btrfs_ioctl_clone_range_args {
#define BTRFS_IOC_CLONE _IOW(BTRFS_IOCTL_MAGIC, 9, int)
#define BTRFS_IOC_ADD_DEV _IOW(BTRFS_IOCTL_MAGIC, 10, \
struct btrfs_ioctl_vol_args)
-#define BTRFS_IOC_RM_DEV _IOW(BTRFS_IOCTL_MAGIC, 11, \
+#define BTRFS_IOC_RM_DEV _IOWR(BTRFS_IOCTL_MAGIC, 11, \
struct btrfs_ioctl_vol_args)
#define BTRFS_IOC_BALANCE _IOW(BTRFS_IOCTL_MAGIC, 12, \
struct btrfs_ioctl_vol_args)
--
1.8.1.227.g44fe835
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html