root/arch/i386/kernel/sys_i386.c

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

DEFINITIONS

This source file includes following definitions.
  1. old_select
  2. 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 
  18 #include <asm/segment.h>
  19 
  20 /*
  21  * Perform the select(nd, in, out, ex, tv) system call.
  22  * Linux/i386 didn't use to be able to handle 5 system call
  23  * parameters, so the old select used a memory block for
  24  * parameter passing..
  25  */
  26 extern asmlinkage int sys_select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
  27 
  28 asmlinkage int old_select(unsigned long *buffer)
     /* [previous][next][first][last][top][bottom][index][help] */
  29 {
  30         int n;
  31         fd_set *inp;
  32         fd_set *outp;
  33         fd_set *exp;
  34         struct timeval *tvp;
  35 
  36         n = verify_area(VERIFY_READ, buffer, 5*sizeof(unsigned long));
  37         if (n)
  38                 return n;
  39         n = get_user(buffer);
  40         inp = (fd_set *) get_user(buffer+1);
  41         outp = (fd_set *) get_user(buffer+2);
  42         exp = (fd_set *) get_user(buffer+3);
  43         tvp = (struct timeval *) get_user(buffer+4);
  44         return sys_select(n, inp, outp, exp, tvp);
  45 }
  46 
  47 /*
  48  * sys_ipc() is the de-multiplexer for the SysV IPC calls..
  49  *
  50  * This is really horribly ugly.
  51  */
  52 asmlinkage int sys_ipc (uint call, int first, int second, int third, void *ptr, long fifth)
     /* [previous][next][first][last][top][bottom][index][help] */
  53 {
  54         int version;
  55 
  56         version = call >> 16; /* hack for backward compatibility */
  57         call &= 0xffff;
  58 
  59         if (call <= SEMCTL)
  60                 switch (call) {
  61                 case SEMOP:
  62                         return sys_semop (first, (struct sembuf *)ptr, second);
  63                 case SEMGET:
  64                         return sys_semget (first, second, third);
  65                 case SEMCTL: {
  66                         union semun fourth;
  67                         int err;
  68                         if (!ptr)
  69                                 return -EINVAL;
  70                         if ((err = verify_area (VERIFY_READ, ptr, sizeof(long))))
  71                                 return err;
  72                         fourth.__pad = (void *) get_fs_long(ptr);
  73                         return sys_semctl (first, second, third, fourth);
  74                         }
  75                 default:
  76                         return -EINVAL;
  77                 }
  78         if (call <= MSGCTL) 
  79                 switch (call) {
  80                 case MSGSND:
  81                         return sys_msgsnd (first, (struct msgbuf *) ptr, 
  82                                            second, third);
  83                 case MSGRCV:
  84                         switch (version) {
  85                         case 0: {
  86                                 struct ipc_kludge tmp;
  87                                 int err;
  88                                 if (!ptr)
  89                                         return -EINVAL;
  90                                 if ((err = verify_area (VERIFY_READ, ptr, sizeof(tmp))))
  91                                         return err;
  92                                 memcpy_fromfs (&tmp,(struct ipc_kludge *) ptr,
  93                                                sizeof (tmp));
  94                                 return sys_msgrcv (first, tmp.msgp, second, tmp.msgtyp, third);
  95                                 }
  96                         case 1: default:
  97                                 return sys_msgrcv (first, (struct msgbuf *) ptr, second, fifth, third);
  98                         }
  99                 case MSGGET:
 100                         return sys_msgget ((key_t) first, second);
 101                 case MSGCTL:
 102                         return sys_msgctl (first, second, (struct msqid_ds *) ptr);
 103                 default:
 104                         return -EINVAL;
 105                 }
 106         if (call <= SHMCTL) 
 107                 switch (call) {
 108                 case SHMAT:
 109                         switch (version) {
 110                         case 0: default: {
 111                                 ulong raddr;
 112                                 int err;
 113                                 if ((err = verify_area(VERIFY_WRITE, (ulong*) third, sizeof(ulong))))
 114                                         return err;
 115                                 err = sys_shmat (first, (char *) ptr, second, &raddr);
 116                                 if (err)
 117                                         return err;
 118                                 put_fs_long (raddr, (ulong *) third);
 119                                 return 0;
 120                                 }
 121                         case 1: /* iBCS2 emulator entry point */
 122                                 if (get_fs() != get_ds())
 123                                         return -EINVAL;
 124                                 return sys_shmat (first, (char *) ptr, second, (ulong *) third);
 125                         }
 126                 case SHMDT: 
 127                         return sys_shmdt ((char *)ptr);
 128                 case SHMGET:
 129                         return sys_shmget (first, second, third);
 130                 case SHMCTL:
 131                         return sys_shmctl (first, second, (struct shmid_ds *) ptr);
 132                 default:
 133                         return -EINVAL;
 134                 }
 135         return -EINVAL;
 136 }

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