<div dir="ltr">Hi All, <div><br></div><div> Here is the complete code attempting to work in the new root of the new namespace. This program is built and executed successfully.</div><div> But within the child context, my root is still the original root directory. My intention is to make <b>/opt/lxc/ </b>as my new root.</div><div> Required executables (bash and ls) along with the required libraries are placed in /opt/lxc. </div><div> ** New PID Namespace is working right. </div><div> # ls /proc is showing the processes that are executed only in the new namespace.<br></div><div> Any help is appreciated.</div><div><br></div><div>-----------------------------------------------------------------------------------------------------------------------------------------</div><div><div>#define STACK_SIZE (8 * 1024)</div><div>unsigned char stack[STACK_SIZE];</div><div>char *args[] = { "/usr/bin/bash", NULL };</div><div><br></div><div>int child_function (void *arg)</div><div>{</div><div><br></div><div> ret = mount("", "/", "", MS_REC|MS_PRIVATE, NULL);</div><div> ret = mount("/opt/lxc/", "/", "", MS_BIND|MS_REC, NULL);</div><div> ret = mount("proc", "/proc", "proc", 0, NULL);</div><div> execv(args[0],args);</div><div> return 0;</div><div>}</div><div>int main()</div><div>{</div><div> unshare (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWPID | CLONE_NEWNET);</div><div><br></div><div> clone(child_function, stack+STACK_SIZE, CLONE_PARENT | SIGCHLD, NULL);</div><div><br></div><div> return 0;</div><div>}</div><div>-----------------------------------------------------------------------------------------------------------------------------------------------------</div><div><br></div><div class="gmail_signature">Regards,<br>Prabhu<br></div>
</div></div>