<div dir="ltr">I wasn't aware that the -n option was no longer relevant, but in that case this patch probably won't be needed. It was just there to prepare for the user namespace support patches, which I will be sending out soon.<div>
<br></div><div>Thanks,</div><div><br></div><div>Sophie</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Aug 5, 2014 at 12:39 AM, Pavel Emelyanov <span dir="ltr"><<a href="mailto:xemul@parallels.com" target="_blank">xemul@parallels.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 08/05/2014 12:10 AM, Sophie Blee-Goldman wrote:<br>
<br>
Hi, Sophie<br>
<div class=""><br>
> Use strtok to parse the -n option in crtools.c. Will be needed for implementing<br>
> user namespace support.<br>
<br>
</div>Can you shed more light on this? The -n option only makes effect if<br>
used on restore from images generated by quite old version of criu.<br>
The prepare_pstree_kobj_ids()'s code<br>
<br>
if (!item->ids) {<br>
if (item == root_item) {<br>
cflags = opts.rst_namespaces_flags;<br>
goto set_mask;<br>
}<br>
<br>
is about this -- item->ids is NULL only when images are created by<br>
criu older than 1.0.<br>
<br>
> Change-Id: Ifb7dc11c94c216a52cf9da7aab4fdf0af4f74152<br>
<br>
Remember putting the signed-off-by: line.<br>
<div class="HOEnZb"><div class="h5"><br>
> ---<br>
> crtools.c | 40 ++++++++++++++++++++++------------------<br>
> 1 file changed, 22 insertions(+), 18 deletions(-)<br>
><br>
> diff --git a/crtools.c b/crtools.c<br>
> index b7ca833..49b488a 100644<br>
> --- a/crtools.c<br>
> +++ b/crtools.c<br>
> @@ -53,30 +53,34 @@ void init_opts(void)<br>
><br>
> static int parse_ns_string(const char *ptr)<br>
> {<br>
> - const char *end = ptr + strlen(ptr);<br>
> + int ret = 0;<br>
> + char *ns;<br>
><br>
> - do {<br>
> - if (ptr[3] != ',' && ptr[3] != '\0')<br>
> - goto bad_ns;<br>
> - if (!strncmp(ptr, "uts", 3))<br>
> + char *copy = strdup(ptr);<br>
> + if (!copy) {<br>
> + pr_msg("Error: malloc failed");<br>
> + return -1;<br>
> + }<br>
> +<br>
> + for (ns = strtok(copy, ","); ns ; ns = strtok(NULL, ",")) {<br>
> + if (!strcmp(ns, "uts")) {<br>
> opts.rst_namespaces_flags |= CLONE_NEWUTS;<br>
> - else if (!strncmp(ptr, "ipc", 3))<br>
> + } else if (!strcmp(ns, "ipc")) {<br>
> opts.rst_namespaces_flags |= CLONE_NEWIPC;<br>
> - else if (!strncmp(ptr, "mnt", 3))<br>
> + } else if (!strcmp(ns, "mnt")) {<br>
> opts.rst_namespaces_flags |= CLONE_NEWNS;<br>
> - else if (!strncmp(ptr, "pid", 3))<br>
> + } else if (!strcmp(ns, "pid")) {<br>
> opts.rst_namespaces_flags |= CLONE_NEWPID;<br>
> - else if (!strncmp(ptr, "net", 3))<br>
> + } else if (!strcmp(ns, "net")) {<br>
> opts.rst_namespaces_flags |= CLONE_NEWNET;<br>
> - else<br>
> - goto bad_ns;<br>
> - ptr += 4;<br>
> - } while (ptr < end);<br>
> - return 0;<br>
> -<br>
> -bad_ns:<br>
> - pr_msg("Error: unknown namespace: %s\n", ptr);<br>
> - return -1;<br>
> + } else {<br>
> + pr_msg("Error: unknown namespace: %s\n", ns);<br>
> + ret = -1;<br>
> + break;<br>
> + }<br>
> + }<br>
> + free(copy);<br>
> + return ret;<br>
> }<br>
><br>
> char criu_dir_name[PATH_MAX];<br>
><br>
<br>
</div></div></blockquote></div><br></div>