[Devel] [RFC][PATCH 06/16] Define is_global_init()
Pavel Emelianov
xemul at sw.ru
Thu May 24 01:28:59 PDT 2007
> Index: lx26-21-mm2/kernel/pid.c
> ===================================================================
> --- lx26-21-mm2.orig/kernel/pid.c 2007-05-22 16:59:34.000000000 -0700
> +++ lx26-21-mm2/kernel/pid.c 2007-05-22 16:59:46.000000000 -0700
> @@ -71,6 +71,27 @@ struct pid_namespace init_pid_ns = {
> .child_reaper = &init_task
> };
>
> +
> +/**
> + * is_global_init - check if a task structure is init
> + * @tsk: Task structure to be checked.
> + *
> + * Check if a task structure is the first user space task the kernel created.
> + */
> +int is_global_init(struct task_struct *tsk)
> +{
> + return (task_active_pid_ns(tsk) == &init_pid_ns && tsk->pid == 1);
This can OOPS if you pass arbitrary task to this call...
tsk->nsproxy can already be NULL.
> +}
> +
> +/*
> + * is_container_init:
> + * check whether in the task is init in it's own pid namespace.
> + */
> +int is_container_init(struct task_struct *tsk)
> +{
> + return tsk->pid == 1;
> +}
> +
> /*
> * Note: disable interrupts while the pidmap_lock is held as an
> * interrupt might come in and do read_lock(&tasklist_lock).
> _______________________________________________
> Containers mailing list
> Containers at lists.linux-foundation.org
> https://lists.linux-foundation.org/mailman/listinfo/containers
>
> _______________________________________________
> Devel mailing list
> Devel at openvz.org
> https://openvz.org/mailman/listinfo/devel
>
_______________________________________________
Containers mailing list
Containers at lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers
More information about the Devel
mailing list