[lxc-devel] [lxc/master] lxczfs: small fixes

brauner on Github lxc-bot at linuxcontainers.org
Tue Sep 13 15:23:06 UTC 2016


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 704 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160913/53ab7440/attachment.bin>
-------------- next part --------------
From 326b171d39153ba6d7043ad6fb14fce92af46c69 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at canonical.com>
Date: Tue, 13 Sep 2016 17:18:23 +0200
Subject: [PATCH] lxczfs: small fixes

- 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 at canonical.com>
---
 src/lxc/bdev/lxczfs.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/lxc/bdev/lxczfs.c b/src/lxc/bdev/lxczfs.c
index dd1005b..6412945 100644
--- a/src/lxc/bdev/lxczfs.c
+++ b/src/lxc/bdev/lxczfs.c
@@ -26,6 +26,7 @@
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
 #include <sys/mount.h>
 
 #include "bdev.h"
@@ -170,6 +171,9 @@ 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, (char *)NULL);
 			exit(EXIT_FAILURE);
 		}
@@ -252,7 +256,7 @@ int zfs_destroy(struct bdev *orig)
 		return -1;
 	*p = '\0';
 
-	execlp("zfs", "zfs", "destroy", output, (char *)NULL);
+	execlp("zfs", "zfs", "destroy", "-r", output, (char *)NULL);
 	exit(EXIT_FAILURE);
 }
 


More information about the lxc-devel mailing list