diff options
author | Karel Zak | 2015-10-15 11:53:44 +0200 |
---|---|---|
committer | Karel Zak | 2015-10-15 12:01:48 +0200 |
commit | 1cd9d0d7463850ef6b16a78b8a55e56dbf9a8db1 (patch) | |
tree | 00d5e1db4f1c5db37f12f223a212d8216b95fa6d | |
parent | libblkid: make XFS Log visible for wipefs (diff) | |
download | kernel-qcow2-util-linux-1cd9d0d7463850ef6b16a78b8a55e56dbf9a8db1.tar.gz kernel-qcow2-util-linux-1cd9d0d7463850ef6b16a78b8a55e56dbf9a8db1.tar.xz kernel-qcow2-util-linux-1cd9d0d7463850ef6b16a78b8a55e56dbf9a8db1.zip |
mount, umount, swapon, fsck, lsblk, findmnt: ignore malformed lines
The libmount provides way how to deal with parsing errors in fstab --
on error callback function is executed and according to the return
libmount manipulate with the malformed line, possible are three
states:
1/ fatal error; all file ignored (callback rc < 0)
2/ recoverable error; malformed line ignored (callback rc > 0)
3/ ignore the error (callback rc == 0)
The 2/ is the default if no callback specified.
Unfortunately our utils uses 3/. The correct way is to use 2/.
Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r-- | disk-utils/fsck.c | 2 | ||||
-rw-r--r-- | misc-utils/findmnt.c | 2 | ||||
-rw-r--r-- | misc-utils/lsblk.c | 11 | ||||
-rw-r--r-- | sys-utils/mount.c | 2 | ||||
-rw-r--r-- | sys-utils/swapon-common.c | 11 | ||||
-rw-r--r-- | sys-utils/umount.c | 2 |
6 files changed, 26 insertions, 4 deletions
diff --git a/disk-utils/fsck.c b/disk-utils/fsck.c index a103408ef..ff504aa1d 100644 --- a/disk-utils/fsck.c +++ b/disk-utils/fsck.c @@ -471,7 +471,7 @@ static int parser_errcb(struct libmnt_table *tb __attribute__ ((__unused__)), const char *filename, int line) { warnx(_("%s: parse error at line %d -- ignore"), filename, line); - return 0; + return 1; } /* diff --git a/misc-utils/findmnt.c b/misc-utils/findmnt.c index 8218464b4..dd84671dc 100644 --- a/misc-utils/findmnt.c +++ b/misc-utils/findmnt.c @@ -805,7 +805,7 @@ static int parser_errcb(struct libmnt_table *tb __attribute__ ((__unused__)), const char *filename, int line) { warnx(_("%s: parse error at line %d"), filename, line); - return 0; + return 1; } static char **append_tabfile(char **files, int *nfiles, char *filename) diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c index d1bb13a54..2604e84c2 100644 --- a/misc-utils/lsblk.c +++ b/misc-utils/lsblk.c @@ -426,6 +426,15 @@ static char *get_device_path(struct blkdev_cxt *cxt) return xstrdup(path); } +static int table_parser_errcb(struct libmnt_table *tb __attribute__((__unused__)), + const char *filename, int line) +{ + if (filename) + warnx(_("%s: parse error: ignore entry at line %d."), + filename, line); + return 1; +} + static int is_active_swap(const char *filename) { if (!swaps) { @@ -435,6 +444,7 @@ static int is_active_swap(const char *filename) if (!mntcache) mntcache = mnt_new_cache(); + mnt_table_set_parser_errcb(swaps, table_parser_errcb); mnt_table_set_cache(swaps, mntcache); mnt_table_parse_swaps(swaps, NULL); } @@ -457,6 +467,7 @@ static char *get_device_mountpoint(struct blkdev_cxt *cxt) if (!mntcache) mntcache = mnt_new_cache(); + mnt_table_set_parser_errcb(mtab, table_parser_errcb); mnt_table_set_cache(mtab, mntcache); mnt_table_parse_mtab(mtab, NULL); } diff --git a/sys-utils/mount.c b/sys-utils/mount.c index c22c8c996..73f9d0b65 100644 --- a/sys-utils/mount.c +++ b/sys-utils/mount.c @@ -101,7 +101,7 @@ static int table_parser_errcb(struct libmnt_table *tb __attribute__((__unused__) if (filename) warnx(_("%s: parse error: ignore entry at line %d."), filename, line); - return 0; + return 1; } /* diff --git a/sys-utils/swapon-common.c b/sys-utils/swapon-common.c index 8f7788cb0..75466a056 100644 --- a/sys-utils/swapon-common.c +++ b/sys-utils/swapon-common.c @@ -12,12 +12,22 @@ static struct libmnt_table *swaps, *fstab; struct libmnt_cache *mntcache; +static int table_parser_errcb(struct libmnt_table *tb __attribute__((__unused__)), + const char *filename, int line) +{ + if (filename) + warnx(_("%s: parse error: ignore entry at line %d."), + filename, line); + return 1; +} + struct libmnt_table *get_fstab(void) { if (!fstab) { fstab = mnt_new_table(); if (!fstab) return NULL; + mnt_table_set_parser_errcb(fstab, table_parser_errcb); mnt_table_set_cache(fstab, mntcache); if (mnt_table_parse_fstab(fstab, NULL) != 0) return NULL; @@ -33,6 +43,7 @@ struct libmnt_table *get_swaps(void) if (!swaps) return NULL; mnt_table_set_cache(swaps, mntcache); + mnt_table_set_parser_errcb(swaps, table_parser_errcb); if (mnt_table_parse_swaps(swaps, NULL) != 0) return NULL; } diff --git a/sys-utils/umount.c b/sys-utils/umount.c index 464c4c87f..1d866fa1a 100644 --- a/sys-utils/umount.c +++ b/sys-utils/umount.c @@ -45,7 +45,7 @@ static int table_parser_errcb(struct libmnt_table *tb __attribute__((__unused__) if (filename) warnx(_("%s: parse error: ignore entry at line %d."), filename, line); - return 0; + return 1; } |