Skip to contentSkip to conversation

libmount: MNT_OMODE_FORCE usage

PATCH Fridolin Pokorny 2 participants 2 messages Feb 6, 2015 – Feb 10, 2015 Util-Linux package

lore
Share & tools
lore
#0 lore raw

Hi,

I have found out that libmount does not respect MNT_OMODE_FORCE mode. I don't see any usage in sources and libmount does not respect this mode when calling library functions. I'm proposing a patch to fix this.

Have a nice day!
Fridolin Pokorny

libmount/src/context.c +3 -2
index c902f39..1c288e5 100644
@@ -2077,6 +2077,7 @@ int mnt_context_apply_fstab(struct libmnt_context *cxt)
 	}
 
 	if (!src && tgt
+	    && !(cxt->optsmode & MNT_OMODE_FORCE)
 	    && !(cxt->optsmode & MNT_OMODE_FSTAB)
 	    && !(cxt->optsmode & MNT_OMODE_MTAB)) {
 		DBG(CXT, ul_debugobj(cxt, "only target; fstab/mtab not required "
@@ -2088,7 +2089,7 @@ int mnt_context_apply_fstab(struct libmnt_context *cxt)
 	ignore_result( mnt_context_get_fs(cxt) );
 
 	/* try fstab */
-	if (cxt->optsmode & MNT_OMODE_FSTAB) {
+	if (cxt->optsmode & (MNT_OMODE_FSTAB | MNT_OMODE_FORCE)) {
 		DBG(CXT, ul_debugobj(cxt, "trying to apply fstab (src=%s, target=%s)", src, tgt));
 		rc = mnt_context_get_fstab(cxt, &tab);
 		if (!rc)
@@ -2096,7 +2097,7 @@ int mnt_context_apply_fstab(struct libmnt_context *cxt)
 	}
 
 	/* try mtab */
-	if (rc < 0 && (cxt->optsmode & MNT_OMODE_MTAB)) {
+	if (rc < 0 && (cxt->optsmode & (MNT_OMODE_MTAB | MNT_OMODE_FORCE))) {
 		DBG(CXT, ul_debugobj(cxt, "trying to apply mtab (src=%s, target=%s)", src, tgt));
 		if (tgt)
 			rc = mnt_context_get_mtab_for_target(cxt, &tab, tgt);
maintainer
#1 lore raw
Quoted 2 lines · Fridolin Pokorny

I have found out that libmount does not respect MNT_OMODE_FORCE mode. I don't see any usage in sources

This is not true. It's used for example by MNT_OMODE_USER (mount by non-root user).

Quoted 2 lines

and libmount does not respect this mode
when calling library functions.

I don't think so, the MNT_OMODE_FORCE flag is extension, no replacement to MNT_OMODE_{FSTAB,MTAB}.

The default mount(8) behavior is not to read fstab if mount source and target are specified, this feature is possible to disable by

MNT_OMODE_FORCE | MNT_OMODE_FSTAB

I guess you forgot to use MNT_OMODE_FSTAB (or/and MNT_OMODE_MTAB), alone MNT_OMODE_FORCE does not make sense.

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com