Beispiel #1
0
/*
 * Clone a new ns copying an original utsname, setting refcount to 1
 * @old_ns: namespace to clone
 * Return NULL on error (failure to kmalloc), new ns otherwise
 */
static struct uts_namespace *clone_uts_ns(struct uts_namespace *old_ns)
{
	struct uts_namespace *ns;

	ns = create_uts_ns();
	if (!ns)
		return ERR_PTR(-ENOMEM);

	down_read(&uts_sem);
	memcpy(&ns->name, &old_ns->name, sizeof(ns->name));
	up_read(&uts_sem);
	return ns;
}
Beispiel #2
0
/*
 * Clone a new ns copying an original utsname, setting refcount to 1
 * @old_ns: namespace to clone
 * Return NULL on error (failure to kmalloc), new ns otherwise
 */
static struct uts_namespace *clone_uts_ns(struct task_struct *tsk,
					  struct uts_namespace *old_ns)
{
	struct uts_namespace *ns;

	ns = create_uts_ns();
	if (!ns)
		return ERR_PTR(-ENOMEM);

	down_read(&uts_sem);
	memcpy(&ns->name, &old_ns->name, sizeof(ns->name));
	ns->user_ns = get_user_ns(task_cred_xxx(tsk, user)->user_ns);
	up_read(&uts_sem);
	return ns;
}
Beispiel #3
0
/*
 * Clone a new ns copying an original utsname, setting refcount to 1
 * @old_ns: namespace to clone
 * Return ERR_PTR(-ENOMEM) on error (failure to kmalloc), new ns otherwise
 */
static struct uts_namespace *clone_uts_ns(struct user_namespace *user_ns,
        struct uts_namespace *old_ns)
{
    struct uts_namespace *ns;
    int err;

    ns = create_uts_ns();
    if (!ns)
        return ERR_PTR(-ENOMEM);

    err = proc_alloc_inum(&ns->proc_inum);
    if (err) {
        kfree(ns);
        return ERR_PTR(err);
    }

    down_read(&uts_sem);
    memcpy(&ns->name, &old_ns->name, sizeof(ns->name));
    ns->user_ns = get_user_ns(user_ns);
    up_read(&uts_sem);
    return ns;
}