* [PATCH] libmount: make mnt_context_is_fs_mounted work for /proc
@ 2017-07-07 1:27 Ivan Delalande
2017-07-18 7:47 ` Karel Zak
0 siblings, 1 reply; 2+ messages in thread
From: Ivan Delalande @ 2017-07-07 1:27 UTC (permalink / raw)
To: Karel Zak; +Cc: util-linux
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] libmount: make mnt_context_is_fs_mounted work for /proc
2017-07-07 1:27 [PATCH] libmount: make mnt_context_is_fs_mounted work for /proc Ivan Delalande
@ 2017-07-18 7:47 ` Karel Zak
0 siblings, 0 replies; 2+ messages in thread
From: Karel Zak @ 2017-07-18 7:47 UTC (permalink / raw)
To: Ivan Delalande; +Cc: util-linux
On Thu, Jul 06, 2017 at 06:27:11PM -0700, Ivan Delalande wrote:
> libmount/src/context.c | 14 ++++++++++++--
> 1 file changed, 12 insertions(+), 2 deletions(-)
Applied, thanks. (Sorry for delay)
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-07-18 7:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-07 1:27 [PATCH] libmount: make mnt_context_is_fs_mounted work for /proc Ivan Delalande
2017-07-18 7:47 ` Karel Zak
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.