]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
conf: make_anonymous_mount_file()
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 1 Aug 2017 20:07:10 +0000 (22:07 +0200)
committerStéphane Graber <stgraber@ubuntu.com>
Tue, 15 Aug 2017 20:36:01 +0000 (16:36 -0400)
non-functional changes

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

index f95c8cca015f10563600bc02e8877f53208a3c6f..e5c431c6718826378f0b66d26897475e0c368bfb 100644 (file)
@@ -2002,39 +2002,42 @@ FILE *make_anonymous_mount_file(struct lxc_list *mount)
        int ret;
        char *mount_entry;
        struct lxc_list *iterator;
-       FILE *file;
+       FILE *f;
        int fd = -1;
 
        fd = memfd_create("lxc_mount_file", MFD_CLOEXEC);
        if (fd < 0) {
                if (errno != ENOSYS)
                        return NULL;
-               file = tmpfile();
+               f = tmpfile();
+               TRACE("Created temporary mount file");
        } else {
-               file = fdopen(fd, "r+");
+               f = fdopen(fd, "r+");
+               TRACE("Created anonymous mount file");
        }
 
-       if (!file) {
-               int saved_errno = errno;
+       if (!f) {
+               SYSERROR("Could not create mount file");
                if (fd != -1)
                        close(fd);
-               ERROR("Could not create mount entry file: %s.", strerror(saved_errno));
                return NULL;
        }
 
        lxc_list_for_each(iterator, mount) {
                mount_entry = iterator->elem;
-               ret = fprintf(file, "%s\n", mount_entry);
+               ret = fprintf(f, "%s\n", mount_entry);
                if (ret < strlen(mount_entry))
-                       WARN("Could not write mount entry to anonymous mount file.");
+                       WARN("Could not write mount entry to mount file");
        }
 
-       if (fseek(file, 0, SEEK_SET) < 0) {
-               fclose(file);
+       ret = fseek(f, 0, SEEK_SET);
+       if (ret < 0) {
+               SYSERROR("Failed to seek mount file");
+               fclose(f);
                return NULL;
        }
 
-       return file;
+       return f;
 }
 
 static int setup_mount_entries(const struct lxc_rootfs *rootfs,