~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/v850/kernel/syscalls.c

Version: ~ [ linux-5.8 ] ~ [ linux-5.7.14 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.57 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.138 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.193 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.232 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.232 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.85 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * arch/v850/kernel/syscalls.c -- Various system-call definitions not
  3  *      defined in machine-independent code
  4  *
  5  *  Copyright (C) 2001,02  NEC Corporation
  6  *  Copyright (C) 2001,02  Miles Bader <miles@gnu.org>
  7  *
  8  * This file is subject to the terms and conditions of the GNU General
  9  * Public License.  See the file COPYING in the main directory of this
 10  * archive for more details.
 11  *
 12  * This file was derived the ppc version, arch/ppc/kernel/syscalls.c
 13  * ... which was derived from "arch/i386/kernel/sys_i386.c" by Gary Thomas;
 14  *     modified by Cort Dougan (cort@cs.nmt.edu)
 15  *     and Paul Mackerras (paulus@cs.anu.edu.au).
 16  */
 17 
 18 #include <linux/config.h>
 19 #include <linux/errno.h>
 20 #include <linux/mm.h>
 21 #include <linux/smp.h>
 22 #include <linux/smp_lock.h>
 23 #include <linux/sem.h>
 24 #include <linux/msg.h>
 25 #include <linux/shm.h>
 26 #include <linux/stat.h>
 27 #include <linux/mman.h>
 28 #include <linux/sys.h>
 29 #include <linux/ipc.h>
 30 #include <linux/utsname.h>
 31 #include <linux/file.h>
 32 
 33 #include <asm/uaccess.h>
 34 #include <asm/ipc.h>
 35 #include <asm/semaphore.h>
 36 
 37 /*
 38  * sys_ipc() is the de-multiplexer for the SysV IPC calls..
 39  *
 40  * This is really horribly ugly.
 41  */
 42 int
 43 sys_ipc (uint call, int first, int second, int third, void *ptr, long fifth)
 44 {
 45         int version, ret;
 46 
 47         version = call >> 16; /* hack for backward compatibility */
 48         call &= 0xffff;
 49 
 50         ret = -EINVAL;
 51         switch (call) {
 52         case SEMOP:
 53                 ret = sys_semop (first, (struct sembuf *)ptr, second);
 54                 break;
 55         case SEMGET:
 56                 ret = sys_semget (first, second, third);
 57                 break;
 58         case SEMCTL:
 59         {
 60                 union semun fourth;
 61 
 62                 if (!ptr)
 63                         break;
 64                 if ((ret = verify_area (VERIFY_READ, ptr, sizeof(long)))
 65                     || (ret = get_user(fourth.__pad, (void **)ptr)))
 66                         break;
 67                 ret = sys_semctl (first, second, third, fourth);
 68                 break;
 69         }
 70         case MSGSND:
 71                 ret = sys_msgsnd (first, (struct msgbuf *) ptr, second, third);
 72                 break;
 73         case MSGRCV:
 74                 switch (version) {
 75                 case 0: {
 76                         struct ipc_kludge tmp;
 77 
 78                         if (!ptr)
 79                                 break;
 80                         if ((ret = verify_area (VERIFY_READ, ptr, sizeof(tmp)))
 81                             || (ret = copy_from_user(&tmp,
 82                                                 (struct ipc_kludge *) ptr,
 83                                                 sizeof (tmp))))
 84                                 break;
 85                         ret = sys_msgrcv (first, tmp.msgp, second, tmp.msgtyp,
 86                                           third);
 87                         break;
 88                         }
 89                 default:
 90                         ret = sys_msgrcv (first, (struct msgbuf *) ptr,
 91                                           second, fifth, third);
 92                         break;
 93                 }
 94                 break;
 95         case MSGGET:
 96                 ret = sys_msgget ((key_t) first, second);
 97                 break;
 98         case MSGCTL:
 99                 ret = sys_msgctl (first, second, (struct msqid_ds *) ptr);
100                 break;
101         case SHMAT:
102                 switch (version) {
103                 default: {
104                         ulong raddr;
105 
106                         if ((ret = verify_area(VERIFY_WRITE, (ulong*) third,
107                                                sizeof(ulong))))
108                                 break;
109                         ret = sys_shmat (first, (char *) ptr, second, &raddr);
110                         if (ret)
111                                 break;
112                         ret = put_user (raddr, (ulong *) third);
113                         break;
114                         }
115                 case 1: /* iBCS2 emulator entry point */
116                         if (!segment_eq(get_fs(), get_ds()))
117                                 break;
118                         ret = sys_shmat (first, (char *) ptr, second,
119                                          (ulong *) third);
120                         break;
121                 }
122                 break;
123         case SHMDT: 
124                 ret = sys_shmdt ((char *)ptr);
125                 break;
126         case SHMGET:
127                 ret = sys_shmget (first, second, third);
128                 break;
129         case SHMCTL:
130                 ret = sys_shmctl (first, second, (struct shmid_ds *) ptr);
131                 break;
132         }
133 
134         return ret;
135 }
136 
137 /*
138  * sys_pipe() is the normal C calling standard for creating
139  * a pipe. It's not the way unix traditionally does this, though.
140  */
141 int sys_pipe (int *fildes)
142 {
143         int fd[2];
144         int error;
145 
146         error = do_pipe (fd);
147         if (!error) {
148                 if (copy_to_user (fildes, fd, 2*sizeof (int)))
149                         error = -EFAULT;
150         }
151         return error;
152 }
153 
154 static inline unsigned long
155 do_mmap2 (unsigned long addr, size_t len,
156          unsigned long prot, unsigned long flags,
157          unsigned long fd, unsigned long pgoff)
158 {
159         struct file * file = NULL;
160         int ret = -EBADF;
161 
162         flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
163         if (! (flags & MAP_ANONYMOUS)) {
164                 if (!(file = fget (fd)))
165                         goto out;
166         }
167         
168         down_write (&current->mm->mmap_sem);
169         ret = do_mmap_pgoff (file, addr, len, prot, flags, pgoff);
170         up_write (&current->mm->mmap_sem);
171         if (file)
172                 fput (file);
173 out:
174         return ret;
175 }
176 
177 unsigned long sys_mmap2 (unsigned long addr, size_t len,
178                         unsigned long prot, unsigned long flags,
179                         unsigned long fd, unsigned long pgoff)
180 {
181         return do_mmap2 (addr, len, prot, flags, fd, pgoff);
182 }
183 
184 unsigned long sys_mmap (unsigned long addr, size_t len,
185                        unsigned long prot, unsigned long flags,
186                        unsigned long fd, off_t offset)
187 {
188         int err = -EINVAL;
189 
190         if (offset & ~PAGE_MASK)
191                 goto out;
192 
193         err = do_mmap2 (addr, len, prot, flags, fd, offset >> PAGE_SHIFT);
194 out:
195         return err;
196 }
197 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp