Re: [PATCH 02/11] Task watchers: Register process events task watcher

Chase Venters
2006-06-14T00:40:05Z

On Tuesday 13 June 2006 18:54, Matt Helsley wrote:

> +static int cn_proc_watch_task(struct notifier_block *nb, unsigned long
> val, + void *t)
> +{
> + struct task_struct *task = t;

Why the copy?

> + int rc = NOTIFY_OK;
> +
> + switch (get_watch_event(val)) {
> + case WATCH_TASK_CLONE:
> + proc_fork_connector(task);
> + break;
> + case WATCH_TASK_EXEC:
> + proc_exec_connector(task);
> + break;
> + case WATCH_TASK_UID:
> + proc_id_connector(task, PROC_EVENT_UID);
> + break;
> + case WATCH_TASK_GID:
> + proc_id_connector(task, PROC_EVENT_GID);
> + break;
> + case WATCH_TASK_EXIT:
> + proc_exit_connector(task);
> + break;
> + default: /* we don't care about WATCH_TASK_INIT|FREE because we
> + don't keep per-task info */
> + rc = NOTIFY_DONE; /* ignore all other notifications */
> + break;
> + }
> + return rc;
> +}
> +

> /*
> * cn_proc_init - initialization entry point
> *
> * Adds the connector callback to the connector driver.
> */
> @@ -219,11 +259,16 @@ static int __init cn_proc_init(void)
> int err;
>
> if ((err = cn_add_callback(&cn_proc_event_id, "cn_proc",
> &cn_proc_mcast_ctl))) {
> printk(KERN_WARNING "cn_proc failed to register\n");
> - return err;
> + goto out;
> }
> - return 0;
> +
> + err = register_task_watcher(&cn_proc_nb);
> + if (err != 0)

if (err)

Thanks,
Chase