Util-Linux package development
 help / color / mirror / Atom feed
From: Ivan Delalande <colona@arista.com>
To: Karel Zak <kzak@redhat.com>
Cc: util-linux@vger.kernel.org
Subject: [PATCH] libmount: make mnt_context_is_fs_mounted work for /proc
Date: Thu, 6 Jul 2017 18:27:11 -0700	[thread overview]
Message-ID: <20170707012711.GA1306@visor> (raw)

Assume that /proc is not mounted instead of returning an error when we
are unable to open the mounts and mountinfo files in /proc. Also set
cxt->mtab back to NULL so that it gets properly parsed when we check if
the next filesystem is mounted.

The goal is to have mount -a work when /proc is not mounted, typically
with /proc on the first line of fstab.

Signed-off-by: Ivan Delalande <colona@arista.com>
---
 libmount/src/context.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/libmount/src/context.c b/libmount/src/context.c
index 7c34cad95..e7f1ee934 100644
--- a/libmount/src/context.c
+++ b/libmount/src/context.c
@@ -33,6 +33,7 @@
 
 #include "mountP.h"
 #include "fileutils.h"
+#include "strutils.h"
 
 #include <sys/wait.h>
 
@@ -2458,14 +2459,23 @@ int mnt_context_helper_setopt(struct libmnt_context *cxt, int c, char *arg)
 int mnt_context_is_fs_mounted(struct libmnt_context *cxt,
 			      struct libmnt_fs *fs, int *mounted)
 {
-	struct libmnt_table *mtab;
+	struct libmnt_table *mtab, *orig;
 	int rc;
 
 	if (!cxt || !fs || !mounted)
 		return -EINVAL;
 
+	orig = cxt->mtab;
 	rc = mnt_context_get_mtab(cxt, &mtab);
-	if (rc)
+	if (rc == -ENOENT && mnt_fs_streq_target(fs, "/proc") &&
+	    (!cxt->mtab_path || startswith(cxt->mtab_path, "/proc/"))) {
+		if (!orig) {
+			mnt_unref_table(cxt->mtab);
+			cxt->mtab = NULL;
+		}
+		*mounted = 0;
+		return 0;	/* /proc not mounted */
+	} else if (rc)
 		return rc;
 
 	*mounted = mnt_table_is_fs_mounted(mtab, fs);
-- 
2.13.2

             reply	other threads:[~2017-07-07  1:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-07  1:27 Ivan Delalande [this message]
2017-07-18  7:47 ` [PATCH] libmount: make mnt_context_is_fs_mounted work for /proc Karel Zak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170707012711.GA1306@visor \
    --to=colona@arista.com \
    --cc=kzak@redhat.com \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox