@@ -61,6 +61,7 @@ static int cmd_device_add(const struct cmd_struct *cmd,
int discard = 1;
int force = 0;
int last_dev;
+ char exop[BTRFS_SYSFS_EXOP_SIZE];
optind = 0;
while (1) {
@@ -96,6 +97,12 @@ static int cmd_device_add(const struct cmd_struct *cmd,
if (fdmnt < 0)
return 1;
+ if (get_exclusive_operation(fdmnt, exop) > 0 && strcmp(exop, "none")) {
+ error("unable to add device: %s in progress", exop);
+ close_file_or_dir(fdmnt, dirstream);
+ return 1;
+ }
+
for (i = optind; i < last_dev; i++){
struct btrfs_ioctl_vol_args ioctl_args;
int devfd, res;
@@ -155,6 +162,7 @@ static int _cmd_device_remove(const struct cmd_struct *cmd,
char *mntpnt;
int i, fdmnt, ret = 0;
DIR *dirstream = NULL;
+ char exop[BTRFS_SYSFS_EXOP_SIZE];
clean_args_no_options(cmd, argc, argv);
@@ -167,6 +175,12 @@ static int _cmd_device_remove(const struct cmd_struct *cmd,
if (fdmnt < 0)
return 1;
+ if (get_exclusive_operation(fdmnt, exop) > 0 && strcmp(exop, "none")) {
+ error("unable to remove device: %s in progress", exop);
+ close_file_or_dir(fdmnt, dirstream);
+ return 1;
+ }
+
for(i = optind; i < argc - 1; i++) {
struct btrfs_ioctl_vol_args arg;
struct btrfs_ioctl_vol_args_v2 argv2 = {0};
@@ -1079,6 +1079,7 @@ static int cmd_filesystem_resize(const struct cmd_struct *cmd,
char *amount, *path;
DIR *dirstream = NULL;
struct stat st;
+ char exop[BTRFS_SYSFS_EXOP_SIZE];
clean_args_no_options_relaxed(cmd, argc, argv);
@@ -1110,6 +1111,12 @@ static int cmd_filesystem_resize(const struct cmd_struct *cmd,
if (fd < 0)
return 1;
+ if (get_exclusive_operation(fd, exop) > 0 && strcmp(exop, "none")) {
+ error("unable to resize: %s in progress", exop);
+ close_file_or_dir(fd, dirstream);
+ return 1;
+ }
+
printf("Resize '%s' of '%s'\n", path, amount);
memset(&args, 0, sizeof(args));
strncpy_null(args.name, amount);