]> git.proxmox.com Git - mirror_lxc.git/commitdiff
rootfs: remove "options" member
authorChristian Brauner <christian.brauner@ubuntu.com>
Thu, 26 Aug 2021 08:25:48 +0000 (10:25 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Thu, 26 Aug 2021 08:27:38 +0000 (10:27 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/conf.c
src/lxc/conf.h
src/lxc/confile.c
src/lxc/storage/storage.c

index 11f42714bdb18289cbbf35f432a84af3b4687140..4b7a73286ec6ff4f619039d664333f11ddfdb677 100644 (file)
@@ -512,7 +512,7 @@ int lxc_storage_prepare(struct lxc_conf *conf)
        if (!rootfs->storage)
                return log_error(-1, "Failed to mount rootfs \"%s\" onto \"%s\" with options \"%s\"",
                                 rootfs->path, rootfs->mount,
-                                rootfs->options ? rootfs->options : "(null)");
+                                rootfs->mnt_opts.raw_options ? rootfs->mnt_opts.raw_options : "(null)");
 
        return 0;
 }
@@ -1425,11 +1425,11 @@ static int lxc_mount_rootfs(struct lxc_rootfs *rootfs)
        if (ret < 0)
                return log_error(-1, "Failed to mount rootfs \"%s\" onto \"%s\" with options \"%s\"",
                                 rootfs->path, rootfs->mount,
-                                rootfs->options ? rootfs->options : "(null)");
+                                rootfs->mnt_opts.raw_options ? rootfs->mnt_opts.raw_options : "(null)");
 
        DEBUG("Mounted rootfs \"%s\" onto \"%s\" with options \"%s\"",
              rootfs->path, rootfs->mount,
-             rootfs->options ? rootfs->options : "(null)");
+             rootfs->mnt_opts.raw_options ? rootfs->mnt_opts.raw_options : "(null)");
 
        rootfs->dfd_mnt = open_at(-EBADF, rootfs->mount, PROTECT_OPATH_DIRECTORY, PROTECT_LOOKUP_ABSOLUTE_XDEV, 0);
        if (rootfs->dfd_mnt < 0)
@@ -4791,7 +4791,6 @@ void lxc_conf_free(struct lxc_conf *conf)
        lxc_terminal_conf_free(&conf->console);
        free(conf->rootfs.mount);
        free(conf->rootfs.bdev_type);
-       free(conf->rootfs.options);
        free(conf->rootfs.path);
        put_lxc_rootfs(&conf->rootfs, true);
        free(conf->logfile);
index 7a63acffcd28f9bf7cde9c4610d8ee1c96487d08..4e31c55d7e1931b31d44ee8e0ead469d26ef8e64 100644 (file)
@@ -218,6 +218,7 @@ struct lxc_mount_options {
        unsigned long prop_flags;
        char *data;
        struct lxc_mount_attr attr;
+       char *raw_options;
 };
 
 /* Defines a structure to store the rootfs location, the
@@ -226,7 +227,6 @@ struct lxc_mount_options {
  * @mount        : where it is mounted
  * @buf                 : static buffer to construct paths
  * @bev_type     : optional backing store type
- * @options      : mount options
  * @managed      : whether it is managed by LXC
  * @dfd_mnt     : fd for @mount
  * @dfd_dev : fd for /dev of the container
@@ -245,7 +245,6 @@ struct lxc_rootfs {
 
        char buf[PATH_MAX];
        char *bdev_type;
-       char *options;
        bool managed;
        struct lxc_mount_options mnt_opts;
        struct lxc_storage *storage;
@@ -613,6 +612,7 @@ static inline void put_lxc_mount_options(struct lxc_mount_options *mnt_opts)
        mnt_opts->prop_flags = 0;
 
        free_disarm(mnt_opts->data);
+       free_disarm(mnt_opts->raw_options);
 }
 
 static inline void put_lxc_rootfs(struct lxc_rootfs *rootfs, bool unpin)
index d9d3e45df83573ceff037ef1fdc5fbaf48e9a272..d0b891d2dd906a2e9819dee0776a5feeb71bba09 100644 (file)
@@ -2784,7 +2784,7 @@ static int set_config_rootfs_options(const char *key, const char *value,
        if (ret < 0)
                return ret_errno(EINVAL);
 
-       rootfs->options = move_ptr(raw_options);
+       rootfs->mnt_opts.raw_options = move_ptr(raw_options);
        return 0;
 }
 
@@ -4169,7 +4169,7 @@ static int get_config_rootfs_mount(const char *key, char *retv, int inlen,
 static int get_config_rootfs_options(const char *key, char *retv, int inlen,
                                     struct lxc_conf *c, void *data)
 {
-       return lxc_get_conf_str(retv, inlen, c->rootfs.options);
+       return lxc_get_conf_str(retv, inlen, c->rootfs.mnt_opts.raw_options);
 }
 
 static int get_config_uts_name(const char *key, char *retv, int inlen,
@@ -4976,7 +4976,6 @@ static inline int clr_config_rootfs_mount(const char *key, struct lxc_conf *c,
 static inline int clr_config_rootfs_options(const char *key, struct lxc_conf *c,
                                            void *data)
 {
-       free_disarm(c->rootfs.options);
        put_lxc_mount_options(&c->rootfs.mnt_opts);
 
        return 0;
index f1bea3e30dd082c19b1ab1db45ffa840afdeca4c..a8c4be5f331446eac2067dcc180c508c18cadbd4 100644 (file)
@@ -606,7 +606,7 @@ struct lxc_storage *storage_init(struct lxc_conf *conf)
        const struct lxc_storage_type *q;
        const char *src = conf->rootfs.path;
        const char *dst = conf->rootfs.mount;
-       const char *mntopts = conf->rootfs.options;
+       const char *mntopts = conf->rootfs.mnt_opts.raw_options;
 
        BUILD_BUG_ON(LXC_STORAGE_INTERNAL_OVERLAY_RESTORE <= LXC_CLONE_MAXFLAGS);