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 current->rlim[RLIMIT_STACK].rlim_max =
132 current->rlim[RLIMIT_STACK].rlim_cur = value;
136 if (value > current->rlim[RLIMIT_STACK].rlim_max) {
140 current->rlim[RLIMIT_STACK].rlim_cur = value;
145 case PR_GETSTACKSIZE:
146 printk("irix_prctl[%s:%d]: Wants PR_GETSTACKSIZE\n",
147 current->comm, current->pid);
148 error = current->rlim[RLIMIT_STACK].rlim_cur;
152 printk("irix_prctl[%s:%d]: Wants PR_MAXPROCS\n",
153 current->comm, current->pid);
158 printk("irix_prctl[%s:%d]: Wants PR_UNBLKONEXEC\n",
159 current->comm, current->pid);
164 printk("irix_prctl[%s:%d]: Wants PR_SETEXITSIG\n",
165 current->comm, current->pid);
167 /* We can probably play some game where we set the task
168 * exit_code to some non-zero value when this is requested,
169 * and check whether exit_code is already set in do_exit().
175 printk("irix_prctl[%s:%d]: Wants PR_RESIDENT\n",
176 current->comm, current->pid);
177 error = 0; /* Compatibility indeed. */
181 printk("irix_prctl[%s:%d]: Wants PR_ATTACHADDR\n",
182 current->comm, current->pid);
187 printk("irix_prctl[%s:%d]: Wants PR_DETACHADDR\n",
188 current->comm, current->pid);
193 printk("irix_prctl[%s:%d]: Wants PR_TERMCHILD\n",
194 current->comm, current->pid);
199 printk("irix_prctl[%s:%d]: Wants PR_GETSHMASK\n",
200 current->comm, current->pid);
201 error = -EINVAL; /* Until I have the sproc() stuff in. */
205 error = 0; /* Until I have the sproc() stuff in. */
209 printk("irix_prctl[%s:%d]: Wants PR_COREPID\n",
210 current->comm, current->pid);
214 case PR_ATTACHADDRPERM:
215 printk("irix_prctl[%s:%d]: Wants PR_ATTACHADDRPERM\n",
216 current->comm, current->pid);
221 printk("irix_prctl[%s:%d]: Wants PR_PTHREADEXIT\n",
222 current->comm, current->pid);
223 do_exit(regs->regs[base + 5]);
226 printk("irix_prctl[%s:%d]: Non-existant opcode %d\n",
227 current->comm, current->pid, (int)cmd);
235 #undef DEBUG_PROCGRPS
237 extern unsigned long irix_mapelf(int fd, struct elf_phdr *user_phdrp, int cnt);
238 extern int getrusage(struct task_struct *p, int who, struct rusage *ru);
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 *buf = (char *) regs->regs[base + 5];
276 /* XXX Use ethernet addr.... */
277 retval = clear_user(buf, 64);
282 int pid = (int) regs->regs[base + 5];
283 char *buf = (char *) regs->regs[base + 6];
284 struct task_struct *p;
287 retval = verify_area(VERIFY_WRITE, buf, 16);
290 read_lock(&tasklist_lock);
291 p = find_task_by_pid(pid);
293 read_unlock(&tasklist_lock);
297 memcpy(comm, p->comm, 16);
298 read_unlock(&tasklist_lock);
300 /* XXX Need to check sizes. */
301 copy_to_user(buf, p->comm, 16);
307 char *name = (char *) regs->regs[base+5];
308 char *buf = (char *) regs->regs[base+6];
310 return -EINVAL; /* til I fix it */
311 retval = verify_area(VERIFY_WRITE, buf, 128);
314 value = prom_getenv(name); /* PROM lock? */
319 /* Do I strlen() for the length? */
320 copy_to_user(buf, value, 128);
326 char *name = (char *) regs->regs[base+5];
327 char *value = (char *) regs->regs[base+6];
328 return -EINVAL; /* til I fix it */
329 retval = prom_setenv(name, value);
330 /* XXX make sure retval conforms to syssgi(2) */
331 printk("[%s:%d] setnvram(\"%s\", \"%s\"): retval %d",
332 current->comm, current->pid, name, value, retval);
333 /* if (retval == PROM_ENOENT)
340 #ifdef DEBUG_PROCGRPS
341 printk("[%s:%d] setpgid(%d, %d) ",
342 current->comm, current->pid,
343 (int) regs->regs[base + 5], (int)regs->regs[base + 6]);
345 retval = sys_setpgid(regs->regs[base + 5], regs->regs[base + 6]);
347 #ifdef DEBUG_PROCGRPS
348 printk("retval=%d\n", retval);
353 switch(regs->regs[base + 5]) {
355 retval = (MAX_ARG_PAGES >> 4); /* XXX estimate... */
358 retval = max_threads;
364 retval = NGROUPS_MAX;
402 retval = sys_setgroups((int) regs->regs[base + 5],
403 (gid_t *) regs->regs[base + 6]);
407 retval = sys_getgroups((int) regs->regs[base + 5],
408 (gid_t *) regs->regs[base + 6]);
412 struct rusage *ru = (struct rusage *) regs->regs[base + 6];
414 switch((int) regs->regs[base + 5]) {
417 retval = getrusage(current, RUSAGE_SELF, ru);
421 /* rusage children */
422 retval = getrusage(current, RUSAGE_CHILDREN, ru);
437 #ifdef DEBUG_PROCGRPS
438 printk("[%s:%d] getsid(%d) ", current->comm, current->pid,
439 (int) regs->regs[base + 5]);
441 retval = sys_getsid(regs->regs[base + 5]);
442 #ifdef DEBUG_PROCGRPS
443 printk("retval=%d\n", retval);
448 retval = irix_mapelf((int) regs->regs[base + 5],
449 (struct elf_phdr *) regs->regs[base + 6],
450 (int) regs->regs[base + 7]);
454 /* XXX We don't need to do anything? */
463 unsigned long addr = regs->regs[base + 5];
464 int *pageno = (int *) (regs->regs[base + 6]);
465 struct mm_struct *mm = current->mm;
470 retval = verify_area(VERIFY_WRITE, pageno, sizeof(int));
474 down_read(&mm->mmap_sem);
475 pgdp = pgd_offset(mm, addr);
476 pmdp = pmd_offset(pgdp, addr);
477 ptep = pte_offset(pmdp, addr);
482 if (pte_val(pte) & (_PAGE_VALID | _PAGE_PRESENT)) {
483 retval = put_user((pte_val(pte) & PAGE_MASK) >>
487 up_read(&mm->mmap_sem);
492 int arg1 = (int) regs->regs [base + 5];
493 void *buffer = (void *) regs->regs [base + 6];
494 int count = (int) regs->regs [base + 7];
498 retval = sizeof (inventory_t);
501 retval = dump_inventory_to_user (buffer, count);
510 printk("irix_syssgi: Unsupported command %d\n", (int)cmd);
519 asmlinkage int irix_gtime(struct pt_regs *regs)
521 return get_seconds();
525 * IRIX is completely broken... it returns 0 on success, otherwise
528 asmlinkage int irix_brk(unsigned long brk)
531 unsigned long newbrk, oldbrk;
532 struct mm_struct *mm = current->mm;
535 down_write(&mm->mmap_sem);
536 if (brk < mm->end_code) {
541 newbrk = PAGE_ALIGN(brk);
542 oldbrk = PAGE_ALIGN(mm->brk);
543 if (oldbrk == newbrk) {
550 * Always allow shrinking brk
552 if (brk <= mm->brk) {
554 do_munmap(mm, newbrk, oldbrk-newbrk);
559 * Check against rlimit and stack..
561 rlim = current->rlim[RLIMIT_DATA].rlim_cur;
562 if (rlim >= RLIM_INFINITY)
564 if (brk - mm->end_code > rlim) {
570 * Check against existing mmap mappings.
572 if (find_vma_intersection(mm, oldbrk, newbrk+PAGE_SIZE)) {
578 * Check if we have enough memory..
580 if (security_vm_enough_memory((newbrk-oldbrk) >> PAGE_SHIFT) ||
581 !vx_vmpages_avail(mm, (newbrk-oldbrk) >> PAGE_SHIFT)) {
587 * Ok, looks good - let it rip.
590 do_brk(oldbrk, newbrk-oldbrk);
594 up_write(&mm->mmap_sem);
598 asmlinkage int irix_getpid(struct pt_regs *regs)
600 regs->regs[3] = current->real_parent->pid;
604 asmlinkage int irix_getuid(struct pt_regs *regs)
606 regs->regs[3] = current->euid;
610 asmlinkage int irix_getgid(struct pt_regs *regs)
612 regs->regs[3] = current->egid;
616 asmlinkage int irix_stime(int value)
618 if (!capable(CAP_SYS_TIME))
621 write_seqlock_irq(&xtime_lock);
622 xtime.tv_sec = value;
624 time_adjust = 0; /* stop active adjtime() */
625 time_status |= STA_UNSYNC;
626 time_maxerror = NTP_PHASE_LIMIT;
627 time_esterror = NTP_PHASE_LIMIT;
628 write_sequnlock_irq(&xtime_lock);
633 static inline void jiffiestotv(unsigned long jiffies, struct timeval *value)
635 value->tv_usec = (jiffies % HZ) * (1000000 / HZ);
636 value->tv_sec = jiffies / HZ;
639 static inline void getitimer_real(struct itimerval *value)
641 register unsigned long val, interval;
643 interval = current->it_real_incr;
645 if (del_timer(¤t->real_timer)) {
646 unsigned long now = jiffies;
647 val = current->real_timer.expires;
648 add_timer(¤t->real_timer);
649 /* look out for negative/zero itimer.. */
654 jiffiestotv(val, &value->it_value);
655 jiffiestotv(interval, &value->it_interval);
658 asmlinkage unsigned int irix_alarm(unsigned int seconds)
660 struct itimerval it_new, it_old;
661 unsigned int oldalarm;
664 getitimer_real(&it_old);
665 del_timer(¤t->real_timer);
667 it_new.it_interval.tv_sec = it_new.it_interval.tv_usec = 0;
668 it_new.it_value.tv_sec = seconds;
669 it_new.it_value.tv_usec = 0;
670 do_setitimer(ITIMER_REAL, &it_new, &it_old);
672 oldalarm = it_old.it_value.tv_sec;
674 * ehhh.. We can't return 0 if we have an alarm pending ...
675 * And we'd better return too much than too little anyway
677 if (it_old.it_value.tv_usec)
683 asmlinkage int irix_pause(void)
685 current->state = TASK_INTERRUPTIBLE;
691 /* XXX need more than this... */
692 asmlinkage int irix_mount(char *dev_name, char *dir_name, unsigned long flags,
693 char *type, void *data, int datalen)
695 printk("[%s:%d] irix_mount(%p,%p,%08lx,%p,%p,%d)\n",
696 current->comm, current->pid,
697 dev_name, dir_name, flags, type, data, datalen);
699 return sys_mount(dev_name, dir_name, type, flags, data);
704 long f_bsize, f_frsize, f_blocks, f_bfree, f_files, f_ffree;
705 char f_fname[6], f_fpack[6];
708 asmlinkage int irix_statfs(const char *path, struct irix_statfs *buf,
709 int len, int fs_type)
715 /* We don't support this feature yet. */
720 error = verify_area(VERIFY_WRITE, buf, sizeof(struct irix_statfs));
723 error = user_path_walk(path, &nd);
727 error = vfs_statfs(nd.dentry->d_inode->i_sb, &kbuf);
731 __put_user(kbuf.f_type, &buf->f_type);
732 __put_user(kbuf.f_bsize, &buf->f_bsize);
733 __put_user(kbuf.f_frsize, &buf->f_frsize);
734 __put_user(kbuf.f_blocks, &buf->f_blocks);
735 __put_user(kbuf.f_bfree, &buf->f_bfree);
736 __put_user(kbuf.f_files, &buf->f_files);
737 __put_user(kbuf.f_ffree, &buf->f_ffree);
738 for (i = 0; i < 6; i++) {
739 __put_user(0, &buf->f_fname[i]);
740 __put_user(0, &buf->f_fpack[i]);
750 asmlinkage int irix_fstatfs(unsigned int fd, struct irix_statfs *buf)
756 error = verify_area(VERIFY_WRITE, buf, sizeof(struct irix_statfs));
759 if (!(file = fget(fd))) {
764 error = vfs_statfs(file->f_dentry->d_inode->i_sb, &kbuf);
768 __put_user(kbuf.f_type, &buf->f_type);
769 __put_user(kbuf.f_bsize, &buf->f_bsize);
770 __put_user(kbuf.f_frsize, &buf->f_frsize);
771 __put_user(kbuf.f_blocks, &buf->f_blocks);
772 __put_user(kbuf.f_bfree, &buf->f_bfree);
773 __put_user(kbuf.f_files, &buf->f_files);
774 __put_user(kbuf.f_ffree, &buf->f_ffree);
775 for(i = 0; i < 6; i++) {
776 __put_user(0, &buf->f_fname[i]);
777 __put_user(0, &buf->f_fpack[i]);
786 asmlinkage int irix_setpgrp(int flags)
790 #ifdef DEBUG_PROCGRPS
791 printk("[%s:%d] setpgrp(%d) ", current->comm, current->pid, flags);
794 error = process_group(current);
796 error = sys_setsid();
797 #ifdef DEBUG_PROCGRPS
798 printk("returning %d\n", process_group(current));
804 asmlinkage int irix_times(struct tms * tbuf)
809 err = verify_area(VERIFY_WRITE,tbuf,sizeof *tbuf);
812 err |= __put_user(current->utime, &tbuf->tms_utime);
813 err |= __put_user(current->stime, &tbuf->tms_stime);
814 err |= __put_user(current->cutime, &tbuf->tms_cutime);
815 err |= __put_user(current->cstime, &tbuf->tms_cstime);
821 asmlinkage int irix_exec(struct pt_regs *regs)
826 if(regs->regs[2] == 1000)
828 filename = getname((char *) (long)regs->regs[base + 4]);
829 error = PTR_ERR(filename);
830 if (IS_ERR(filename))
833 error = do_execve(filename, (char **) (long)regs->regs[base + 5],
840 asmlinkage int irix_exece(struct pt_regs *regs)
845 if (regs->regs[2] == 1000)
847 filename = getname((char *) (long)regs->regs[base + 4]);
848 error = PTR_ERR(filename);
849 if (IS_ERR(filename))
851 error = do_execve(filename, (char **) (long)regs->regs[base + 5],
852 (char **) (long)regs->regs[base + 6], regs);
858 asmlinkage unsigned long irix_gethostid(void)
860 printk("[%s:%d]: irix_gethostid() called...\n",
861 current->comm, current->pid);
866 asmlinkage unsigned long irix_sethostid(unsigned long val)
868 printk("[%s:%d]: irix_sethostid(%08lx) called...\n",
869 current->comm, current->pid, val);
874 asmlinkage int irix_socket(int family, int type, int protocol)
886 type = 9; /* Invalid... */
898 type = SOCK_SEQPACKET;
905 return sys_socket(family, type, protocol);
908 asmlinkage int irix_getdomainname(char *name, int len)
912 error = verify_area(VERIFY_WRITE, name, len);
917 if(len > (__NEW_UTS_LEN - 1))
918 len = __NEW_UTS_LEN - 1;
920 if (copy_to_user(name, system_utsname.domainname, len))
927 asmlinkage unsigned long irix_getpagesize(void)
932 asmlinkage int irix_msgsys(int opcode, unsigned long arg0, unsigned long arg1,
933 unsigned long arg2, unsigned long arg3,
938 return sys_msgget((key_t) arg0, (int) arg1);
940 return sys_msgctl((int) arg0, (int) arg1, (struct msqid_ds *)arg2);
942 return sys_msgrcv((int) arg0, (struct msgbuf *) arg1,
943 (size_t) arg2, (long) arg3, (int) arg4);
945 return sys_msgsnd((int) arg0, (struct msgbuf *) arg1,
946 (size_t) arg2, (int) arg3);
952 asmlinkage int irix_shmsys(int opcode, unsigned long arg0, unsigned long arg1,
953 unsigned long arg2, unsigned long arg3)
957 return do_shmat((int) arg0, (char *)arg1, (int) arg2,
958 (unsigned long *) arg3);
960 return sys_shmctl((int)arg0, (int)arg1, (struct shmid_ds *)arg2);
962 return sys_shmdt((char *)arg0);
964 return sys_shmget((key_t) arg0, (int) arg1, (int) arg2);
970 asmlinkage int irix_semsys(int opcode, unsigned long arg0, unsigned long arg1,
971 unsigned long arg2, int arg3)
975 return sys_semctl((int) arg0, (int) arg1, (int) arg2,
978 return sys_semget((key_t) arg0, (int) arg1, (int) arg2);
980 return sys_semop((int) arg0, (struct sembuf *)arg1,
981 (unsigned int) arg2);
987 static inline loff_t llseek(struct file *file, loff_t offset, int origin)
989 loff_t (*fn)(struct file *, loff_t, int);
993 if (file->f_op && file->f_op->llseek)
994 fn = file->f_op->llseek;
996 retval = fn(file, offset, origin);
1001 asmlinkage int irix_lseek64(int fd, int _unused, int offhi, int offlow,
1016 offset = llseek(file, ((loff_t) offhi << 32) | offlow, origin);
1017 retval = (int) offset;
1025 asmlinkage int irix_sginap(int ticks)
1027 current->state = TASK_INTERRUPTIBLE;
1028 schedule_timeout(ticks);
1032 asmlinkage int irix_sgikopt(char *istring, char *ostring, int len)
1037 asmlinkage int irix_gettimeofday(struct timeval *tv)
1043 if (verify_area(VERIFY_WRITE, tv, sizeof(struct timeval)))
1047 seq = read_seqbegin(&xtime_lock);
1049 nsec = xtime.tv_nsec;
1050 } while (read_seqretry(&xtime_lock, seq));
1052 err = __put_user(sec, &tv->tv_sec);
1053 err |= __put_user((nsec / 1000), &tv->tv_usec);
1058 #define IRIX_MAP_AUTOGROW 0x40
1060 asmlinkage unsigned long irix_mmap32(unsigned long addr, size_t len, int prot,
1061 int flags, int fd, off_t offset)
1063 struct file *file = NULL;
1064 unsigned long retval;
1066 if (!(flags & MAP_ANONYMOUS)) {
1067 if (!(file = fget(fd)))
1070 /* Ok, bad taste hack follows, try to think in something else
1071 * when reading this. */
1072 if (flags & IRIX_MAP_AUTOGROW) {
1073 unsigned long old_pos;
1074 long max_size = offset + len;
1076 if (max_size > file->f_dentry->d_inode->i_size) {
1077 old_pos = sys_lseek (fd, max_size - 1, 0);
1078 sys_write (fd, "", 1);
1079 sys_lseek (fd, old_pos, 0);
1084 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
1086 down_write(¤t->mm->mmap_sem);
1087 retval = do_mmap(file, addr, len, prot, flags, offset);
1088 up_write(¤t->mm->mmap_sem);
1095 asmlinkage int irix_madvise(unsigned long addr, int len, int behavior)
1097 printk("[%s:%d] Wheee.. irix_madvise(%08lx,%d,%d)\n",
1098 current->comm, current->pid, addr, len, behavior);
1103 asmlinkage int irix_pagelock(char *addr, int len, int op)
1105 printk("[%s:%d] Wheee.. irix_pagelock(%p,%d,%d)\n",
1106 current->comm, current->pid, addr, len, op);
1111 asmlinkage int irix_quotactl(struct pt_regs *regs)
1113 printk("[%s:%d] Wheee.. irix_quotactl()\n",
1114 current->comm, current->pid);
1119 asmlinkage int irix_BSDsetpgrp(int pid, int pgrp)
1123 #ifdef DEBUG_PROCGRPS
1124 printk("[%s:%d] BSDsetpgrp(%d, %d) ", current->comm, current->pid,
1130 /* Wheee, weird sysv thing... */
1131 if ((pgrp == 0) && (pid == current->pid))
1132 error = sys_setsid();
1134 error = sys_setpgid(pid, pgrp);
1136 #ifdef DEBUG_PROCGRPS
1137 printk("error = %d\n", error);
1143 asmlinkage int irix_systeminfo(int cmd, char *buf, int cnt)
1145 printk("[%s:%d] Wheee.. irix_systeminfo(%d,%p,%d)\n",
1146 current->comm, current->pid, cmd, buf, cnt);
1152 char sysname[257], nodename[257], release[257];
1153 char version[257], machine[257];
1154 char m_type[257], base_rel[257];
1155 char _unused0[257], _unused1[257], _unused2[257];
1156 char _unused3[257], _unused4[257], _unused5[257];
1159 asmlinkage int irix_uname(struct iuname *buf)
1161 down_read(&uts_sem);
1162 if (copy_to_user(system_utsname.sysname, buf->sysname, 65)
1163 || copy_to_user(system_utsname.nodename, buf->nodename, 65)
1164 || copy_to_user(system_utsname.release, buf->release, 65)
1165 || copy_to_user(system_utsname.version, buf->version, 65)
1166 || copy_to_user(system_utsname.machine, buf->machine, 65)) {
1176 static int irix_xstat32_xlate(struct kstat *stat, void *ubuf)
1179 u32 st_dev, st_pad1[3], st_ino, st_mode, st_nlink, st_uid, st_gid;
1180 u32 st_rdev, st_pad2[2], st_size, st_pad3;
1181 u32 st_atime0, st_atime1;
1182 u32 st_mtime0, st_mtime1;
1183 u32 st_ctime0, st_ctime1;
1184 u32 st_blksize, st_blocks;
1189 if (!sysv_valid_dev(stat->dev) || !sysv_valid_dev(stat->rdev))
1191 ub.st_dev = sysv_encode_dev(stat->dev);
1192 ub.st_ino = stat->ino;
1193 ub.st_mode = stat->mode;
1194 ub.st_nlink = stat->nlink;
1195 SET_UID(ub.st_uid, stat->uid);
1196 SET_GID(ub.st_gid, stat->gid);
1197 ub.st_rdev = sysv_encode_dev(stat->rdev);
1198 #if BITS_PER_LONG == 32
1199 if (stat->size > MAX_NON_LFS)
1202 ub.st_size = stat->size;
1203 ub.st_atime0 = stat->atime.tv_sec;
1204 ub.st_atime1 = stat->atime.tv_nsec;
1205 ub.st_mtime0 = stat->mtime.tv_sec;
1206 ub.st_mtime1 = stat->atime.tv_nsec;
1207 ub.st_ctime0 = stat->ctime.tv_sec;
1208 ub.st_ctime1 = stat->atime.tv_nsec;
1209 ub.st_blksize = stat->blksize;
1210 ub.st_blocks = stat->blocks;
1211 strcpy (ub.st_fstype, "efs");
1213 return copy_to_user(ubuf, &ub, sizeof(ub)) ? -EFAULT : 0;
1216 static int irix_xstat64_xlate(struct kstat *stat, void *ubuf)
1219 u32 st_dev; s32 st_pad1[3];
1220 unsigned long long st_ino;
1222 u32 st_nlink; s32 st_uid; s32 st_gid; u32 st_rdev;
1226 struct { s32 tv_sec, tv_nsec; } st_atime, st_mtime, st_ctime;
1228 long long st_blocks;
1233 if (!sysv_valid_dev(stat->dev) || !sysv_valid_dev(stat->rdev))
1236 ks.st_dev = sysv_encode_dev(stat->dev);
1237 ks.st_pad1[0] = ks.st_pad1[1] = ks.st_pad1[2] = 0;
1238 ks.st_ino = (unsigned long long) stat->ino;
1239 ks.st_mode = (u32) stat->mode;
1240 ks.st_nlink = (u32) stat->nlink;
1241 ks.st_uid = (s32) stat->uid;
1242 ks.st_gid = (s32) stat->gid;
1243 ks.st_rdev = sysv_encode_dev (stat->rdev);
1244 ks.st_pad2[0] = ks.st_pad2[1] = 0;
1245 ks.st_size = (long long) stat->size;
1248 /* XXX hackety hack... */
1249 ks.st_atime.tv_sec = (s32) stat->atime.tv_sec;
1250 ks.st_atime.tv_nsec = stat->atime.tv_nsec;
1251 ks.st_mtime.tv_sec = (s32) stat->mtime.tv_sec;
1252 ks.st_mtime.tv_nsec = stat->mtime.tv_nsec;
1253 ks.st_ctime.tv_sec = (s32) stat->ctime.tv_sec;
1254 ks.st_ctime.tv_nsec = stat->ctime.tv_nsec;
1256 ks.st_blksize = (s32) stat->blksize;
1257 ks.st_blocks = (long long) stat->blocks;
1258 memset(ks.st_fstype, 0, 16);
1259 ks.st_pad4[0] = ks.st_pad4[1] = ks.st_pad4[2] = ks.st_pad4[3] = 0;
1260 ks.st_pad4[4] = ks.st_pad4[5] = ks.st_pad4[6] = ks.st_pad4[7] = 0;
1262 /* Now write it all back. */
1263 return copy_to_user(ubuf, &ks, sizeof(ks)) ? -EFAULT : 0;
1266 asmlinkage int irix_xstat(int version, char *filename, struct stat *statbuf)
1272 printk("[%s:%d] Wheee.. irix_xstat(%d,%s,%p) ",
1273 current->comm, current->pid, version, filename, statbuf);
1276 retval = vfs_stat(filename, &stat);
1280 retval = irix_xstat32_xlate(&stat, statbuf);
1283 retval = irix_xstat64_xlate(&stat, statbuf);
1292 asmlinkage int irix_lxstat(int version, char *filename, struct stat *statbuf)
1298 printk("[%s:%d] Wheee.. irix_lxstat(%d,%s,%p) ",
1299 current->comm, current->pid, version, filename, statbuf);
1302 error = vfs_lstat(filename, &stat);
1307 error = irix_xstat32_xlate(&stat, statbuf);
1310 error = irix_xstat64_xlate(&stat, statbuf);
1319 asmlinkage int irix_fxstat(int version, int fd, struct stat *statbuf)
1325 printk("[%s:%d] Wheee.. irix_fxstat(%d,%d,%p) ",
1326 current->comm, current->pid, version, fd, statbuf);
1329 error = vfs_fstat(fd, &stat);
1333 error = irix_xstat32_xlate(&stat, statbuf);
1336 error = irix_xstat64_xlate(&stat, statbuf);
1345 asmlinkage int irix_xmknod(int ver, char *filename, int mode, unsigned dev)
1348 printk("[%s:%d] Wheee.. irix_xmknod(%d,%s,%x,%x)\n",
1349 current->comm, current->pid, ver, filename, mode, dev);
1353 /* shouldn't we convert here as well as on stat()? */
1354 retval = sys_mknod(filename, mode, dev);
1365 asmlinkage int irix_swapctl(int cmd, char *arg)
1367 printk("[%s:%d] Wheee.. irix_swapctl(%d,%p)\n",
1368 current->comm, current->pid, cmd, arg);
1373 struct irix_statvfs {
1374 u32 f_bsize; u32 f_frsize; u32 f_blocks;
1375 u32 f_bfree; u32 f_bavail; u32 f_files; u32 f_ffree; u32 f_favail;
1376 u32 f_fsid; char f_basetype[16];
1377 u32 f_flag; u32 f_namemax;
1378 char f_fstr[32]; u32 f_filler[16];
1381 asmlinkage int irix_statvfs(char *fname, struct irix_statvfs *buf)
1383 struct nameidata nd;
1384 struct kstatfs kbuf;
1387 printk("[%s:%d] Wheee.. irix_statvfs(%s,%p)\n",
1388 current->comm, current->pid, fname, buf);
1389 error = verify_area(VERIFY_WRITE, buf, sizeof(struct irix_statvfs));
1392 error = user_path_walk(fname, &nd);
1395 error = vfs_statfs(nd.dentry->d_inode->i_sb, &kbuf);
1399 __put_user(kbuf.f_bsize, &buf->f_bsize);
1400 __put_user(kbuf.f_frsize, &buf->f_frsize);
1401 __put_user(kbuf.f_blocks, &buf->f_blocks);
1402 __put_user(kbuf.f_bfree, &buf->f_bfree);
1403 __put_user(kbuf.f_bfree, &buf->f_bavail); /* XXX hackety hack... */
1404 __put_user(kbuf.f_files, &buf->f_files);
1405 __put_user(kbuf.f_ffree, &buf->f_ffree);
1406 __put_user(kbuf.f_ffree, &buf->f_favail); /* XXX hackety hack... */
1408 __put_user(kbuf.f_fsid.val[1], &buf->f_fsid);
1410 __put_user(kbuf.f_fsid.val[0], &buf->f_fsid);
1412 for (i = 0; i < 16; i++)
1413 __put_user(0, &buf->f_basetype[i]);
1414 __put_user(0, &buf->f_flag);
1415 __put_user(kbuf.f_namelen, &buf->f_namemax);
1416 for (i = 0; i < 32; i++)
1417 __put_user(0, &buf->f_fstr[i]);
1427 asmlinkage int irix_fstatvfs(int fd, struct irix_statvfs *buf)
1429 struct kstatfs kbuf;
1433 printk("[%s:%d] Wheee.. irix_fstatvfs(%d,%p)\n",
1434 current->comm, current->pid, fd, buf);
1436 error = verify_area(VERIFY_WRITE, buf, sizeof(struct irix_statvfs));
1439 if (!(file = fget(fd))) {
1443 error = vfs_statfs(file->f_dentry->d_inode->i_sb, &kbuf);
1447 __put_user(kbuf.f_bsize, &buf->f_bsize);
1448 __put_user(kbuf.f_frsize, &buf->f_frsize);
1449 __put_user(kbuf.f_blocks, &buf->f_blocks);
1450 __put_user(kbuf.f_bfree, &buf->f_bfree);
1451 __put_user(kbuf.f_bfree, &buf->f_bavail); /* XXX hackety hack... */
1452 __put_user(kbuf.f_files, &buf->f_files);
1453 __put_user(kbuf.f_ffree, &buf->f_ffree);
1454 __put_user(kbuf.f_ffree, &buf->f_favail); /* XXX hackety hack... */
1456 __put_user(kbuf.f_fsid.val[1], &buf->f_fsid);
1458 __put_user(kbuf.f_fsid.val[0], &buf->f_fsid);
1460 for(i = 0; i < 16; i++)
1461 __put_user(0, &buf->f_basetype[i]);
1462 __put_user(0, &buf->f_flag);
1463 __put_user(kbuf.f_namelen, &buf->f_namemax);
1464 __clear_user(&buf->f_fstr, sizeof(buf->f_fstr));
1472 asmlinkage int irix_priocntl(struct pt_regs *regs)
1474 printk("[%s:%d] Wheee.. irix_priocntl()\n",
1475 current->comm, current->pid);
1480 asmlinkage int irix_sigqueue(int pid, int sig, int code, int val)
1482 printk("[%s:%d] Wheee.. irix_sigqueue(%d,%d,%d,%d)\n",
1483 current->comm, current->pid, pid, sig, code, val);
1488 asmlinkage int irix_truncate64(char *name, int pad, int size1, int size2)
1496 retval = sys_truncate(name, size2);
1502 asmlinkage int irix_ftruncate64(int fd, int pad, int size1, int size2)
1510 retval = sys_ftruncate(fd, size2);
1516 asmlinkage int irix_mmap64(struct pt_regs *regs)
1518 int len, prot, flags, fd, off1, off2, error, base = 0;
1519 unsigned long addr, pgoff, *sp;
1520 struct file *file = NULL;
1522 if (regs->regs[2] == 1000)
1524 sp = (unsigned long *) (regs->regs[29] + 16);
1525 addr = regs->regs[base + 4];
1526 len = regs->regs[base + 5];
1527 prot = regs->regs[base + 6];
1529 flags = regs->regs[base + 7];
1530 error = verify_area(VERIFY_READ, sp, (4 * sizeof(unsigned long)));
1534 __get_user(off1, &sp[1]);
1535 __get_user(off2, &sp[2]);
1537 error = verify_area(VERIFY_READ, sp, (5 * sizeof(unsigned long)));
1540 __get_user(flags, &sp[0]);
1541 __get_user(fd, &sp[1]);
1542 __get_user(off1, &sp[2]);
1543 __get_user(off2, &sp[3]);
1546 if (off1 & PAGE_MASK) {
1551 pgoff = (off1 << (32 - PAGE_SHIFT)) | (off2 >> PAGE_SHIFT);
1553 if (!(flags & MAP_ANONYMOUS)) {
1554 if (!(file = fget(fd))) {
1559 /* Ok, bad taste hack follows, try to think in something else
1560 when reading this */
1561 if (flags & IRIX_MAP_AUTOGROW) {
1562 unsigned long old_pos;
1563 long max_size = off2 + len;
1565 if (max_size > file->f_dentry->d_inode->i_size) {
1566 old_pos = sys_lseek (fd, max_size - 1, 0);
1567 sys_write (fd, "", 1);
1568 sys_lseek (fd, old_pos, 0);
1573 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
1575 down_write(¤t->mm->mmap_sem);
1576 error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
1577 up_write(¤t->mm->mmap_sem);
1586 asmlinkage int irix_dmi(struct pt_regs *regs)
1588 printk("[%s:%d] Wheee.. irix_dmi()\n",
1589 current->comm, current->pid);
1594 asmlinkage int irix_pread(int fd, char *buf, int cnt, int off64,
1597 printk("[%s:%d] Wheee.. irix_pread(%d,%p,%d,%d,%d,%d)\n",
1598 current->comm, current->pid, fd, buf, cnt, off64, off1, off2);
1603 asmlinkage int irix_pwrite(int fd, char *buf, int cnt, int off64,
1606 printk("[%s:%d] Wheee.. irix_pwrite(%d,%p,%d,%d,%d,%d)\n",
1607 current->comm, current->pid, fd, buf, cnt, off64, off1, off2);
1612 asmlinkage int irix_sgifastpath(int cmd, unsigned long arg0, unsigned long arg1,
1613 unsigned long arg2, unsigned long arg3,
1614 unsigned long arg4, unsigned long arg5)
1616 printk("[%s:%d] Wheee.. irix_fastpath(%d,%08lx,%08lx,%08lx,%08lx,"
1618 current->comm, current->pid, cmd, arg0, arg1, arg2,
1624 struct irix_statvfs64 {
1625 u32 f_bsize; u32 f_frsize;
1626 u64 f_blocks; u64 f_bfree; u64 f_bavail;
1627 u64 f_files; u64 f_ffree; u64 f_favail;
1629 char f_basetype[16];
1630 u32 f_flag; u32 f_namemax;
1635 asmlinkage int irix_statvfs64(char *fname, struct irix_statvfs64 *buf)
1637 struct nameidata nd;
1638 struct kstatfs kbuf;
1641 printk("[%s:%d] Wheee.. irix_statvfs(%s,%p)\n",
1642 current->comm, current->pid, fname, buf);
1643 error = verify_area(VERIFY_WRITE, buf, sizeof(struct irix_statvfs));
1646 error = user_path_walk(fname, &nd);
1649 error = vfs_statfs(nd.dentry->d_inode->i_sb, &kbuf);
1653 __put_user(kbuf.f_bsize, &buf->f_bsize);
1654 __put_user(kbuf.f_frsize, &buf->f_frsize);
1655 __put_user(kbuf.f_blocks, &buf->f_blocks);
1656 __put_user(kbuf.f_bfree, &buf->f_bfree);
1657 __put_user(kbuf.f_bfree, &buf->f_bavail); /* XXX hackety hack... */
1658 __put_user(kbuf.f_files, &buf->f_files);
1659 __put_user(kbuf.f_ffree, &buf->f_ffree);
1660 __put_user(kbuf.f_ffree, &buf->f_favail); /* XXX hackety hack... */
1662 __put_user(kbuf.f_fsid.val[1], &buf->f_fsid);
1664 __put_user(kbuf.f_fsid.val[0], &buf->f_fsid);
1666 for(i = 0; i < 16; i++)
1667 __put_user(0, &buf->f_basetype[i]);
1668 __put_user(0, &buf->f_flag);
1669 __put_user(kbuf.f_namelen, &buf->f_namemax);
1670 for(i = 0; i < 32; i++)
1671 __put_user(0, &buf->f_fstr[i]);
1681 asmlinkage int irix_fstatvfs64(int fd, struct irix_statvfs *buf)
1683 struct kstatfs kbuf;
1687 printk("[%s:%d] Wheee.. irix_fstatvfs(%d,%p)\n",
1688 current->comm, current->pid, fd, buf);
1690 error = verify_area(VERIFY_WRITE, buf, sizeof(struct irix_statvfs));
1693 if (!(file = fget(fd))) {
1697 error = vfs_statfs(file->f_dentry->d_inode->i_sb, &kbuf);
1701 __put_user(kbuf.f_bsize, &buf->f_bsize);
1702 __put_user(kbuf.f_frsize, &buf->f_frsize);
1703 __put_user(kbuf.f_blocks, &buf->f_blocks);
1704 __put_user(kbuf.f_bfree, &buf->f_bfree);
1705 __put_user(kbuf.f_bfree, &buf->f_bavail); /* XXX hackety hack... */
1706 __put_user(kbuf.f_files, &buf->f_files);
1707 __put_user(kbuf.f_ffree, &buf->f_ffree);
1708 __put_user(kbuf.f_ffree, &buf->f_favail); /* XXX hackety hack... */
1710 __put_user(kbuf.f_fsid.val[1], &buf->f_fsid);
1712 __put_user(kbuf.f_fsid.val[0], &buf->f_fsid);
1714 for(i = 0; i < 16; i++)
1715 __put_user(0, &buf->f_basetype[i]);
1716 __put_user(0, &buf->f_flag);
1717 __put_user(kbuf.f_namelen, &buf->f_namemax);
1718 __clear_user(buf->f_fstr, sizeof(buf->f_fstr[i]));
1726 asmlinkage int irix_getmountid(char *fname, unsigned long *midbuf)
1730 printk("[%s:%d] irix_getmountid(%s, %p)\n",
1731 current->comm, current->pid, fname, midbuf);
1732 err = verify_area(VERIFY_WRITE, midbuf, (sizeof(unsigned long) * 4));
1737 * The idea with this system call is that when trying to determine
1738 * 'pwd' and it's a toss-up for some reason, userland can use the
1739 * fsid of the filesystem to try and make the right decision, but
1740 * we don't have this so for now. XXX
1742 err |= __put_user(0, &midbuf[0]);
1743 err |= __put_user(0, &midbuf[1]);
1744 err |= __put_user(0, &midbuf[2]);
1745 err |= __put_user(0, &midbuf[3]);
1750 asmlinkage int irix_nsproc(unsigned long entry, unsigned long mask,
1751 unsigned long arg, unsigned long sp, int slen)
1753 printk("[%s:%d] Wheee.. irix_nsproc(%08lx,%08lx,%08lx,%08lx,%d)\n",
1754 current->comm, current->pid, entry, mask, arg, sp, slen);
1759 #undef DEBUG_GETDENTS
1761 struct irix_dirent32 {
1764 unsigned short d_reclen;
1768 struct irix_dirent32_callback {
1769 struct irix_dirent32 *current_dir;
1770 struct irix_dirent32 *previous;
1775 #define NAME_OFFSET32(de) ((int) ((de)->d_name - (char *) (de)))
1776 #define ROUND_UP32(x) (((x)+sizeof(u32)-1) & ~(sizeof(u32)-1))
1778 static int irix_filldir32(void *__buf, const char *name, int namlen,
1779 loff_t offset, ino_t ino, unsigned int d_type)
1781 struct irix_dirent32 *dirent;
1782 struct irix_dirent32_callback *buf =
1783 (struct irix_dirent32_callback *)__buf;
1784 unsigned short reclen = ROUND_UP32(NAME_OFFSET32(dirent) + namlen + 1);
1786 #ifdef DEBUG_GETDENTS
1787 printk("\nirix_filldir32[reclen<%d>namlen<%d>count<%d>]",
1788 reclen, namlen, buf->count);
1790 buf->error = -EINVAL; /* only used if we fail.. */
1791 if (reclen > buf->count)
1793 dirent = buf->previous;
1795 __put_user(offset, &dirent->d_off);
1796 dirent = buf->current_dir;
1797 buf->previous = dirent;
1798 __put_user(ino, &dirent->d_ino);
1799 __put_user(reclen, &dirent->d_reclen);
1800 copy_to_user(dirent->d_name, name, namlen);
1801 __put_user(0, &dirent->d_name[namlen]);
1802 ((char *) dirent) += reclen;
1803 buf->current_dir = dirent;
1804 buf->count -= reclen;
1809 asmlinkage int irix_ngetdents(unsigned int fd, void * dirent,
1810 unsigned int count, int *eob)
1813 struct irix_dirent32 *lastdirent;
1814 struct irix_dirent32_callback buf;
1817 #ifdef DEBUG_GETDENTS
1818 printk("[%s:%d] ngetdents(%d, %p, %d, %p) ", current->comm,
1819 current->pid, fd, dirent, count, eob);
1826 buf.current_dir = (struct irix_dirent32 *) dirent;
1827 buf.previous = NULL;
1831 error = vfs_readdir(file, irix_filldir32, &buf);
1836 lastdirent = buf.previous;
1838 put_user(file->f_pos, &lastdirent->d_off);
1839 error = count - buf.count;
1842 if (put_user(0, eob) < 0) {
1847 #ifdef DEBUG_GETDENTS
1848 printk("eob=%d returning %d\n", *eob, count - buf.count);
1850 error = count - buf.count;
1858 struct irix_dirent64 {
1861 unsigned short d_reclen;
1865 struct irix_dirent64_callback {
1866 struct irix_dirent64 *curr;
1867 struct irix_dirent64 *previous;
1872 #define NAME_OFFSET64(de) ((int) ((de)->d_name - (char *) (de)))
1873 #define ROUND_UP64(x) (((x)+sizeof(u64)-1) & ~(sizeof(u64)-1))
1875 static int irix_filldir64(void * __buf, const char * name, int namlen,
1876 loff_t offset, ino_t ino, unsigned int d_type)
1878 struct irix_dirent64 *dirent;
1879 struct irix_dirent64_callback * buf =
1880 (struct irix_dirent64_callback *) __buf;
1881 unsigned short reclen = ROUND_UP64(NAME_OFFSET64(dirent) + namlen + 1);
1883 buf->error = -EINVAL; /* only used if we fail.. */
1884 if (reclen > buf->count)
1886 dirent = buf->previous;
1888 __put_user(offset, &dirent->d_off);
1890 buf->previous = dirent;
1891 __put_user(ino, &dirent->d_ino);
1892 __put_user(reclen, &dirent->d_reclen);
1893 __copy_to_user(dirent->d_name, name, namlen);
1894 __put_user(0, &dirent->d_name[namlen]);
1895 ((char *) dirent) += reclen;
1897 buf->count -= reclen;
1902 asmlinkage int irix_getdents64(int fd, void *dirent, int cnt)
1905 struct irix_dirent64 *lastdirent;
1906 struct irix_dirent64_callback buf;
1909 #ifdef DEBUG_GETDENTS
1910 printk("[%s:%d] getdents64(%d, %p, %d) ", current->comm,
1911 current->pid, fd, dirent, cnt);
1914 if (!(file = fget(fd)))
1918 if (!access_ok(VERIFY_WRITE, dirent, cnt))
1922 if (cnt < (sizeof(struct irix_dirent64) + 255))
1925 buf.curr = (struct irix_dirent64 *) dirent;
1926 buf.previous = NULL;
1929 error = vfs_readdir(file, irix_filldir64, &buf);
1932 lastdirent = buf.previous;
1937 lastdirent->d_off = (u64) file->f_pos;
1938 #ifdef DEBUG_GETDENTS
1939 printk("returning %d\n", cnt - buf.count);
1941 error = cnt - buf.count;
1949 asmlinkage int irix_ngetdents64(int fd, void *dirent, int cnt, int *eob)
1952 struct irix_dirent64 *lastdirent;
1953 struct irix_dirent64_callback buf;
1956 #ifdef DEBUG_GETDENTS
1957 printk("[%s:%d] ngetdents64(%d, %p, %d) ", current->comm,
1958 current->pid, fd, dirent, cnt);
1961 if (!(file = fget(fd)))
1965 if (!access_ok(VERIFY_WRITE, dirent, cnt) ||
1966 !access_ok(VERIFY_WRITE, eob, sizeof(*eob)))
1970 if (cnt < (sizeof(struct irix_dirent64) + 255))
1974 buf.curr = (struct irix_dirent64 *) dirent;
1975 buf.previous = NULL;
1978 error = vfs_readdir(file, irix_filldir64, &buf);
1981 lastdirent = buf.previous;
1986 lastdirent->d_off = (u64) file->f_pos;
1987 #ifdef DEBUG_GETDENTS
1988 printk("eob=%d returning %d\n", *eob, cnt - buf.count);
1990 error = cnt - buf.count;
1998 asmlinkage int irix_uadmin(unsigned long op, unsigned long func, unsigned long arg)
2005 printk("[%s:%d] irix_uadmin: Wants to reboot...\n",
2006 current->comm, current->pid);
2012 printk("[%s:%d] irix_uadmin: Wants to shutdown...\n",
2013 current->comm, current->pid);
2019 printk("[%s:%d] irix_uadmin: Wants to remount root...\n",
2020 current->comm, current->pid);
2025 /* Kill all tasks. */
2026 printk("[%s:%d] irix_uadmin: Wants to kill all tasks...\n",
2027 current->comm, current->pid);
2032 /* Set magic mushrooms... */
2033 printk("[%s:%d] irix_uadmin: Wants to set magic mushroom[%d]...\n",
2034 current->comm, current->pid, (int) func);
2039 printk("[%s:%d] irix_uadmin: Unknown operation [%d]...\n",
2040 current->comm, current->pid, (int) op);
2049 asmlinkage int irix_utssys(char *inbuf, int arg, int type, char *outbuf)
2056 retval = irix_uname((struct iuname *)inbuf);
2061 printk("[%s:%d] irix_utssys: Wants to do ustat()\n",
2062 current->comm, current->pid);
2068 printk("[%s:%d] irix_utssys: Wants to do fusers()\n",
2069 current->comm, current->pid);
2074 printk("[%s:%d] irix_utssys: Wants to do unknown type[%d]\n",
2075 current->comm, current->pid, (int) type);
2086 #define IRIX_F_ALLOCSP 10
2088 asmlinkage int irix_fcntl(int fd, int cmd, int arg)
2093 printk("[%s:%d] irix_fcntl(%d, %d, %d) ", current->comm,
2094 current->pid, fd, cmd, arg);
2096 if (cmd == IRIX_F_ALLOCSP){
2099 retval = sys_fcntl(fd, cmd, arg);
2101 printk("%d\n", retval);
2106 asmlinkage int irix_ulimit(int cmd, int arg)
2112 printk("[%s:%d] irix_ulimit: Wants to get file size limit.\n",
2113 current->comm, current->pid);
2118 printk("[%s:%d] irix_ulimit: Wants to set file size limit.\n",
2119 current->comm, current->pid);
2124 printk("[%s:%d] irix_ulimit: Wants to get brk limit.\n",
2125 current->comm, current->pid);
2131 printk("[%s:%d] irix_ulimit: Wants to get fd limit.\n",
2132 current->comm, current->pid);
2136 retval = current->rlim[RLIMIT_NOFILE].rlim_cur;
2140 printk("[%s:%d] irix_ulimit: Wants to get txt offset.\n",
2141 current->comm, current->pid);
2146 printk("[%s:%d] irix_ulimit: Unknown command [%d].\n",
2147 current->comm, current->pid, cmd);
2155 asmlinkage int irix_unimp(struct pt_regs *regs)
2157 printk("irix_unimp [%s:%d] v0=%d v1=%d a0=%08lx a1=%08lx a2=%08lx "
2158 "a3=%08lx\n", current->comm, current->pid,
2159 (int) regs->regs[2], (int) regs->regs[3],
2160 regs->regs[4], regs->regs[5], regs->regs[6], regs->regs[7]);