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/errno.h>
  10 #include <linux/sched.h>
  11 #include <linux/mm.h>
  12 #include <linux/sem.h>
  13 #include <linux/msg.h>
  14 #include <linux/shm.h>
  15 #include <linux/stat.h>
  16 #include <linux/mman.h>
  17 
  18 #include <asm/segment.h>
  19 
  20 /*
  21  * sys_pipe() is the normal C calling standard for creating
  22  * a pipe. It's not the way unix tranditionally does this, though.
  23  */
  24 asmlinkage int sys_pipe(unsigned long * fildes)
     /* [previous][next][first][last][top][bottom][index][help] */
  25 {
  26         int fd[2];
  27         int error;
  28 
  29         error = verify_area(VERIFY_WRITE,fildes,8);
  30         if (error)
  31                 return error;
  32         error = do_pipe(fd);
  33         if (error)
  34                 return error;
  35         put_fs_long(fd[0],0+fildes);
  36         put_fs_long(fd[1],1+fildes);
  37         return 0;
  38 }
  39 
  40 /*
  41  * Perform the select(nd, in, out, ex, tv) and mmap() system
  42  * calls. Linux/i386 didn't use to be able to handle more than
  43  * 4 system call parameters, so these system calls used a memory
  44  * block for parameter passing..
  45  */
  46 asmlinkage int old_mmap(unsigned long *buffer)
     /* [previous][next][first][last][top][bottom][index][help] */
  47 {
  48         int error;
  49         unsigned long flags;
  50         struct file * file = NULL;
  51 
  52         error = verify_area(VERIFY_READ, buffer, 6*sizeof(long));
  53         if (error)
  54                 return error;
  55         flags = get_user(buffer+3);
  56         if (!(flags & MAP_ANONYMOUS)) {
  57                 unsigned long fd = get_user(buffer+4);
  58                 if (fd >= NR_OPEN || !(file = current->files->fd[fd]))
  59                         return -EBADF;
  60         }
  61         flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
  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 extern asmlinkage int sys_select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
  67 
  68 asmlinkage int old_select(unsigned long *buffer)
     /* [previous][next][first][last][top][bottom][index][help] */
  69 {
  70         int n;
  71         fd_set *inp;
  72         fd_set *outp;
  73         fd_set *exp;
  74         struct timeval *tvp;
  75 
  76         n = verify_area(VERIFY_READ, buffer, 5*sizeof(unsigned long));
  77         if (n)
  78                 return n;
  79         n = get_user(buffer);
  80         inp = (fd_set *) get_user(buffer+1);
  81         outp = (fd_set *) get_user(buffer+2);
  82         exp = (fd_set *) get_user(buffer+3);
  83         tvp = (struct timeval *) get_user(buffer+4);
  84         return sys_select(n, inp, outp, exp, tvp);
  85 }
  86 
  87 /*
  88  * sys_ipc() is the de-multiplexer for the SysV IPC calls..
  89  *
  90  * This is really horribly ugly.
  91  */
  92 asmlinkage int sys_ipc (uint call, int first, int second, int third, void *ptr, long fifth)
     /* [previous][next][first][last][top][bottom][index][help] */
  93 {
  94         int version;
  95 
  96         version = call >> 16; /* hack for backward compatibility */
  97         call &= 0xffff;
  98 
  99         if (call <= SEMCTL)
 100                 switch (call) {
 101                 case SEMOP:
 102                         return sys_semop (first, (struct sembuf *)ptr, second);
 103                 case SEMGET:
 104                         return sys_semget (first, second, third);
 105                 case SEMCTL: {
 106                         union semun fourth;
 107                         int err;
 108                         if (!ptr)
 109                                 return -EINVAL;
 110                         if ((err = verify_area (VERIFY_READ, ptr, sizeof(long))))
 111                                 return err;
 112                         fourth.__pad = (void *) get_fs_long(ptr);
 113                         return sys_semctl (first, second, third, fourth);
 114                         }
 115                 default:
 116                         return -EINVAL;
 117                 }
 118         if (call <= MSGCTL) 
 119                 switch (call) {
 120                 case MSGSND:
 121                         return sys_msgsnd (first, (struct msgbuf *) ptr, 
 122                                            second, third);
 123                 case MSGRCV:
 124                         switch (version) {
 125                         case 0: {
 126                                 struct ipc_kludge tmp;
 127                                 int err;
 128                                 if (!ptr)
 129                                         return -EINVAL;
 130                                 if ((err = verify_area (VERIFY_READ, ptr, sizeof(tmp))))
 131                                         return err;
 132                                 memcpy_fromfs (&tmp,(struct ipc_kludge *) ptr,
 133                                                sizeof (tmp));
 134                                 return sys_msgrcv (first, tmp.msgp, second, tmp.msgtyp, third);
 135                                 }
 136                         case 1: default:
 137                                 return sys_msgrcv (first, (struct msgbuf *) ptr, second, fifth, third);
 138                         }
 139                 case MSGGET:
 140                         return sys_msgget ((key_t) first, second);
 141                 case MSGCTL:
 142                         return sys_msgctl (first, second, (struct msqid_ds *) ptr);
 143                 default:
 144                         return -EINVAL;
 145                 }
 146         if (call <= SHMCTL) 
 147                 switch (call) {
 148                 case SHMAT:
 149                         switch (version) {
 150                         case 0: default: {
 151                                 ulong raddr;
 152                                 int err;
 153                                 if ((err = verify_area(VERIFY_WRITE, (ulong*) third, sizeof(ulong))))
 154                                         return err;
 155                                 err = sys_shmat (first, (char *) ptr, second, &raddr);
 156                                 if (err)
 157                                         return err;
 158                                 put_fs_long (raddr, (ulong *) third);
 159                                 return 0;
 160                                 }
 161                         case 1: /* iBCS2 emulator entry point */
 162                                 if (get_fs() != get_ds())
 163                                         return -EINVAL;
 164                                 return sys_shmat (first, (char *) ptr, second, (ulong *) third);
 165                         }
 166                 case SHMDT: 
 167                         return sys_shmdt ((char *)ptr);
 168                 case SHMGET:
 169                         return sys_shmget (first, second, third);
 170                 case SHMCTL:
 171                         return sys_shmctl (first, second, (struct shmid_ds *) ptr);
 172                 default:
 173                         return -EINVAL;
 174                 }
 175         return -EINVAL;
 176 }

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