]> 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)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 1 Aug 2017 20:09:43 +0000 (22:09 +0200)
non-functional changes

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

index e301a72a53bc182af0ac5fadf7e390e055b9cd9d..dd2b28caebe29969143feb1c3d264237b0bf6da4 100644 (file)
@@ -2041,39 +2041,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,