From: Serge Hallyn Date: Tue, 18 Feb 2014 21:01:38 +0000 (-0600) Subject: cache whether 'optional' was in mntopts X-Git-Tag: lxc-1.0.0.rc4~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4f1d50d114f8acbdd738c458548b1ec17149f806;p=thirdparty%2Flxc.git cache whether 'optional' was in mntopts after commit 4e4ca16158f91ac1271495638a4e62881169474e we are checking for optional in mntopts after we forcibly remove it. Cache whether we had it before removing it. Signed-off-by: Serge Hallyn --- diff --git a/src/lxc/conf.c b/src/lxc/conf.c index 483dff413..d482d2220 100644 --- a/src/lxc/conf.c +++ b/src/lxc/conf.c @@ -1913,6 +1913,7 @@ static inline int mount_entry_on_systemfs(struct mntent *mntent) int ret; FILE *pathfile = NULL; char* pathdirname = NULL; + bool optional = hasmntopt(mntent, "optional") != NULL; if (hasmntopt(mntent, "create=dir")) { if (mkdir_p(mntent->mnt_dir, 0755) < 0) { @@ -1946,7 +1947,7 @@ static inline int mount_entry_on_systemfs(struct mntent *mntent) ret = mount_entry(mntent->mnt_fsname, mntent->mnt_dir, mntent->mnt_type, mntflags, mntdata); - if (hasmntopt(mntent, "optional") != NULL) + if (optional) ret = 0; free(pathdirname); @@ -1967,6 +1968,7 @@ static int mount_entry_on_absolute_rootfs(struct mntent *mntent, const char *lxcpath; FILE *pathfile = NULL; char *pathdirname = NULL; + bool optional = hasmntopt(mntent, "optional") != NULL; lxcpath = lxc_global_config_value("lxc.lxcpath"); if (!lxcpath) { @@ -2037,7 +2039,7 @@ skipabs: free(mntdata); - if (hasmntopt(mntent, "optional") != NULL) + if (optional) ret = 0; out: @@ -2054,6 +2056,7 @@ static int mount_entry_on_relative_rootfs(struct mntent *mntent, int ret; FILE *pathfile = NULL; char *pathdirname = NULL; + bool optional = hasmntopt(mntent, "optional") != NULL; /* relative to root mount point */ ret = snprintf(path, sizeof(path), "%s/%s", rootfs, mntent->mnt_dir); @@ -2093,7 +2096,7 @@ static int mount_entry_on_relative_rootfs(struct mntent *mntent, ret = mount_entry(mntent->mnt_fsname, path, mntent->mnt_type, mntflags, mntdata); - if (hasmntopt(mntent, "optional") != NULL) + if (optional) ret = 0; free(pathdirname);