From d5a8c30cebc874c4adcdef6a12a3e6567a81da23 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Fri, 29 May 2009 13:20:47 +0200 Subject: [PATCH] mount: use TAG parsing function from libblkid Signed-off-by: Karel Zak --- lib/fsprobe.c | 26 ++++---------------------- mount/fstab.c | 1 + 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/lib/fsprobe.c b/lib/fsprobe.c index 0f5a4ac0..b47de0ec 100644 --- a/lib/fsprobe.c +++ b/lib/fsprobe.c @@ -47,35 +47,16 @@ open_device(const char *devname) * Parses NAME=value, returns -1 on parse error, 0 success. The success is also * when the 'spec' doesn't contain name=value pair (because the spec could be * a devname too). In particular case the pointer 'name' is set to NULL. - - * The result is a new allocated string (the 'name' pointer). */ int fsprobe_parse_spec(const char *spec, char **name, char **value) { - char *vl, *tk, *cp; - *name = NULL; *value = NULL; - if (!(cp = strchr(spec, '='))) - return 0; /* no name= */ - - tk = strdup(spec); - vl = tk + (cp - spec); - *vl++ = '\0'; - - if (*vl == '"' || *vl == '\'') { - if (!(cp = strrchr(vl+1, *vl))) { - free(tk); - return -1; /* parse error */ - } - vl++; - *cp = '\0'; - } + if (strchr(spec, '=')) + return blkid_parse_tag_string(spec, name, value); - *name = tk; - *value = vl; return 0; } @@ -96,7 +77,8 @@ fsprobe_get_devname_by_spec(const char *spec) else if (!strcmp(name,"UUID")) nspec = fsprobe_get_devname_by_uuid(value); - free((void *) name); + free(name); + free(value); return nspec; } diff --git a/mount/fstab.c b/mount/fstab.c index 13dda871..82e90f3a 100644 --- a/mount/fstab.c +++ b/mount/fstab.c @@ -404,6 +404,7 @@ getfs_by_spec (const char *spec) { mc = getfs_by_uuid (value); free(name); + free(value); return mc; } -- 2.39.5