summaryrefslogtreecommitdiffstats
path: root/lib/mangle.c
diff options
context:
space:
mode:
authorKarel Zak2010-10-01 13:05:58 +0200
committerKarel Zak2011-01-03 12:28:43 +0100
commit8f3f6383a581e64d5dbe9a13130e078f45babf07 (patch)
tree323304a71688a9fc157dceaee666ea0a449650ba /lib/mangle.c
parentlibmount: fix mount helpers call (diff)
downloadkernel-qcow2-util-linux-8f3f6383a581e64d5dbe9a13130e078f45babf07.tar.gz
kernel-qcow2-util-linux-8f3f6383a581e64d5dbe9a13130e078f45babf07.tar.xz
kernel-qcow2-util-linux-8f3f6383a581e64d5dbe9a13130e078f45babf07.zip
libmount: rewrite mountinfo/fstab parsers to use sscanf()
The old solution (without scanf()) was based on old code from mount(8). It seems that the modern libc is able to provide all necessary functionality by sscanf() and %ms directive. Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'lib/mangle.c')
-rw-r--r--lib/mangle.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/mangle.c b/lib/mangle.c
index e320cfb7c..938dd8e55 100644
--- a/lib/mangle.c
+++ b/lib/mangle.c
@@ -115,10 +115,19 @@ int main(int argc, char *argv[])
else if (!strcmp(argv[1], "--unmangle")) {
char *x = unmangle(argv[2]);
- if (x)
+
+ if (x) {
printf("unmangled: '%s'\n", x);
- else
- err(EXIT_FAILURE, "unmangle failed");
+ free(x);
+ }
+
+ x = strdup(argv[2]);
+ unmangle_to_buffer(x, x, strlen(x) + 1);
+
+ if (x) {
+ printf("self-unmangled: '%s'\n", x);
+ free(x);
+ }
}
return EXIT_SUCCESS;