]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* $Id: sys_cris.c,v 1.6 2004/03/11 11:38:40 starvik Exp $ |
2 | * | |
3 | * linux/arch/cris/kernel/sys_cris.c | |
4 | * | |
5 | * This file contains various random system calls that | |
6 | * have a non-standard calling sequence on some platforms. | |
7 | * Since we don't have to do any backwards compatibility, our | |
8 | * versions are done in the most "normal" way possible. | |
9 | * | |
10 | */ | |
11 | ||
12 | #include <linux/errno.h> | |
13 | #include <linux/sched.h> | |
14 | #include <linux/syscalls.h> | |
15 | #include <linux/mm.h> | |
5978e791 | 16 | #include <linux/fs.h> |
1da177e4 | 17 | #include <linux/smp.h> |
1da177e4 LT |
18 | #include <linux/sem.h> |
19 | #include <linux/msg.h> | |
20 | #include <linux/shm.h> | |
21 | #include <linux/stat.h> | |
22 | #include <linux/mman.h> | |
23 | #include <linux/file.h> | |
cba4fbbf | 24 | #include <linux/ipc.h> |
1da177e4 LT |
25 | |
26 | #include <asm/uaccess.h> | |
1da177e4 LT |
27 | #include <asm/segment.h> |
28 | ||
1da177e4 LT |
29 | /* common code for old and new mmaps */ |
30 | static inline long | |
31 | do_mmap2(unsigned long addr, unsigned long len, unsigned long prot, | |
32 | unsigned long flags, unsigned long fd, unsigned long pgoff) | |
33 | { | |
34 | int error = -EBADF; | |
35 | struct file * file = NULL; | |
36 | ||
37 | flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE); | |
38 | if (!(flags & MAP_ANONYMOUS)) { | |
39 | file = fget(fd); | |
40 | if (!file) | |
41 | goto out; | |
42 | } | |
43 | ||
44 | down_write(¤t->mm->mmap_sem); | |
45 | error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff); | |
46 | up_write(¤t->mm->mmap_sem); | |
47 | ||
48 | if (file) | |
49 | fput(file); | |
50 | out: | |
51 | return error; | |
52 | } | |
53 | ||
54 | asmlinkage unsigned long old_mmap(unsigned long __user *args) | |
55 | { | |
56 | unsigned long buffer[6]; | |
57 | int err = -EFAULT; | |
58 | ||
59 | if (copy_from_user(&buffer, args, sizeof(buffer))) | |
60 | goto out; | |
61 | ||
62 | err = -EINVAL; | |
63 | if (buffer[5] & ~PAGE_MASK) /* verify that offset is on page boundary */ | |
64 | goto out; | |
65 | ||
66 | err = do_mmap2(buffer[0], buffer[1], buffer[2], buffer[3], | |
67 | buffer[4], buffer[5] >> PAGE_SHIFT); | |
68 | out: | |
69 | return err; | |
70 | } | |
71 | ||
72 | asmlinkage long | |
73 | sys_mmap2(unsigned long addr, unsigned long len, unsigned long prot, | |
74 | unsigned long flags, unsigned long fd, unsigned long pgoff) | |
75 | { | |
76 | return do_mmap2(addr, len, prot, flags, fd, pgoff); | |
77 | } | |
78 | ||
79 | /* | |
80 | * sys_ipc() is the de-multiplexer for the SysV IPC calls.. | |
81 | * | |
82 | * This is really horribly ugly. (same as arch/i386) | |
83 | */ | |
84 | ||
85 | asmlinkage int sys_ipc (uint call, int first, int second, | |
86 | int third, void __user *ptr, long fifth) | |
87 | { | |
88 | int version, ret; | |
89 | ||
90 | version = call >> 16; /* hack for backward compatibility */ | |
91 | call &= 0xffff; | |
92 | ||
93 | switch (call) { | |
94 | case SEMOP: | |
95 | return sys_semtimedop (first, (struct sembuf __user *)ptr, second, NULL); | |
96 | case SEMTIMEDOP: | |
97 | return sys_semtimedop(first, (struct sembuf __user *)ptr, second, | |
98 | (const struct timespec __user *)fifth); | |
99 | ||
100 | case SEMGET: | |
101 | return sys_semget (first, second, third); | |
102 | case SEMCTL: { | |
103 | union semun fourth; | |
104 | if (!ptr) | |
105 | return -EINVAL; | |
106 | if (get_user(fourth.__pad, (void * __user *) ptr)) | |
107 | return -EFAULT; | |
108 | return sys_semctl (first, second, third, fourth); | |
109 | } | |
110 | ||
111 | case MSGSND: | |
112 | return sys_msgsnd (first, (struct msgbuf __user *) ptr, | |
113 | second, third); | |
114 | case MSGRCV: | |
115 | switch (version) { | |
116 | case 0: { | |
117 | struct ipc_kludge tmp; | |
118 | if (!ptr) | |
119 | return -EINVAL; | |
120 | ||
121 | if (copy_from_user(&tmp, | |
122 | (struct ipc_kludge __user *) ptr, | |
123 | sizeof (tmp))) | |
124 | return -EFAULT; | |
125 | return sys_msgrcv (first, tmp.msgp, second, | |
126 | tmp.msgtyp, third); | |
127 | } | |
128 | default: | |
129 | return sys_msgrcv (first, | |
130 | (struct msgbuf __user *) ptr, | |
131 | second, fifth, third); | |
132 | } | |
133 | case MSGGET: | |
134 | return sys_msgget ((key_t) first, second); | |
135 | case MSGCTL: | |
136 | return sys_msgctl (first, second, (struct msqid_ds __user *) ptr); | |
137 | ||
138 | case SHMAT: { | |
139 | ulong raddr; | |
140 | ret = do_shmat (first, (char __user *) ptr, second, &raddr); | |
141 | if (ret) | |
142 | return ret; | |
143 | return put_user (raddr, (ulong __user *) third); | |
144 | } | |
145 | case SHMDT: | |
146 | return sys_shmdt ((char __user *)ptr); | |
147 | case SHMGET: | |
148 | return sys_shmget (first, second, third); | |
149 | case SHMCTL: | |
150 | return sys_shmctl (first, second, | |
151 | (struct shmid_ds __user *) ptr); | |
152 | default: | |
153 | return -ENOSYS; | |
154 | } | |
155 | } |