From 2e478a46c3754ede1a7af57b961056a2a375a799 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sun, 14 Feb 2010 01:02:46 +0100 Subject: mount,device: drop prefix from unit names to make them easily decodable --- unit.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'unit.c') diff --git a/unit.c b/unit.c index 980c3711eb..39c9e5e7e8 100644 --- a/unit.c +++ b/unit.c @@ -1001,10 +1001,10 @@ int set_unit_path(const char *p) { return 0; } -char *unit_name_escape_path(const char *prefix, const char *path, const char *suffix) { +char *unit_name_escape_path(const char *path, const char *suffix) { char *r, *t; const char *f; - size_t a, b, c; + size_t a, b; assert(path); @@ -1017,22 +1017,16 @@ char *unit_name_escape_path(const char *prefix, const char *path, const char *su * escaping is hence reversible. */ - if (!prefix) - prefix = ""; - if (!suffix) suffix = ""; - a = strlen(prefix); - b = strlen(path); - c = strlen(suffix); + a = strlen(path); + b = strlen(suffix); - if (!(r = new(char, a+b*4+c+1))) + if (!(r = new(char, a*4+b+1))) return NULL; - memcpy(r, prefix, a); - - for (f = path, t = r+a; *f; f++) { + for (f = path, t = r; *f; f++) { if (*f == '/') *(t++) = '.'; else if (*f == '.' || *f == '\\' || !strchr(VALID_CHARS, *f)) { @@ -1044,7 +1038,7 @@ char *unit_name_escape_path(const char *prefix, const char *path, const char *su *(t++) = *f; } - memcpy(t, suffix, c+1); + memcpy(t, suffix, b+1); return r; } -- cgit v1.2.3-54-g00ecf