root/arch/i386/kernel/sys_i386.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. sys_pipe
  2. old_mmap
  3. old_select
  4. sys_ipc

   1 /*
   2  * linux/arch/i386/kernel/sys_i386.c
   3  *
   4  * This file contains various random system calls that
   5  * have a non-standard calling sequence on the Linux/i386
   6  * platform.
   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  * sys_pipe() is the normal C calling standard for creating
  23  * a pipe. It's not the way unix tranditionally does this, though.
  24  */
  25 asmlinkage int sys_pipe(unsigned long * fildes)
     /* [previous][next][first][last][top][bottom][index][help] */
  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  * Perform the select(nd, in, out, ex, tv) and mmap() system
  43  * calls. Linux/i386 didn't use to be able to handle more than
  44  * 4 system call parameters, so these system calls used a memory
  45  * block for parameter passing..
  46  */
  47 asmlinkage int old_mmap(unsigned long *buffer)
     /* [previous][next][first][last][top][bottom][index][help] */
  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         flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
  63         return do_mmap(file, get_user(buffer), get_user(buffer+1),
  64                        get_user(buffer+2), flags, get_user(buffer+5));
  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)
     /* [previous][next][first][last][top][bottom][index][help] */
  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  * sys_ipc() is the de-multiplexer for the SysV IPC calls..
  90  *
  91  * This is really horribly ugly.
  92  */
  93 asmlinkage int sys_ipc (uint call, int first, int second, int third, void *ptr, long fifth)
     /* [previous][next][first][last][top][bottom][index][help] */
  94 {
  95         int version;
  96 
  97         version = call >> 16; /* hack for backward compatibility */
  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: /* iBCS2 emulator entry point */
 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 }

/* [previous][next][first][last][top][bottom][index][help] */