/* Called from unshare. Unshare all the namespaces part of nsproxy. On success, returns the new nsproxy.  */
int unshare_nsproxy_namespaces(unsigned long unshare_flags, struct nsproxy **new_nsp, struct fs_struct *new_fs)
/* Called from unshare. Unshare all the namespaces part of nsproxy. On success, returns the new nsproxy.  */
int unshare_nsproxy_namespaces(unsigned long unshare_flags, struct nsproxy **new_nsp, struct fs_struct *new_fs)
{
	int err = 0;
	if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
			       CLONE_NEWNET)))
		return 0;
	if (!capable(CAP_SYS_ADMIN))
		return -EPERM;
	*new_nsp = create_new_namespaces(unshare_flags, current,
				new_fs ? new_fs : current->fs);
	if (IS_ERR(*new_nsp)) {
		err = PTR_ERR(*new_nsp);
		goto out;
	}
	err = ns_cgroup_clone(current, task_pid(current));
	if (err)
		put_nsproxy(*new_nsp);
out:
	return err;
}