This source file includes following definitions.
- sys_pipe
- old_mmap
- old_select
- sys_ipc
1
2
3
4
5
6
7
8
9 #include <linux/config.h>
10 #include <linux/errno.h>
11 #include <linux/sched.h>
12 #include <linux/mm.h>
13 #include <linux/sem.h>
14 #include <linux/msg.h>
15 #include <linux/shm.h>
16 #include <linux/stat.h>
17 #include <linux/mman.h>
18
19 #include <asm/segment.h>
20
21
22
23
24
25 asmlinkage int sys_pipe(unsigned long * fildes)
26 {
27 int fd[2];
28 int error;
29
30 error = verify_area(VERIFY_WRITE,fildes,8);
31 if (error)
32 return error;
33 error = do_pipe(fd);
34 if (error)
35 return error;
36 put_fs_long(fd[0],0+fildes);
37 put_fs_long(fd[1],1+fildes);
38 return 0;
39 }
40
41
42
43
44
45
46
47 asmlinkage int old_mmap(unsigned long *buffer)
48 {
49 int error;
50 unsigned long flags;
51 struct file * file = NULL;
52
53 error = verify_area(VERIFY_READ, buffer, 6*sizeof(long));
54 if (error)
55 return error;
56 flags = get_user(buffer+3);
57 if (!(flags & MAP_ANONYMOUS)) {
58 unsigned long fd = get_user(buffer+4);
59 if (fd >= NR_OPEN || !(file = current->files->fd[fd]))
60 return -EBADF;
61 }
62 return do_mmap(file, get_user(buffer), get_user(buffer+1),
63 get_user(buffer+2), flags, get_user(buffer+5));
64 }
65
66
67 extern asmlinkage int sys_select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
68
69 asmlinkage int old_select(unsigned long *buffer)
70 {
71 int n;
72 fd_set *inp;
73 fd_set *outp;
74 fd_set *exp;
75 struct timeval *tvp;
76
77 n = verify_area(VERIFY_READ, buffer, 5*sizeof(unsigned long));
78 if (n)
79 return n;
80 n = get_user(buffer);
81 inp = (fd_set *) get_user(buffer+1);
82 outp = (fd_set *) get_user(buffer+2);
83 exp = (fd_set *) get_user(buffer+3);
84 tvp = (struct timeval *) get_user(buffer+4);
85 return sys_select(n, inp, outp, exp, tvp);
86 }
87
88
89
90
91
92
93 asmlinkage int sys_ipc (uint call, int first, int second, int third, void *ptr, long fifth)
94 {
95 int version;
96
97 version = call >> 16;
98 call &= 0xffff;
99
100 if (call <= SEMCTL)
101 switch (call) {
102 case SEMOP:
103 return sys_semop (first, (struct sembuf *)ptr, second);
104 case SEMGET:
105 return sys_semget (first, second, third);
106 case SEMCTL: {
107 union semun fourth;
108 int err;
109 if (!ptr)
110 return -EINVAL;
111 if ((err = verify_area (VERIFY_READ, ptr, sizeof(long))))
112 return err;
113 fourth.__pad = (void *) get_fs_long(ptr);
114 return sys_semctl (first, second, third, fourth);
115 }
116 default:
117 return -EINVAL;
118 }
119 if (call <= MSGCTL)
120 switch (call) {
121 case MSGSND:
122 return sys_msgsnd (first, (struct msgbuf *) ptr,
123 second, third);
124 case MSGRCV:
125 switch (version) {
126 case 0: {
127 struct ipc_kludge tmp;
128 int err;
129 if (!ptr)
130 return -EINVAL;
131 if ((err = verify_area (VERIFY_READ, ptr, sizeof(tmp))))
132 return err;
133 memcpy_fromfs (&tmp,(struct ipc_kludge *) ptr,
134 sizeof (tmp));
135 return sys_msgrcv (first, tmp.msgp, second, tmp.msgtyp, third);
136 }
137 case 1: default:
138 return sys_msgrcv (first, (struct msgbuf *) ptr, second, fifth, third);
139 }
140 case MSGGET:
141 return sys_msgget ((key_t) first, second);
142 case MSGCTL:
143 return sys_msgctl (first, second, (struct msqid_ds *) ptr);
144 default:
145 return -EINVAL;
146 }
147 if (call <= SHMCTL)
148 switch (call) {
149 case SHMAT:
150 switch (version) {
151 case 0: default: {
152 ulong raddr;
153 int err;
154 if ((err = verify_area(VERIFY_WRITE, (ulong*) third, sizeof(ulong))))
155 return err;
156 err = sys_shmat (first, (char *) ptr, second, &raddr);
157 if (err)
158 return err;
159 put_fs_long (raddr, (ulong *) third);
160 return 0;
161 }
162 case 1:
163 if (get_fs() != get_ds())
164 return -EINVAL;
165 return sys_shmat (first, (char *) ptr, second, (ulong *) third);
166 }
167 case SHMDT:
168 return sys_shmdt ((char *)ptr);
169 case SHMGET:
170 return sys_shmget (first, second, third);
171 case SHMCTL:
172 return sys_shmctl (first, second, (struct shmid_ds *) ptr);
173 default:
174 return -EINVAL;
175 }
176 return -EINVAL;
177 }