From: Karel Zak Date: Wed, 23 Jun 2010 08:22:02 +0000 (+0200) Subject: findmnt: add /etc/fstab.d support X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2005515135216801a64926d8e807b7665304d028;p=util-linux findmnt: add /etc/fstab.d support Signed-off-by: Karel Zak --- diff --git a/misc-utils/findmnt.8 b/misc-utils/findmnt.8 index c7a15357..65cef44b 100644 --- a/misc-utils/findmnt.8 +++ b/misc-utils/findmnt.8 @@ -22,6 +22,7 @@ will list all mounted filesytems or search for a filesystem. The .B findmnt command is able to search in .IR /etc/fstab , +.IR /etc/fstab.d , .IR /etc/mtab or .IR /proc/self/mountinfo . @@ -37,7 +38,9 @@ The command prints all mounted filesystems in the tree-like format by default. Print help and exit. .IP "\fB\-s, \-\-fstab\fP" Search in -.IR /etc/fstab . +.IR /etc/fstab +and +.IR /etc/fstab.d . The output is in the list format (see --list). .IP "\fB\-m, \-\-mtab\fP" Search in diff --git a/misc-utils/findmnt.c b/misc-utils/findmnt.c index 1754da1d..76564f6b 100644 --- a/misc-utils/findmnt.c +++ b/misc-utils/findmnt.c @@ -308,15 +308,32 @@ leave: return rc; } +/* error callback */ +static int parser_errcb(mnt_tab *tb, const char *filename, int line, int flag) +{ + warn(_("%s: parse error at line %d"), filename, line); + return 0; +} + /* calls libmount fstab/mtab/mountinfo parser */ static mnt_tab *parse_tabfile(const char *path) { - mnt_tab *tb = mnt_new_tab(path); + int rc; + mnt_tab *tb = mnt_new_tab(); + if (!tb) { warn(_("failed to initialize libmount tab")); return NULL; } - if (mnt_tab_parse_file(tb) != 0) { + + mnt_tab_set_parser_errcb(tb, parser_errcb); + + if (!strcmp(path, _PATH_MNTTAB)) + rc = mnt_tab_parse_fstab(tb); + else + rc = mnt_tab_parse_file(tb, path); + + if (rc) { mnt_free_tab(tb); warn(_("can't read: %s"), path); return NULL;