This patch makes mount command read fstab.d/*.fstab if the command is built with --enable-libmount-mount. Signed-off-by: Masatake YAMATO <yamato@xxxxxxxxxx> 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. */ -- To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html