summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2010-10-01 13:05:58 +0200
committerKarel Zak <kzak@redhat.com>2011-01-03 12:28:43 +0100
commit8f3f6383a581e64d5dbe9a13130e078f45babf07 (patch)
tree323304a71688a9fc157dceaee666ea0a449650ba /lib
parent0a98127b8734204ffaa9faf33b59e61fafc685bb (diff)
downloadutil-linux-old-8f3f6383a581e64d5dbe9a13130e078f45babf07.tar.gz
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')
-rw-r--r--lib/mangle.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/mangle.c b/lib/mangle.c
index e320cfb7..938dd8e5 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;