[lxc-devel] [lxc/master] tools: use fclose() after fdopen() + add newline

brauner on Github lxc-bot at linuxcontainers.org
Sat Aug 13 23:58:54 UTC 2016


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 753 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160813/01b1eb4b/attachment.bin>
-------------- next part --------------
From b44c42e8f09eb78f85afb567b7ec847538156ae7 Mon Sep 17 00:00:00 2001
From: Christian Brauner <cbrauner at suse.de>
Date: Sun, 14 Aug 2016 01:01:04 +0200
Subject: [PATCH] tools: use fclose() after fdopen() + add newline

So far we accidently used close() on the original file descriptor. (After
fdopen() the original fd is considered private and should not be used anymore.
The close operations should be performed on the new file handle. We did the
correct thing on error but not on success.) Using close() on the original fd
caused "Text file busy" errors and prevented the cloned tmpfs container from
starting.

Signed-off-by: Christian Brauner <cbrauner at suse.de>
---
 src/lxc/tools/lxc_copy.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/lxc/tools/lxc_copy.c b/src/lxc/tools/lxc_copy.c
index 9f653e3..3257ab7 100644
--- a/src/lxc/tools/lxc_copy.c
+++ b/src/lxc/tools/lxc_copy.c
@@ -454,7 +454,7 @@ static int do_clone_ephemeral(struct lxc_container *c,
 
 	if (arg->tmpfs && !my_args.quiet)
 		printf("Container is placed on tmpfs.\nRebooting will cause "
-		       "all changes made to it to be lost!");
+		       "all changes made to it to be lost!\n");
 
 	if (!arg->daemonize && arg->argc) {
 		clone->want_daemonize(clone, true);
@@ -863,7 +863,7 @@ static char *mount_tmpfs(const char *oldname, const char *newname,
 			goto err_close;
 	}
 
-	close(fd);
+	fclose(fp);
 	return premount;
 
 err_close:


More information about the lxc-devel mailing list