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>
33 #include <linux/vs_cvirt.h>
35 #include <asm/ptrace.h>
37 #include <asm/uaccess.h>
38 #include <asm/inventory.h>
40 /* 2,191 lines of complete and utter shit coming up... */
42 extern int max_threads;
44 /* The sysmp commands supported thus far. */
45 #define MP_NPROCS 1 /* # processor in complex */
46 #define MP_NAPROCS 2 /* # active processors in complex */
47 #define MP_PGSIZE 14 /* Return system page size in v1. */
49 asmlinkage int irix_sysmp(struct pt_regs *regs)
55 if(regs->regs[2] == 1000)
57 cmd = regs->regs[base + 4];
64 error = num_online_cpus();
67 printk("SYSMP[%s:%d]: Unsupported opcode %d\n",
68 current->comm, current->pid, (int)cmd);
76 /* The prctl commands. */
77 #define PR_MAXPROCS 1 /* Tasks/user. */
78 #define PR_ISBLOCKED 2 /* If blocked, return 1. */
79 #define PR_SETSTACKSIZE 3 /* Set largest task stack size. */
80 #define PR_GETSTACKSIZE 4 /* Get largest task stack size. */
81 #define PR_MAXPPROCS 5 /* Num parallel tasks. */
82 #define PR_UNBLKONEXEC 6 /* When task exec/exit's, unblock. */
83 #define PR_SETEXITSIG 8 /* When task exit's, set signal. */
84 #define PR_RESIDENT 9 /* Make task unswappable. */
85 #define PR_ATTACHADDR 10 /* (Re-)Connect a vma to a task. */
86 #define PR_DETACHADDR 11 /* Disconnect a vma from a task. */
87 #define PR_TERMCHILD 12 /* When parent sleeps with fishes, kill child. */
88 #define PR_GETSHMASK 13 /* Get the sproc() share mask. */
89 #define PR_GETNSHARE 14 /* Number of share group members. */
90 #define PR_COREPID 15 /* Add task pid to name when it core. */
91 #define PR_ATTACHADDRPERM 16 /* (Re-)Connect vma, with specified prot. */
92 #define PR_PTHREADEXIT 17 /* Kill a pthread without prejudice. */
94 asmlinkage int irix_prctl(struct pt_regs *regs)
97 int error = 0, base = 0;
99 if (regs->regs[2] == 1000)
101 cmd = regs->regs[base + 4];
104 printk("irix_prctl[%s:%d]: Wants PR_MAXPROCS\n",
105 current->comm, current->pid);
110 struct task_struct *task;
112 printk("irix_prctl[%s:%d]: Wants PR_ISBLOCKED\n",
113 current->comm, current->pid);
114 read_lock(&tasklist_lock);
115 task = find_task_by_pid(regs->regs[base + 5]);
118 error = (task->run_list.next != NULL);
119 read_unlock(&tasklist_lock);
120 /* Can _your_ OS find this out that fast? */
124 case PR_SETSTACKSIZE: {
125 long value = regs->regs[base + 5];
127 printk("irix_prctl[%s:%d]: Wants PR_SETSTACKSIZE<%08lx>\n",
128 current->comm, current->pid, (unsigned long) value);
129 if (value > RLIM_INFINITY)
130 value = RLIM_INFINITY;
131 if (capable(CAP_SYS_ADMIN)) {
132 current->rlim[RLIMIT_STACK].rlim_max =
133 current->rlim[RLIMIT_STACK].rlim_cur = value;
137 if (value > current->rlim[RLIMIT_STACK].rlim_max) {
141 current->rlim[RLIMIT_STACK].rlim_cur = value;
146 case PR_GETSTACKSIZE:
147 printk("irix_prctl[%s:%d]: Wants PR_GETSTACKSIZE\n",
148 current->comm, current->pid);
149 error = current->rlim[RLIMIT_STACK].rlim_cur;
153 printk("irix_prctl[%s:%d]: Wants PR_MAXPROCS\n",
154 current->comm, current->pid);
159 printk("irix_prctl[%s:%d]: Wants PR_UNBLKONEXEC\n",
160 current->comm, current->pid);
165 printk("irix_prctl[%s:%d]: Wants PR_SETEXITSIG\n",
166 current->comm, current->pid);
168 /* We can probably play some game where we set the task
169 * exit_code to some non-zero value when this is requested,
170 * and check whether exit_code is already set in do_exit().
176 printk("irix_prctl[%s:%d]: Wants PR_RESIDENT\n",
177 current->comm, current->pid);
178 error = 0; /* Compatibility indeed. */
182 printk("irix_prctl[%s:%d]: Wants PR_ATTACHADDR\n",
183 current->comm, current->pid);
188 printk("irix_prctl[%s:%d]: Wants PR_DETACHADDR\n",
189 current->comm, current->pid);
194 printk("irix_prctl[%s:%d]: Wants PR_TERMCHILD\n",
195 current->comm, current->pid);
200 printk("irix_prctl[%s:%d]: Wants PR_GETSHMASK\n",
201 current->comm, current->pid);
202 error = -EINVAL; /* Until I have the sproc() stuff in. */
206 error = 0; /* Until I have the sproc() stuff in. */
210 printk("irix_prctl[%s:%d]: Wants PR_COREPID\n",
211 current->comm, current->pid);
215 case PR_ATTACHADDRPERM:
216 printk("irix_prctl[%s:%d]: Wants PR_ATTACHADDRPERM\n",
217 current->comm, current->pid);
222 printk("irix_prctl[%s:%d]: Wants PR_PTHREADEXIT\n",
223 current->comm, current->pid);
224 do_exit(regs->regs[base + 5]);
227 printk("irix_prctl[%s:%d]: Non-existant opcode %d\n",
228 current->comm, current->pid, (int)cmd);
236 #undef DEBUG_PROCGRPS
238 extern unsigned long irix_mapelf(int fd, struct elf_phdr *user_phdrp, int cnt);
239 extern int getrusage(struct task_struct *p, int who, struct rusage __user *ru);
240 extern char *prom_getenv(char *name);
241 extern long prom_setenv(char *name, char *value);
243 /* The syssgi commands supported thus far. */
244 #define SGI_SYSID 1 /* Return unique per-machine identifier. */
245 #define SGI_INVENT 5 /* Fetch inventory */
246 # define SGI_INV_SIZEOF 1
247 # define SGI_INV_READ 2
248 #define SGI_RDNAME 6 /* Return string name of a process. */
249 #define SGI_SETNVRAM 8 /* Set PROM variable. */
250 #define SGI_GETNVRAM 9 /* Get PROM variable. */
251 #define SGI_SETPGID 21 /* Set process group id. */
252 #define SGI_SYSCONF 22 /* POSIX sysconf garbage. */
253 #define SGI_PATHCONF 24 /* POSIX sysconf garbage. */
254 #define SGI_SETGROUPS 40 /* POSIX sysconf garbage. */
255 #define SGI_GETGROUPS 41 /* POSIX sysconf garbage. */
256 #define SGI_RUSAGE 56 /* BSD style rusage(). */
257 #define SGI_SSYNC 62 /* Synchronous fs sync. */
258 #define SGI_GETSID 65 /* SysVr4 get session id. */
259 #define SGI_ELFMAP 68 /* Map an elf image. */
260 #define SGI_TOSSTSAVE 108 /* Toss saved vma's. */
261 #define SGI_FP_BCOPY 129 /* Should FPU bcopy be used on this machine? */
262 #define SGI_PHYSP 1011 /* Translate virtual into physical page. */
264 asmlinkage int irix_syssgi(struct pt_regs *regs)
267 int retval, base = 0;
269 if (regs->regs[2] == 1000)
272 cmd = regs->regs[base + 4];
275 char *buf = (char *) regs->regs[base + 5];
277 /* XXX Use ethernet addr.... */
278 retval = clear_user(buf, 64);
283 int pid = (int) regs->regs[base + 5];
284 char *buf = (char *) regs->regs[base + 6];
285 struct task_struct *p;
288 retval = verify_area(VERIFY_WRITE, buf, 16);
291 read_lock(&tasklist_lock);
292 p = find_task_by_pid(pid);
294 read_unlock(&tasklist_lock);
298 memcpy(comm, p->comm, 16);
299 read_unlock(&tasklist_lock);
301 /* XXX Need to check sizes. */
302 copy_to_user(buf, p->comm, 16);
308 char *name = (char *) regs->regs[base+5];
309 char *buf = (char *) regs->regs[base+6];
311 return -EINVAL; /* til I fix it */
312 retval = verify_area(VERIFY_WRITE, buf, 128);
315 value = prom_getenv(name); /* PROM lock? */
320 /* Do I strlen() for the length? */
321 copy_to_user(buf, value, 128);
327 char *name = (char *) regs->regs[base+5];
328 char *value = (char *) regs->regs[base+6];
329 return -EINVAL; /* til I fix it */
330 retval = prom_setenv(name, value);
331 /* XXX make sure retval conforms to syssgi(2) */
332 printk("[%s:%d] setnvram(\"%s\", \"%s\"): retval %d",
333 current->comm, current->pid, name, value, retval);
334 /* if (retval == PROM_ENOENT)
341 #ifdef DEBUG_PROCGRPS
342 printk("[%s:%d] setpgid(%d, %d) ",
343 current->comm, current->pid,
344 (int) regs->regs[base + 5], (int)regs->regs[base + 6]);
346 retval = sys_setpgid(regs->regs[base + 5], regs->regs[base + 6]);
348 #ifdef DEBUG_PROCGRPS
349 printk("retval=%d\n", retval);
354 switch(regs->regs[base + 5]) {
356 retval = (MAX_ARG_PAGES >> 4); /* XXX estimate... */
359 retval = max_threads;
365 retval = NGROUPS_MAX;
403 retval = sys_setgroups((int) regs->regs[base + 5],
404 (gid_t *) regs->regs[base + 6]);
408 retval = sys_getgroups((int) regs->regs[base + 5],
409 (gid_t *) regs->regs[base + 6]);
413 struct rusage *ru = (struct rusage *) regs->regs[base + 6];
415 switch((int) regs->regs[base + 5]) {
418 retval = getrusage(current, RUSAGE_SELF, ru);
422 /* rusage children */
423 retval = getrusage(current, RUSAGE_CHILDREN, ru);
438 #ifdef DEBUG_PROCGRPS
439 printk("[%s:%d] getsid(%d) ", current->comm, current->pid,
440 (int) regs->regs[base + 5]);
442 retval = sys_getsid(regs->regs[base + 5]);
443 #ifdef DEBUG_PROCGRPS
444 printk("retval=%d\n", retval);
449 retval = irix_mapelf((int) regs->regs[base + 5],
450 (struct elf_phdr *) regs->regs[base + 6],
451 (int) regs->regs[base + 7]);
455 /* XXX We don't need to do anything? */
464 unsigned long addr = regs->regs[base + 5];
465 int *pageno = (int *) (regs->regs[base + 6]);
466 struct mm_struct *mm = current->mm;
471 retval = verify_area(VERIFY_WRITE, pageno, sizeof(int));
475 down_read(&mm->mmap_sem);
476 pgdp = pgd_offset(mm, addr);
477 pmdp = pmd_offset(pgdp, addr);
478 ptep = pte_offset(pmdp, addr);
483 if (pte_val(pte) & (_PAGE_VALID | _PAGE_PRESENT)) {
484 retval = put_user((pte_val(pte) & PAGE_MASK) >>
488 up_read(&mm->mmap_sem);
493 int arg1 = (int) regs->regs [base + 5];
494 void *buffer = (void *) regs->regs [base + 6];
495 int count = (int) regs->regs [base + 7];
499 retval = sizeof (inventory_t);
502 retval = dump_inventory_to_user (buffer, count);
511 printk("irix_syssgi: Unsupported command %d\n", (int)cmd);
520 asmlinkage int irix_gtime(struct pt_regs *regs)
522 return get_seconds();
526 * IRIX is completely broken... it returns 0 on success, otherwise
529 asmlinkage int irix_brk(unsigned long brk)
532 unsigned long newbrk, oldbrk;
533 struct mm_struct *mm = current->mm;
536 down_write(&mm->mmap_sem);
537 if (brk < mm->end_code) {
542 newbrk = PAGE_ALIGN(brk);
543 oldbrk = PAGE_ALIGN(mm->brk);
544 if (oldbrk == newbrk) {
551 * Always allow shrinking brk
553 if (brk <= mm->brk) {
555 do_munmap(mm, newbrk, oldbrk-newbrk);
560 * Check against rlimit and stack..
562 rlim = current->rlim[RLIMIT_DATA].rlim_cur;
563 if (rlim >= RLIM_INFINITY)
565 if (brk - mm->end_code > rlim) {
571 * Check against existing mmap mappings.
573 if (find_vma_intersection(mm, oldbrk, newbrk+PAGE_SIZE)) {
579 * Check if we have enough memory..
581 if (security_vm_enough_memory((newbrk-oldbrk) >> PAGE_SHIFT) ||
582 !vx_vmpages_avail(mm, (newbrk-oldbrk) >> PAGE_SHIFT)) {
588 * Ok, looks good - let it rip.
591 do_brk(oldbrk, newbrk-oldbrk);
595 up_write(&mm->mmap_sem);
599 asmlinkage int irix_getpid(struct pt_regs *regs)
601 regs->regs[3] = current->real_parent->pid;
605 asmlinkage int irix_getuid(struct pt_regs *regs)
607 regs->regs[3] = current->euid;
611 asmlinkage int irix_getgid(struct pt_regs *regs)
613 regs->regs[3] = current->egid;
617 asmlinkage int irix_stime(int value)
619 if (!capable(CAP_SYS_TIME))
622 write_seqlock_irq(&xtime_lock);
623 xtime.tv_sec = value;
625 time_adjust = 0; /* stop active adjtime() */
626 time_status |= STA_UNSYNC;
627 time_maxerror = NTP_PHASE_LIMIT;
628 time_esterror = NTP_PHASE_LIMIT;
629 write_sequnlock_irq(&xtime_lock);
634 static inline void jiffiestotv(unsigned long jiffies, struct timeval *value)
636 value->tv_usec = (jiffies % HZ) * (1000000 / HZ);
637 value->tv_sec = jiffies / HZ;
640 static inline void getitimer_real(struct itimerval *value)
642 register unsigned long val, interval;
644 interval = current->it_real_incr;
646 if (del_timer(¤t->real_timer)) {
647 unsigned long now = jiffies;
648 val = current->real_timer.expires;
649 add_timer(¤t->real_timer);
650 /* look out for negative/zero itimer.. */
655 jiffiestotv(val, &value->it_value);
656 jiffiestotv(interval, &value->it_interval);
659 asmlinkage unsigned int irix_alarm(unsigned int seconds)
661 struct itimerval it_new, it_old;
662 unsigned int oldalarm;
665 getitimer_real(&it_old);
666 del_timer(¤t->real_timer);
668 it_new.it_interval.tv_sec = it_new.it_interval.tv_usec = 0;
669 it_new.it_value.tv_sec = seconds;
670 it_new.it_value.tv_usec = 0;
671 do_setitimer(ITIMER_REAL, &it_new, &it_old);
673 oldalarm = it_old.it_value.tv_sec;
675 * ehhh.. We can't return 0 if we have an alarm pending ...
676 * And we'd better return too much than too little anyway
678 if (it_old.it_value.tv_usec)
684 asmlinkage int irix_pause(void)
686 current->state = TASK_INTERRUPTIBLE;
692 /* XXX need more than this... */
693 asmlinkage int irix_mount(char *dev_name, char *dir_name, unsigned long flags,
694 char *type, void *data, int datalen)
696 printk("[%s:%d] irix_mount(%p,%p,%08lx,%p,%p,%d)\n",
697 current->comm, current->pid,
698 dev_name, dir_name, flags, type, data, datalen);
700 return sys_mount(dev_name, dir_name, type, flags, data);
705 long f_bsize, f_frsize, f_blocks, f_bfree, f_files, f_ffree;
706 char f_fname[6], f_fpack[6];
709 asmlinkage int irix_statfs(const char *path, struct irix_statfs *buf,
710 int len, int fs_type)
716 /* We don't support this feature yet. */
721 error = verify_area(VERIFY_WRITE, buf, sizeof(struct irix_statfs));
724 error = user_path_walk(path, &nd);
728 error = vfs_statfs(nd.dentry->d_inode->i_sb, &kbuf);
732 __put_user(kbuf.f_type, &buf->f_type);
733 __put_user(kbuf.f_bsize, &buf->f_bsize);
734 __put_user(kbuf.f_frsize, &buf->f_frsize);
735 __put_user(kbuf.f_blocks, &buf->f_blocks);
736 __put_user(kbuf.f_bfree, &buf->f_bfree);
737 __put_user(kbuf.f_files, &buf->f_files);
738 __put_user(kbuf.f_ffree, &buf->f_ffree);
739 for (i = 0; i < 6; i++) {
740 __put_user(0, &buf->f_fname[i]);
741 __put_user(0, &buf->f_fpack[i]);
751 asmlinkage int irix_fstatfs(unsigned int fd, struct irix_statfs *buf)
757 error = verify_area(VERIFY_WRITE, buf, sizeof(struct irix_statfs));
760 if (!(file = fget(fd))) {
765 error = vfs_statfs(file->f_dentry->d_inode->i_sb, &kbuf);
769 __put_user(kbuf.f_type, &buf->f_type);
770 __put_user(kbuf.f_bsize, &buf->f_bsize);
771 __put_user(kbuf.f_frsize, &buf->f_frsize);
772 __put_user(kbuf.f_blocks, &buf->f_blocks);
773 __put_user(kbuf.f_bfree, &buf->f_bfree);
774 __put_user(kbuf.f_files, &buf->f_files);
775 __put_user(kbuf.f_ffree, &buf->f_ffree);
776 for(i = 0; i < 6; i++) {
777 __put_user(0, &buf->f_fname[i]);
778 __put_user(0, &buf->f_fpack[i]);
787 asmlinkage int irix_setpgrp(int flags)
791 #ifdef DEBUG_PROCGRPS
792 printk("[%s:%d] setpgrp(%d) ", current->comm, current->pid, flags);
795 error = process_group(current);
797 error = sys_setsid();
798 #ifdef DEBUG_PROCGRPS
799 printk("returning %d\n", process_group(current));
805 asmlinkage int irix_times(struct tms * tbuf)
810 err = verify_area(VERIFY_WRITE,tbuf,sizeof *tbuf);
813 err |= __put_user(current->utime, &tbuf->tms_utime);
814 err |= __put_user(current->stime, &tbuf->tms_stime);
815 err |= __put_user(current->signal->cutime, &tbuf->tms_cutime);
816 err |= __put_user(current->signal->cstime, &tbuf->tms_cstime);
822 asmlinkage int irix_exec(struct pt_regs *regs)
827 if(regs->regs[2] == 1000)
829 filename = getname((char *) (long)regs->regs[base + 4]);
830 error = PTR_ERR(filename);
831 if (IS_ERR(filename))
834 error = do_execve(filename, (char **) (long)regs->regs[base + 5],
841 asmlinkage int irix_exece(struct pt_regs *regs)
846 if (regs->regs[2] == 1000)
848 filename = getname((char *) (long)regs->regs[base + 4]);
849 error = PTR_ERR(filename);
850 if (IS_ERR(filename))
852 error = do_execve(filename, (char **) (long)regs->regs[base + 5],
853 (char **) (long)regs->regs[base + 6], regs);
859 asmlinkage unsigned long irix_gethostid(void)
861 printk("[%s:%d]: irix_gethostid() called...\n",
862 current->comm, current->pid);
867 asmlinkage unsigned long irix_sethostid(unsigned long val)
869 printk("[%s:%d]: irix_sethostid(%08lx) called...\n",
870 current->comm, current->pid, val);
875 asmlinkage int irix_socket(int family, int type, int protocol)
887 type = 9; /* Invalid... */
899 type = SOCK_SEQPACKET;
906 return sys_socket(family, type, protocol);
909 asmlinkage int irix_getdomainname(char *name, int len)
913 error = verify_area(VERIFY_WRITE, name, len);
918 if(len > (__NEW_UTS_LEN - 1))
919 len = __NEW_UTS_LEN - 1;
921 if (copy_to_user(name, system_utsname.domainname, len))
928 asmlinkage unsigned long irix_getpagesize(void)
933 asmlinkage int irix_msgsys(int opcode, unsigned long arg0, unsigned long arg1,
934 unsigned long arg2, unsigned long arg3,
939 return sys_msgget((key_t) arg0, (int) arg1);
941 return sys_msgctl((int) arg0, (int) arg1, (struct msqid_ds *)arg2);
943 return sys_msgrcv((int) arg0, (struct msgbuf *) arg1,
944 (size_t) arg2, (long) arg3, (int) arg4);
946 return sys_msgsnd((int) arg0, (struct msgbuf *) arg1,
947 (size_t) arg2, (int) arg3);
953 asmlinkage int irix_shmsys(int opcode, unsigned long arg0, unsigned long arg1,
954 unsigned long arg2, unsigned long arg3)
958 return do_shmat((int) arg0, (char *)arg1, (int) arg2,
959 (unsigned long *) arg3);
961 return sys_shmctl((int)arg0, (int)arg1, (struct shmid_ds *)arg2);
963 return sys_shmdt((char *)arg0);
965 return sys_shmget((key_t) arg0, (int) arg1, (int) arg2);
971 asmlinkage int irix_semsys(int opcode, unsigned long arg0, unsigned long arg1,
972 unsigned long arg2, int arg3)
976 return sys_semctl((int) arg0, (int) arg1, (int) arg2,
979 return sys_semget((key_t) arg0, (int) arg1, (int) arg2);
981 return sys_semop((int) arg0, (struct sembuf *)arg1,
982 (unsigned int) arg2);
988 static inline loff_t llseek(struct file *file, loff_t offset, int origin)
990 loff_t (*fn)(struct file *, loff_t, int);
994 if (file->f_op && file->f_op->llseek)
995 fn = file->f_op->llseek;
997 retval = fn(file, offset, origin);
1002 asmlinkage int irix_lseek64(int fd, int _unused, int offhi, int offlow,
1017 offset = llseek(file, ((loff_t) offhi << 32) | offlow, origin);
1018 retval = (int) offset;
1026 asmlinkage int irix_sginap(int ticks)
1028 current->state = TASK_INTERRUPTIBLE;
1029 schedule_timeout(ticks);
1033 asmlinkage int irix_sgikopt(char *istring, char *ostring, int len)
1038 asmlinkage int irix_gettimeofday(struct timeval *tv)
1044 if (verify_area(VERIFY_WRITE, tv, sizeof(struct timeval)))
1048 seq = read_seqbegin(&xtime_lock);
1050 nsec = xtime.tv_nsec;
1051 } while (read_seqretry(&xtime_lock, seq));
1053 err = __put_user(sec, &tv->tv_sec);
1054 err |= __put_user((nsec / 1000), &tv->tv_usec);
1059 #define IRIX_MAP_AUTOGROW 0x40
1061 asmlinkage unsigned long irix_mmap32(unsigned long addr, size_t len, int prot,
1062 int flags, int fd, off_t offset)
1064 struct file *file = NULL;
1065 unsigned long retval;
1067 if (!(flags & MAP_ANONYMOUS)) {
1068 if (!(file = fget(fd)))
1071 /* Ok, bad taste hack follows, try to think in something else
1072 * when reading this. */
1073 if (flags & IRIX_MAP_AUTOGROW) {
1074 unsigned long old_pos;
1075 long max_size = offset + len;
1077 if (max_size > file->f_dentry->d_inode->i_size) {
1078 old_pos = sys_lseek (fd, max_size - 1, 0);
1079 sys_write (fd, "", 1);
1080 sys_lseek (fd, old_pos, 0);
1085 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
1087 down_write(¤t->mm->mmap_sem);
1088 retval = do_mmap(file, addr, len, prot, flags, offset);
1089 up_write(¤t->mm->mmap_sem);
1096 asmlinkage int irix_madvise(unsigned long addr, int len, int behavior)
1098 printk("[%s:%d] Wheee.. irix_madvise(%08lx,%d,%d)\n",
1099 current->comm, current->pid, addr, len, behavior);
1104 asmlinkage int irix_pagelock(char *addr, int len, int op)
1106 printk("[%s:%d] Wheee.. irix_pagelock(%p,%d,%d)\n",
1107 current->comm, current->pid, addr, len, op);
1112 asmlinkage int irix_quotactl(struct pt_regs *regs)
1114 printk("[%s:%d] Wheee.. irix_quotactl()\n",
1115 current->comm, current->pid);
1120 asmlinkage int irix_BSDsetpgrp(int pid, int pgrp)
1124 #ifdef DEBUG_PROCGRPS
1125 printk("[%s:%d] BSDsetpgrp(%d, %d) ", current->comm, current->pid,
1131 /* Wheee, weird sysv thing... */
1132 if ((pgrp == 0) && (pid == current->pid))
1133 error = sys_setsid();
1135 error = sys_setpgid(pid, pgrp);
1137 #ifdef DEBUG_PROCGRPS
1138 printk("error = %d\n", error);
1144 asmlinkage int irix_systeminfo(int cmd, char *buf, int cnt)
1146 printk("[%s:%d] Wheee.. irix_systeminfo(%d,%p,%d)\n",
1147 current->comm, current->pid, cmd, buf, cnt);
1153 char sysname[257], nodename[257], release[257];
1154 char version[257], machine[257];
1155 char m_type[257], base_rel[257];
1156 char _unused0[257], _unused1[257], _unused2[257];
1157 char _unused3[257], _unused4[257], _unused5[257];
1160 asmlinkage int irix_uname(struct iuname *buf)
1162 down_read(&uts_sem);
1163 if (copy_to_user(system_utsname.sysname, buf->sysname, 65)
1164 || copy_to_user(system_utsname.nodename, buf->nodename, 65)
1165 || copy_to_user(system_utsname.release, buf->release, 65)
1166 || copy_to_user(system_utsname.version, buf->version, 65)
1167 || copy_to_user(system_utsname.machine, buf->machine, 65)) {
1177 static int irix_xstat32_xlate(struct kstat *stat, void *ubuf)
1180 u32 st_dev, st_pad1[3], st_ino, st_mode, st_nlink, st_uid, st_gid;
1181 u32 st_rdev, st_pad2[2], st_size, st_pad3;
1182 u32 st_atime0, st_atime1;
1183 u32 st_mtime0, st_mtime1;
1184 u32 st_ctime0, st_ctime1;
1185 u32 st_blksize, st_blocks;
1190 if (!sysv_valid_dev(stat->dev) || !sysv_valid_dev(stat->rdev))
1192 ub.st_dev = sysv_encode_dev(stat->dev);
1193 ub.st_ino = stat->ino;
1194 ub.st_mode = stat->mode;
1195 ub.st_nlink = stat->nlink;
1196 SET_UID(ub.st_uid, stat->uid);
1197 SET_GID(ub.st_gid, stat->gid);
1198 ub.st_rdev = sysv_encode_dev(stat->rdev);
1199 #if BITS_PER_LONG == 32
1200 if (stat->size > MAX_NON_LFS)
1203 ub.st_size = stat->size;
1204 ub.st_atime0 = stat->atime.tv_sec;
1205 ub.st_atime1 = stat->atime.tv_nsec;
1206 ub.st_mtime0 = stat->mtime.tv_sec;
1207 ub.st_mtime1 = stat->atime.tv_nsec;
1208 ub.st_ctime0 = stat->ctime.tv_sec;
1209 ub.st_ctime1 = stat->atime.tv_nsec;
1210 ub.st_blksize = stat->blksize;
1211 ub.st_blocks = stat->blocks;
1212 strcpy (ub.st_fstype, "efs");
1214 return copy_to_user(ubuf, &ub, sizeof(ub)) ? -EFAULT : 0;
1217 static int irix_xstat64_xlate(struct kstat *stat, void *ubuf)
1220 u32 st_dev; s32 st_pad1[3];
1221 unsigned long long st_ino;
1223 u32 st_nlink; s32 st_uid; s32 st_gid; u32 st_rdev;
1227 struct { s32 tv_sec, tv_nsec; } st_atime, st_mtime, st_ctime;
1229 long long st_blocks;
1234 if (!sysv_valid_dev(stat->dev) || !sysv_valid_dev(stat->rdev))
1237 ks.st_dev = sysv_encode_dev(stat->dev);
1238 ks.st_pad1[0] = ks.st_pad1[1] = ks.st_pad1[2] = 0;
1239 ks.st_ino = (unsigned long long) stat->ino;
1240 ks.st_mode = (u32) stat->mode;
1241 ks.st_nlink = (u32) stat->nlink;
1242 ks.st_uid = (s32) stat->uid;
1243 ks.st_gid = (s32) stat->gid;
1244 ks.st_rdev = sysv_encode_dev (stat->rdev);
1245 ks.st_pad2[0] = ks.st_pad2[1] = 0;
1246 ks.st_size = (long long) stat->size;
1249 /* XXX hackety hack... */
1250 ks.st_atime.tv_sec = (s32) stat->atime.tv_sec;
1251 ks.st_atime.tv_nsec = stat->atime.tv_nsec;
1252 ks.st_mtime.tv_sec = (s32) stat->mtime.tv_sec;
1253 ks.st_mtime.tv_nsec = stat->mtime.tv_nsec;
1254 ks.st_ctime.tv_sec = (s32) stat->ctime.tv_sec;
1255 ks.st_ctime.tv_nsec = stat->ctime.tv_nsec;
1257 ks.st_blksize = (s32) stat->blksize;
1258 ks.st_blocks = (long long) stat->blocks;
1259 memset(ks.st_fstype, 0, 16);
1260 ks.st_pad4[0] = ks.st_pad4[1] = ks.st_pad4[2] = ks.st_pad4[3] = 0;
1261 ks.st_pad4[4] = ks.st_pad4[5] = ks.st_pad4[6] = ks.st_pad4[7] = 0;
1263 /* Now write it all back. */
1264 return copy_to_user(ubuf, &ks, sizeof(ks)) ? -EFAULT : 0;
1267 asmlinkage int irix_xstat(int version, char *filename, struct stat *statbuf)
1273 printk("[%s:%d] Wheee.. irix_xstat(%d,%s,%p) ",
1274 current->comm, current->pid, version, filename, statbuf);
1277 retval = vfs_stat(filename, &stat);
1281 retval = irix_xstat32_xlate(&stat, statbuf);
1284 retval = irix_xstat64_xlate(&stat, statbuf);
1293 asmlinkage int irix_lxstat(int version, char *filename, struct stat *statbuf)
1299 printk("[%s:%d] Wheee.. irix_lxstat(%d,%s,%p) ",
1300 current->comm, current->pid, version, filename, statbuf);
1303 error = vfs_lstat(filename, &stat);
1308 error = irix_xstat32_xlate(&stat, statbuf);
1311 error = irix_xstat64_xlate(&stat, statbuf);
1320 asmlinkage int irix_fxstat(int version, int fd, struct stat *statbuf)
1326 printk("[%s:%d] Wheee.. irix_fxstat(%d,%d,%p) ",
1327 current->comm, current->pid, version, fd, statbuf);
1330 error = vfs_fstat(fd, &stat);
1334 error = irix_xstat32_xlate(&stat, statbuf);
1337 error = irix_xstat64_xlate(&stat, statbuf);
1346 asmlinkage int irix_xmknod(int ver, char *filename, int mode, unsigned dev)
1349 printk("[%s:%d] Wheee.. irix_xmknod(%d,%s,%x,%x)\n",
1350 current->comm, current->pid, ver, filename, mode, dev);
1354 /* shouldn't we convert here as well as on stat()? */
1355 retval = sys_mknod(filename, mode, dev);
1366 asmlinkage int irix_swapctl(int cmd, char *arg)
1368 printk("[%s:%d] Wheee.. irix_swapctl(%d,%p)\n",
1369 current->comm, current->pid, cmd, arg);
1374 struct irix_statvfs {
1375 u32 f_bsize; u32 f_frsize; u32 f_blocks;
1376 u32 f_bfree; u32 f_bavail; u32 f_files; u32 f_ffree; u32 f_favail;
1377 u32 f_fsid; char f_basetype[16];
1378 u32 f_flag; u32 f_namemax;
1379 char f_fstr[32]; u32 f_filler[16];
1382 asmlinkage int irix_statvfs(char *fname, struct irix_statvfs *buf)
1384 struct nameidata nd;
1385 struct kstatfs kbuf;
1388 printk("[%s:%d] Wheee.. irix_statvfs(%s,%p)\n",
1389 current->comm, current->pid, fname, buf);
1390 error = verify_area(VERIFY_WRITE, buf, sizeof(struct irix_statvfs));
1393 error = user_path_walk(fname, &nd);
1396 error = vfs_statfs(nd.dentry->d_inode->i_sb, &kbuf);
1400 __put_user(kbuf.f_bsize, &buf->f_bsize);
1401 __put_user(kbuf.f_frsize, &buf->f_frsize);
1402 __put_user(kbuf.f_blocks, &buf->f_blocks);
1403 __put_user(kbuf.f_bfree, &buf->f_bfree);
1404 __put_user(kbuf.f_bfree, &buf->f_bavail); /* XXX hackety hack... */
1405 __put_user(kbuf.f_files, &buf->f_files);
1406 __put_user(kbuf.f_ffree, &buf->f_ffree);
1407 __put_user(kbuf.f_ffree, &buf->f_favail); /* XXX hackety hack... */
1409 __put_user(kbuf.f_fsid.val[1], &buf->f_fsid);
1411 __put_user(kbuf.f_fsid.val[0], &buf->f_fsid);
1413 for (i = 0; i < 16; i++)
1414 __put_user(0, &buf->f_basetype[i]);
1415 __put_user(0, &buf->f_flag);
1416 __put_user(kbuf.f_namelen, &buf->f_namemax);
1417 for (i = 0; i < 32; i++)
1418 __put_user(0, &buf->f_fstr[i]);
1428 asmlinkage int irix_fstatvfs(int fd, struct irix_statvfs *buf)
1430 struct kstatfs kbuf;
1434 printk("[%s:%d] Wheee.. irix_fstatvfs(%d,%p)\n",
1435 current->comm, current->pid, fd, buf);
1437 error = verify_area(VERIFY_WRITE, buf, sizeof(struct irix_statvfs));
1440 if (!(file = fget(fd))) {
1444 error = vfs_statfs(file->f_dentry->d_inode->i_sb, &kbuf);
1448 __put_user(kbuf.f_bsize, &buf->f_bsize);
1449 __put_user(kbuf.f_frsize, &buf->f_frsize);
1450 __put_user(kbuf.f_blocks, &buf->f_blocks);
1451 __put_user(kbuf.f_bfree, &buf->f_bfree);
1452 __put_user(kbuf.f_bfree, &buf->f_bavail); /* XXX hackety hack... */
1453 __put_user(kbuf.f_files, &buf->f_files);
1454 __put_user(kbuf.f_ffree, &buf->f_ffree);
1455 __put_user(kbuf.f_ffree, &buf->f_favail); /* XXX hackety hack... */
1457 __put_user(kbuf.f_fsid.val[1], &buf->f_fsid);
1459 __put_user(kbuf.f_fsid.val[0], &buf->f_fsid);
1461 for(i = 0; i < 16; i++)
1462 __put_user(0, &buf->f_basetype[i]);
1463 __put_user(0, &buf->f_flag);
1464 __put_user(kbuf.f_namelen, &buf->f_namemax);
1465 __clear_user(&buf->f_fstr, sizeof(buf->f_fstr));
1473 asmlinkage int irix_priocntl(struct pt_regs *regs)
1475 printk("[%s:%d] Wheee.. irix_priocntl()\n",
1476 current->comm, current->pid);
1481 asmlinkage int irix_sigqueue(int pid, int sig, int code, int val)
1483 printk("[%s:%d] Wheee.. irix_sigqueue(%d,%d,%d,%d)\n",
1484 current->comm, current->pid, pid, sig, code, val);
1489 asmlinkage int irix_truncate64(char *name, int pad, int size1, int size2)
1497 retval = sys_truncate(name, size2);
1503 asmlinkage int irix_ftruncate64(int fd, int pad, int size1, int size2)
1511 retval = sys_ftruncate(fd, size2);
1517 asmlinkage int irix_mmap64(struct pt_regs *regs)
1519 int len, prot, flags, fd, off1, off2, error, base = 0;
1520 unsigned long addr, pgoff, *sp;
1521 struct file *file = NULL;
1523 if (regs->regs[2] == 1000)
1525 sp = (unsigned long *) (regs->regs[29] + 16);
1526 addr = regs->regs[base + 4];
1527 len = regs->regs[base + 5];
1528 prot = regs->regs[base + 6];
1530 flags = regs->regs[base + 7];
1531 error = verify_area(VERIFY_READ, sp, (4 * sizeof(unsigned long)));
1535 __get_user(off1, &sp[1]);
1536 __get_user(off2, &sp[2]);
1538 error = verify_area(VERIFY_READ, sp, (5 * sizeof(unsigned long)));
1541 __get_user(flags, &sp[0]);
1542 __get_user(fd, &sp[1]);
1543 __get_user(off1, &sp[2]);
1544 __get_user(off2, &sp[3]);
1547 if (off1 & PAGE_MASK) {
1552 pgoff = (off1 << (32 - PAGE_SHIFT)) | (off2 >> PAGE_SHIFT);
1554 if (!(flags & MAP_ANONYMOUS)) {
1555 if (!(file = fget(fd))) {
1560 /* Ok, bad taste hack follows, try to think in something else
1561 when reading this */
1562 if (flags & IRIX_MAP_AUTOGROW) {
1563 unsigned long old_pos;
1564 long max_size = off2 + len;
1566 if (max_size > file->f_dentry->d_inode->i_size) {
1567 old_pos = sys_lseek (fd, max_size - 1, 0);
1568 sys_write (fd, "", 1);
1569 sys_lseek (fd, old_pos, 0);
1574 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
1576 down_write(¤t->mm->mmap_sem);
1577 error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
1578 up_write(¤t->mm->mmap_sem);
1587 asmlinkage int irix_dmi(struct pt_regs *regs)
1589 printk("[%s:%d] Wheee.. irix_dmi()\n",
1590 current->comm, current->pid);
1595 asmlinkage int irix_pread(int fd, char *buf, int cnt, int off64,
1598 printk("[%s:%d] Wheee.. irix_pread(%d,%p,%d,%d,%d,%d)\n",
1599 current->comm, current->pid, fd, buf, cnt, off64, off1, off2);
1604 asmlinkage int irix_pwrite(int fd, char *buf, int cnt, int off64,
1607 printk("[%s:%d] Wheee.. irix_pwrite(%d,%p,%d,%d,%d,%d)\n",
1608 current->comm, current->pid, fd, buf, cnt, off64, off1, off2);
1613 asmlinkage int irix_sgifastpath(int cmd, unsigned long arg0, unsigned long arg1,
1614 unsigned long arg2, unsigned long arg3,
1615 unsigned long arg4, unsigned long arg5)
1617 printk("[%s:%d] Wheee.. irix_fastpath(%d,%08lx,%08lx,%08lx,%08lx,"
1619 current->comm, current->pid, cmd, arg0, arg1, arg2,
1625 struct irix_statvfs64 {
1626 u32 f_bsize; u32 f_frsize;
1627 u64 f_blocks; u64 f_bfree; u64 f_bavail;
1628 u64 f_files; u64 f_ffree; u64 f_favail;
1630 char f_basetype[16];
1631 u32 f_flag; u32 f_namemax;
1636 asmlinkage int irix_statvfs64(char *fname, struct irix_statvfs64 *buf)
1638 struct nameidata nd;
1639 struct kstatfs kbuf;
1642 printk("[%s:%d] Wheee.. irix_statvfs(%s,%p)\n",
1643 current->comm, current->pid, fname, buf);
1644 error = verify_area(VERIFY_WRITE, buf, sizeof(struct irix_statvfs64));
1647 error = user_path_walk(fname, &nd);
1650 error = vfs_statfs(nd.dentry->d_inode->i_sb, &kbuf);
1654 __put_user(kbuf.f_bsize, &buf->f_bsize);
1655 __put_user(kbuf.f_frsize, &buf->f_frsize);
1656 __put_user(kbuf.f_blocks, &buf->f_blocks);
1657 __put_user(kbuf.f_bfree, &buf->f_bfree);
1658 __put_user(kbuf.f_bfree, &buf->f_bavail); /* XXX hackety hack... */
1659 __put_user(kbuf.f_files, &buf->f_files);
1660 __put_user(kbuf.f_ffree, &buf->f_ffree);
1661 __put_user(kbuf.f_ffree, &buf->f_favail); /* XXX hackety hack... */
1663 __put_user(kbuf.f_fsid.val[1], &buf->f_fsid);
1665 __put_user(kbuf.f_fsid.val[0], &buf->f_fsid);
1667 for(i = 0; i < 16; i++)
1668 __put_user(0, &buf->f_basetype[i]);
1669 __put_user(0, &buf->f_flag);
1670 __put_user(kbuf.f_namelen, &buf->f_namemax);
1671 for(i = 0; i < 32; i++)
1672 __put_user(0, &buf->f_fstr[i]);
1682 asmlinkage int irix_fstatvfs64(int fd, struct irix_statvfs *buf)
1684 struct kstatfs kbuf;
1688 printk("[%s:%d] Wheee.. irix_fstatvfs(%d,%p)\n",
1689 current->comm, current->pid, fd, buf);
1691 error = verify_area(VERIFY_WRITE, buf, sizeof(struct irix_statvfs));
1694 if (!(file = fget(fd))) {
1698 error = vfs_statfs(file->f_dentry->d_inode->i_sb, &kbuf);
1702 __put_user(kbuf.f_bsize, &buf->f_bsize);
1703 __put_user(kbuf.f_frsize, &buf->f_frsize);
1704 __put_user(kbuf.f_blocks, &buf->f_blocks);
1705 __put_user(kbuf.f_bfree, &buf->f_bfree);
1706 __put_user(kbuf.f_bfree, &buf->f_bavail); /* XXX hackety hack... */
1707 __put_user(kbuf.f_files, &buf->f_files);
1708 __put_user(kbuf.f_ffree, &buf->f_ffree);
1709 __put_user(kbuf.f_ffree, &buf->f_favail); /* XXX hackety hack... */
1711 __put_user(kbuf.f_fsid.val[1], &buf->f_fsid);
1713 __put_user(kbuf.f_fsid.val[0], &buf->f_fsid);
1715 for(i = 0; i < 16; i++)
1716 __put_user(0, &buf->f_basetype[i]);
1717 __put_user(0, &buf->f_flag);
1718 __put_user(kbuf.f_namelen, &buf->f_namemax);
1719 __clear_user(buf->f_fstr, sizeof(buf->f_fstr[i]));
1727 asmlinkage int irix_getmountid(char *fname, unsigned long *midbuf)
1731 printk("[%s:%d] irix_getmountid(%s, %p)\n",
1732 current->comm, current->pid, fname, midbuf);
1733 err = verify_area(VERIFY_WRITE, midbuf, (sizeof(unsigned long) * 4));
1738 * The idea with this system call is that when trying to determine
1739 * 'pwd' and it's a toss-up for some reason, userland can use the
1740 * fsid of the filesystem to try and make the right decision, but
1741 * we don't have this so for now. XXX
1743 err |= __put_user(0, &midbuf[0]);
1744 err |= __put_user(0, &midbuf[1]);
1745 err |= __put_user(0, &midbuf[2]);
1746 err |= __put_user(0, &midbuf[3]);
1751 asmlinkage int irix_nsproc(unsigned long entry, unsigned long mask,
1752 unsigned long arg, unsigned long sp, int slen)
1754 printk("[%s:%d] Wheee.. irix_nsproc(%08lx,%08lx,%08lx,%08lx,%d)\n",
1755 current->comm, current->pid, entry, mask, arg, sp, slen);
1760 #undef DEBUG_GETDENTS
1762 struct irix_dirent32 {
1765 unsigned short d_reclen;
1769 struct irix_dirent32_callback {
1770 struct irix_dirent32 *current_dir;
1771 struct irix_dirent32 *previous;
1776 #define NAME_OFFSET32(de) ((int) ((de)->d_name - (char *) (de)))
1777 #define ROUND_UP32(x) (((x)+sizeof(u32)-1) & ~(sizeof(u32)-1))
1779 static int irix_filldir32(void *__buf, const char *name, int namlen,
1780 loff_t offset, ino_t ino, unsigned int d_type)
1782 struct irix_dirent32 *dirent;
1783 struct irix_dirent32_callback *buf =
1784 (struct irix_dirent32_callback *)__buf;
1785 unsigned short reclen = ROUND_UP32(NAME_OFFSET32(dirent) + namlen + 1);
1787 #ifdef DEBUG_GETDENTS
1788 printk("\nirix_filldir32[reclen<%d>namlen<%d>count<%d>]",
1789 reclen, namlen, buf->count);
1791 buf->error = -EINVAL; /* only used if we fail.. */
1792 if (reclen > buf->count)
1794 dirent = buf->previous;
1796 __put_user(offset, &dirent->d_off);
1797 dirent = buf->current_dir;
1798 buf->previous = dirent;
1799 __put_user(ino, &dirent->d_ino);
1800 __put_user(reclen, &dirent->d_reclen);
1801 copy_to_user(dirent->d_name, name, namlen);
1802 __put_user(0, &dirent->d_name[namlen]);
1803 ((char *) dirent) += reclen;
1804 buf->current_dir = dirent;
1805 buf->count -= reclen;
1810 asmlinkage int irix_ngetdents(unsigned int fd, void * dirent,
1811 unsigned int count, int *eob)
1814 struct irix_dirent32 *lastdirent;
1815 struct irix_dirent32_callback buf;
1818 #ifdef DEBUG_GETDENTS
1819 printk("[%s:%d] ngetdents(%d, %p, %d, %p) ", current->comm,
1820 current->pid, fd, dirent, count, eob);
1827 buf.current_dir = (struct irix_dirent32 *) dirent;
1828 buf.previous = NULL;
1832 error = vfs_readdir(file, irix_filldir32, &buf);
1837 lastdirent = buf.previous;
1839 put_user(file->f_pos, &lastdirent->d_off);
1840 error = count - buf.count;
1843 if (put_user(0, eob) < 0) {
1848 #ifdef DEBUG_GETDENTS
1849 printk("eob=%d returning %d\n", *eob, count - buf.count);
1851 error = count - buf.count;
1859 struct irix_dirent64 {
1862 unsigned short d_reclen;
1866 struct irix_dirent64_callback {
1867 struct irix_dirent64 *curr;
1868 struct irix_dirent64 *previous;
1873 #define NAME_OFFSET64(de) ((int) ((de)->d_name - (char *) (de)))
1874 #define ROUND_UP64(x) (((x)+sizeof(u64)-1) & ~(sizeof(u64)-1))
1876 static int irix_filldir64(void * __buf, const char * name, int namlen,
1877 loff_t offset, ino_t ino, unsigned int d_type)
1879 struct irix_dirent64 *dirent;
1880 struct irix_dirent64_callback * buf =
1881 (struct irix_dirent64_callback *) __buf;
1882 unsigned short reclen = ROUND_UP64(NAME_OFFSET64(dirent) + namlen + 1);
1884 buf->error = -EINVAL; /* only used if we fail.. */
1885 if (reclen > buf->count)
1887 dirent = buf->previous;
1889 __put_user(offset, &dirent->d_off);
1891 buf->previous = dirent;
1892 __put_user(ino, &dirent->d_ino);
1893 __put_user(reclen, &dirent->d_reclen);
1894 __copy_to_user(dirent->d_name, name, namlen);
1895 __put_user(0, &dirent->d_name[namlen]);
1896 ((char *) dirent) += reclen;
1898 buf->count -= reclen;
1903 asmlinkage int irix_getdents64(int fd, void *dirent, int cnt)
1906 struct irix_dirent64 *lastdirent;
1907 struct irix_dirent64_callback buf;
1910 #ifdef DEBUG_GETDENTS
1911 printk("[%s:%d] getdents64(%d, %p, %d) ", current->comm,
1912 current->pid, fd, dirent, cnt);
1915 if (!(file = fget(fd)))
1919 if (!access_ok(VERIFY_WRITE, dirent, cnt))
1923 if (cnt < (sizeof(struct irix_dirent64) + 255))
1926 buf.curr = (struct irix_dirent64 *) dirent;
1927 buf.previous = NULL;
1930 error = vfs_readdir(file, irix_filldir64, &buf);
1933 lastdirent = buf.previous;
1938 lastdirent->d_off = (u64) file->f_pos;
1939 #ifdef DEBUG_GETDENTS
1940 printk("returning %d\n", cnt - buf.count);
1942 error = cnt - buf.count;
1950 asmlinkage int irix_ngetdents64(int fd, void *dirent, int cnt, int *eob)
1953 struct irix_dirent64 *lastdirent;
1954 struct irix_dirent64_callback buf;
1957 #ifdef DEBUG_GETDENTS
1958 printk("[%s:%d] ngetdents64(%d, %p, %d) ", current->comm,
1959 current->pid, fd, dirent, cnt);
1962 if (!(file = fget(fd)))
1966 if (!access_ok(VERIFY_WRITE, dirent, cnt) ||
1967 !access_ok(VERIFY_WRITE, eob, sizeof(*eob)))
1971 if (cnt < (sizeof(struct irix_dirent64) + 255))
1975 buf.curr = (struct irix_dirent64 *) dirent;
1976 buf.previous = NULL;
1979 error = vfs_readdir(file, irix_filldir64, &buf);
1982 lastdirent = buf.previous;
1987 lastdirent->d_off = (u64) file->f_pos;
1988 #ifdef DEBUG_GETDENTS
1989 printk("eob=%d returning %d\n", *eob, cnt - buf.count);
1991 error = cnt - buf.count;
1999 asmlinkage int irix_uadmin(unsigned long op, unsigned long func, unsigned long arg)
2006 printk("[%s:%d] irix_uadmin: Wants to reboot...\n",
2007 current->comm, current->pid);
2013 printk("[%s:%d] irix_uadmin: Wants to shutdown...\n",
2014 current->comm, current->pid);
2020 printk("[%s:%d] irix_uadmin: Wants to remount root...\n",
2021 current->comm, current->pid);
2026 /* Kill all tasks. */
2027 printk("[%s:%d] irix_uadmin: Wants to kill all tasks...\n",
2028 current->comm, current->pid);
2033 /* Set magic mushrooms... */
2034 printk("[%s:%d] irix_uadmin: Wants to set magic mushroom[%d]...\n",
2035 current->comm, current->pid, (int) func);
2040 printk("[%s:%d] irix_uadmin: Unknown operation [%d]...\n",
2041 current->comm, current->pid, (int) op);
2050 asmlinkage int irix_utssys(char *inbuf, int arg, int type, char *outbuf)
2057 retval = irix_uname((struct iuname *)inbuf);
2062 printk("[%s:%d] irix_utssys: Wants to do ustat()\n",
2063 current->comm, current->pid);
2069 printk("[%s:%d] irix_utssys: Wants to do fusers()\n",
2070 current->comm, current->pid);
2075 printk("[%s:%d] irix_utssys: Wants to do unknown type[%d]\n",
2076 current->comm, current->pid, (int) type);
2087 #define IRIX_F_ALLOCSP 10
2089 asmlinkage int irix_fcntl(int fd, int cmd, int arg)
2094 printk("[%s:%d] irix_fcntl(%d, %d, %d) ", current->comm,
2095 current->pid, fd, cmd, arg);
2097 if (cmd == IRIX_F_ALLOCSP){
2100 retval = sys_fcntl(fd, cmd, arg);
2102 printk("%d\n", retval);
2107 asmlinkage int irix_ulimit(int cmd, int arg)
2113 printk("[%s:%d] irix_ulimit: Wants to get file size limit.\n",
2114 current->comm, current->pid);
2119 printk("[%s:%d] irix_ulimit: Wants to set file size limit.\n",
2120 current->comm, current->pid);
2125 printk("[%s:%d] irix_ulimit: Wants to get brk limit.\n",
2126 current->comm, current->pid);
2132 printk("[%s:%d] irix_ulimit: Wants to get fd limit.\n",
2133 current->comm, current->pid);
2137 retval = current->rlim[RLIMIT_NOFILE].rlim_cur;
2141 printk("[%s:%d] irix_ulimit: Wants to get txt offset.\n",
2142 current->comm, current->pid);
2147 printk("[%s:%d] irix_ulimit: Unknown command [%d].\n",
2148 current->comm, current->pid, cmd);
2156 asmlinkage int irix_unimp(struct pt_regs *regs)
2158 printk("irix_unimp [%s:%d] v0=%d v1=%d a0=%08lx a1=%08lx a2=%08lx "
2159 "a3=%08lx\n", current->comm, current->pid,
2160 (int) regs->regs[2], (int) regs->regs[3],
2161 regs->regs[4], regs->regs[5], regs->regs[6], regs->regs[7]);