*/
static int apply_fs(struct libmnt_context *cxt, struct libmnt_fs *fs, unsigned long mflags)
{
+ struct libmnt_optlist *ls;
int rc;
if (!cxt->optsmode) {
if (rc)
goto done;
+ ls = mnt_context_get_optlist(cxt);
+ if (!ls) {
+ rc = -ENOMEM;
+ goto done;
+ }
+
if (cxt->optsmode & MNT_OMODE_IGNORE)
;
else if (cxt->optsmode & MNT_OMODE_REPLACE) {
- rc = mnt_fs_set_options(cxt->fs, mnt_fs_get_options(fs));
+ rc = mnt_optlist_set_optstr(ls, mnt_fs_get_options(fs), NULL);
/* mount --read-only for non-root users is allowed */
if (rc == 0 && (mflags & MS_RDONLY)
&& mnt_context_is_restricted(cxt)
&& cxt->optsmode == MNT_OMODE_USER)
- rc = mnt_fs_append_options(cxt->fs, "ro");
+ rc = mnt_optlist_append_optstr(ls, "ro", NULL);
}
else if (cxt->optsmode & MNT_OMODE_APPEND)
- rc = mnt_fs_append_options(cxt->fs, mnt_fs_get_options(fs));
+ rc = mnt_optlist_append_optstr(ls, mnt_fs_get_options(fs), NULL);
else if (cxt->optsmode & MNT_OMODE_PREPEND)
- rc = mnt_fs_prepend_options(cxt->fs, mnt_fs_get_options(fs));
+ rc = mnt_optlist_prepend_optstr(ls, mnt_fs_get_options(fs), NULL);
if (!rc)
cxt->flags |= MNT_FL_TAB_APPLIED;
done:
- DBG(CXT, ul_debugobj(cxt, "final entry [rc=%d]:", rc));
+ DBG(CXT, ul_debugobj(cxt, "final entry [rc=%d]", rc));
DBG(CXT, mnt_fs_print_debug(cxt->fs, stderr));
return rc;
rc = -MNT_ERR_NOFSTAB;
- } else if (isremount && !iscmdbind) {
+ } else if (isremount && !iscmdbind && cxt->optlist) {
- /* remove "bind" from fstab (or no-op if not present) */
- mnt_optstr_remove_option(&cxt->fs->optstr, "bind");
+ /* ignore "bind" on remount when the flag is read from fstab */
+ mnt_optlist_remove_named(cxt->optlist, "bind", NULL);
}
return rc;
}
extern void mnt_unref_optlist(struct libmnt_optlist *ls);
extern int mnt_optlist_register_map(struct libmnt_optlist *ls, const struct libmnt_optmap *map);
extern int mnt_optlist_remove_opt(struct libmnt_optlist *ls, struct libmnt_opt *opt);
+extern int mnt_optlist_remove_named(struct libmnt_optlist *ls, const char *name,
+ const struct libmnt_optmap *map);
extern int mnt_optlist_next_opt(struct libmnt_optlist *ls,
struct libmnt_iter *itr, struct libmnt_opt **opt);
extern struct libmnt_opt *mnt_optlist_get_opt(struct libmnt_optlist *ls,
unsigned long id, const struct libmnt_optmap *map);
extern struct libmnt_opt *mnt_optlist_get_named(struct libmnt_optlist *ls,
- char *name, const struct libmnt_optmap *map);
+ const char *name, const struct libmnt_optmap *map);
extern int mnt_optlist_set_optstr(struct libmnt_optlist *ls, const char *optstr,
const struct libmnt_optmap *map);
extern int mnt_optlist_append_optstr(struct libmnt_optlist *ls, const char *optstr,
return 0;
}
+int mnt_optlist_remove_named(struct libmnt_optlist *ls, const char *name,
+ const struct libmnt_optmap *map)
+{
+ struct libmnt_opt *opt = mnt_optlist_get_named(ls, name, map);
+
+ return opt ? mnt_optlist_remove_opt(ls, opt) : 0;
+}
+
int mnt_optlist_next_opt(struct libmnt_optlist *ls,
struct libmnt_iter *itr, struct libmnt_opt **opt)
{
}
struct libmnt_opt *mnt_optlist_get_named(struct libmnt_optlist *ls,
- char *name, const struct libmnt_optmap *map)
+ const char *name, const struct libmnt_optmap *map)
{
struct libmnt_iter itr;
struct libmnt_opt *opt;