2 * sysirix.c: IRIX system call emulation.
4 * Copyright (C) 1996 David S. Miller
5 * Copyright (C) 1997 Miguel de Icaza
6 * Copyright (C) 1997, 1998, 1999, 2000 Ralf Baechle
8 #include <linux/kernel.h>
9 #include <linux/sched.h>
10 #include <linux/binfmts.h>
11 #include <linux/capability.h>
12 #include <linux/highuid.h>
13 #include <linux/pagemap.h>
15 #include <linux/mman.h>
16 #include <linux/slab.h>
17 #include <linux/swap.h>
18 #include <linux/errno.h>
19 #include <linux/time.h>
20 #include <linux/timex.h>
21 #include <linux/times.h>
22 #include <linux/elf.h>
23 #include <linux/msg.h>
24 #include <linux/shm.h>
25 #include <linux/smp.h>
26 #include <linux/smp_lock.h>
27 #include <linux/utsname.h>
28 #include <linux/file.h>
29 #include <linux/vfs.h>
30 #include <linux/namei.h>
31 #include <linux/socket.h>
32 #include <linux/security.h>
33 #include <linux/syscalls.h>
34 #include <linux/resource.h>
36 #include <asm/ptrace.h>
38 #include <asm/uaccess.h>
39 #include <asm/inventory.h>
41 /* 2,191 lines of complete and utter shit coming up... */
43 extern int max_threads
;
45 /* The sysmp commands supported thus far. */
46 #define MP_NPROCS 1 /* # processor in complex */
47 #define MP_NAPROCS 2 /* # active processors in complex */
48 #define MP_PGSIZE 14 /* Return system page size in v1. */
50 asmlinkage
int irix_sysmp(struct pt_regs
*regs
)
56 if(regs
->regs
[2] == 1000)
58 cmd
= regs
->regs
[base
+ 4];
65 error
= num_online_cpus();
68 printk("SYSMP[%s:%d]: Unsupported opcode %d\n",
69 current
->comm
, current
->pid
, (int)cmd
);
77 /* The prctl commands. */
78 #define PR_MAXPROCS 1 /* Tasks/user. */
79 #define PR_ISBLOCKED 2 /* If blocked, return 1. */
80 #define PR_SETSTACKSIZE 3 /* Set largest task stack size. */
81 #define PR_GETSTACKSIZE 4 /* Get largest task stack size. */
82 #define PR_MAXPPROCS 5 /* Num parallel tasks. */
83 #define PR_UNBLKONEXEC 6 /* When task exec/exit's, unblock. */
84 #define PR_SETEXITSIG 8 /* When task exit's, set signal. */
85 #define PR_RESIDENT 9 /* Make task unswappable. */
86 #define PR_ATTACHADDR 10 /* (Re-)Connect a vma to a task. */
87 #define PR_DETACHADDR 11 /* Disconnect a vma from a task. */
88 #define PR_TERMCHILD 12 /* Kill child if the parent dies. */
89 #define PR_GETSHMASK 13 /* Get the sproc() share mask. */
90 #define PR_GETNSHARE 14 /* Number of share group members. */
91 #define PR_COREPID 15 /* Add task pid to name when it core. */
92 #define PR_ATTACHADDRPERM 16 /* (Re-)Connect vma, with specified prot. */
93 #define PR_PTHREADEXIT 17 /* Kill a pthread, only for IRIX 6.[234] */
95 asmlinkage
int irix_prctl(unsigned option
, ...)
100 va_start(args
, option
);
103 printk("irix_prctl[%s:%d]: Wants PR_MAXPROCS\n",
104 current
->comm
, current
->pid
);
109 struct task_struct
*task
;
111 printk("irix_prctl[%s:%d]: Wants PR_ISBLOCKED\n",
112 current
->comm
, current
->pid
);
113 read_lock(&tasklist_lock
);
114 task
= find_task_by_pid(va_arg(args
, pid_t
));
117 error
= (task
->run_list
.next
!= NULL
);
118 read_unlock(&tasklist_lock
);
119 /* Can _your_ OS find this out that fast? */
123 case PR_SETSTACKSIZE
: {
124 long value
= va_arg(args
, long);
126 printk("irix_prctl[%s:%d]: Wants PR_SETSTACKSIZE<%08lx>\n",
127 current
->comm
, current
->pid
, (unsigned long) value
);
128 if (value
> RLIM_INFINITY
)
129 value
= RLIM_INFINITY
;
130 if (capable(CAP_SYS_ADMIN
)) {
131 task_lock(current
->group_leader
);
132 current
->signal
->rlim
[RLIMIT_STACK
].rlim_max
=
133 current
->signal
->rlim
[RLIMIT_STACK
].rlim_cur
= value
;
134 task_unlock(current
->group_leader
);
138 task_lock(current
->group_leader
);
139 if (value
> current
->signal
->rlim
[RLIMIT_STACK
].rlim_max
) {
141 task_unlock(current
->group_leader
);
144 current
->signal
->rlim
[RLIMIT_STACK
].rlim_cur
= value
;
145 task_unlock(current
->group_leader
);
150 case PR_GETSTACKSIZE
:
151 printk("irix_prctl[%s:%d]: Wants PR_GETSTACKSIZE\n",
152 current
->comm
, current
->pid
);
153 error
= current
->signal
->rlim
[RLIMIT_STACK
].rlim_cur
;
157 printk("irix_prctl[%s:%d]: Wants PR_MAXPROCS\n",
158 current
->comm
, current
->pid
);
163 printk("irix_prctl[%s:%d]: Wants PR_UNBLKONEXEC\n",
164 current
->comm
, current
->pid
);
169 printk("irix_prctl[%s:%d]: Wants PR_SETEXITSIG\n",
170 current
->comm
, current
->pid
);
172 /* We can probably play some game where we set the task
173 * exit_code to some non-zero value when this is requested,
174 * and check whether exit_code is already set in do_exit().
180 printk("irix_prctl[%s:%d]: Wants PR_RESIDENT\n",
181 current
->comm
, current
->pid
);
182 error
= 0; /* Compatibility indeed. */
186 printk("irix_prctl[%s:%d]: Wants PR_ATTACHADDR\n",
187 current
->comm
, current
->pid
);
192 printk("irix_prctl[%s:%d]: Wants PR_DETACHADDR\n",
193 current
->comm
, current
->pid
);
198 printk("irix_prctl[%s:%d]: Wants PR_TERMCHILD\n",
199 current
->comm
, current
->pid
);
204 printk("irix_prctl[%s:%d]: Wants PR_GETSHMASK\n",
205 current
->comm
, current
->pid
);
206 error
= -EINVAL
; /* Until I have the sproc() stuff in. */
210 error
= 0; /* Until I have the sproc() stuff in. */
214 printk("irix_prctl[%s:%d]: Wants PR_COREPID\n",
215 current
->comm
, current
->pid
);
219 case PR_ATTACHADDRPERM
:
220 printk("irix_prctl[%s:%d]: Wants PR_ATTACHADDRPERM\n",
221 current
->comm
, current
->pid
);
226 printk("irix_prctl[%s:%d]: Non-existant opcode %d\n",
227 current
->comm
, current
->pid
, option
);
236 #undef DEBUG_PROCGRPS
238 extern unsigned long irix_mapelf(int fd
, struct elf_phdr __user
*user_phdrp
, int cnt
);
239 extern char *prom_getenv(char *name
);
240 extern long prom_setenv(char *name
, char *value
);
242 /* The syssgi commands supported thus far. */
243 #define SGI_SYSID 1 /* Return unique per-machine identifier. */
244 #define SGI_INVENT 5 /* Fetch inventory */
245 # define SGI_INV_SIZEOF 1
246 # define SGI_INV_READ 2
247 #define SGI_RDNAME 6 /* Return string name of a process. */
248 #define SGI_SETNVRAM 8 /* Set PROM variable. */
249 #define SGI_GETNVRAM 9 /* Get PROM variable. */
250 #define SGI_SETPGID 21 /* Set process group id. */
251 #define SGI_SYSCONF 22 /* POSIX sysconf garbage. */
252 #define SGI_PATHCONF 24 /* POSIX sysconf garbage. */
253 #define SGI_SETGROUPS 40 /* POSIX sysconf garbage. */
254 #define SGI_GETGROUPS 41 /* POSIX sysconf garbage. */
255 #define SGI_RUSAGE 56 /* BSD style rusage(). */
256 #define SGI_SSYNC 62 /* Synchronous fs sync. */
257 #define SGI_GETSID 65 /* SysVr4 get session id. */
258 #define SGI_ELFMAP 68 /* Map an elf image. */
259 #define SGI_TOSSTSAVE 108 /* Toss saved vma's. */
260 #define SGI_FP_BCOPY 129 /* Should FPU bcopy be used on this machine? */
261 #define SGI_PHYSP 1011 /* Translate virtual into physical page. */
263 asmlinkage
int irix_syssgi(struct pt_regs
*regs
)
266 int retval
, base
= 0;
268 if (regs
->regs
[2] == 1000)
271 cmd
= regs
->regs
[base
+ 4];
274 char __user
*buf
= (char __user
*) regs
->regs
[base
+ 5];
276 /* XXX Use ethernet addr.... */
277 retval
= clear_user(buf
, 64) ? -EFAULT
: 0;
282 int pid
= (int) regs
->regs
[base
+ 5];
283 char __user
*buf
= (char __user
*) regs
->regs
[base
+ 6];
284 struct task_struct
*p
;
285 char tcomm
[sizeof(current
->comm
)];
287 read_lock(&tasklist_lock
);
288 p
= find_task_by_pid(pid
);
290 read_unlock(&tasklist_lock
);
294 get_task_comm(tcomm
, p
);
295 read_unlock(&tasklist_lock
);
297 /* XXX Need to check sizes. */
298 retval
= copy_to_user(buf
, tcomm
, sizeof(tcomm
)) ? -EFAULT
: 0;
303 char __user
*name
= (char __user
*) regs
->regs
[base
+5];
304 char __user
*buf
= (char __user
*) regs
->regs
[base
+6];
306 return -EINVAL
; /* til I fix it */
307 value
= prom_getenv(name
); /* PROM lock? */
312 /* Do I strlen() for the length? */
313 retval
= copy_to_user(buf
, value
, 128) ? -EFAULT
: 0;
318 char __user
*name
= (char __user
*) regs
->regs
[base
+5];
319 char __user
*value
= (char __user
*) regs
->regs
[base
+6];
320 return -EINVAL
; /* til I fix it */
321 retval
= prom_setenv(name
, value
);
322 /* XXX make sure retval conforms to syssgi(2) */
323 printk("[%s:%d] setnvram(\"%s\", \"%s\"): retval %d",
324 current
->comm
, current
->pid
, name
, value
, retval
);
325 /* if (retval == PROM_ENOENT)
332 #ifdef DEBUG_PROCGRPS
333 printk("[%s:%d] setpgid(%d, %d) ",
334 current
->comm
, current
->pid
,
335 (int) regs
->regs
[base
+ 5], (int)regs
->regs
[base
+ 6]);
337 retval
= sys_setpgid(regs
->regs
[base
+ 5], regs
->regs
[base
+ 6]);
339 #ifdef DEBUG_PROCGRPS
340 printk("retval=%d\n", retval
);
345 switch(regs
->regs
[base
+ 5]) {
347 retval
= (MAX_ARG_PAGES
>> 4); /* XXX estimate... */
350 retval
= max_threads
;
356 retval
= NGROUPS_MAX
;
394 retval
= sys_setgroups((int) regs
->regs
[base
+ 5],
395 (gid_t __user
*) regs
->regs
[base
+ 6]);
399 retval
= sys_getgroups((int) regs
->regs
[base
+ 5],
400 (gid_t __user
*) regs
->regs
[base
+ 6]);
404 struct rusage __user
*ru
= (struct rusage __user
*) regs
->regs
[base
+ 6];
406 switch((int) regs
->regs
[base
+ 5]) {
409 retval
= getrusage(current
, RUSAGE_SELF
, ru
);
413 /* rusage children */
414 retval
= getrusage(current
, RUSAGE_CHILDREN
, ru
);
429 #ifdef DEBUG_PROCGRPS
430 printk("[%s:%d] getsid(%d) ", current
->comm
, current
->pid
,
431 (int) regs
->regs
[base
+ 5]);
433 retval
= sys_getsid(regs
->regs
[base
+ 5]);
434 #ifdef DEBUG_PROCGRPS
435 printk("retval=%d\n", retval
);
440 retval
= irix_mapelf((int) regs
->regs
[base
+ 5],
441 (struct elf_phdr __user
*) regs
->regs
[base
+ 6],
442 (int) regs
->regs
[base
+ 7]);
446 /* XXX We don't need to do anything? */
455 unsigned long addr
= regs
->regs
[base
+ 5];
456 int __user
*pageno
= (int __user
*) (regs
->regs
[base
+ 6]);
457 struct mm_struct
*mm
= current
->mm
;
463 down_read(&mm
->mmap_sem
);
464 pgdp
= pgd_offset(mm
, addr
);
465 pudp
= pud_offset(pgdp
, addr
);
466 pmdp
= pmd_offset(pudp
, addr
);
467 ptep
= pte_offset(pmdp
, addr
);
472 if (pte_val(pte
) & (_PAGE_VALID
| _PAGE_PRESENT
)) {
473 /* b0rked on 64-bit */
474 retval
= put_user((pte_val(pte
) & PAGE_MASK
) >>
478 up_read(&mm
->mmap_sem
);
483 int arg1
= (int) regs
->regs
[base
+ 5];
484 void __user
*buffer
= (void __user
*) regs
->regs
[base
+ 6];
485 int count
= (int) regs
->regs
[base
+ 7];
489 retval
= sizeof (inventory_t
);
492 retval
= dump_inventory_to_user (buffer
, count
);
501 printk("irix_syssgi: Unsupported command %d\n", (int)cmd
);
510 asmlinkage
int irix_gtime(struct pt_regs
*regs
)
512 return get_seconds();
516 * IRIX is completely broken... it returns 0 on success, otherwise
519 asmlinkage
int irix_brk(unsigned long brk
)
522 unsigned long newbrk
, oldbrk
;
523 struct mm_struct
*mm
= current
->mm
;
526 down_write(&mm
->mmap_sem
);
527 if (brk
< mm
->end_code
) {
532 newbrk
= PAGE_ALIGN(brk
);
533 oldbrk
= PAGE_ALIGN(mm
->brk
);
534 if (oldbrk
== newbrk
) {
541 * Always allow shrinking brk
543 if (brk
<= mm
->brk
) {
545 do_munmap(mm
, newbrk
, oldbrk
-newbrk
);
550 * Check against rlimit and stack..
552 rlim
= current
->signal
->rlim
[RLIMIT_DATA
].rlim_cur
;
553 if (rlim
>= RLIM_INFINITY
)
555 if (brk
- mm
->end_code
> rlim
) {
561 * Check against existing mmap mappings.
563 if (find_vma_intersection(mm
, oldbrk
, newbrk
+PAGE_SIZE
)) {
569 * Ok, looks good - let it rip.
571 if (do_brk(oldbrk
, newbrk
-oldbrk
) != oldbrk
) {
579 up_write(&mm
->mmap_sem
);
583 asmlinkage
int irix_getpid(struct pt_regs
*regs
)
585 regs
->regs
[3] = current
->real_parent
->pid
;
589 asmlinkage
int irix_getuid(struct pt_regs
*regs
)
591 regs
->regs
[3] = current
->euid
;
595 asmlinkage
int irix_getgid(struct pt_regs
*regs
)
597 regs
->regs
[3] = current
->egid
;
601 asmlinkage
int irix_stime(int value
)
608 err
= security_settime(&tv
, NULL
);
612 write_seqlock_irq(&xtime_lock
);
613 xtime
.tv_sec
= value
;
616 write_sequnlock_irq(&xtime_lock
);
621 static inline void jiffiestotv(unsigned long jiffies
, struct timeval
*value
)
623 value
->tv_usec
= (jiffies
% HZ
) * (1000000 / HZ
);
624 value
->tv_sec
= jiffies
/ HZ
;
627 static inline void getitimer_real(struct itimerval
*value
)
629 register unsigned long val
, interval
;
631 interval
= current
->it_real_incr
;
633 if (del_timer(¤t
->real_timer
)) {
634 unsigned long now
= jiffies
;
635 val
= current
->real_timer
.expires
;
636 add_timer(¤t
->real_timer
);
637 /* look out for negative/zero itimer.. */
642 jiffiestotv(val
, &value
->it_value
);
643 jiffiestotv(interval
, &value
->it_interval
);
646 asmlinkage
unsigned int irix_alarm(unsigned int seconds
)
648 return alarm_setitimer(seconds
);
651 asmlinkage
int irix_pause(void)
653 current
->state
= TASK_INTERRUPTIBLE
;
659 /* XXX need more than this... */
660 asmlinkage
int irix_mount(char __user
*dev_name
, char __user
*dir_name
,
661 unsigned long flags
, char __user
*type
, void __user
*data
, int datalen
)
663 printk("[%s:%d] irix_mount(%p,%p,%08lx,%p,%p,%d)\n",
664 current
->comm
, current
->pid
,
665 dev_name
, dir_name
, flags
, type
, data
, datalen
);
667 return sys_mount(dev_name
, dir_name
, type
, flags
, data
);
672 long f_bsize
, f_frsize
, f_blocks
, f_bfree
, f_files
, f_ffree
;
673 char f_fname
[6], f_fpack
[6];
676 asmlinkage
int irix_statfs(const char __user
*path
,
677 struct irix_statfs __user
*buf
, int len
, int fs_type
)
683 /* We don't support this feature yet. */
688 if (!access_ok(VERIFY_WRITE
, buf
, sizeof(struct irix_statfs
))) {
693 error
= user_path_walk(path
, &nd
);
697 error
= vfs_statfs(nd
.dentry
, &kbuf
);
701 error
= __put_user(kbuf
.f_type
, &buf
->f_type
);
702 error
|= __put_user(kbuf
.f_bsize
, &buf
->f_bsize
);
703 error
|= __put_user(kbuf
.f_frsize
, &buf
->f_frsize
);
704 error
|= __put_user(kbuf
.f_blocks
, &buf
->f_blocks
);
705 error
|= __put_user(kbuf
.f_bfree
, &buf
->f_bfree
);
706 error
|= __put_user(kbuf
.f_files
, &buf
->f_files
);
707 error
|= __put_user(kbuf
.f_ffree
, &buf
->f_ffree
);
708 for (i
= 0; i
< 6; i
++) {
709 error
|= __put_user(0, &buf
->f_fname
[i
]);
710 error
|= __put_user(0, &buf
->f_fpack
[i
]);
719 asmlinkage
int irix_fstatfs(unsigned int fd
, struct irix_statfs __user
*buf
)
725 if (!access_ok(VERIFY_WRITE
, buf
, sizeof(struct irix_statfs
))) {
730 if (!(file
= fget(fd
))) {
735 error
= vfs_statfs(file
->f_dentry
, &kbuf
);
739 error
= __put_user(kbuf
.f_type
, &buf
->f_type
);
740 error
|= __put_user(kbuf
.f_bsize
, &buf
->f_bsize
);
741 error
|= __put_user(kbuf
.f_frsize
, &buf
->f_frsize
);
742 error
|= __put_user(kbuf
.f_blocks
, &buf
->f_blocks
);
743 error
|= __put_user(kbuf
.f_bfree
, &buf
->f_bfree
);
744 error
|= __put_user(kbuf
.f_files
, &buf
->f_files
);
745 error
|= __put_user(kbuf
.f_ffree
, &buf
->f_ffree
);
747 for (i
= 0; i
< 6; i
++) {
748 error
|= __put_user(0, &buf
->f_fname
[i
]);
749 error
|= __put_user(0, &buf
->f_fpack
[i
]);
758 asmlinkage
int irix_setpgrp(int flags
)
762 #ifdef DEBUG_PROCGRPS
763 printk("[%s:%d] setpgrp(%d) ", current
->comm
, current
->pid
, flags
);
766 error
= process_group(current
);
768 error
= sys_setsid();
769 #ifdef DEBUG_PROCGRPS
770 printk("returning %d\n", process_group(current
));
776 asmlinkage
int irix_times(struct tms __user
*tbuf
)
781 if (!access_ok(VERIFY_WRITE
,tbuf
,sizeof *tbuf
))
784 err
= __put_user(current
->utime
, &tbuf
->tms_utime
);
785 err
|= __put_user(current
->stime
, &tbuf
->tms_stime
);
786 err
|= __put_user(current
->signal
->cutime
, &tbuf
->tms_cutime
);
787 err
|= __put_user(current
->signal
->cstime
, &tbuf
->tms_cstime
);
793 asmlinkage
int irix_exec(struct pt_regs
*regs
)
798 if(regs
->regs
[2] == 1000)
800 filename
= getname((char __user
*) (long)regs
->regs
[base
+ 4]);
801 error
= PTR_ERR(filename
);
802 if (IS_ERR(filename
))
805 error
= do_execve(filename
, (char __user
* __user
*) (long)regs
->regs
[base
+ 5],
812 asmlinkage
int irix_exece(struct pt_regs
*regs
)
817 if (regs
->regs
[2] == 1000)
819 filename
= getname((char __user
*) (long)regs
->regs
[base
+ 4]);
820 error
= PTR_ERR(filename
);
821 if (IS_ERR(filename
))
823 error
= do_execve(filename
, (char __user
* __user
*) (long)regs
->regs
[base
+ 5],
824 (char __user
* __user
*) (long)regs
->regs
[base
+ 6], regs
);
830 asmlinkage
unsigned long irix_gethostid(void)
832 printk("[%s:%d]: irix_gethostid() called...\n",
833 current
->comm
, current
->pid
);
838 asmlinkage
unsigned long irix_sethostid(unsigned long val
)
840 printk("[%s:%d]: irix_sethostid(%08lx) called...\n",
841 current
->comm
, current
->pid
, val
);
846 asmlinkage
int irix_socket(int family
, int type
, int protocol
)
858 type
= 9; /* Invalid... */
870 type
= SOCK_SEQPACKET
;
877 return sys_socket(family
, type
, protocol
);
880 asmlinkage
int irix_getdomainname(char __user
*name
, int len
)
885 if (len
> __NEW_UTS_LEN
)
887 err
= copy_to_user(name
, utsname()->domainname
, len
) ? -EFAULT
: 0;
893 asmlinkage
unsigned long irix_getpagesize(void)
898 asmlinkage
int irix_msgsys(int opcode
, unsigned long arg0
, unsigned long arg1
,
899 unsigned long arg2
, unsigned long arg3
,
904 return sys_msgget((key_t
) arg0
, (int) arg1
);
906 return sys_msgctl((int) arg0
, (int) arg1
,
907 (struct msqid_ds __user
*)arg2
);
909 return sys_msgrcv((int) arg0
, (struct msgbuf __user
*) arg1
,
910 (size_t) arg2
, (long) arg3
, (int) arg4
);
912 return sys_msgsnd((int) arg0
, (struct msgbuf __user
*) arg1
,
913 (size_t) arg2
, (int) arg3
);
919 asmlinkage
int irix_shmsys(int opcode
, unsigned long arg0
, unsigned long arg1
,
920 unsigned long arg2
, unsigned long arg3
)
924 return do_shmat((int) arg0
, (char __user
*) arg1
, (int) arg2
,
925 (unsigned long *) arg3
);
927 return sys_shmctl((int)arg0
, (int)arg1
,
928 (struct shmid_ds __user
*)arg2
);
930 return sys_shmdt((char __user
*)arg0
);
932 return sys_shmget((key_t
) arg0
, (int) arg1
, (int) arg2
);
938 asmlinkage
int irix_semsys(int opcode
, unsigned long arg0
, unsigned long arg1
,
939 unsigned long arg2
, int arg3
)
943 return sys_semctl((int) arg0
, (int) arg1
, (int) arg2
,
946 return sys_semget((key_t
) arg0
, (int) arg1
, (int) arg2
);
948 return sys_semop((int) arg0
, (struct sembuf __user
*)arg1
,
949 (unsigned int) arg2
);
955 static inline loff_t
llseek(struct file
*file
, loff_t offset
, int origin
)
957 loff_t (*fn
)(struct file
*, loff_t
, int);
961 if (file
->f_op
&& file
->f_op
->llseek
)
962 fn
= file
->f_op
->llseek
;
964 retval
= fn(file
, offset
, origin
);
970 asmlinkage
int irix_lseek64(int fd
, int _unused
, int offhi
, int offlow
,
985 offset
= llseek(file
, ((loff_t
) offhi
<< 32) | offlow
, origin
);
986 retval
= (int) offset
;
994 asmlinkage
int irix_sginap(int ticks
)
996 schedule_timeout_interruptible(ticks
);
1000 asmlinkage
int irix_sgikopt(char __user
*istring
, char __user
*ostring
, int len
)
1005 asmlinkage
int irix_gettimeofday(struct timeval __user
*tv
)
1011 if (!access_ok(VERIFY_WRITE
, tv
, sizeof(struct timeval
)))
1015 seq
= read_seqbegin(&xtime_lock
);
1017 nsec
= xtime
.tv_nsec
;
1018 } while (read_seqretry(&xtime_lock
, seq
));
1020 err
= __put_user(sec
, &tv
->tv_sec
);
1021 err
|= __put_user((nsec
/ 1000), &tv
->tv_usec
);
1026 #define IRIX_MAP_AUTOGROW 0x40
1028 asmlinkage
unsigned long irix_mmap32(unsigned long addr
, size_t len
, int prot
,
1029 int flags
, int fd
, off_t offset
)
1031 struct file
*file
= NULL
;
1032 unsigned long retval
;
1034 if (!(flags
& MAP_ANONYMOUS
)) {
1035 if (!(file
= fget(fd
)))
1038 /* Ok, bad taste hack follows, try to think in something else
1039 * when reading this. */
1040 if (flags
& IRIX_MAP_AUTOGROW
) {
1041 unsigned long old_pos
;
1042 long max_size
= offset
+ len
;
1044 if (max_size
> file
->f_dentry
->d_inode
->i_size
) {
1045 old_pos
= sys_lseek (fd
, max_size
- 1, 0);
1046 sys_write (fd
, (void __user
*) "", 1);
1047 sys_lseek (fd
, old_pos
, 0);
1052 flags
&= ~(MAP_EXECUTABLE
| MAP_DENYWRITE
);
1054 down_write(¤t
->mm
->mmap_sem
);
1055 retval
= do_mmap(file
, addr
, len
, prot
, flags
, offset
);
1056 up_write(¤t
->mm
->mmap_sem
);
1063 asmlinkage
int irix_madvise(unsigned long addr
, int len
, int behavior
)
1065 printk("[%s:%d] Wheee.. irix_madvise(%08lx,%d,%d)\n",
1066 current
->comm
, current
->pid
, addr
, len
, behavior
);
1071 asmlinkage
int irix_pagelock(char __user
*addr
, int len
, int op
)
1073 printk("[%s:%d] Wheee.. irix_pagelock(%p,%d,%d)\n",
1074 current
->comm
, current
->pid
, addr
, len
, op
);
1079 asmlinkage
int irix_quotactl(struct pt_regs
*regs
)
1081 printk("[%s:%d] Wheee.. irix_quotactl()\n",
1082 current
->comm
, current
->pid
);
1087 asmlinkage
int irix_BSDsetpgrp(int pid
, int pgrp
)
1091 #ifdef DEBUG_PROCGRPS
1092 printk("[%s:%d] BSDsetpgrp(%d, %d) ", current
->comm
, current
->pid
,
1098 /* Wheee, weird sysv thing... */
1099 if ((pgrp
== 0) && (pid
== current
->pid
))
1100 error
= sys_setsid();
1102 error
= sys_setpgid(pid
, pgrp
);
1104 #ifdef DEBUG_PROCGRPS
1105 printk("error = %d\n", error
);
1111 asmlinkage
int irix_systeminfo(int cmd
, char __user
*buf
, int cnt
)
1113 printk("[%s:%d] Wheee.. irix_systeminfo(%d,%p,%d)\n",
1114 current
->comm
, current
->pid
, cmd
, buf
, cnt
);
1120 char sysname
[257], nodename
[257], release
[257];
1121 char version
[257], machine
[257];
1122 char m_type
[257], base_rel
[257];
1123 char _unused0
[257], _unused1
[257], _unused2
[257];
1124 char _unused3
[257], _unused4
[257], _unused5
[257];
1127 asmlinkage
int irix_uname(struct iuname __user
*buf
)
1129 down_read(&uts_sem
);
1130 if (copy_from_user(utsname()->sysname
, buf
->sysname
, 65)
1131 || copy_from_user(utsname()->nodename
, buf
->nodename
, 65)
1132 || copy_from_user(utsname()->release
, buf
->release
, 65)
1133 || copy_from_user(utsname()->version
, buf
->version
, 65)
1134 || copy_from_user(utsname()->machine
, buf
->machine
, 65)) {
1144 static int irix_xstat32_xlate(struct kstat
*stat
, void __user
*ubuf
)
1147 u32 st_dev
, st_pad1
[3], st_ino
, st_mode
, st_nlink
, st_uid
, st_gid
;
1148 u32 st_rdev
, st_pad2
[2], st_size
, st_pad3
;
1149 u32 st_atime0
, st_atime1
;
1150 u32 st_mtime0
, st_mtime1
;
1151 u32 st_ctime0
, st_ctime1
;
1152 u32 st_blksize
, st_blocks
;
1157 if (!sysv_valid_dev(stat
->dev
) || !sysv_valid_dev(stat
->rdev
))
1159 ub
.st_dev
= sysv_encode_dev(stat
->dev
);
1160 ub
.st_ino
= stat
->ino
;
1161 ub
.st_mode
= stat
->mode
;
1162 ub
.st_nlink
= stat
->nlink
;
1163 SET_UID(ub
.st_uid
, stat
->uid
);
1164 SET_GID(ub
.st_gid
, stat
->gid
);
1165 ub
.st_rdev
= sysv_encode_dev(stat
->rdev
);
1166 #if BITS_PER_LONG == 32
1167 if (stat
->size
> MAX_NON_LFS
)
1170 ub
.st_size
= stat
->size
;
1171 ub
.st_atime0
= stat
->atime
.tv_sec
;
1172 ub
.st_atime1
= stat
->atime
.tv_nsec
;
1173 ub
.st_mtime0
= stat
->mtime
.tv_sec
;
1174 ub
.st_mtime1
= stat
->atime
.tv_nsec
;
1175 ub
.st_ctime0
= stat
->ctime
.tv_sec
;
1176 ub
.st_ctime1
= stat
->atime
.tv_nsec
;
1177 ub
.st_blksize
= stat
->blksize
;
1178 ub
.st_blocks
= stat
->blocks
;
1179 strcpy (ub
.st_fstype
, "efs");
1181 return copy_to_user(ubuf
, &ub
, sizeof(ub
)) ? -EFAULT
: 0;
1184 static int irix_xstat64_xlate(struct kstat
*stat
, void __user
*ubuf
)
1187 u32 st_dev
; s32 st_pad1
[3];
1188 unsigned long long st_ino
;
1190 u32 st_nlink
; s32 st_uid
; s32 st_gid
; u32 st_rdev
;
1194 struct { s32 tv_sec
, tv_nsec
; } st_atime
, st_mtime
, st_ctime
;
1196 long long st_blocks
;
1201 if (!sysv_valid_dev(stat
->dev
) || !sysv_valid_dev(stat
->rdev
))
1204 ks
.st_dev
= sysv_encode_dev(stat
->dev
);
1205 ks
.st_pad1
[0] = ks
.st_pad1
[1] = ks
.st_pad1
[2] = 0;
1206 ks
.st_ino
= (unsigned long long) stat
->ino
;
1207 ks
.st_mode
= (u32
) stat
->mode
;
1208 ks
.st_nlink
= (u32
) stat
->nlink
;
1209 ks
.st_uid
= (s32
) stat
->uid
;
1210 ks
.st_gid
= (s32
) stat
->gid
;
1211 ks
.st_rdev
= sysv_encode_dev (stat
->rdev
);
1212 ks
.st_pad2
[0] = ks
.st_pad2
[1] = 0;
1213 ks
.st_size
= (long long) stat
->size
;
1216 /* XXX hackety hack... */
1217 ks
.st_atime
.tv_sec
= (s32
) stat
->atime
.tv_sec
;
1218 ks
.st_atime
.tv_nsec
= stat
->atime
.tv_nsec
;
1219 ks
.st_mtime
.tv_sec
= (s32
) stat
->mtime
.tv_sec
;
1220 ks
.st_mtime
.tv_nsec
= stat
->mtime
.tv_nsec
;
1221 ks
.st_ctime
.tv_sec
= (s32
) stat
->ctime
.tv_sec
;
1222 ks
.st_ctime
.tv_nsec
= stat
->ctime
.tv_nsec
;
1224 ks
.st_blksize
= (s32
) stat
->blksize
;
1225 ks
.st_blocks
= (long long) stat
->blocks
;
1226 memset(ks
.st_fstype
, 0, 16);
1227 ks
.st_pad4
[0] = ks
.st_pad4
[1] = ks
.st_pad4
[2] = ks
.st_pad4
[3] = 0;
1228 ks
.st_pad4
[4] = ks
.st_pad4
[5] = ks
.st_pad4
[6] = ks
.st_pad4
[7] = 0;
1230 /* Now write it all back. */
1231 return copy_to_user(ubuf
, &ks
, sizeof(ks
)) ? -EFAULT
: 0;
1234 asmlinkage
int irix_xstat(int version
, char __user
*filename
, struct stat __user
*statbuf
)
1240 printk("[%s:%d] Wheee.. irix_xstat(%d,%s,%p) ",
1241 current
->comm
, current
->pid
, version
, filename
, statbuf
);
1244 retval
= vfs_stat(filename
, &stat
);
1248 retval
= irix_xstat32_xlate(&stat
, statbuf
);
1251 retval
= irix_xstat64_xlate(&stat
, statbuf
);
1260 asmlinkage
int irix_lxstat(int version
, char __user
*filename
, struct stat __user
*statbuf
)
1266 printk("[%s:%d] Wheee.. irix_lxstat(%d,%s,%p) ",
1267 current
->comm
, current
->pid
, version
, filename
, statbuf
);
1270 error
= vfs_lstat(filename
, &stat
);
1275 error
= irix_xstat32_xlate(&stat
, statbuf
);
1278 error
= irix_xstat64_xlate(&stat
, statbuf
);
1287 asmlinkage
int irix_fxstat(int version
, int fd
, struct stat __user
*statbuf
)
1293 printk("[%s:%d] Wheee.. irix_fxstat(%d,%d,%p) ",
1294 current
->comm
, current
->pid
, version
, fd
, statbuf
);
1297 error
= vfs_fstat(fd
, &stat
);
1301 error
= irix_xstat32_xlate(&stat
, statbuf
);
1304 error
= irix_xstat64_xlate(&stat
, statbuf
);
1313 asmlinkage
int irix_xmknod(int ver
, char __user
*filename
, int mode
, unsigned dev
)
1316 printk("[%s:%d] Wheee.. irix_xmknod(%d,%s,%x,%x)\n",
1317 current
->comm
, current
->pid
, ver
, filename
, mode
, dev
);
1321 /* shouldn't we convert here as well as on stat()? */
1322 retval
= sys_mknod(filename
, mode
, dev
);
1333 asmlinkage
int irix_swapctl(int cmd
, char __user
*arg
)
1335 printk("[%s:%d] Wheee.. irix_swapctl(%d,%p)\n",
1336 current
->comm
, current
->pid
, cmd
, arg
);
1341 struct irix_statvfs
{
1342 u32 f_bsize
; u32 f_frsize
; u32 f_blocks
;
1343 u32 f_bfree
; u32 f_bavail
; u32 f_files
; u32 f_ffree
; u32 f_favail
;
1344 u32 f_fsid
; char f_basetype
[16];
1345 u32 f_flag
; u32 f_namemax
;
1346 char f_fstr
[32]; u32 f_filler
[16];
1349 asmlinkage
int irix_statvfs(char __user
*fname
, struct irix_statvfs __user
*buf
)
1351 struct nameidata nd
;
1352 struct kstatfs kbuf
;
1355 printk("[%s:%d] Wheee.. irix_statvfs(%s,%p)\n",
1356 current
->comm
, current
->pid
, fname
, buf
);
1357 if (!access_ok(VERIFY_WRITE
, buf
, sizeof(struct irix_statvfs
)))
1360 error
= user_path_walk(fname
, &nd
);
1363 error
= vfs_statfs(nd
.dentry
, &kbuf
);
1367 error
|= __put_user(kbuf
.f_bsize
, &buf
->f_bsize
);
1368 error
|= __put_user(kbuf
.f_frsize
, &buf
->f_frsize
);
1369 error
|= __put_user(kbuf
.f_blocks
, &buf
->f_blocks
);
1370 error
|= __put_user(kbuf
.f_bfree
, &buf
->f_bfree
);
1371 error
|= __put_user(kbuf
.f_bfree
, &buf
->f_bavail
); /* XXX hackety hack... */
1372 error
|= __put_user(kbuf
.f_files
, &buf
->f_files
);
1373 error
|= __put_user(kbuf
.f_ffree
, &buf
->f_ffree
);
1374 error
|= __put_user(kbuf
.f_ffree
, &buf
->f_favail
); /* XXX hackety hack... */
1376 error
|= __put_user(kbuf
.f_fsid
.val
[1], &buf
->f_fsid
);
1378 error
|= __put_user(kbuf
.f_fsid
.val
[0], &buf
->f_fsid
);
1380 for (i
= 0; i
< 16; i
++)
1381 error
|= __put_user(0, &buf
->f_basetype
[i
]);
1382 error
|= __put_user(0, &buf
->f_flag
);
1383 error
|= __put_user(kbuf
.f_namelen
, &buf
->f_namemax
);
1384 for (i
= 0; i
< 32; i
++)
1385 error
|= __put_user(0, &buf
->f_fstr
[i
]);
1393 asmlinkage
int irix_fstatvfs(int fd
, struct irix_statvfs __user
*buf
)
1395 struct kstatfs kbuf
;
1399 printk("[%s:%d] Wheee.. irix_fstatvfs(%d,%p)\n",
1400 current
->comm
, current
->pid
, fd
, buf
);
1402 if (!access_ok(VERIFY_WRITE
, buf
, sizeof(struct irix_statvfs
)))
1405 if (!(file
= fget(fd
))) {
1409 error
= vfs_statfs(file
->f_dentry
, &kbuf
);
1413 error
= __put_user(kbuf
.f_bsize
, &buf
->f_bsize
);
1414 error
|= __put_user(kbuf
.f_frsize
, &buf
->f_frsize
);
1415 error
|= __put_user(kbuf
.f_blocks
, &buf
->f_blocks
);
1416 error
|= __put_user(kbuf
.f_bfree
, &buf
->f_bfree
);
1417 error
|= __put_user(kbuf
.f_bfree
, &buf
->f_bavail
); /* XXX hackety hack... */
1418 error
|= __put_user(kbuf
.f_files
, &buf
->f_files
);
1419 error
|= __put_user(kbuf
.f_ffree
, &buf
->f_ffree
);
1420 error
|= __put_user(kbuf
.f_ffree
, &buf
->f_favail
); /* XXX hackety hack... */
1422 error
|= __put_user(kbuf
.f_fsid
.val
[1], &buf
->f_fsid
);
1424 error
|= __put_user(kbuf
.f_fsid
.val
[0], &buf
->f_fsid
);
1426 for(i
= 0; i
< 16; i
++)
1427 error
|= __put_user(0, &buf
->f_basetype
[i
]);
1428 error
|= __put_user(0, &buf
->f_flag
);
1429 error
|= __put_user(kbuf
.f_namelen
, &buf
->f_namemax
);
1430 error
|= __clear_user(&buf
->f_fstr
, sizeof(buf
->f_fstr
)) ? -EFAULT
: 0;
1438 asmlinkage
int irix_priocntl(struct pt_regs
*regs
)
1440 printk("[%s:%d] Wheee.. irix_priocntl()\n",
1441 current
->comm
, current
->pid
);
1446 asmlinkage
int irix_sigqueue(int pid
, int sig
, int code
, int val
)
1448 printk("[%s:%d] Wheee.. irix_sigqueue(%d,%d,%d,%d)\n",
1449 current
->comm
, current
->pid
, pid
, sig
, code
, val
);
1454 asmlinkage
int irix_truncate64(char __user
*name
, int pad
, int size1
, int size2
)
1462 retval
= sys_truncate(name
, size2
);
1468 asmlinkage
int irix_ftruncate64(int fd
, int pad
, int size1
, int size2
)
1476 retval
= sys_ftruncate(fd
, size2
);
1482 asmlinkage
int irix_mmap64(struct pt_regs
*regs
)
1484 int len
, prot
, flags
, fd
, off1
, off2
, error
, base
= 0;
1485 unsigned long addr
, pgoff
, *sp
;
1486 struct file
*file
= NULL
;
1489 if (regs
->regs
[2] == 1000)
1491 sp
= (unsigned long *) (regs
->regs
[29] + 16);
1492 addr
= regs
->regs
[base
+ 4];
1493 len
= regs
->regs
[base
+ 5];
1494 prot
= regs
->regs
[base
+ 6];
1496 flags
= regs
->regs
[base
+ 7];
1497 if (!access_ok(VERIFY_READ
, sp
, (4 * sizeof(unsigned long))))
1500 err
= __get_user(off1
, &sp
[1]);
1501 err
|= __get_user(off2
, &sp
[2]);
1503 if (!access_ok(VERIFY_READ
, sp
, (5 * sizeof(unsigned long))))
1505 err
= __get_user(flags
, &sp
[0]);
1506 err
|= __get_user(fd
, &sp
[1]);
1507 err
|= __get_user(off1
, &sp
[2]);
1508 err
|= __get_user(off2
, &sp
[3]);
1514 if (off1
& PAGE_MASK
)
1517 pgoff
= (off1
<< (32 - PAGE_SHIFT
)) | (off2
>> PAGE_SHIFT
);
1519 if (!(flags
& MAP_ANONYMOUS
)) {
1520 if (!(file
= fget(fd
)))
1523 /* Ok, bad taste hack follows, try to think in something else
1524 when reading this */
1525 if (flags
& IRIX_MAP_AUTOGROW
) {
1526 unsigned long old_pos
;
1527 long max_size
= off2
+ len
;
1529 if (max_size
> file
->f_dentry
->d_inode
->i_size
) {
1530 old_pos
= sys_lseek (fd
, max_size
- 1, 0);
1531 sys_write (fd
, (void __user
*) "", 1);
1532 sys_lseek (fd
, old_pos
, 0);
1537 flags
&= ~(MAP_EXECUTABLE
| MAP_DENYWRITE
);
1539 down_write(¤t
->mm
->mmap_sem
);
1540 error
= do_mmap_pgoff(file
, addr
, len
, prot
, flags
, pgoff
);
1541 up_write(¤t
->mm
->mmap_sem
);
1549 asmlinkage
int irix_dmi(struct pt_regs
*regs
)
1551 printk("[%s:%d] Wheee.. irix_dmi()\n",
1552 current
->comm
, current
->pid
);
1557 asmlinkage
int irix_pread(int fd
, char __user
*buf
, int cnt
, int off64
,
1560 printk("[%s:%d] Wheee.. irix_pread(%d,%p,%d,%d,%d,%d)\n",
1561 current
->comm
, current
->pid
, fd
, buf
, cnt
, off64
, off1
, off2
);
1566 asmlinkage
int irix_pwrite(int fd
, char __user
*buf
, int cnt
, int off64
,
1569 printk("[%s:%d] Wheee.. irix_pwrite(%d,%p,%d,%d,%d,%d)\n",
1570 current
->comm
, current
->pid
, fd
, buf
, cnt
, off64
, off1
, off2
);
1575 asmlinkage
int irix_sgifastpath(int cmd
, unsigned long arg0
, unsigned long arg1
,
1576 unsigned long arg2
, unsigned long arg3
,
1577 unsigned long arg4
, unsigned long arg5
)
1579 printk("[%s:%d] Wheee.. irix_fastpath(%d,%08lx,%08lx,%08lx,%08lx,"
1581 current
->comm
, current
->pid
, cmd
, arg0
, arg1
, arg2
,
1587 struct irix_statvfs64
{
1588 u32 f_bsize
; u32 f_frsize
;
1589 u64 f_blocks
; u64 f_bfree
; u64 f_bavail
;
1590 u64 f_files
; u64 f_ffree
; u64 f_favail
;
1592 char f_basetype
[16];
1593 u32 f_flag
; u32 f_namemax
;
1598 asmlinkage
int irix_statvfs64(char __user
*fname
, struct irix_statvfs64 __user
*buf
)
1600 struct nameidata nd
;
1601 struct kstatfs kbuf
;
1604 printk("[%s:%d] Wheee.. irix_statvfs64(%s,%p)\n",
1605 current
->comm
, current
->pid
, fname
, buf
);
1606 if (!access_ok(VERIFY_WRITE
, buf
, sizeof(struct irix_statvfs64
))) {
1611 error
= user_path_walk(fname
, &nd
);
1614 error
= vfs_statfs(nd
.dentry
, &kbuf
);
1618 error
= __put_user(kbuf
.f_bsize
, &buf
->f_bsize
);
1619 error
|= __put_user(kbuf
.f_frsize
, &buf
->f_frsize
);
1620 error
|= __put_user(kbuf
.f_blocks
, &buf
->f_blocks
);
1621 error
|= __put_user(kbuf
.f_bfree
, &buf
->f_bfree
);
1622 error
|= __put_user(kbuf
.f_bfree
, &buf
->f_bavail
); /* XXX hackety hack... */
1623 error
|= __put_user(kbuf
.f_files
, &buf
->f_files
);
1624 error
|= __put_user(kbuf
.f_ffree
, &buf
->f_ffree
);
1625 error
|= __put_user(kbuf
.f_ffree
, &buf
->f_favail
); /* XXX hackety hack... */
1627 error
|= __put_user(kbuf
.f_fsid
.val
[1], &buf
->f_fsid
);
1629 error
|= __put_user(kbuf
.f_fsid
.val
[0], &buf
->f_fsid
);
1631 for(i
= 0; i
< 16; i
++)
1632 error
|= __put_user(0, &buf
->f_basetype
[i
]);
1633 error
|= __put_user(0, &buf
->f_flag
);
1634 error
|= __put_user(kbuf
.f_namelen
, &buf
->f_namemax
);
1635 for(i
= 0; i
< 32; i
++)
1636 error
|= __put_user(0, &buf
->f_fstr
[i
]);
1644 asmlinkage
int irix_fstatvfs64(int fd
, struct irix_statvfs __user
*buf
)
1646 struct kstatfs kbuf
;
1650 printk("[%s:%d] Wheee.. irix_fstatvfs64(%d,%p)\n",
1651 current
->comm
, current
->pid
, fd
, buf
);
1653 if (!access_ok(VERIFY_WRITE
, buf
, sizeof(struct irix_statvfs
))) {
1657 if (!(file
= fget(fd
))) {
1661 error
= vfs_statfs(file
->f_dentry
, &kbuf
);
1665 error
= __put_user(kbuf
.f_bsize
, &buf
->f_bsize
);
1666 error
|= __put_user(kbuf
.f_frsize
, &buf
->f_frsize
);
1667 error
|= __put_user(kbuf
.f_blocks
, &buf
->f_blocks
);
1668 error
|= __put_user(kbuf
.f_bfree
, &buf
->f_bfree
);
1669 error
|= __put_user(kbuf
.f_bfree
, &buf
->f_bavail
); /* XXX hackety hack... */
1670 error
|= __put_user(kbuf
.f_files
, &buf
->f_files
);
1671 error
|= __put_user(kbuf
.f_ffree
, &buf
->f_ffree
);
1672 error
|= __put_user(kbuf
.f_ffree
, &buf
->f_favail
); /* XXX hackety hack... */
1674 error
|= __put_user(kbuf
.f_fsid
.val
[1], &buf
->f_fsid
);
1676 error
|= __put_user(kbuf
.f_fsid
.val
[0], &buf
->f_fsid
);
1678 for(i
= 0; i
< 16; i
++)
1679 error
|= __put_user(0, &buf
->f_basetype
[i
]);
1680 error
|= __put_user(0, &buf
->f_flag
);
1681 error
|= __put_user(kbuf
.f_namelen
, &buf
->f_namemax
);
1682 error
|= __clear_user(buf
->f_fstr
, sizeof(buf
->f_fstr
[i
])) ? -EFAULT
: 0;
1690 asmlinkage
int irix_getmountid(char __user
*fname
, unsigned long __user
*midbuf
)
1694 printk("[%s:%d] irix_getmountid(%s, %p)\n",
1695 current
->comm
, current
->pid
, fname
, midbuf
);
1696 if (!access_ok(VERIFY_WRITE
, midbuf
, (sizeof(unsigned long) * 4)))
1700 * The idea with this system call is that when trying to determine
1701 * 'pwd' and it's a toss-up for some reason, userland can use the
1702 * fsid of the filesystem to try and make the right decision, but
1703 * we don't have this so for now. XXX
1705 err
= __put_user(0, &midbuf
[0]);
1706 err
|= __put_user(0, &midbuf
[1]);
1707 err
|= __put_user(0, &midbuf
[2]);
1708 err
|= __put_user(0, &midbuf
[3]);
1713 asmlinkage
int irix_nsproc(unsigned long entry
, unsigned long mask
,
1714 unsigned long arg
, unsigned long sp
, int slen
)
1716 printk("[%s:%d] Wheee.. irix_nsproc(%08lx,%08lx,%08lx,%08lx,%d)\n",
1717 current
->comm
, current
->pid
, entry
, mask
, arg
, sp
, slen
);
1722 #undef DEBUG_GETDENTS
1724 struct irix_dirent32
{
1727 unsigned short d_reclen
;
1731 struct irix_dirent32_callback
{
1732 struct irix_dirent32 __user
*current_dir
;
1733 struct irix_dirent32 __user
*previous
;
1738 #define NAME_OFFSET32(de) ((int) ((de)->d_name - (char *) (de)))
1739 #define ROUND_UP32(x) (((x)+sizeof(u32)-1) & ~(sizeof(u32)-1))
1741 static int irix_filldir32(void *__buf
, const char *name
,
1742 int namlen
, loff_t offset
, u64 ino
, unsigned int d_type
)
1744 struct irix_dirent32 __user
*dirent
;
1745 struct irix_dirent32_callback
*buf
= __buf
;
1746 unsigned short reclen
= ROUND_UP32(NAME_OFFSET32(dirent
) + namlen
+ 1);
1750 #ifdef DEBUG_GETDENTS
1751 printk("\nirix_filldir32[reclen<%d>namlen<%d>count<%d>]",
1752 reclen
, namlen
, buf
->count
);
1754 buf
->error
= -EINVAL
; /* only used if we fail.. */
1755 if (reclen
> buf
->count
)
1758 if (sizeof(d_ino
) < sizeof(ino
) && d_ino
!= ino
)
1760 dirent
= buf
->previous
;
1762 err
= __put_user(offset
, &dirent
->d_off
);
1763 dirent
= buf
->current_dir
;
1764 err
|= __put_user(dirent
, &buf
->previous
);
1765 err
|= __put_user(d_ino
, &dirent
->d_ino
);
1766 err
|= __put_user(reclen
, &dirent
->d_reclen
);
1767 err
|= copy_to_user((char __user
*)dirent
->d_name
, name
, namlen
) ? -EFAULT
: 0;
1768 err
|= __put_user(0, &dirent
->d_name
[namlen
]);
1769 dirent
= (struct irix_dirent32 __user
*) ((char __user
*) dirent
+ reclen
);
1771 buf
->current_dir
= dirent
;
1772 buf
->count
-= reclen
;
1777 asmlinkage
int irix_ngetdents(unsigned int fd
, void __user
* dirent
,
1778 unsigned int count
, int __user
*eob
)
1781 struct irix_dirent32 __user
*lastdirent
;
1782 struct irix_dirent32_callback buf
;
1785 #ifdef DEBUG_GETDENTS
1786 printk("[%s:%d] ngetdents(%d, %p, %d, %p) ", current
->comm
,
1787 current
->pid
, fd
, dirent
, count
, eob
);
1794 buf
.current_dir
= (struct irix_dirent32 __user
*) dirent
;
1795 buf
.previous
= NULL
;
1799 error
= vfs_readdir(file
, irix_filldir32
, &buf
);
1804 lastdirent
= buf
.previous
;
1806 put_user(file
->f_pos
, &lastdirent
->d_off
);
1807 error
= count
- buf
.count
;
1810 if (put_user(0, eob
) < 0) {
1815 #ifdef DEBUG_GETDENTS
1816 printk("eob=%d returning %d\n", *eob
, count
- buf
.count
);
1818 error
= count
- buf
.count
;
1826 struct irix_dirent64
{
1829 unsigned short d_reclen
;
1833 struct irix_dirent64_callback
{
1834 struct irix_dirent64 __user
*curr
;
1835 struct irix_dirent64 __user
*previous
;
1840 #define NAME_OFFSET64(de) ((int) ((de)->d_name - (char *) (de)))
1841 #define ROUND_UP64(x) (((x)+sizeof(u64)-1) & ~(sizeof(u64)-1))
1843 static int irix_filldir64(void *__buf
, const char *name
,
1844 int namlen
, loff_t offset
, u64 ino
, unsigned int d_type
)
1846 struct irix_dirent64 __user
*dirent
;
1847 struct irix_dirent64_callback
* buf
= __buf
;
1848 unsigned short reclen
= ROUND_UP64(NAME_OFFSET64(dirent
) + namlen
+ 1);
1851 if (!access_ok(VERIFY_WRITE
, buf
, sizeof(*buf
)))
1854 if (__put_user(-EINVAL
, &buf
->error
)) /* only used if we fail.. */
1856 if (reclen
> buf
->count
)
1858 dirent
= buf
->previous
;
1860 err
= __put_user(offset
, &dirent
->d_off
);
1862 buf
->previous
= dirent
;
1863 err
|= __put_user(ino
, &dirent
->d_ino
);
1864 err
|= __put_user(reclen
, &dirent
->d_reclen
);
1865 err
|= __copy_to_user((char __user
*)dirent
->d_name
, name
, namlen
)
1867 err
|= __put_user(0, &dirent
->d_name
[namlen
]);
1869 dirent
= (struct irix_dirent64 __user
*) ((char __user
*) dirent
+ reclen
);
1872 buf
->count
-= reclen
;
1877 asmlinkage
int irix_getdents64(int fd
, void __user
*dirent
, int cnt
)
1880 struct irix_dirent64 __user
*lastdirent
;
1881 struct irix_dirent64_callback buf
;
1884 #ifdef DEBUG_GETDENTS
1885 printk("[%s:%d] getdents64(%d, %p, %d) ", current
->comm
,
1886 current
->pid
, fd
, dirent
, cnt
);
1889 if (!(file
= fget(fd
)))
1893 if (!access_ok(VERIFY_WRITE
, dirent
, cnt
))
1897 if (cnt
< (sizeof(struct irix_dirent64
) + 255))
1900 buf
.curr
= (struct irix_dirent64 __user
*) dirent
;
1901 buf
.previous
= NULL
;
1904 error
= vfs_readdir(file
, irix_filldir64
, &buf
);
1907 lastdirent
= buf
.previous
;
1912 if (put_user(file
->f_pos
, &lastdirent
->d_off
))
1914 #ifdef DEBUG_GETDENTS
1915 printk("returning %d\n", cnt
- buf
.count
);
1917 error
= cnt
- buf
.count
;
1925 asmlinkage
int irix_ngetdents64(int fd
, void __user
*dirent
, int cnt
, int *eob
)
1928 struct irix_dirent64 __user
*lastdirent
;
1929 struct irix_dirent64_callback buf
;
1932 #ifdef DEBUG_GETDENTS
1933 printk("[%s:%d] ngetdents64(%d, %p, %d) ", current
->comm
,
1934 current
->pid
, fd
, dirent
, cnt
);
1937 if (!(file
= fget(fd
)))
1941 if (!access_ok(VERIFY_WRITE
, dirent
, cnt
) ||
1942 !access_ok(VERIFY_WRITE
, eob
, sizeof(*eob
)))
1946 if (cnt
< (sizeof(struct irix_dirent64
) + 255))
1950 buf
.curr
= (struct irix_dirent64 __user
*) dirent
;
1951 buf
.previous
= NULL
;
1954 error
= vfs_readdir(file
, irix_filldir64
, &buf
);
1957 lastdirent
= buf
.previous
;
1962 if (put_user(file
->f_pos
, &lastdirent
->d_off
))
1964 #ifdef DEBUG_GETDENTS
1965 printk("eob=%d returning %d\n", *eob
, cnt
- buf
.count
);
1967 error
= cnt
- buf
.count
;
1975 asmlinkage
int irix_uadmin(unsigned long op
, unsigned long func
, unsigned long arg
)
1982 printk("[%s:%d] irix_uadmin: Wants to reboot...\n",
1983 current
->comm
, current
->pid
);
1989 printk("[%s:%d] irix_uadmin: Wants to shutdown...\n",
1990 current
->comm
, current
->pid
);
1996 printk("[%s:%d] irix_uadmin: Wants to remount root...\n",
1997 current
->comm
, current
->pid
);
2002 /* Kill all tasks. */
2003 printk("[%s:%d] irix_uadmin: Wants to kill all tasks...\n",
2004 current
->comm
, current
->pid
);
2009 /* Set magic mushrooms... */
2010 printk("[%s:%d] irix_uadmin: Wants to set magic mushroom[%d]...\n",
2011 current
->comm
, current
->pid
, (int) func
);
2016 printk("[%s:%d] irix_uadmin: Unknown operation [%d]...\n",
2017 current
->comm
, current
->pid
, (int) op
);
2026 asmlinkage
int irix_utssys(char __user
*inbuf
, int arg
, int type
, char __user
*outbuf
)
2033 retval
= irix_uname((struct iuname __user
*)inbuf
);
2038 printk("[%s:%d] irix_utssys: Wants to do ustat()\n",
2039 current
->comm
, current
->pid
);
2045 printk("[%s:%d] irix_utssys: Wants to do fusers()\n",
2046 current
->comm
, current
->pid
);
2051 printk("[%s:%d] irix_utssys: Wants to do unknown type[%d]\n",
2052 current
->comm
, current
->pid
, (int) type
);
2063 #define IRIX_F_ALLOCSP 10
2065 asmlinkage
int irix_fcntl(int fd
, int cmd
, int arg
)
2070 printk("[%s:%d] irix_fcntl(%d, %d, %d) ", current
->comm
,
2071 current
->pid
, fd
, cmd
, arg
);
2073 if (cmd
== IRIX_F_ALLOCSP
){
2076 retval
= sys_fcntl(fd
, cmd
, arg
);
2078 printk("%d\n", retval
);
2083 asmlinkage
int irix_ulimit(int cmd
, int arg
)
2089 printk("[%s:%d] irix_ulimit: Wants to get file size limit.\n",
2090 current
->comm
, current
->pid
);
2095 printk("[%s:%d] irix_ulimit: Wants to set file size limit.\n",
2096 current
->comm
, current
->pid
);
2101 printk("[%s:%d] irix_ulimit: Wants to get brk limit.\n",
2102 current
->comm
, current
->pid
);
2108 printk("[%s:%d] irix_ulimit: Wants to get fd limit.\n",
2109 current
->comm
, current
->pid
);
2113 retval
= current
->signal
->rlim
[RLIMIT_NOFILE
].rlim_cur
;
2117 printk("[%s:%d] irix_ulimit: Wants to get txt offset.\n",
2118 current
->comm
, current
->pid
);
2123 printk("[%s:%d] irix_ulimit: Unknown command [%d].\n",
2124 current
->comm
, current
->pid
, cmd
);
2132 asmlinkage
int irix_unimp(struct pt_regs
*regs
)
2134 printk("irix_unimp [%s:%d] v0=%d v1=%d a0=%08lx a1=%08lx a2=%08lx "
2135 "a3=%08lx\n", current
->comm
, current
->pid
,
2136 (int) regs
->regs
[2], (int) regs
->regs
[3],
2137 regs
->regs
[4], regs
->regs
[5], regs
->regs
[6], regs
->regs
[7]);