summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Olsa <Jiri Olsa jolsa@redhat.com>2010-04-13 18:51:11 +0200
committerJiri Olsa <Jiri Olsa jolsa@redhat.com>2010-04-13 18:51:11 +0200
commitf6c0943a2b6e8e0a9fc0939dbe5628ecca8d78e4 (patch)
tree8122d15661f11de1800b059e93e30936b87ee842
parent7fab518ce3dfefbe3ef99a78f28041f64d3ec542 (diff)
downloadtsnif-f6c0943a2b6e8e0a9fc0939dbe5628ecca8d78e4.tar.gz
tsnif-f6c0943a2b6e8e0a9fc0939dbe5628ecca8d78e4.tar.xz
tsnif-f6c0943a2b6e8e0a9fc0939dbe5628ecca8d78e4.zip
updating the kernel patch
-rw-r--r--kernel/0001-tty-notifier.patch2
-rw-r--r--kernel/0002-gennl-changes-adding-non-locking-multicast-functions.patch10
-rw-r--r--kernel/0003-alive.patch143
3 files changed, 130 insertions, 25 deletions
diff --git a/kernel/0001-tty-notifier.patch b/kernel/0001-tty-notifier.patch
index d0dbf79..247d409 100644
--- a/kernel/0001-tty-notifier.patch
+++ b/kernel/0001-tty-notifier.patch
@@ -1,4 +1,4 @@
-From 8e0eded3aa1159d3ccdc89fd1d83b71dd5b8cee1 Mon Sep 17 00:00:00 2001
+From 92c4cb569be3e9d939c2314329f2c191caec7563 Mon Sep 17 00:00:00 2001
From: jolsa@redhat.com <jolsa@redhat.com>
Date: Mon, 8 Mar 2010 17:52:48 +0100
Subject: [PATCH 1/3] tty notifier
diff --git a/kernel/0002-gennl-changes-adding-non-locking-multicast-functions.patch b/kernel/0002-gennl-changes-adding-non-locking-multicast-functions.patch
index 1fc45e4..31abbb3 100644
--- a/kernel/0002-gennl-changes-adding-non-locking-multicast-functions.patch
+++ b/kernel/0002-gennl-changes-adding-non-locking-multicast-functions.patch
@@ -1,4 +1,4 @@
-From a234b5fd654474b10f344fc01e4de22b827c4c00 Mon Sep 17 00:00:00 2001
+From 8c9688bec17381a9ec999bc5cc80cefd0894319c Mon Sep 17 00:00:00 2001
From: jolsa@redhat.com <jolsa@redhat.com>
Date: Thu, 25 Mar 2010 08:59:04 +0100
Subject: [PATCH 2/3] gennl changes - adding non locking multicast functions
@@ -27,10 +27,10 @@ index eb551ba..e06a026 100644
/**
* genlmsg_put - Add generic netlink header to netlink message
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
-index a4b6e14..5d9d158 100644
+index 06438fa..3a3f579 100644
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
-@@ -123,7 +123,7 @@ static struct genl_multicast_group notify_grp;
+@@ -124,7 +124,7 @@ static struct genl_multicast_group notify_grp;
* @family: The generic netlink family the group shall be registered for.
* @grp: The group to register, must have a name.
*/
@@ -39,7 +39,7 @@ index a4b6e14..5d9d158 100644
struct genl_multicast_group *grp)
{
int id;
-@@ -132,8 +132,6 @@ int genl_register_mc_group(struct genl_family *family,
+@@ -133,8 +133,6 @@ int genl_register_mc_group(struct genl_family *family,
BUG_ON(grp->name[0] == '\0');
@@ -48,7 +48,7 @@ index a4b6e14..5d9d158 100644
/* special-case our own group */
if (grp == &notify_grp)
id = GENL_ID_CTRL;
-@@ -201,13 +199,25 @@ int genl_register_mc_group(struct genl_family *family,
+@@ -202,13 +200,25 @@ int genl_register_mc_group(struct genl_family *family,
genl_ctrl_event(CTRL_CMD_NEWMCAST_GRP, grp);
out:
diff --git a/kernel/0003-alive.patch b/kernel/0003-alive.patch
index 7e00ba1..ca08a49 100644
--- a/kernel/0003-alive.patch
+++ b/kernel/0003-alive.patch
@@ -1,16 +1,16 @@
-From b9a1b1faaeece7956b59ade53aa808bedf1d2087 Mon Sep 17 00:00:00 2001
+From 719d12ed07f6d23bcf2c91cb93ebaece75fbc252 Mon Sep 17 00:00:00 2001
From: jolsa@redhat.com <jolsa@redhat.com>
-Date: Tue, 30 Mar 2010 10:41:56 +0200
+Date: Tue, 13 Apr 2010 18:45:53 +0200
Subject: [PATCH 3/3] alive
---
drivers/char/Kconfig | 9 +
drivers/char/Makefile | 2 +
- drivers/char/tsnif.c | 857 +++++++++++++++++++++++++++++++++++++++++++++++++
- drivers/char/tty_io.c | 29 ++
- include/linux/tsnif.h | 63 ++++
- include/linux/tty.h | 1 +
- 6 files changed, 961 insertions(+), 0 deletions(-)
+ drivers/char/tsnif.c | 935 +++++++++++++++++++++++++++++++++++++++++++++++++
+ drivers/char/tty_io.c | 48 +++
+ include/linux/tsnif.h | 65 ++++
+ include/linux/tty.h | 5 +
+ 6 files changed, 1064 insertions(+), 0 deletions(-)
create mode 100644 drivers/char/tsnif.c
create mode 100644 include/linux/tsnif.h
@@ -48,10 +48,10 @@ index f957edf..537c771 100644
diff --git a/drivers/char/tsnif.c b/drivers/char/tsnif.c
new file mode 100644
-index 0000000..a076f1c
+index 0000000..9b436ba
--- /dev/null
+++ b/drivers/char/tsnif.c
-@@ -0,0 +1,857 @@
+@@ -0,0 +1,935 @@
+
+#include <linux/module.h>
+#include <linux/kernel.h>
@@ -77,7 +77,7 @@ index 0000000..a076f1c
+ } \
+} while(0)
+
-+int tsnif_debug = 0;
++int tsnif_debug = 1;
+module_param_named(debug, tsnif_debug, int, 0444);
+MODULE_PARM_DESC(debug, "debug output");
+
@@ -268,6 +268,7 @@ index 0000000..a076f1c
+ if (genlmsg_end(skb, hdr) < 0)
+ goto nla_put_failure;
+
++ TSNIF_DEBUG("cmd %d, type %d, idx %d\n", cmd, type, idx);
+ return genlmsg_multicast_allns(skb, 0, gnl_ctrl_group.id, GFP_KERNEL);
+
+nla_put_failure:
@@ -809,7 +810,7 @@ index 0000000..a076f1c
+ skb_answer = make_msg(NLMSG_GOODSIZE, TSNIF_CMD_MGROUP,
+ info->snd_pid, info->snd_seq);
+
-+ if (!skb)
++ if (!skb_answer)
+ return -ENOMEM;
+
+ NLA_PUT_U32(skb_answer, TSNIF_ATTR_GROUP, gnl_ctrl_group.id);
@@ -818,10 +819,76 @@ index 0000000..a076f1c
+ return TSNIF_RET(send_msg(skb_answer, info->snd_pid));
+
+nla_put_failure:
-+ nlmsg_free(skb);
++ nlmsg_free(skb_answer);
++ return -EMSGSIZE;
++}
++
++struct ts_tty {
++ int type;
++ int idx;
++ struct list_head list;
++};
++
++void tty_list_cb(void *data, struct tty_struct *tty)
++{
++ struct list_head *h = data;
++ struct ts_tty *t;
++
++ t = kmalloc(sizeof(*t), GFP_KERNEL);
++ if (!t)
++ return;
++
++ t->type = get_type(tty);
++ t->idx = tty->index;
++ list_add(&t->list, h);
++
++ TSNIF_DEBUG("got type %d, idx %d\n", t->type, t->idx);
++}
++
++static int send_tty_list(struct genl_info *info, int type, int idx)
++{
++ struct sk_buff *skb_answer;
++
++ skb_answer = make_msg(NLMSG_GOODSIZE, TSNIF_CMD_TTY_LIST,
++ info->snd_pid, info->snd_seq);
++
++ if (!skb_answer)
++ return -ENOMEM;
++
++ NLA_PUT_U32(skb_answer, TSNIF_ATTR_TYPE, type);
++ NLA_PUT_U32(skb_answer, TSNIF_ATTR_IDX, idx);
++
++ TSNIF_DEBUG("sending tty list - type %d, idx %d\n",
++ type, idx);
++
++ return TSNIF_RET(send_msg(skb_answer, info->snd_pid));
++
++nla_put_failure:
++ nlmsg_free(skb_answer);
+ return -EMSGSIZE;
+}
+
++static int cmd_tty_list(struct sk_buff *skb, struct genl_info *info)
++{
++ struct list_head ttys;
++ struct ts_tty *t;
++ int err;
++
++ INIT_LIST_HEAD(&ttys);
++ tty_list(tty_list_cb, &ttys);
++
++ list_for_each_entry(t, &ttys, list) {
++ err = send_tty_list(info, t->type, t->idx);
++ if (err != TSNIF_OK)
++ break;
++ }
++
++ list_for_each_entry(t, &ttys, list)
++ kfree(t);
++
++ return err;
++}
++
+TSNIF_POLICY(gnl_policy);
+
+static struct genl_ops gnl_ops_attach = {
@@ -842,6 +909,12 @@ index 0000000..a076f1c
+ .policy = gnl_policy,
+};
+
++static struct genl_ops gnl_ops_tty_list = {
++ .cmd = TSNIF_CMD_TTY_LIST,
++ .doit = cmd_tty_list,
++ .policy = gnl_policy,
++};
++
+int __init tsnif_init(void)
+{
+ int err;
@@ -871,6 +944,10 @@ index 0000000..a076f1c
+ if (err < 0)
+ goto release_gnl;
+
++ err = genl_register_ops(&gnl_family, &gnl_ops_tty_list);
++ if (err < 0)
++ goto release_gnl;
++
+ register_tty_notifier(&tty_nb);
+ netlink_register_notifier(&netlink_nb);
+
@@ -899,6 +976,7 @@ index 0000000..a076f1c
+ genl_unregister_ops(&gnl_family, &gnl_ops_attach);
+ genl_unregister_ops(&gnl_family, &gnl_ops_detach);
+ genl_unregister_ops(&gnl_family, &gnl_ops_mgroup);
++ genl_unregister_ops(&gnl_family, &gnl_ops_tty_list);
+ genl_unregister_family(&gnl_family);
+
+ hash_release();
@@ -910,13 +988,32 @@ index 0000000..a076f1c
+
+MODULE_LICENSE("GPL");
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
-index 1f77159..15a6ad6 100644
+index 1f77159..4375844 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
-@@ -159,6 +159,35 @@ static LIST_HEAD(tty_structs); /* linked list of tty structs */
+@@ -159,6 +159,54 @@ static LIST_HEAD(tty_structs); /* linked list of tty structs */
static ATOMIC_NOTIFIER_HEAD(tty_notifier_list);
/**
++ * tty_list - list all the active ttys
++ * @cb: callback function called for each active tty
++ *
++ * Returns true, if there's active tty for given type and line.
++ */
++void tty_list(cb_tty_list_t cb, void *data)
++{
++ struct tty_struct *tty;
++
++ mutex_lock(&tty_mutex);
++
++ list_for_each_entry(tty, &tty_structs, list)
++ cb(data, tty);
++
++ mutex_unlock(&tty_mutex);
++}
++EXPORT_SYMBOL_GPL(tty_list);
++
++/**
+ * tty_is_active - checks wether the tty is active
+ * @type: tty driver type
+ * @line: tty line
@@ -951,10 +1048,10 @@ index 1f77159..15a6ad6 100644
* Locking: none
diff --git a/include/linux/tsnif.h b/include/linux/tsnif.h
new file mode 100644
-index 0000000..86e49fd
+index 0000000..efb426e
--- /dev/null
+++ b/include/linux/tsnif.h
-@@ -0,0 +1,63 @@
+@@ -0,0 +1,65 @@
+#ifndef TSNIF_H
+#define TSNIF_H
+
@@ -989,17 +1086,19 @@ index 0000000..86e49fd
+ [TSNIF_ATTR_GROUP] = { .type = NLA_U32 }, \
+ [TSNIF_ATTR_FLAGS] = { .type = NLA_U32 }, \
+ [TSNIF_ATTR_DATA] = { .type = NLA_UNSPEC}, \
++ [TSNIF_ATTR_TIME] = { .type = NLA_UNSPEC}, \
++ [TSNIF_ATTR_WS] = { .type = NLA_UNSPEC}, \
+};
+
+enum {
+ TSNIF_CMD_ATTACH,
+ TSNIF_CMD_DETACH,
-+ TSNIF_CMD_RELEASE,
+ TSNIF_CMD_MGROUP,
+ TSNIF_CMD_TGROUP,
+ TSNIF_CMD_DATA,
+ TSNIF_CMD_TTY_CREATE,
+ TSNIF_CMD_TTY_RELEASE,
++ TSNIF_CMD_TTY_LIST,
+ __TSNIF_CMD_MAX,
+};
+
@@ -1019,14 +1118,20 @@ index 0000000..86e49fd
+
+#endif /* TSNIF_H */
diff --git a/include/linux/tty.h b/include/linux/tty.h
-index 7d57719..113d155 100644
+index 7d57719..3945347 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
-@@ -345,6 +345,7 @@ struct tty_notifier_param {
+@@ -343,8 +343,13 @@ struct tty_notifier_param {
+ size_t size;
+ };
++typedef void(*cb_tty_list_t)(void *data, struct tty_struct *tty);
++
extern int register_tty_notifier(struct notifier_block *nb);
extern int unregister_tty_notifier(struct notifier_block *nb);
++extern void tty_list(cb_tty_list_t cb, void *data);
+extern bool tty_is_active(int type, int line);
++
#endif /* CONFIG_TTY_NOTIFIER */