Private userspace notifications.

Allows to register notifications of any private userspace
events over kevent. Events can be marked as ready using 
kevent_ctl(KEVENT_READY) command.

Signed-off-by: Evgeniy Polyakov <[EMAIL PROTECTED]>

diff --git a/kernel/kevent/kevent_unotify.c b/kernel/kevent/kevent_unotify.c
new file mode 100644
index 0000000..618c09c
--- /dev/null
+++ b/kernel/kevent/kevent_unotify.c
@@ -0,0 +1,62 @@
+/*
+ * 2006 Copyright (c) Evgeniy Polyakov <[EMAIL PROTECTED]>
+ * All rights reserved.
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <linux/kernel.h>
+#include <linux/kevent.h>
+
+static int kevent_unotify_callback(struct kevent *k)
+{
+       return 1;
+}
+
+int kevent_unotify_enqueue(struct kevent *k)
+{
+       int err;
+
+       err = kevent_storage_enqueue(&k->user->st, k);
+       if (err)
+               goto err_out_exit;
+
+       if (k->event.req_flags & KEVENT_REQ_ALWAYS_QUEUE)
+               kevent_requeue(k);
+
+       return 0;
+
+err_out_exit:
+       return err;
+}
+
+int kevent_unotify_dequeue(struct kevent *k)
+{
+       kevent_storage_dequeue(k->st, k);
+       return 0;
+}
+
+static int __init kevent_init_unotify(void)
+{
+       struct kevent_callbacks sc = {
+               .callback = &kevent_unotify_callback,
+               .enqueue = &kevent_unotify_enqueue,
+               .dequeue = &kevent_unotify_dequeue,
+               .flags = 0,
+       };
+
+       return kevent_add_callbacks(&sc, KEVENT_UNOTIFY);
+}
+module_init(kevent_init_unotify);

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to