diff options
author | Karel Zak | 2012-08-06 12:45:08 +0200 |
---|---|---|
committer | Karel Zak | 2012-08-06 12:49:41 +0200 |
commit | 5f7c18902fe2cd1e8b7d8d205680546d056000f7 (patch) | |
tree | 1424d122a05ab42d6642cd56936a17cb615d520a /sys-utils/mount.c | |
parent | docs: update tests docs (diff) | |
download | kernel-qcow2-util-linux-5f7c18902fe2cd1e8b7d8d205680546d056000f7.tar.gz kernel-qcow2-util-linux-5f7c18902fe2cd1e8b7d8d205680546d056000f7.tar.xz kernel-qcow2-util-linux-5f7c18902fe2cd1e8b7d8d205680546d056000f7.zip |
mount: replace control chars in mountpoint name
For compatibility with coreutils and to avoid complex solutions in
mount output mount replaces control characters with '?'.
Note that the listing mode in mount(8) is in maintenance mode --
findmnt(8) provides more robust and better solutions.
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils/mount.c')
-rw-r--r-- | sys-utils/mount.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/sys-utils/mount.c b/sys-utils/mount.c index 3b9f2c4b6..2d1d2cd41 100644 --- a/sys-utils/mount.c +++ b/sys-utils/mount.c @@ -30,6 +30,7 @@ #include <sys/stat.h> #include <stdarg.h> #include <libmount.h> +#include <ctype.h> #include "nls.h" #include "c.h" @@ -130,6 +131,22 @@ static void encrypt_pass_release(struct libmnt_context *cxt munlockall(); } +/* + * Replace control chars with '?' to be compatible with coreutils. For more + * robust solution use findmnt(1) where we use \x?? hex encoding. + */ +static void safe_fputs(const char *data) +{ + const char *p; + + for (p = data; p && *p; p++) { + if (iscntrl((unsigned char) *p)) + fputc('?', stdout); + else + fputc(*p, stdout); + } +} + static void print_all(struct libmnt_context *cxt, char *pattern, int show_label) { struct libmnt_table *tb; @@ -157,7 +174,9 @@ static void print_all(struct libmnt_context *cxt, char *pattern, int show_label) if (!mnt_fs_is_pseudofs(fs)) xsrc = mnt_pretty_path(src, cache); - printf ("%s on %s", xsrc ? xsrc : src, mnt_fs_get_target(fs)); + printf ("%s on ", xsrc ? xsrc : src); + safe_fputs(mnt_fs_get_target(fs)); + if (type) printf (" type %s", type); if (optstr) |