summaryrefslogtreecommitdiff
path: root/unit.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-02-14 01:02:46 +0100
committerLennart Poettering <lennart@poettering.net>2010-02-14 01:02:46 +0100
commit2e478a46c3754ede1a7af57b961056a2a375a799 (patch)
treeced795692cd778911743b09a42bb88a090313de3 /unit.c
parent6be1e7d538e12f4e5c79c1271dba90e66726d8fd (diff)
mount,device: drop prefix from unit names to make them easily decodable
Diffstat (limited to 'unit.c')
-rw-r--r--unit.c20
1 files changed, 7 insertions, 13 deletions
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;
}