summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--WHATS_NEW_DM1
-rw-r--r--libdm/ioctl/libdm-iface.c25
2 files changed, 23 insertions, 3 deletions
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 719dc478..1103380d 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.71 -
====================================
+ Replace any '\' char with '\\' in table specification on input.
Add mangle command to dmsetup to provide renaming to correct mangled form.
Add 'mangled_name' and 'unmangled_name' fields to dmsetup info -c -o.
Add --manglename option to dmsetup to select the name mangling mode.
diff --git a/libdm/ioctl/libdm-iface.c b/libdm/ioctl/libdm-iface.c
index c5734e33..f6795997 100644
--- a/libdm/ioctl/libdm-iface.c
+++ b/libdm/ioctl/libdm-iface.c
@@ -866,7 +866,9 @@ static char *_add_target(struct target *t, char *out, char *end)
char *out_sp = out;
struct dm_target_spec sp;
size_t sp_size = sizeof(struct dm_target_spec);
+ unsigned int backslash_count = 0;
int len;
+ char *pt;
if (strlen(t->type) >= sizeof(sp.target_type)) {
log_error("Target type name %s is too long.", t->type);
@@ -880,15 +882,32 @@ static char *_add_target(struct target *t, char *out, char *end)
sp.target_type[sizeof(sp.target_type) - 1] = '\0';
out += sp_size;
- len = strlen(t->params);
+ pt = t->params;
+
+ while (*pt)
+ if (*pt++ == '\\')
+ backslash_count++;
+ len = strlen(t->params) + backslash_count;
if ((out >= end) || (out + len + 1) >= end) {
log_error("Ran out of memory building ioctl parameter");
return NULL;
}
- strcpy(out, t->params);
- out += len + 1;
+ if (backslash_count) {
+ /* replace "\" with "\\" */
+ pt = t->params;
+ do {
+ if (*pt == '\\')
+ *out++ = '\\';
+ *out++ = *pt++;
+ } while (*pt);
+ *out++ = '\0';
+ }
+ else {
+ strcpy(out, t->params);
+ out += len + 1;
+ }
/* align next block */
out = _align(out, ALIGNMENT);