conf: make_anonymous_mount_file()

non-functional changes Signed-off-by: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
parent 42dff448
...@@ -2041,39 +2041,42 @@ FILE *make_anonymous_mount_file(struct lxc_list *mount) ...@@ -2041,39 +2041,42 @@ FILE *make_anonymous_mount_file(struct lxc_list *mount)
int ret; int ret;
char *mount_entry; char *mount_entry;
struct lxc_list *iterator; struct lxc_list *iterator;
FILE *file; FILE *f;
int fd = -1; int fd = -1;
fd = memfd_create("lxc_mount_file", MFD_CLOEXEC); fd = memfd_create("lxc_mount_file", MFD_CLOEXEC);
if (fd < 0) { if (fd < 0) {
if (errno != ENOSYS) if (errno != ENOSYS)
return NULL; return NULL;
file = tmpfile(); f = tmpfile();
TRACE("Created temporary mount file");
} else { } else {
file = fdopen(fd, "r+"); f = fdopen(fd, "r+");
TRACE("Created anonymous mount file");
} }
if (!file) { if (!f) {
int saved_errno = errno; SYSERROR("Could not create mount file");
if (fd != -1) if (fd != -1)
close(fd); close(fd);
ERROR("Could not create mount entry file: %s.", strerror(saved_errno));
return NULL; return NULL;
} }
lxc_list_for_each(iterator, mount) { lxc_list_for_each(iterator, mount) {
mount_entry = iterator->elem; mount_entry = iterator->elem;
ret = fprintf(file, "%s\n", mount_entry); ret = fprintf(f, "%s\n", mount_entry);
if (ret < strlen(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) { ret = fseek(f, 0, SEEK_SET);
fclose(file); if (ret < 0) {
SYSERROR("Failed to seek mount file");
fclose(f);
return NULL; return NULL;
} }
return file; return f;
} }
static int setup_mount_entries(const struct lxc_rootfs *rootfs, static int setup_mount_entries(const struct lxc_rootfs *rootfs,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment