util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* libmount: MNT_OMODE_FORCE usage
@ 2015-02-06 14:55 Fridolin Pokorny
  2015-02-10 10:52 ` Karel Zak
  0 siblings, 1 reply; 2+ messages in thread
From: Fridolin Pokorny @ 2015-02-06 14:55 UTC (permalink / raw)
  To: util-linux

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


diff --git a/libmount/src/context.c b/libmount/src/context.c
index c902f39..1c288e5 100644
--- a/libmount/src/context.c
+++ b/libmount/src/context.c
@@ -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);



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: libmount: MNT_OMODE_FORCE usage
  2015-02-06 14:55 libmount: MNT_OMODE_FORCE usage Fridolin Pokorny
@ 2015-02-10 10:52 ` Karel Zak
  0 siblings, 0 replies; 2+ messages in thread
From: Karel Zak @ 2015-02-10 10:52 UTC (permalink / raw)
  To: Fridolin Pokorny; +Cc: util-linux

On Fri, Feb 06, 2015 at 03:55:21PM +0100, Fridolin Pokorny wrote:
> 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).

> 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

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-02-10 10:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-06 14:55 libmount: MNT_OMODE_FORCE usage Fridolin Pokorny
2015-02-10 10:52 ` Karel Zak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).