return 0;
}
+const char *lxc_mount_options_info[LXC_MOUNT_MAX] = {
+ "create=dir",
+ "create=file",
+ "optional",
+ "relative",
+};
+
/* Remove "optional", "create=dir", and "create=file" from mntopt */
-static void cull_mntent_opt(struct mntent *mntent)
+void parse_lxc_mntopts(struct lxc_mount_options *opts, char *mnt_opts)
{
- int i;
- char *list[] = {
- "create=dir",
- "create=file",
- "optional",
- "relative",
- NULL
- };
- for (i = 0; list[i]; i++) {
+ for (size_t i = LXC_MOUNT_CREATE_DIR; i < LXC_MOUNT_MAX; i++) {
+ const char *opt_name = lxc_mount_options_info[i];
char *p, *p2;
- p = strstr(mntent->mnt_opts, list[i]);
+ p = strstr(mnt_opts, opt_name);
if (!p)
continue;
- p2 = strchr(p, ',');
- if (!p2) {
- /* no more mntopts, so just chop it here */
- *p = '\0';
+ switch (i) {
+ case LXC_MOUNT_CREATE_DIR:
+ opts->create_dir = 1;
+ break;
+ case LXC_MOUNT_CREATE_FILE:
+ opts->create_file = 1;
+ break;
+ case LXC_MOUNT_OPTIONAL:
+ opts->optional = 1;
+ break;
+ case LXC_MOUNT_RELATIVE:
+ opts->relative = 1;
+ break;
+ default:
+ WARN("Unknown LXC specific mount option");
continue;
}
- memmove(p, p2 + 1, strlen(p2 + 1) + 1);
+ p2 = strchr(p, ',');
+ if (!p2)
+ *p = '\0'; /* no more mntopts, so just chop it here */
+ else
+ memmove(p, p2 + 1, strlen(p2 + 1) + 1);
}
}
char *rootfs_path = NULL;
int ret;
bool dev, optional, relative;
+ struct lxc_mount_options opts = {};
optional = hasmntopt(mntent, "optional") != NULL;
dev = hasmntopt(mntent, "dev") != NULL;
return -1;
}
- cull_mntent_opt(mntent);
+ parse_lxc_mntopts(&opts, mntent->mnt_opts);
ret = parse_propagationopts(mntent->mnt_opts, &pflags);
if (ret < 0)
struct lxc_terminal_info *tty;
};
+typedef enum lxc_mount_options_t {
+ LXC_MOUNT_CREATE_DIR = 0,
+ LXC_MOUNT_CREATE_FILE = 1,
+ LXC_MOUNT_OPTIONAL = 2,
+ LXC_MOUNT_RELATIVE = 3,
+ LXC_MOUNT_MAX = 4,
+} lxc_mount_options_t;
+
+__hidden extern const char *lxc_mount_options_info[LXC_MOUNT_MAX];
+
+struct lxc_mount_options {
+ int create_dir : 1;
+ int create_file : 1;
+ int optional : 1;
+ int relative : 1;
+};
+
/* Defines a structure to store the rootfs location, the
* optionals pivot_root, rootfs mount paths
* @path : the rootfs source (directory or device)
unsigned long mountflags;
char *data;
bool managed;
+ struct lxc_mount_options mnt_opts;
};
/*
const char *fn_name);
__hidden extern int parse_mntopts(const char *mntopts, unsigned long *mntflags, char **mntdata);
__hidden extern int parse_propagationopts(const char *mntopts, unsigned long *pflags);
+__hidden extern void parse_lxc_mntopts(struct lxc_mount_options *opts, char *mnt_opts);
__hidden extern void tmp_proc_unmount(struct lxc_conf *lxc_conf);
__hidden extern void suggest_default_idmap(void);
__hidden extern FILE *make_anonymous_mount_file(struct lxc_list *mount, bool include_nesting_helpers);