Commit 696eeef6 authored by Stanislav Kinsburskiy's avatar Stanislav Kinsburskiy Committed by Pavel Emelyanov

mount: use xstrcat() in attach_option()

v2:
Check for empty string is simplified
Signed-off-by: 's avatarStanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 16fd1989
......@@ -1163,24 +1163,11 @@ out:
static int attach_option(struct mount_info *pm, char *opt)
{
char *buf;
int len, olen;
len = strlen(pm->options);
olen = strlen(opt);
buf = xrealloc(pm->options, len + olen + 2);
if (buf == NULL)
return -1;
if (len && buf[len - 1] != ',') {
buf[len] = ',';
len++;
}
memcpy(buf + len, opt, olen + 1);
pm->options = buf;
return 0;
if (pm->options[0] == '\0')
pm->options = xstrcat(pm->options, "%s", opt);
else
pm->options = xstrcat(pm->options, ",%s", opt);
return pm->options ? 0 : -1;
}
/* Is it mounted w or w/o the newinstance option */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment