Skip to content

Commit

Permalink
btrfs: simplify
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
  • Loading branch information
Christian Brauner committed Jul 31, 2017
1 parent 7a9e0f3 commit 45dd65e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
5 changes: 0 additions & 5 deletions src/lxc/bdev/bdev.c
Expand Up @@ -441,11 +441,6 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
goto err;
}

if (mkdir_p(new->dest, 0755) < 0) {
ERROR("Failed to create directory \"%s\"", new->dest);
goto err;
}

arg.src = orig->dest;
arg.dest = new->dest;
if (am_unpriv())
Expand Down
17 changes: 15 additions & 2 deletions src/lxc/bdev/lxcbtrfs.c
Expand Up @@ -416,8 +416,19 @@ int btrfs_clonepaths(struct bdev *orig, struct bdev *new, const char *oldname,

if (snap) {
struct rsync_data_char sdata;
if (!am_unpriv())
return btrfs_snapshot(orig->dest, new->dest);
if (!am_unpriv()) {
ret = btrfs_snapshot(orig->dest, new->dest);
if (ret < 0) {
SYSERROR("Failed to create btrfs snapshot "
"\"%s\" from \"%s\"",
new->dest, orig->dest);
return -1;
}
TRACE("Created btrfs snapshot \"%s\" from \"%s\"",
new->dest, orig->dest);
return 0;
}

sdata.dest = new->dest;
sdata.src = orig->dest;
return userns_exec_1(conf, btrfs_snapshot_wrapper, &sdata,
Expand All @@ -433,6 +444,8 @@ int btrfs_clonepaths(struct bdev *orig, struct bdev *new, const char *oldname,
ret = btrfs_subvolume_create(new->dest);
if (ret < 0)
SYSERROR("Failed to create btrfs subvolume \"%s\"", new->dest);
else
TRACE("Created btrfs subvolume \"%s\"", new->dest);
return ret;
}

Expand Down

0 comments on commit 45dd65e

Please sign in to comment.