| 1 | /* |
| 2 | * Copyright (C) 2011 Mathieu Desnoyers (mathieu.desnoyers@efficios.com) |
| 3 | * |
| 4 | * wrapper around poll __pollwait and poll_get_entry. Using KALLSYMS to get its |
| 5 | * address when available, else we need to have a kernel that exports this |
| 6 | * function to GPL modules. |
| 7 | * |
| 8 | * Dual LGPL v2.1/GPL v2 license. |
| 9 | */ |
| 10 | |
| 11 | #ifdef CONFIG_KALLSYMS |
| 12 | |
| 13 | #include <linux/kallsyms.h> |
| 14 | #include <linux/poll.h> |
| 15 | |
| 16 | struct poll_table_entry; |
| 17 | struct splice_pipe_desc; |
| 18 | |
| 19 | static |
| 20 | void (*__pollwait_sym)(struct file *filp, wait_queue_head_t *wait_address, |
| 21 | poll_table *p); |
| 22 | static |
| 23 | struct poll_table_entry *(*poll_get_entry_sym)(struct poll_wqueues *p); |
| 24 | |
| 25 | void wrapper_pollwait_exclusive(struct file *filp, |
| 26 | wait_queue_head_t *wait_address, |
| 27 | poll_table *p) |
| 28 | |
| 29 | { |
| 30 | struct poll_wqueues *pwq = container_of(p, struct poll_wqueues, pt); |
| 31 | struct poll_table_entry *entry; |
| 32 | |
| 33 | if (!poll_get_entry_sym) |
| 34 | poll_get_entry_sym = (void *) kallsyms_lookup_name("poll_get_entry"); |
| 35 | if (!poll_get_entry_sym) { |
| 36 | printk(KERN_WARNING "LTTng: poll_get_entry_sym symbol lookup failed.\n"); |
| 37 | return; |
| 38 | } |
| 39 | entry = poll_get_entry_sym(pwq); |
| 40 | |
| 41 | if (!__pollwait_sym) |
| 42 | __pollwait_sym = (void *) kallsyms_lookup_name("__pollwait"); |
| 43 | if (!__pollwait_sym) { |
| 44 | printk(KERN_WARNING "LTTng: __pollwait symbol lookup failed.\n"); |
| 45 | return; |
| 46 | } |
| 47 | return __pollwait_sym(filp, wait_address, p); |
| 48 | } |
| 49 | |
| 50 | #else |
| 51 | |
| 52 | #include <linux/poll.h> |
| 53 | |
| 54 | ssize_t wrapper_pollwait_exclusive(struct file *filp, |
| 55 | wait_queue_head_t *wait_address, |
| 56 | poll_table *p) |
| 57 | { |
| 58 | return pollwait_exclusive(filp, wait_address, p); |
| 59 | } |
| 60 | |
| 61 | #endif |