2 * linux/arch/i386/kernel/sys_i386.c
4 * This file contains various random system calls that
5 * have a non-standard calling sequence on the Linux/i386
9 #include <linux/errno.h>
10 #include <linux/sched.h>
12 #include <linux/smp.h>
13 #include <linux/smp_lock.h>
14 #include <linux/sem.h>
15 #include <linux/msg.h>
16 #include <linux/shm.h>
17 #include <linux/stat.h>
18 #include <linux/mman.h>
19 #include <linux/file.h>
20 #include <linux/utsname.h>
22 #include <asm/uaccess.h>
26 * sys_pipe() is the normal C calling standard for creating
27 * a pipe. It's not the way Unix traditionally does this, though.
29 asmlinkage
int sys_pipe(unsigned long * fildes
)
36 if (copy_to_user(fildes
, fd
, 2*sizeof(int)))
42 /* common code for old and new mmaps */
43 static inline long do_mmap2(
44 unsigned long addr
, unsigned long len
,
45 unsigned long prot
, unsigned long flags
,
46 unsigned long fd
, unsigned long pgoff
)
49 struct file
* file
= NULL
;
51 flags
&= ~(MAP_EXECUTABLE
| MAP_DENYWRITE
);
52 if (!(flags
& MAP_ANONYMOUS
)) {
58 down(¤t
->mm
->mmap_sem
);
59 error
= do_mmap_pgoff(file
, addr
, len
, prot
, flags
, pgoff
);
60 up(¤t
->mm
->mmap_sem
);
68 asmlinkage
long sys_mmap2(unsigned long addr
, unsigned long len
,
69 unsigned long prot
, unsigned long flags
,
70 unsigned long fd
, unsigned long pgoff
)
72 return do_mmap2(addr
, len
, prot
, flags
, fd
, pgoff
);
76 * Perform the select(nd, in, out, ex, tv) and mmap() system
77 * calls. Linux/i386 didn't use to be able to handle more than
78 * 4 system call parameters, so these system calls used a memory
79 * block for parameter passing..
82 struct mmap_arg_struct
{
91 asmlinkage
int old_mmap(struct mmap_arg_struct
*arg
)
93 struct mmap_arg_struct a
;
96 if (copy_from_user(&a
, arg
, sizeof(a
)))
100 if (a
.offset
& ~PAGE_MASK
)
103 err
= do_mmap2(a
.addr
, a
.len
, a
.prot
, a
.flags
, a
.fd
, a
.offset
>> PAGE_SHIFT
);
109 extern asmlinkage
int sys_select(int, fd_set
*, fd_set
*, fd_set
*, struct timeval
*);
111 struct sel_arg_struct
{
113 fd_set
*inp
, *outp
, *exp
;
117 asmlinkage
int old_select(struct sel_arg_struct
*arg
)
119 struct sel_arg_struct a
;
121 if (copy_from_user(&a
, arg
, sizeof(a
)))
123 /* sys_select() does the appropriate kernel locking */
124 return sys_select(a
.n
, a
.inp
, a
.outp
, a
.exp
, a
.tvp
);
128 * sys_ipc() is the de-multiplexer for the SysV IPC calls..
130 * This is really horribly ugly.
132 asmlinkage
int sys_ipc (uint call
, int first
, int second
,
133 int third
, void *ptr
, long fifth
)
137 version
= call
>> 16; /* hack for backward compatibility */
142 return sys_semop (first
, (struct sembuf
*)ptr
, second
);
144 return sys_semget (first
, second
, third
);
149 if (get_user(fourth
.__pad
, (void **) ptr
))
151 return sys_semctl (first
, second
, third
, fourth
);
155 return sys_msgsnd (first
, (struct msgbuf
*) ptr
,
160 struct ipc_kludge tmp
;
164 if (copy_from_user(&tmp
,
165 (struct ipc_kludge
*) ptr
,
168 return sys_msgrcv (first
, tmp
.msgp
, second
,
172 return sys_msgrcv (first
,
173 (struct msgbuf
*) ptr
,
174 second
, fifth
, third
);
177 return sys_msgget ((key_t
) first
, second
);
179 return sys_msgctl (first
, second
, (struct msqid_ds
*) ptr
);
185 ret
= sys_shmat (first
, (char *) ptr
, second
, &raddr
);
188 return put_user (raddr
, (ulong
*) third
);
190 case 1: /* iBCS2 emulator entry point */
191 if (!segment_eq(get_fs(), get_ds()))
193 return sys_shmat (first
, (char *) ptr
, second
, (ulong
*) third
);
196 return sys_shmdt ((char *)ptr
);
198 return sys_shmget (first
, second
, third
);
200 return sys_shmctl (first
, second
,
201 (struct shmid_ds
*) ptr
);
210 asmlinkage
int sys_uname(struct old_utsname
* name
)
216 err
=copy_to_user(name
, &system_utsname
, sizeof (*name
));
218 return err
?-EFAULT
:0;
221 asmlinkage
int sys_olduname(struct oldold_utsname
* name
)
227 if (!access_ok(VERIFY_WRITE
,name
,sizeof(struct oldold_utsname
)))
232 error
= __copy_to_user(&name
->sysname
,&system_utsname
.sysname
,__OLD_UTS_LEN
);
233 error
|= __put_user(0,name
->sysname
+__OLD_UTS_LEN
);
234 error
|= __copy_to_user(&name
->nodename
,&system_utsname
.nodename
,__OLD_UTS_LEN
);
235 error
|= __put_user(0,name
->nodename
+__OLD_UTS_LEN
);
236 error
|= __copy_to_user(&name
->release
,&system_utsname
.release
,__OLD_UTS_LEN
);
237 error
|= __put_user(0,name
->release
+__OLD_UTS_LEN
);
238 error
|= __copy_to_user(&name
->version
,&system_utsname
.version
,__OLD_UTS_LEN
);
239 error
|= __put_user(0,name
->version
+__OLD_UTS_LEN
);
240 error
|= __copy_to_user(&name
->machine
,&system_utsname
.machine
,__OLD_UTS_LEN
);
241 error
|= __put_user(0,name
->machine
+__OLD_UTS_LEN
);
245 error
= error
? -EFAULT
: 0;
250 asmlinkage
int sys_pause(void)
252 current
->state
= TASK_INTERRUPTIBLE
;
254 return -ERESTARTNOHAND
;