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/highuid.h>
12 #include <linux/pagemap.h>
14 #include <linux/mman.h>
15 #include <linux/slab.h>
16 #include <linux/swap.h>
17 #include <linux/errno.h>
18 #include <linux/time.h>
19 #include <linux/timex.h>
20 #include <linux/times.h>
21 #include <linux/elf.h>
22 #include <linux/msg.h>
23 #include <linux/shm.h>
24 #include <linux/smp.h>
25 #include <linux/smp_lock.h>
26 #include <linux/utsname.h>
27 #include <linux/file.h>
28 #include <linux/vfs.h>
29 #include <linux/namei.h>
30 #include <linux/socket.h>
31 #include <linux/security.h>
32 #include <linux/syscalls.h>
34 #include <asm/ptrace.h>
36 #include <asm/uaccess.h>
37 #include <asm/inventory.h>
39 /* 2,191 lines of complete and utter shit coming up... */
41 extern int max_threads;
43 /* The sysmp commands supported thus far. */
44 #define MP_NPROCS 1 /* # processor in complex */
45 #define MP_NAPROCS 2 /* # active processors in complex */
46 #define MP_PGSIZE 14 /* Return system page size in v1. */
48 asmlinkage int irix_sysmp(struct pt_regs *regs)
54 if(regs->regs[2] == 1000)
56 cmd = regs->regs[base + 4];
63 error = num_online_cpus();
66 printk("SYSMP[%s:%d]: Unsupported opcode %d\n",
67 current->comm, current->pid, (int)cmd);
75 /* The prctl commands. */
76 #define PR_MAXPROCS 1 /* Tasks/user. */
77 #define PR_ISBLOCKED 2 /* If blocked, return 1. */
78 #define PR_SETSTACKSIZE 3 /* Set largest task stack size. */
79 #define PR_GETSTACKSIZE 4 /* Get largest task stack size. */
80 #define PR_MAXPPROCS 5 /* Num parallel tasks. */
81 #define PR_UNBLKONEXEC 6 /* When task exec/exit's, unblock. */
82 #define PR_SETEXITSIG 8 /* When task exit's, set signal. */
83 #define PR_RESIDENT 9 /* Make task unswappable. */
84 #define PR_ATTACHADDR 10 /* (Re-)Connect a vma to a task. */
85 #define PR_DETACHADDR 11 /* Disconnect a vma from a task. */
86 #define PR_TERMCHILD 12 /* When parent sleeps with fishes, kill child. */
87 #define PR_GETSHMASK 13 /* Get the sproc() share mask. */
88 #define PR_GETNSHARE 14 /* Number of share group members. */
89 #define PR_COREPID 15 /* Add task pid to name when it core. */
90 #define PR_ATTACHADDRPERM 16 /* (Re-)Connect vma, with specified prot. */
91 #define PR_PTHREADEXIT 17 /* Kill a pthread without prejudice. */
93 asmlinkage int irix_prctl(struct pt_regs *regs)
96 int error = 0, base = 0;
98 if (regs->regs[2] == 1000)
100 cmd = regs->regs[base + 4];
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(regs->regs[base + 5]);
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 = regs->regs[base + 5];
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]: Wants PR_PTHREADEXIT\n",
227 current->comm, current->pid);
228 do_exit(regs->regs[base + 5]);
231 printk("irix_prctl[%s:%d]: Non-existant opcode %d\n",
232 current->comm, current->pid, (int)cmd);
240 #undef DEBUG_PROCGRPS
242 extern unsigned long irix_mapelf(int fd, struct elf_phdr *user_phdrp, int cnt);
243 extern int getrusage(struct task_struct *p, int who, struct rusage __user *ru);
244 extern char *prom_getenv(char *name);
245 extern long prom_setenv(char *name, char *value);
247 /* The syssgi commands supported thus far. */
248 #define SGI_SYSID 1 /* Return unique per-machine identifier. */
249 #define SGI_INVENT 5 /* Fetch inventory */
250 # define SGI_INV_SIZEOF 1
251 # define SGI_INV_READ 2
252 #define SGI_RDNAME 6 /* Return string name of a process. */
253 #define SGI_SETNVRAM 8 /* Set PROM variable. */
254 #define SGI_GETNVRAM 9 /* Get PROM variable. */
255 #define SGI_SETPGID 21 /* Set process group id. */
256 #define SGI_SYSCONF 22 /* POSIX sysconf garbage. */
257 #define SGI_PATHCONF 24 /* POSIX sysconf garbage. */
258 #define SGI_SETGROUPS 40 /* POSIX sysconf garbage. */
259 #define SGI_GETGROUPS 41 /* POSIX sysconf garbage. */
260 #define SGI_RUSAGE 56 /* BSD style rusage(). */
261 #define SGI_SSYNC 62 /* Synchronous fs sync. */
262 #define SGI_GETSID 65 /* SysVr4 get session id. */
263 #define SGI_ELFMAP 68 /* Map an elf image. */
264 #define SGI_TOSSTSAVE 108 /* Toss saved vma's. */
265 #define SGI_FP_BCOPY 129 /* Should FPU bcopy be used on this machine? */
266 #define SGI_PHYSP 1011 /* Translate virtual into physical page. */
268 asmlinkage int irix_syssgi(struct pt_regs *regs)
271 int retval, base = 0;
273 if (regs->regs[2] == 1000)
276 cmd = regs->regs[base + 4];
279 char *buf = (char *) regs->regs[base + 5];
281 /* XXX Use ethernet addr.... */
282 retval = clear_user(buf, 64);
287 int pid = (int) regs->regs[base + 5];
288 char *buf = (char *) regs->regs[base + 6];
289 struct task_struct *p;
290 char tcomm[sizeof(current->comm)];
292 if (!access_ok(VERIFY_WRITE, buf, sizeof(tcomm))) {
296 read_lock(&tasklist_lock);
297 p = find_task_by_pid(pid);
299 read_unlock(&tasklist_lock);
303 get_task_comm(tcomm, p);
304 read_unlock(&tasklist_lock);
306 /* XXX Need to check sizes. */
307 copy_to_user(buf, tcomm, sizeof(tcomm));
313 char *name = (char *) regs->regs[base+5];
314 char *buf = (char *) regs->regs[base+6];
316 return -EINVAL; /* til I fix it */
317 if (!access_ok(VERIFY_WRITE, buf, 128)) {
321 value = prom_getenv(name); /* PROM lock? */
326 /* Do I strlen() for the length? */
327 copy_to_user(buf, value, 128);
333 char *name = (char *) regs->regs[base+5];
334 char *value = (char *) regs->regs[base+6];
335 return -EINVAL; /* til I fix it */
336 retval = prom_setenv(name, value);
337 /* XXX make sure retval conforms to syssgi(2) */
338 printk("[%s:%d] setnvram(\"%s\", \"%s\"): retval %d",
339 current->comm, current->pid, name, value, retval);
340 /* if (retval == PROM_ENOENT)
347 #ifdef DEBUG_PROCGRPS
348 printk("[%s:%d] setpgid(%d, %d) ",
349 current->comm, current->pid,
350 (int) regs->regs[base + 5], (int)regs->regs[base + 6]);
352 retval = sys_setpgid(regs->regs[base + 5], regs->regs[base + 6]);
354 #ifdef DEBUG_PROCGRPS
355 printk("retval=%d\n", retval);
360 switch(regs->regs[base + 5]) {
362 retval = (MAX_ARG_PAGES >> 4); /* XXX estimate... */
365 retval = max_threads;
371 retval = NGROUPS_MAX;
409 retval = sys_setgroups((int) regs->regs[base + 5],
410 (gid_t *) regs->regs[base + 6]);
414 retval = sys_getgroups((int) regs->regs[base + 5],
415 (gid_t *) regs->regs[base + 6]);
419 struct rusage *ru = (struct rusage *) regs->regs[base + 6];
421 switch((int) regs->regs[base + 5]) {
424 retval = getrusage(current, RUSAGE_SELF, ru);
428 /* rusage children */
429 retval = getrusage(current, RUSAGE_CHILDREN, ru);
444 #ifdef DEBUG_PROCGRPS
445 printk("[%s:%d] getsid(%d) ", current->comm, current->pid,
446 (int) regs->regs[base + 5]);
448 retval = sys_getsid(regs->regs[base + 5]);
449 #ifdef DEBUG_PROCGRPS
450 printk("retval=%d\n", retval);
455 retval = irix_mapelf((int) regs->regs[base + 5],
456 (struct elf_phdr *) regs->regs[base + 6],
457 (int) regs->regs[base + 7]);
461 /* XXX We don't need to do anything? */
470 unsigned long addr = regs->regs[base + 5];
471 int *pageno = (int *) (regs->regs[base + 6]);
472 struct mm_struct *mm = current->mm;
477 if (!access_ok(VERIFY_WRITE, pageno, sizeof(int)))
480 down_read(&mm->mmap_sem);
481 pgdp = pgd_offset(mm, addr);
482 pmdp = pmd_offset(pgdp, addr);
483 ptep = pte_offset(pmdp, addr);
488 if (pte_val(pte) & (_PAGE_VALID | _PAGE_PRESENT)) {
489 retval = put_user((pte_val(pte) & PAGE_MASK) >>
493 up_read(&mm->mmap_sem);
498 int arg1 = (int) regs->regs [base + 5];
499 void *buffer = (void *) regs->regs [base + 6];
500 int count = (int) regs->regs [base + 7];
504 retval = sizeof (inventory_t);
507 retval = dump_inventory_to_user (buffer, count);
516 printk("irix_syssgi: Unsupported command %d\n", (int)cmd);
525 asmlinkage int irix_gtime(struct pt_regs *regs)
527 return get_seconds();
531 * IRIX is completely broken... it returns 0 on success, otherwise
534 asmlinkage int irix_brk(unsigned long brk)
537 unsigned long newbrk, oldbrk;
538 struct mm_struct *mm = current->mm;
541 down_write(&mm->mmap_sem);
542 if (brk < mm->end_code) {
547 newbrk = PAGE_ALIGN(brk);
548 oldbrk = PAGE_ALIGN(mm->brk);
549 if (oldbrk == newbrk) {
556 * Always allow shrinking brk
558 if (brk <= mm->brk) {
560 do_munmap(mm, newbrk, oldbrk-newbrk);
565 * Check against rlimit and stack..
567 rlim = current->signal->rlim[RLIMIT_DATA].rlim_cur;
568 if (rlim >= RLIM_INFINITY)
570 if (brk - mm->end_code > rlim) {
576 * Check against existing mmap mappings.
578 if (find_vma_intersection(mm, oldbrk, newbrk+PAGE_SIZE)) {
584 * Check if we have enough memory..
586 if (security_vm_enough_memory((newbrk-oldbrk) >> PAGE_SHIFT)) {
592 * Ok, looks good - let it rip.
595 do_brk(oldbrk, newbrk-oldbrk);
599 up_write(&mm->mmap_sem);
603 asmlinkage int irix_getpid(struct pt_regs *regs)
605 regs->regs[3] = current->real_parent->pid;
609 asmlinkage int irix_getuid(struct pt_regs *regs)
611 regs->regs[3] = current->euid;
615 asmlinkage int irix_getgid(struct pt_regs *regs)
617 regs->regs[3] = current->egid;
621 asmlinkage int irix_stime(int value)
628 err = security_settime(&tv, NULL);
632 write_seqlock_irq(&xtime_lock);
633 xtime.tv_sec = value;
636 write_sequnlock_irq(&xtime_lock);
641 static inline void jiffiestotv(unsigned long jiffies, struct timeval *value)
643 value->tv_usec = (jiffies % HZ) * (1000000 / HZ);
644 value->tv_sec = jiffies / HZ;
647 static inline void getitimer_real(struct itimerval *value)
649 register unsigned long val, interval;
651 interval = current->it_real_incr;
653 if (del_timer(¤t->real_timer)) {
654 unsigned long now = jiffies;
655 val = current->real_timer.expires;
656 add_timer(¤t->real_timer);
657 /* look out for negative/zero itimer.. */
662 jiffiestotv(val, &value->it_value);
663 jiffiestotv(interval, &value->it_interval);
666 asmlinkage unsigned int irix_alarm(unsigned int seconds)
668 struct itimerval it_new, it_old;
669 unsigned int oldalarm;
672 getitimer_real(&it_old);
673 del_timer(¤t->real_timer);
675 it_new.it_interval.tv_sec = it_new.it_interval.tv_usec = 0;
676 it_new.it_value.tv_sec = seconds;
677 it_new.it_value.tv_usec = 0;
678 do_setitimer(ITIMER_REAL, &it_new, &it_old);
680 oldalarm = it_old.it_value.tv_sec;
682 * ehhh.. We can't return 0 if we have an alarm pending ...
683 * And we'd better return too much than too little anyway
685 if (it_old.it_value.tv_usec)
691 asmlinkage int irix_pause(void)
693 current->state = TASK_INTERRUPTIBLE;
699 /* XXX need more than this... */
700 asmlinkage int irix_mount(char *dev_name, char *dir_name, unsigned long flags,
701 char *type, void *data, int datalen)
703 printk("[%s:%d] irix_mount(%p,%p,%08lx,%p,%p,%d)\n",
704 current->comm, current->pid,
705 dev_name, dir_name, flags, type, data, datalen);
707 return sys_mount(dev_name, dir_name, type, flags, data);
712 long f_bsize, f_frsize, f_blocks, f_bfree, f_files, f_ffree;
713 char f_fname[6], f_fpack[6];
716 asmlinkage int irix_statfs(const char *path, struct irix_statfs *buf,
717 int len, int fs_type)
723 /* We don't support this feature yet. */
728 if (!access_ok(VERIFY_WRITE, buf, sizeof(struct irix_statfs))) {
732 error = user_path_walk(path, &nd);
736 error = vfs_statfs(nd.dentry->d_inode->i_sb, &kbuf);
740 __put_user(kbuf.f_type, &buf->f_type);
741 __put_user(kbuf.f_bsize, &buf->f_bsize);
742 __put_user(kbuf.f_frsize, &buf->f_frsize);
743 __put_user(kbuf.f_blocks, &buf->f_blocks);
744 __put_user(kbuf.f_bfree, &buf->f_bfree);
745 __put_user(kbuf.f_files, &buf->f_files);
746 __put_user(kbuf.f_ffree, &buf->f_ffree);
747 for (i = 0; i < 6; i++) {
748 __put_user(0, &buf->f_fname[i]);
749 __put_user(0, &buf->f_fpack[i]);
759 asmlinkage int irix_fstatfs(unsigned int fd, struct irix_statfs *buf)
765 if (!access_ok(VERIFY_WRITE, buf, sizeof(struct irix_statfs))) {
769 if (!(file = fget(fd))) {
774 error = vfs_statfs(file->f_dentry->d_inode->i_sb, &kbuf);
778 __put_user(kbuf.f_type, &buf->f_type);
779 __put_user(kbuf.f_bsize, &buf->f_bsize);
780 __put_user(kbuf.f_frsize, &buf->f_frsize);
781 __put_user(kbuf.f_blocks, &buf->f_blocks);
782 __put_user(kbuf.f_bfree, &buf->f_bfree);
783 __put_user(kbuf.f_files, &buf->f_files);
784 __put_user(kbuf.f_ffree, &buf->f_ffree);
785 for(i = 0; i < 6; i++) {
786 __put_user(0, &buf->f_fname[i]);
787 __put_user(0, &buf->f_fpack[i]);
796 asmlinkage int irix_setpgrp(int flags)
800 #ifdef DEBUG_PROCGRPS
801 printk("[%s:%d] setpgrp(%d) ", current->comm, current->pid, flags);
804 error = process_group(current);
806 error = sys_setsid();
807 #ifdef DEBUG_PROCGRPS
808 printk("returning %d\n", process_group(current));
814 asmlinkage int irix_times(struct tms * tbuf)
819 if (!access_ok(VERIFY_WRITE,tbuf,sizeof *tbuf))
821 err |= __put_user(current->utime, &tbuf->tms_utime);
822 err |= __put_user(current->stime, &tbuf->tms_stime);
823 err |= __put_user(current->signal->cutime, &tbuf->tms_cutime);
824 err |= __put_user(current->signal->cstime, &tbuf->tms_cstime);
830 asmlinkage int irix_exec(struct pt_regs *regs)
835 if(regs->regs[2] == 1000)
837 filename = getname((char *) (long)regs->regs[base + 4]);
838 error = PTR_ERR(filename);
839 if (IS_ERR(filename))
842 error = do_execve(filename, (char **) (long)regs->regs[base + 5],
849 asmlinkage int irix_exece(struct pt_regs *regs)
854 if (regs->regs[2] == 1000)
856 filename = getname((char *) (long)regs->regs[base + 4]);
857 error = PTR_ERR(filename);
858 if (IS_ERR(filename))
860 error = do_execve(filename, (char **) (long)regs->regs[base + 5],
861 (char **) (long)regs->regs[base + 6], regs);
867 asmlinkage unsigned long irix_gethostid(void)
869 printk("[%s:%d]: irix_gethostid() called...\n",
870 current->comm, current->pid);
875 asmlinkage unsigned long irix_sethostid(unsigned long val)
877 printk("[%s:%d]: irix_sethostid(%08lx) called...\n",
878 current->comm, current->pid, val);
883 asmlinkage int irix_socket(int family, int type, int protocol)
895 type = 9; /* Invalid... */
907 type = SOCK_SEQPACKET;
914 return sys_socket(family, type, protocol);
917 asmlinkage int irix_getdomainname(char *name, int len)
921 if (!access_ok(VERIFY_WRITE, name, len))
925 if (len > __NEW_UTS_LEN)
928 if (copy_to_user(name, system_utsname.domainname, len))
935 asmlinkage unsigned long irix_getpagesize(void)
940 asmlinkage int irix_msgsys(int opcode, unsigned long arg0, unsigned long arg1,
941 unsigned long arg2, unsigned long arg3,
946 return sys_msgget((key_t) arg0, (int) arg1);
948 return sys_msgctl((int) arg0, (int) arg1, (struct msqid_ds *)arg2);
950 return sys_msgrcv((int) arg0, (struct msgbuf *) arg1,
951 (size_t) arg2, (long) arg3, (int) arg4);
953 return sys_msgsnd((int) arg0, (struct msgbuf *) arg1,
954 (size_t) arg2, (int) arg3);
960 asmlinkage int irix_shmsys(int opcode, unsigned long arg0, unsigned long arg1,
961 unsigned long arg2, unsigned long arg3)
965 return do_shmat((int) arg0, (char *)arg1, (int) arg2,
966 (unsigned long *) arg3);
968 return sys_shmctl((int)arg0, (int)arg1, (struct shmid_ds *)arg2);
970 return sys_shmdt((char *)arg0);
972 return sys_shmget((key_t) arg0, (int) arg1, (int) arg2);
978 asmlinkage int irix_semsys(int opcode, unsigned long arg0, unsigned long arg1,
979 unsigned long arg2, int arg3)
983 return sys_semctl((int) arg0, (int) arg1, (int) arg2,
986 return sys_semget((key_t) arg0, (int) arg1, (int) arg2);
988 return sys_semop((int) arg0, (struct sembuf *)arg1,
989 (unsigned int) arg2);
995 static inline loff_t llseek(struct file *file, loff_t offset, int origin)
997 loff_t (*fn)(struct file *, loff_t, int);
1000 fn = default_llseek;
1001 if (file->f_op && file->f_op->llseek)
1002 fn = file->f_op->llseek;
1004 retval = fn(file, offset, origin);
1009 asmlinkage int irix_lseek64(int fd, int _unused, int offhi, int offlow,
1024 offset = llseek(file, ((loff_t) offhi << 32) | offlow, origin);
1025 retval = (int) offset;
1033 asmlinkage int irix_sginap(int ticks)
1035 current->state = TASK_INTERRUPTIBLE;
1036 schedule_timeout(ticks);
1040 asmlinkage int irix_sgikopt(char *istring, char *ostring, int len)
1045 asmlinkage int irix_gettimeofday(struct timeval *tv)
1051 if (!access_ok(VERIFY_WRITE, tv, sizeof(struct timeval)))
1055 seq = read_seqbegin(&xtime_lock);
1057 nsec = xtime.tv_nsec;
1058 } while (read_seqretry(&xtime_lock, seq));
1060 err = __put_user(sec, &tv->tv_sec);
1061 err |= __put_user((nsec / 1000), &tv->tv_usec);
1066 #define IRIX_MAP_AUTOGROW 0x40
1068 asmlinkage unsigned long irix_mmap32(unsigned long addr, size_t len, int prot,
1069 int flags, int fd, off_t offset)
1071 struct file *file = NULL;
1072 unsigned long retval;
1074 if (!(flags & MAP_ANONYMOUS)) {
1075 if (!(file = fget(fd)))
1078 /* Ok, bad taste hack follows, try to think in something else
1079 * when reading this. */
1080 if (flags & IRIX_MAP_AUTOGROW) {
1081 unsigned long old_pos;
1082 long max_size = offset + len;
1084 if (max_size > file->f_dentry->d_inode->i_size) {
1085 old_pos = sys_lseek (fd, max_size - 1, 0);
1086 sys_write (fd, "", 1);
1087 sys_lseek (fd, old_pos, 0);
1092 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
1094 down_write(¤t->mm->mmap_sem);
1095 retval = do_mmap(file, addr, len, prot, flags, offset);
1096 up_write(¤t->mm->mmap_sem);
1103 asmlinkage int irix_madvise(unsigned long addr, int len, int behavior)
1105 printk("[%s:%d] Wheee.. irix_madvise(%08lx,%d,%d)\n",
1106 current->comm, current->pid, addr, len, behavior);
1111 asmlinkage int irix_pagelock(char *addr, int len, int op)
1113 printk("[%s:%d] Wheee.. irix_pagelock(%p,%d,%d)\n",
1114 current->comm, current->pid, addr, len, op);
1119 asmlinkage int irix_quotactl(struct pt_regs *regs)
1121 printk("[%s:%d] Wheee.. irix_quotactl()\n",
1122 current->comm, current->pid);
1127 asmlinkage int irix_BSDsetpgrp(int pid, int pgrp)
1131 #ifdef DEBUG_PROCGRPS
1132 printk("[%s:%d] BSDsetpgrp(%d, %d) ", current->comm, current->pid,
1138 /* Wheee, weird sysv thing... */
1139 if ((pgrp == 0) && (pid == current->pid))
1140 error = sys_setsid();
1142 error = sys_setpgid(pid, pgrp);
1144 #ifdef DEBUG_PROCGRPS
1145 printk("error = %d\n", error);
1151 asmlinkage int irix_systeminfo(int cmd, char *buf, int cnt)
1153 printk("[%s:%d] Wheee.. irix_systeminfo(%d,%p,%d)\n",
1154 current->comm, current->pid, cmd, buf, cnt);
1160 char sysname[257], nodename[257], release[257];
1161 char version[257], machine[257];
1162 char m_type[257], base_rel[257];
1163 char _unused0[257], _unused1[257], _unused2[257];
1164 char _unused3[257], _unused4[257], _unused5[257];
1167 asmlinkage int irix_uname(struct iuname *buf)
1169 down_read(&uts_sem);
1170 if (copy_to_user(system_utsname.sysname, buf->sysname, 65)
1171 || copy_to_user(system_utsname.nodename, buf->nodename, 65)
1172 || copy_to_user(system_utsname.release, buf->release, 65)
1173 || copy_to_user(system_utsname.version, buf->version, 65)
1174 || copy_to_user(system_utsname.machine, buf->machine, 65)) {
1184 static int irix_xstat32_xlate(struct kstat *stat, void *ubuf)
1187 u32 st_dev, st_pad1[3], st_ino, st_mode, st_nlink, st_uid, st_gid;
1188 u32 st_rdev, st_pad2[2], st_size, st_pad3;
1189 u32 st_atime0, st_atime1;
1190 u32 st_mtime0, st_mtime1;
1191 u32 st_ctime0, st_ctime1;
1192 u32 st_blksize, st_blocks;
1197 if (!sysv_valid_dev(stat->dev) || !sysv_valid_dev(stat->rdev))
1199 ub.st_dev = sysv_encode_dev(stat->dev);
1200 ub.st_ino = stat->ino;
1201 ub.st_mode = stat->mode;
1202 ub.st_nlink = stat->nlink;
1203 SET_UID(ub.st_uid, stat->uid);
1204 SET_GID(ub.st_gid, stat->gid);
1205 ub.st_rdev = sysv_encode_dev(stat->rdev);
1206 #if BITS_PER_LONG == 32
1207 if (stat->size > MAX_NON_LFS)
1210 ub.st_size = stat->size;
1211 ub.st_atime0 = stat->atime.tv_sec;
1212 ub.st_atime1 = stat->atime.tv_nsec;
1213 ub.st_mtime0 = stat->mtime.tv_sec;
1214 ub.st_mtime1 = stat->atime.tv_nsec;
1215 ub.st_ctime0 = stat->ctime.tv_sec;
1216 ub.st_ctime1 = stat->atime.tv_nsec;
1217 ub.st_blksize = stat->blksize;
1218 ub.st_blocks = stat->blocks;
1219 strcpy (ub.st_fstype, "efs");
1221 return copy_to_user(ubuf, &ub, sizeof(ub)) ? -EFAULT : 0;
1224 static int irix_xstat64_xlate(struct kstat *stat, void *ubuf)
1227 u32 st_dev; s32 st_pad1[3];
1228 unsigned long long st_ino;
1230 u32 st_nlink; s32 st_uid; s32 st_gid; u32 st_rdev;
1234 struct { s32 tv_sec, tv_nsec; } st_atime, st_mtime, st_ctime;
1236 long long st_blocks;
1241 if (!sysv_valid_dev(stat->dev) || !sysv_valid_dev(stat->rdev))
1244 ks.st_dev = sysv_encode_dev(stat->dev);
1245 ks.st_pad1[0] = ks.st_pad1[1] = ks.st_pad1[2] = 0;
1246 ks.st_ino = (unsigned long long) stat->ino;
1247 ks.st_mode = (u32) stat->mode;
1248 ks.st_nlink = (u32) stat->nlink;
1249 ks.st_uid = (s32) stat->uid;
1250 ks.st_gid = (s32) stat->gid;
1251 ks.st_rdev = sysv_encode_dev (stat->rdev);
1252 ks.st_pad2[0] = ks.st_pad2[1] = 0;
1253 ks.st_size = (long long) stat->size;
1256 /* XXX hackety hack... */
1257 ks.st_atime.tv_sec = (s32) stat->atime.tv_sec;
1258 ks.st_atime.tv_nsec = stat->atime.tv_nsec;
1259 ks.st_mtime.tv_sec = (s32) stat->mtime.tv_sec;
1260 ks.st_mtime.tv_nsec = stat->mtime.tv_nsec;
1261 ks.st_ctime.tv_sec = (s32) stat->ctime.tv_sec;
1262 ks.st_ctime.tv_nsec = stat->ctime.tv_nsec;
1264 ks.st_blksize = (s32) stat->blksize;
1265 ks.st_blocks = (long long) stat->blocks;
1266 memset(ks.st_fstype, 0, 16);
1267 ks.st_pad4[0] = ks.st_pad4[1] = ks.st_pad4[2] = ks.st_pad4[3] = 0;
1268 ks.st_pad4[4] = ks.st_pad4[5] = ks.st_pad4[6] = ks.st_pad4[7] = 0;
1270 /* Now write it all back. */
1271 return copy_to_user(ubuf, &ks, sizeof(ks)) ? -EFAULT : 0;
1274 asmlinkage int irix_xstat(int version, char *filename, struct stat *statbuf)
1280 printk("[%s:%d] Wheee.. irix_xstat(%d,%s,%p) ",
1281 current->comm, current->pid, version, filename, statbuf);
1284 retval = vfs_stat(filename, &stat);
1288 retval = irix_xstat32_xlate(&stat, statbuf);
1291 retval = irix_xstat64_xlate(&stat, statbuf);
1300 asmlinkage int irix_lxstat(int version, char *filename, struct stat *statbuf)
1306 printk("[%s:%d] Wheee.. irix_lxstat(%d,%s,%p) ",
1307 current->comm, current->pid, version, filename, statbuf);
1310 error = vfs_lstat(filename, &stat);
1315 error = irix_xstat32_xlate(&stat, statbuf);
1318 error = irix_xstat64_xlate(&stat, statbuf);
1327 asmlinkage int irix_fxstat(int version, int fd, struct stat *statbuf)
1333 printk("[%s:%d] Wheee.. irix_fxstat(%d,%d,%p) ",
1334 current->comm, current->pid, version, fd, statbuf);
1337 error = vfs_fstat(fd, &stat);
1341 error = irix_xstat32_xlate(&stat, statbuf);
1344 error = irix_xstat64_xlate(&stat, statbuf);
1353 asmlinkage int irix_xmknod(int ver, char *filename, int mode, unsigned dev)
1356 printk("[%s:%d] Wheee.. irix_xmknod(%d,%s,%x,%x)\n",
1357 current->comm, current->pid, ver, filename, mode, dev);
1361 /* shouldn't we convert here as well as on stat()? */
1362 retval = sys_mknod(filename, mode, dev);
1373 asmlinkage int irix_swapctl(int cmd, char *arg)
1375 printk("[%s:%d] Wheee.. irix_swapctl(%d,%p)\n",
1376 current->comm, current->pid, cmd, arg);
1381 struct irix_statvfs {
1382 u32 f_bsize; u32 f_frsize; u32 f_blocks;
1383 u32 f_bfree; u32 f_bavail; u32 f_files; u32 f_ffree; u32 f_favail;
1384 u32 f_fsid; char f_basetype[16];
1385 u32 f_flag; u32 f_namemax;
1386 char f_fstr[32]; u32 f_filler[16];
1389 asmlinkage int irix_statvfs(char *fname, struct irix_statvfs *buf)
1391 struct nameidata nd;
1392 struct kstatfs kbuf;
1395 printk("[%s:%d] Wheee.. irix_statvfs(%s,%p)\n",
1396 current->comm, current->pid, fname, buf);
1397 if (!access_ok(VERIFY_WRITE, buf, sizeof(struct irix_statvfs))) {
1401 error = user_path_walk(fname, &nd);
1404 error = vfs_statfs(nd.dentry->d_inode->i_sb, &kbuf);
1408 __put_user(kbuf.f_bsize, &buf->f_bsize);
1409 __put_user(kbuf.f_frsize, &buf->f_frsize);
1410 __put_user(kbuf.f_blocks, &buf->f_blocks);
1411 __put_user(kbuf.f_bfree, &buf->f_bfree);
1412 __put_user(kbuf.f_bfree, &buf->f_bavail); /* XXX hackety hack... */
1413 __put_user(kbuf.f_files, &buf->f_files);
1414 __put_user(kbuf.f_ffree, &buf->f_ffree);
1415 __put_user(kbuf.f_ffree, &buf->f_favail); /* XXX hackety hack... */
1417 __put_user(kbuf.f_fsid.val[1], &buf->f_fsid);
1419 __put_user(kbuf.f_fsid.val[0], &buf->f_fsid);
1421 for (i = 0; i < 16; i++)
1422 __put_user(0, &buf->f_basetype[i]);
1423 __put_user(0, &buf->f_flag);
1424 __put_user(kbuf.f_namelen, &buf->f_namemax);
1425 for (i = 0; i < 32; i++)
1426 __put_user(0, &buf->f_fstr[i]);
1436 asmlinkage int irix_fstatvfs(int fd, struct irix_statvfs *buf)
1438 struct kstatfs kbuf;
1442 printk("[%s:%d] Wheee.. irix_fstatvfs(%d,%p)\n",
1443 current->comm, current->pid, fd, buf);
1445 if (!access_ok(VERIFY_WRITE, buf, sizeof(struct irix_statvfs))) {
1449 if (!(file = fget(fd))) {
1453 error = vfs_statfs(file->f_dentry->d_inode->i_sb, &kbuf);
1457 __put_user(kbuf.f_bsize, &buf->f_bsize);
1458 __put_user(kbuf.f_frsize, &buf->f_frsize);
1459 __put_user(kbuf.f_blocks, &buf->f_blocks);
1460 __put_user(kbuf.f_bfree, &buf->f_bfree);
1461 __put_user(kbuf.f_bfree, &buf->f_bavail); /* XXX hackety hack... */
1462 __put_user(kbuf.f_files, &buf->f_files);
1463 __put_user(kbuf.f_ffree, &buf->f_ffree);
1464 __put_user(kbuf.f_ffree, &buf->f_favail); /* XXX hackety hack... */
1466 __put_user(kbuf.f_fsid.val[1], &buf->f_fsid);
1468 __put_user(kbuf.f_fsid.val[0], &buf->f_fsid);
1470 for(i = 0; i < 16; i++)
1471 __put_user(0, &buf->f_basetype[i]);
1472 __put_user(0, &buf->f_flag);
1473 __put_user(kbuf.f_namelen, &buf->f_namemax);
1474 __clear_user(&buf->f_fstr, sizeof(buf->f_fstr));
1482 asmlinkage int irix_priocntl(struct pt_regs *regs)
1484 printk("[%s:%d] Wheee.. irix_priocntl()\n",
1485 current->comm, current->pid);
1490 asmlinkage int irix_sigqueue(int pid, int sig, int code, int val)
1492 printk("[%s:%d] Wheee.. irix_sigqueue(%d,%d,%d,%d)\n",
1493 current->comm, current->pid, pid, sig, code, val);
1498 asmlinkage int irix_truncate64(char *name, int pad, int size1, int size2)
1506 retval = sys_truncate(name, size2);
1512 asmlinkage int irix_ftruncate64(int fd, int pad, int size1, int size2)
1520 retval = sys_ftruncate(fd, size2);
1526 asmlinkage int irix_mmap64(struct pt_regs *regs)
1528 int len, prot, flags, fd, off1, off2, error, base = 0;
1529 unsigned long addr, pgoff, *sp;
1530 struct file *file = NULL;
1532 if (regs->regs[2] == 1000)
1534 sp = (unsigned long *) (regs->regs[29] + 16);
1535 addr = regs->regs[base + 4];
1536 len = regs->regs[base + 5];
1537 prot = regs->regs[base + 6];
1539 flags = regs->regs[base + 7];
1540 if (!access_ok(VERIFY_READ, sp, (4 * sizeof(unsigned long)))) {
1545 __get_user(off1, &sp[1]);
1546 __get_user(off2, &sp[2]);
1548 if (!access_ok(VERIFY_READ, sp, (5 * sizeof(unsigned long)))) {
1552 __get_user(flags, &sp[0]);
1553 __get_user(fd, &sp[1]);
1554 __get_user(off1, &sp[2]);
1555 __get_user(off2, &sp[3]);
1558 if (off1 & PAGE_MASK) {
1563 pgoff = (off1 << (32 - PAGE_SHIFT)) | (off2 >> PAGE_SHIFT);
1565 if (!(flags & MAP_ANONYMOUS)) {
1566 if (!(file = fget(fd))) {
1571 /* Ok, bad taste hack follows, try to think in something else
1572 when reading this */
1573 if (flags & IRIX_MAP_AUTOGROW) {
1574 unsigned long old_pos;
1575 long max_size = off2 + len;
1577 if (max_size > file->f_dentry->d_inode->i_size) {
1578 old_pos = sys_lseek (fd, max_size - 1, 0);
1579 sys_write (fd, "", 1);
1580 sys_lseek (fd, old_pos, 0);
1585 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
1587 down_write(¤t->mm->mmap_sem);
1588 error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
1589 up_write(¤t->mm->mmap_sem);
1598 asmlinkage int irix_dmi(struct pt_regs *regs)
1600 printk("[%s:%d] Wheee.. irix_dmi()\n",
1601 current->comm, current->pid);
1606 asmlinkage int irix_pread(int fd, char *buf, int cnt, int off64,
1609 printk("[%s:%d] Wheee.. irix_pread(%d,%p,%d,%d,%d,%d)\n",
1610 current->comm, current->pid, fd, buf, cnt, off64, off1, off2);
1615 asmlinkage int irix_pwrite(int fd, char *buf, int cnt, int off64,
1618 printk("[%s:%d] Wheee.. irix_pwrite(%d,%p,%d,%d,%d,%d)\n",
1619 current->comm, current->pid, fd, buf, cnt, off64, off1, off2);
1624 asmlinkage int irix_sgifastpath(int cmd, unsigned long arg0, unsigned long arg1,
1625 unsigned long arg2, unsigned long arg3,
1626 unsigned long arg4, unsigned long arg5)
1628 printk("[%s:%d] Wheee.. irix_fastpath(%d,%08lx,%08lx,%08lx,%08lx,"
1630 current->comm, current->pid, cmd, arg0, arg1, arg2,
1636 struct irix_statvfs64 {
1637 u32 f_bsize; u32 f_frsize;
1638 u64 f_blocks; u64 f_bfree; u64 f_bavail;
1639 u64 f_files; u64 f_ffree; u64 f_favail;
1641 char f_basetype[16];
1642 u32 f_flag; u32 f_namemax;
1647 asmlinkage int irix_statvfs64(char *fname, struct irix_statvfs64 *buf)
1649 struct nameidata nd;
1650 struct kstatfs kbuf;
1653 printk("[%s:%d] Wheee.. irix_statvfs64(%s,%p)\n",
1654 current->comm, current->pid, fname, buf);
1655 if (!access_ok(VERIFY_WRITE, buf, sizeof(struct irix_statvfs64))) {
1659 error = user_path_walk(fname, &nd);
1662 error = vfs_statfs(nd.dentry->d_inode->i_sb, &kbuf);
1666 __put_user(kbuf.f_bsize, &buf->f_bsize);
1667 __put_user(kbuf.f_frsize, &buf->f_frsize);
1668 __put_user(kbuf.f_blocks, &buf->f_blocks);
1669 __put_user(kbuf.f_bfree, &buf->f_bfree);
1670 __put_user(kbuf.f_bfree, &buf->f_bavail); /* XXX hackety hack... */
1671 __put_user(kbuf.f_files, &buf->f_files);
1672 __put_user(kbuf.f_ffree, &buf->f_ffree);
1673 __put_user(kbuf.f_ffree, &buf->f_favail); /* XXX hackety hack... */
1675 __put_user(kbuf.f_fsid.val[1], &buf->f_fsid);
1677 __put_user(kbuf.f_fsid.val[0], &buf->f_fsid);
1679 for(i = 0; i < 16; i++)
1680 __put_user(0, &buf->f_basetype[i]);
1681 __put_user(0, &buf->f_flag);
1682 __put_user(kbuf.f_namelen, &buf->f_namemax);
1683 for(i = 0; i < 32; i++)
1684 __put_user(0, &buf->f_fstr[i]);
1694 asmlinkage int irix_fstatvfs64(int fd, struct irix_statvfs *buf)
1696 struct kstatfs kbuf;
1700 printk("[%s:%d] Wheee.. irix_fstatvfs64(%d,%p)\n",
1701 current->comm, current->pid, fd, buf);
1703 if (!access_ok(VERIFY_WRITE, buf, sizeof(struct irix_statvfs))) {
1707 if (!(file = fget(fd))) {
1711 error = vfs_statfs(file->f_dentry->d_inode->i_sb, &kbuf);
1715 __put_user(kbuf.f_bsize, &buf->f_bsize);
1716 __put_user(kbuf.f_frsize, &buf->f_frsize);
1717 __put_user(kbuf.f_blocks, &buf->f_blocks);
1718 __put_user(kbuf.f_bfree, &buf->f_bfree);
1719 __put_user(kbuf.f_bfree, &buf->f_bavail); /* XXX hackety hack... */
1720 __put_user(kbuf.f_files, &buf->f_files);
1721 __put_user(kbuf.f_ffree, &buf->f_ffree);
1722 __put_user(kbuf.f_ffree, &buf->f_favail); /* XXX hackety hack... */
1724 __put_user(kbuf.f_fsid.val[1], &buf->f_fsid);
1726 __put_user(kbuf.f_fsid.val[0], &buf->f_fsid);
1728 for(i = 0; i < 16; i++)
1729 __put_user(0, &buf->f_basetype[i]);
1730 __put_user(0, &buf->f_flag);
1731 __put_user(kbuf.f_namelen, &buf->f_namemax);
1732 __clear_user(buf->f_fstr, sizeof(buf->f_fstr[i]));
1740 asmlinkage int irix_getmountid(char *fname, unsigned long *midbuf)
1744 printk("[%s:%d] irix_getmountid(%s, %p)\n",
1745 current->comm, current->pid, fname, midbuf);
1746 if (!access_ok(VERIFY_WRITE, midbuf, (sizeof(unsigned long) * 4)))
1750 * The idea with this system call is that when trying to determine
1751 * 'pwd' and it's a toss-up for some reason, userland can use the
1752 * fsid of the filesystem to try and make the right decision, but
1753 * we don't have this so for now. XXX
1755 err |= __put_user(0, &midbuf[0]);
1756 err |= __put_user(0, &midbuf[1]);
1757 err |= __put_user(0, &midbuf[2]);
1758 err |= __put_user(0, &midbuf[3]);
1763 asmlinkage int irix_nsproc(unsigned long entry, unsigned long mask,
1764 unsigned long arg, unsigned long sp, int slen)
1766 printk("[%s:%d] Wheee.. irix_nsproc(%08lx,%08lx,%08lx,%08lx,%d)\n",
1767 current->comm, current->pid, entry, mask, arg, sp, slen);
1772 #undef DEBUG_GETDENTS
1774 struct irix_dirent32 {
1777 unsigned short d_reclen;
1781 struct irix_dirent32_callback {
1782 struct irix_dirent32 *current_dir;
1783 struct irix_dirent32 *previous;
1788 #define NAME_OFFSET32(de) ((int) ((de)->d_name - (char *) (de)))
1789 #define ROUND_UP32(x) (((x)+sizeof(u32)-1) & ~(sizeof(u32)-1))
1791 static int irix_filldir32(void *__buf, const char *name, int namlen,
1792 loff_t offset, ino_t ino, unsigned int d_type)
1794 struct irix_dirent32 *dirent;
1795 struct irix_dirent32_callback *buf =
1796 (struct irix_dirent32_callback *)__buf;
1797 unsigned short reclen = ROUND_UP32(NAME_OFFSET32(dirent) + namlen + 1);
1799 #ifdef DEBUG_GETDENTS
1800 printk("\nirix_filldir32[reclen<%d>namlen<%d>count<%d>]",
1801 reclen, namlen, buf->count);
1803 buf->error = -EINVAL; /* only used if we fail.. */
1804 if (reclen > buf->count)
1806 dirent = buf->previous;
1808 __put_user(offset, &dirent->d_off);
1809 dirent = buf->current_dir;
1810 buf->previous = dirent;
1811 __put_user(ino, &dirent->d_ino);
1812 __put_user(reclen, &dirent->d_reclen);
1813 copy_to_user(dirent->d_name, name, namlen);
1814 __put_user(0, &dirent->d_name[namlen]);
1815 ((char *) dirent) += reclen;
1816 buf->current_dir = dirent;
1817 buf->count -= reclen;
1822 asmlinkage int irix_ngetdents(unsigned int fd, void * dirent,
1823 unsigned int count, int *eob)
1826 struct irix_dirent32 *lastdirent;
1827 struct irix_dirent32_callback buf;
1830 #ifdef DEBUG_GETDENTS
1831 printk("[%s:%d] ngetdents(%d, %p, %d, %p) ", current->comm,
1832 current->pid, fd, dirent, count, eob);
1839 buf.current_dir = (struct irix_dirent32 *) dirent;
1840 buf.previous = NULL;
1844 error = vfs_readdir(file, irix_filldir32, &buf);
1849 lastdirent = buf.previous;
1851 put_user(file->f_pos, &lastdirent->d_off);
1852 error = count - buf.count;
1855 if (put_user(0, eob) < 0) {
1860 #ifdef DEBUG_GETDENTS
1861 printk("eob=%d returning %d\n", *eob, count - buf.count);
1863 error = count - buf.count;
1871 struct irix_dirent64 {
1874 unsigned short d_reclen;
1878 struct irix_dirent64_callback {
1879 struct irix_dirent64 *curr;
1880 struct irix_dirent64 *previous;
1885 #define NAME_OFFSET64(de) ((int) ((de)->d_name - (char *) (de)))
1886 #define ROUND_UP64(x) (((x)+sizeof(u64)-1) & ~(sizeof(u64)-1))
1888 static int irix_filldir64(void * __buf, const char * name, int namlen,
1889 loff_t offset, ino_t ino, unsigned int d_type)
1891 struct irix_dirent64 *dirent;
1892 struct irix_dirent64_callback * buf =
1893 (struct irix_dirent64_callback *) __buf;
1894 unsigned short reclen = ROUND_UP64(NAME_OFFSET64(dirent) + namlen + 1);
1896 buf->error = -EINVAL; /* only used if we fail.. */
1897 if (reclen > buf->count)
1899 dirent = buf->previous;
1901 __put_user(offset, &dirent->d_off);
1903 buf->previous = dirent;
1904 __put_user(ino, &dirent->d_ino);
1905 __put_user(reclen, &dirent->d_reclen);
1906 __copy_to_user(dirent->d_name, name, namlen);
1907 __put_user(0, &dirent->d_name[namlen]);
1908 ((char *) dirent) += reclen;
1910 buf->count -= reclen;
1915 asmlinkage int irix_getdents64(int fd, void *dirent, int cnt)
1918 struct irix_dirent64 *lastdirent;
1919 struct irix_dirent64_callback buf;
1922 #ifdef DEBUG_GETDENTS
1923 printk("[%s:%d] getdents64(%d, %p, %d) ", current->comm,
1924 current->pid, fd, dirent, cnt);
1927 if (!(file = fget(fd)))
1931 if (!access_ok(VERIFY_WRITE, dirent, cnt))
1935 if (cnt < (sizeof(struct irix_dirent64) + 255))
1938 buf.curr = (struct irix_dirent64 *) dirent;
1939 buf.previous = NULL;
1942 error = vfs_readdir(file, irix_filldir64, &buf);
1945 lastdirent = buf.previous;
1950 lastdirent->d_off = (u64) file->f_pos;
1951 #ifdef DEBUG_GETDENTS
1952 printk("returning %d\n", cnt - buf.count);
1954 error = cnt - buf.count;
1962 asmlinkage int irix_ngetdents64(int fd, void *dirent, int cnt, int *eob)
1965 struct irix_dirent64 *lastdirent;
1966 struct irix_dirent64_callback buf;
1969 #ifdef DEBUG_GETDENTS
1970 printk("[%s:%d] ngetdents64(%d, %p, %d) ", current->comm,
1971 current->pid, fd, dirent, cnt);
1974 if (!(file = fget(fd)))
1978 if (!access_ok(VERIFY_WRITE, dirent, cnt) ||
1979 !access_ok(VERIFY_WRITE, eob, sizeof(*eob)))
1983 if (cnt < (sizeof(struct irix_dirent64) + 255))
1987 buf.curr = (struct irix_dirent64 *) dirent;
1988 buf.previous = NULL;
1991 error = vfs_readdir(file, irix_filldir64, &buf);
1994 lastdirent = buf.previous;
1999 lastdirent->d_off = (u64) file->f_pos;
2000 #ifdef DEBUG_GETDENTS
2001 printk("eob=%d returning %d\n", *eob, cnt - buf.count);
2003 error = cnt - buf.count;
2011 asmlinkage int irix_uadmin(unsigned long op, unsigned long func, unsigned long arg)
2018 printk("[%s:%d] irix_uadmin: Wants to reboot...\n",
2019 current->comm, current->pid);
2025 printk("[%s:%d] irix_uadmin: Wants to shutdown...\n",
2026 current->comm, current->pid);
2032 printk("[%s:%d] irix_uadmin: Wants to remount root...\n",
2033 current->comm, current->pid);
2038 /* Kill all tasks. */
2039 printk("[%s:%d] irix_uadmin: Wants to kill all tasks...\n",
2040 current->comm, current->pid);
2045 /* Set magic mushrooms... */
2046 printk("[%s:%d] irix_uadmin: Wants to set magic mushroom[%d]...\n",
2047 current->comm, current->pid, (int) func);
2052 printk("[%s:%d] irix_uadmin: Unknown operation [%d]...\n",
2053 current->comm, current->pid, (int) op);
2062 asmlinkage int irix_utssys(char *inbuf, int arg, int type, char *outbuf)
2069 retval = irix_uname((struct iuname *)inbuf);
2074 printk("[%s:%d] irix_utssys: Wants to do ustat()\n",
2075 current->comm, current->pid);
2081 printk("[%s:%d] irix_utssys: Wants to do fusers()\n",
2082 current->comm, current->pid);
2087 printk("[%s:%d] irix_utssys: Wants to do unknown type[%d]\n",
2088 current->comm, current->pid, (int) type);
2099 #define IRIX_F_ALLOCSP 10
2101 asmlinkage int irix_fcntl(int fd, int cmd, int arg)
2106 printk("[%s:%d] irix_fcntl(%d, %d, %d) ", current->comm,
2107 current->pid, fd, cmd, arg);
2109 if (cmd == IRIX_F_ALLOCSP){
2112 retval = sys_fcntl(fd, cmd, arg);
2114 printk("%d\n", retval);
2119 asmlinkage int irix_ulimit(int cmd, int arg)
2125 printk("[%s:%d] irix_ulimit: Wants to get file size limit.\n",
2126 current->comm, current->pid);
2131 printk("[%s:%d] irix_ulimit: Wants to set file size limit.\n",
2132 current->comm, current->pid);
2137 printk("[%s:%d] irix_ulimit: Wants to get brk limit.\n",
2138 current->comm, current->pid);
2144 printk("[%s:%d] irix_ulimit: Wants to get fd limit.\n",
2145 current->comm, current->pid);
2149 retval = current->signal->rlim[RLIMIT_NOFILE].rlim_cur;
2153 printk("[%s:%d] irix_ulimit: Wants to get txt offset.\n",
2154 current->comm, current->pid);
2159 printk("[%s:%d] irix_ulimit: Unknown command [%d].\n",
2160 current->comm, current->pid, cmd);
2168 asmlinkage int irix_unimp(struct pt_regs *regs)
2170 printk("irix_unimp [%s:%d] v0=%d v1=%d a0=%08lx a1=%08lx a2=%08lx "
2171 "a3=%08lx\n", current->comm, current->pid,
2172 (int) regs->regs[2], (int) regs->regs[3],
2173 regs->regs[4], regs->regs[5], regs->regs[6], regs->regs[7]);