Util-Linux package development
 help / color / mirror / Atom feed
* [patch] Enable fstab.d in mount -a
@ 2011-11-14 13:47 Masatake YAMATO
  2011-11-22 14:47 ` Karel Zak
  0 siblings, 1 reply; 3+ messages in thread
From: Masatake YAMATO @ 2011-11-14 13:47 UTC (permalink / raw)
  To: util-linux

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.  */

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

end of thread, other threads:[~2011-11-22 17:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-14 13:47 [patch] Enable fstab.d in mount -a Masatake YAMATO
2011-11-22 14:47 ` Karel Zak
2011-11-22 17:09   ` Masatake YAMATO

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox