summaryrefslogtreecommitdiffstats
path: root/misc-utils
diff options
context:
space:
mode:
authorKarel Zak2010-06-23 10:22:02 +0200
committerKarel Zak2011-01-03 12:28:39 +0100
commit2005515135216801a64926d8e807b7665304d028 (patch)
treeda7395794d35a686952965640ebf53e9b7e61760 /misc-utils
parentlibmount: add /etc/fstab.d support (diff)
downloadkernel-qcow2-util-linux-2005515135216801a64926d8e807b7665304d028.tar.gz
kernel-qcow2-util-linux-2005515135216801a64926d8e807b7665304d028.tar.xz
kernel-qcow2-util-linux-2005515135216801a64926d8e807b7665304d028.zip
findmnt: add /etc/fstab.d support
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'misc-utils')
-rw-r--r--misc-utils/findmnt.85
-rw-r--r--misc-utils/findmnt.c21
2 files changed, 23 insertions, 3 deletions
diff --git a/misc-utils/findmnt.8 b/misc-utils/findmnt.8
index c7a15357b..65cef44bb 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 1754da1d5..76564f6b8 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;