]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lxczfs: small fixes
authorChristian Brauner <christian.brauner@canonical.com>
Tue, 13 Sep 2016 15:18:23 +0000 (17:18 +0200)
committerStéphane Graber <stgraber@ubuntu.com>
Thu, 17 Nov 2016 23:34:03 +0000 (18:34 -0500)
- We expect destroy to fail in zfs_clone() so try to silence it so users are
  not irritated when they create zfs snapshots.
- Add -r recursive to zfs_destroy(). This code is only hit when a) the
  container has no snapshots or b) the user calls destroy with snapshots. So
  this should be safe. Without -r snapshots will remain.

Signed-off-by: Christian Brauner <christian.brauner@canonical.com>
src/lxc/bdev.c

index cbfb1eccf69c5c64f602bf876b44d7ff6115b710..529b92b4fe6e6698c090deac6e7160e1bef07cb0 100644 (file)
@@ -660,6 +660,9 @@ static int zfs_clone(const char *opath, const char *npath, const char *oname,
                if ((pid = fork()) < 0)
                        return -1;
                if (!pid) {
+                       int dev0 = open("/dev/null", O_WRONLY);
+                       if (dev0 >= 0)
+                               dup2(dev0, STDERR_FILENO);
                        execlp("zfs", "zfs", "destroy", path1, NULL);
                        exit(1);
                }
@@ -740,7 +743,7 @@ static int zfs_destroy(struct bdev *orig)
                return -1;
        *p = '\0';
 
-       execlp("zfs", "zfs", "destroy", output, NULL);
+       execlp("zfs", "zfs", "destroy", "-r", output, NULL);
        exit(1);
 }