btrfs-progs: add btrfs_clear_free_space_tree() from the kernel
[platform/upstream/btrfs-progs.git] / cmds-receive.c
index f4a3a4f..62a7985 100644 (file)
@@ -166,8 +166,18 @@ static int process_subvol(const char *path, const u8 *uuid, u64 ctransid,
        if (ret < 0)
                goto out;
 
-       BUG_ON(r->cur_subvol.path);
-       BUG_ON(r->cur_subvol_path[0]);
+       if (r->cur_subvol.path) {
+               error("subvol: another one already started, path ptr: %s",
+                               r->cur_subvol.path);
+               ret = -EINVAL;
+               goto out;
+       }
+       if (r->cur_subvol_path[0]) {
+               error("subvol: another one already started, path buf: %s",
+                               r->cur_subvol.path);
+               ret = -EINVAL;
+               goto out;
+       }
 
        if (*r->dest_dir_path == 0) {
                strncpy_null(r->cur_subvol_path, path);
@@ -224,8 +234,18 @@ static int process_snapshot(const char *path, const u8 *uuid, u64 ctransid,
        if (ret < 0)
                goto out;
 
-       BUG_ON(r->cur_subvol.path);
-       BUG_ON(r->cur_subvol_path[0]);
+       if (r->cur_subvol.path) {
+               error("snapshot: another one already started, path ptr: %s",
+                               r->cur_subvol.path);
+               ret = -EINVAL;
+               goto out;
+       }
+       if (r->cur_subvol_path[0]) {
+               error("snapshot: another one already started, path buf: %s",
+                               r->cur_subvol.path);
+               ret = -EINVAL;
+               goto out;
+       }
 
        if (*r->dest_dir_path == 0) {
                strncpy_null(r->cur_subvol_path, path);
@@ -1086,11 +1106,8 @@ static int do_receive(struct btrfs_receive *r, const char *tomnt,
         * subvols we want to receive in.
         */
        ret = btrfs_list_get_path_rootid(r->mnt_fd, &subvol_id);
-       if (ret) {
-               error("cannot resolve our subvolid: %d",
-                       ret);
+       if (ret)
                goto out;
-       }
 
        root_subvol_path[0] = 0;
        ret = btrfs_subvolid_resolve(r->mnt_fd, root_subvol_path,