From: Masatake YAMATO <yamato@redhat.com>
To: util-linux@vger.kernel.org
Subject: [patch] Enable fstab.d in mount -a
Date: Mon, 14 Nov 2011 22:47:53 +0900 (JST) [thread overview]
Message-ID: <20111114.224753.785892012923334635.yamato@redhat.com> (raw)
This patch makes mount command read fstab.d/*.fstab if the command
is built with --enable-libmount-mount.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
diff --git a/mount/fstab.c b/mount/fstab.c
index a1bae90..3621d3a 100644
--- a/mount/fstab.c
+++ b/mount/fstab.c
@@ -153,20 +153,23 @@ read_mntentchn(mntFILE *mfp, const char *fnam, struct mntentchn *mc0) {
#define USE_UNSTABLE_LIBMOUNT_API
#include <libmount.h> /* libmount */
-
-static void read_mounttable()
+static void read_tab_common(struct mntentchn *mc0,
+ int *got_p,
+ int (* reader)(struct libmnt_table *tb,
+ const char *filename),
+ const char *name_in_errmsg)
{
- struct mntentchn *mc0 = &mounttable, *mc = mc0;
+ struct mntentchn *mc = mc0;
struct libmnt_table *tb = mnt_new_table();
struct libmnt_iter *itr = mnt_new_iter(MNT_ITER_FORWARD);
struct libmnt_fs *fs;
- got_mtab = 1;
+ *got_p = 1;
mc->nxt = mc->prev = NULL;
if (!tb || !itr)
goto err;
- if (mnt_table_parse_mtab(tb, NULL))
+ if (reader(tb, NULL))
goto err;
while(mnt_table_next_fs(tb, itr, &fs) == 0) {
@@ -187,12 +190,28 @@ static void read_mounttable()
mc0->prev = mc;
return;
err:
- error(_("warning: failed to read mtab"));
+ error(_("warning: failed to %s"),
+ name_in_errmsg);
mnt_free_table(tb);
mnt_free_iter(itr);
mc->nxt = mc->prev = NULL;
}
+static void read_mounttable()
+{
+ read_tab_common(&mounttable,
+ &got_mtab,
+ mnt_table_parse_mtab,
+ "mtab");
+}
+
+static void read_fstab()
+{
+ read_tab_common(&fstab,
+ &got_fstab,
+ mnt_table_parse_fstab,
+ "fstab/fstab.d");
+}
#else /* !HAVE_LIBMOUNT_MOUNT */
/*
@@ -226,7 +245,6 @@ read_mounttable() {
}
read_mntentchn(mfp, fnam, mc);
}
-#endif /* HAVE_LIBMOUNT_MOUNT */
static void
read_fstab() {
@@ -247,6 +265,7 @@ read_fstab() {
}
read_mntentchn(mfp, fnam, mc);
}
+#endif /* HAVE_LIBMOUNT_MOUNT */
/* Given the name NAME, try to find it in mtab. */
next reply other threads:[~2011-11-14 13:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-14 13:47 Masatake YAMATO [this message]
2011-11-22 14:47 ` [patch] Enable fstab.d in mount -a Karel Zak
2011-11-22 17:09 ` Masatake YAMATO
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=20111114.224753.785892012923334635.yamato@redhat.com \
--to=yamato@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