Statistics
| Branch: | Tag: | Revision:

root / xseg / drivers / kernel / xseg_posix.c @ 7ce25cf6

History | View | Annotate | Download (2.5 kB)

1
/* xseg_posix.c
2
 * kernel driver for posix peers
3
 */
4

    
5
#include <linux/module.h>
6
#include <linux/moduleparam.h>
7
#include <linux/init.h>
8
#include <linux/sched.h>
9
#include <linux/kernel.h>
10
#include <linux/slab.h>
11
#include <linux/fs.h>
12
#include <linux/errno.h>
13
#include <linux/timer.h>
14
#include <linux/types.h>
15
#include <linux/vmalloc.h>
16
#include <linux/genhd.h>
17
#include <linux/blkdev.h>
18
#include <linux/bio.h>
19
#include <linux/device.h>
20
#include <linux/completion.h>
21

    
22
MODULE_DESCRIPTION("xseg_posix");
23
MODULE_AUTHOR("XSEG");
24
MODULE_LICENSE("GPL");
25

    
26
static int posix_signal_init(void)
27
{
28
        return 0;
29
}
30

    
31
static void posix_signal_quit(void)
32
{
33
        return;
34
}
35

    
36
static int posix_prepare_wait(struct xseg *xseg, uint32_t portno)
37
{
38
        return -1;
39
}
40

    
41
static int posix_cancel_wait(struct xseg *xseg, uint32_t portno)
42
{
43
        return -1;
44
}
45

    
46
static int posix_wait_signal(struct xseg *xseg, uint32_t timeout)
47
{
48
        return -1;
49
}
50

    
51
static int posix_signal(struct xseg *xseg, uint32_t portno)
52
{
53
        struct pid *pid;
54
        struct xseg_port *port = &xseg->ports[portno];
55
        struct task_struct *task;
56
        int ret = -ENOENT;
57

    
58
        rcu_read_lock();
59
        /* XXX Security: xseg peers can kill anyone */
60
        pid = find_vpid((pid_t)port->waitcue);
61
        if (!pid)
62
                goto out;
63
        task = pid_task(pid, PIDTYPE_PID);
64
        if (!task)
65
                goto out;
66

    
67
        ret = send_sig(SIGIO, task, 1);
68
out:
69
        rcu_read_unlock();
70
        return ret;
71
}
72

    
73
static void *posix_malloc(uint64_t size)
74
{
75
        return NULL;
76
}
77

    
78
static void *posix_realloc(void *mem, uint64_t size)
79
{
80
        return NULL;
81
}
82

    
83
static void posix_mfree(void *mem) { }
84

    
85
static struct xseg_peer xseg_peer_posix = {
86
        /* xseg signal operations */
87
        {
88
                .signal_init = posix_signal_init,
89
                .signal_quit = posix_signal_quit,
90
                .cancel_wait = posix_cancel_wait,
91
                .prepare_wait = posix_prepare_wait,
92
                .wait_signal = posix_wait_signal,
93
                .signal = posix_signal,
94
                .malloc = posix_malloc,
95
                .realloc = posix_realloc,
96
                .mfree = posix_mfree
97
        },
98
        /* name */
99
        "posix"
100
};
101

    
102
static int posix_init(void)
103
{
104
        int r;
105

    
106
        XSEGLOG("registering xseg types");
107

    
108
        r = xseg_register_peer(&xseg_peer_posix);
109

    
110
        return r;
111
}
112

    
113
static int posix_quit(void)
114
{
115
        xseg_unregister_peer(xseg_peer_posix.name);
116
        return 0;
117
}
118

    
119
/* *************************** */
120
/* ** Module Initialization ** */
121
/* *************************** */
122

    
123
static int __init xseg_posix_init(void)
124
{
125
        int ret = -ENOSYS;
126

    
127
        ret = posix_init();
128
        if (ret)
129
                goto out;
130

    
131
        XSEGLOG("initialization complete");
132
out:
133
        return ret;
134
}
135

    
136
static void __exit xseg_posix_exit(void)
137
{
138
        posix_quit();
139
}
140

    
141
module_init(xseg_posix_init);
142
module_exit(xseg_posix_exit);