/*
 * sysirix.c: IRIX system call emulation.
 *
 * Copyright (C) 1996 David S. Miller
 * Copyright (C) 1997 Miguel de Icaza
 * Copyright (C) 1997, 1998, 1999, 2000 Ralf Baechle
 */
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/binfmts.h>
#include <linux/capability.h>
#include <linux/highuid.h>
#include <linux/pagemap.h>
#include <linux/mm.h>
#include <linux/mman.h>
#include <linux/slab.h>
#include <linux/swap.h>
#include <linux/errno.h>
#include <linux/time.h>
#include <linux/timex.h>
#include <linux/times.h>
#include <linux/elf.h>
#include <linux/msg.h>
#include <linux/shm.h>
#include <linux/smp.h>
#include <linux/smp_lock.h>
#include <linux/utsname.h>
#include <linux/file.h>
#include <linux/vfs.h>
#include <linux/namei.h>
#include <linux/socket.h>
#include <linux/security.h>
#include <linux/syscalls.h>

#include <asm/ptrace.h>
#include <asm/page.h>
#include <asm/uaccess.h>
#include <asm/inventory.h>

/* 2,191 lines of complete and utter shit coming up... */

extern int max_threads;

/* The sysmp commands supported thus far. */
#define MP_NPROCS       	1 /* # processor in complex */
#define MP_NAPROCS      	2 /* # active processors in complex */
#define MP_PGSIZE           	14 /* Return system page size in v1. */

asmlinkage int irix_sysmp(struct pt_regs *regs)
{
	unsigned long cmd;
	int base = 0;
	int error = 0;

	if(regs->regs[2] == 1000)
		base = 1;
	cmd = regs->regs[base + 4];
	switch(cmd) {
	case MP_PGSIZE:
		error = PAGE_SIZE;
		break;
	case MP_NPROCS:
	case MP_NAPROCS:
		error = num_online_cpus();
		break;
	default:
		printk("SYSMP[%s:%d]: Unsupported opcode %d\n",
		       current->comm, current->pid, (int)cmd);
		error = -EINVAL;
		break;
	}

	return error;
}

/* The prctl commands. */
#define PR_MAXPROCS		 1 /* Tasks/user. */
#define PR_ISBLOCKED		 2 /* If blocked, return 1. */
#define PR_SETSTACKSIZE		 3 /* Set largest task stack size. */
#define PR_GETSTACKSIZE		 4 /* Get largest task stack size. */
#define PR_MAXPPROCS		 5 /* Num parallel tasks. */
#define PR_UNBLKONEXEC		 6 /* When task exec/exit's, unblock. */
#define PR_SETEXITSIG		 8 /* When task exit's, set signal. */
#define PR_RESIDENT		 9 /* Make task unswappable. */
#define PR_ATTACHADDR		10 /* (Re-)Connect a vma to a task. */
#define PR_DETACHADDR		11 /* Disconnect a vma from a task. */
#define PR_TERMCHILD		12 /* Kill child if the parent dies. */
#define PR_GETSHMASK		13 /* Get the sproc() share mask. */
#define PR_GETNSHARE		14 /* Number of share group members. */
#define PR_COREPID		15 /* Add task pid to name when it core. */
#define PR_ATTACHADDRPERM	16 /* (Re-)Connect vma, with specified prot. */
#define PR_PTHREADEXIT		17 /* Kill a pthread, only for IRIX 6.[234] */

asmlinkage int irix_prctl(unsigned option, ...)
{
	va_list args;
	int error = 0;

	va_start(args, option);
	switch (option) {
	case PR_MAXPROCS:
		printk("irix_prctl[%s:%d]: Wants PR_MAXPROCS\n",
		       current->comm, current->pid);
		error = max_threads;
		break;

	case PR_ISBLOCKED: {
		struct task_struct *task;

		printk("irix_prctl[%s:%d]: Wants PR_ISBLOCKED\n",
		       current->comm, current->pid);
		read_lock(&tasklist_lock);
		task = find_task_by_pid(va_arg(args, pid_t));
		error = -ESRCH;
		if (error)
			error = (task->run_list.next != NULL);
		read_unlock(&tasklist_lock);
		/* Can _your_ OS find this out that fast? */
		break;
	}

	case PR_SETSTACKSIZE: {
		long value = va_arg(args, long);

		printk("irix_prctl[%s:%d]: Wants PR_SETSTACKSIZE<%08lx>\n",
		       current->comm, current->pid, (unsigned long) value);
		if (value > RLIM_INFINITY)
			value = RLIM_INFINITY;
		if (capable(CAP_SYS_ADMIN)) {
			task_lock(current->group_leader);
			current->signal->rlim[RLIMIT_STACK].rlim_max =
				current->signal->rlim[RLIMIT_STACK].rlim_cur = value;
			task_unlock(current->group_leader);
			error = value;
			break;
		}
		task_lock(current->group_leader);
		if (value > current->signal->rlim[RLIMIT_STACK].rlim_max) {
			error = -EINVAL;
			task_unlock(current->group_leader);
			break;
		}
		current->signal->rlim[RLIMIT_STACK].rlim_cur = value;
		task_unlock(current->group_leader);
		error = value;
		break;
	}

	case PR_GETSTACKSIZE:
		printk("irix_prctl[%s:%d]: Wants PR_GETSTACKSIZE\n",
		       current->comm, current->pid);
		error = current->signal->rlim[RLIMIT_STACK].rlim_cur;
		break;

	case PR_MAXPPROCS:
		printk("irix_prctl[%s:%d]: Wants PR_MAXPROCS\n",
		       current->comm, current->pid);
		error = 1;
		break;

	case PR_UNBLKONEXEC:
		printk("irix_prctl[%s:%d]: Wants PR_UNBLKONEXEC\n",
		       current->comm, current->pid);
		error = -EINVAL;
		break;

	case PR_SETEXITSIG:
		printk("irix_prctl[%s:%d]: Wants PR_SETEXITSIG\n",
		       current->comm, current->pid);

		/* We can probably play some game where we set the task
		 * exit_code to some non-zero value when this is requested,
		 * and check whether exit_code is already set in do_exit().
		 */
		error = -EINVAL;
		break;

	case PR_RESIDENT:
		printk("irix_prctl[%s:%d]: Wants PR_RESIDENT\n",
		       current->comm, current->pid);
		error = 0; /* Compatibility indeed. */
		break;

	case PR_ATTACHADDR:
		printk("irix_prctl[%s:%d]: Wants PR_ATTACHADDR\n",
		       current->comm, current->pid);
		error = -EINVAL;
		break;

	case PR_DETACHADDR:
		printk("irix_prctl[%s:%d]: Wants PR_DETACHADDR\n",
		       current->comm, current->pid);
		error = -EINVAL;
		break;

	case PR_TERMCHILD:
		printk("irix_prctl[%s:%d]: Wants PR_TERMCHILD\n",
		       current->comm, current->pid);
		error = -EINVAL;
		break;

	case PR_GETSHMASK:
		printk("irix_prctl[%s:%d]: Wants PR_GETSHMASK\n",
		       current->comm, current->pid);
		error = -EINVAL; /* Until I have the sproc() stuff in. */
		break;

	case PR_GETNSHARE:
		error = 0;       /* Until I have the sproc() stuff in. */
		break;

	case PR_COREPID:
		printk("irix_prctl[%s:%d]: Wants PR_COREPID\n",
		       current->comm, current->pid);
		error = -EINVAL;
		break;

	case PR_ATTACHADDRPERM:
		printk("irix_prctl[%s:%d]: Wants PR_ATTACHADDRPERM\n",
		       current->comm, current->pid);
		error = -EINVAL;
		break;

	default:
		printk("irix_prctl[%s:%d]: Non-existant opcode %d\n",
		       current->comm, current->pid, option);
		error = -EINVAL;
		break;
	}
	va_end(args);

	return error;
}

#undef DEBUG_PROCGRPS

extern unsigned long irix_mapelf(int fd, struct elf_phdr __user *user_phdrp, int cnt);
extern int getrusage(struct task_struct *p, int who, struct rusage __user *ru);
extern char *prom_getenv(char *name);
extern long prom_setenv(char *name, char *value);

/* The syssgi commands supported thus far. */
#define SGI_SYSID         1       /* Return unique per-machine identifier. */
#define SGI_INVENT        5       /* Fetch inventory  */
#   define SGI_INV_SIZEOF 1
#   define SGI_INV_READ   2
#define SGI_RDNAME        6       /* Return string name of a process. */
#define SGI_SETNVRAM	  8	  /* Set PROM variable. */
#define SGI_GETNVRAM	  9	  /* Get PROM variable. */
#define SGI_SETPGID      21       /* Set process group id. */
#define SGI_SYSCONF      22       /* POSIX sysconf garbage. */
#define SGI_PATHCONF     24       /* POSIX sysconf garbage. */
#define SGI_SETGROUPS    40       /* POSIX sysconf garbage. */
#define SGI_GETGROUPS    41       /* POSIX sysconf garbage. */
#define SGI_RUSAGE       56       /* BSD style rusage(). */
#define SGI_SSYNC        62       /* Synchronous fs sync. */
#define SGI_GETSID       65       /* SysVr4 get session id. */
#define SGI_ELFMAP       68       /* Map an elf image. */
#define SGI_TOSSTSAVE   108       /* Toss saved vma's. */
#define SGI_FP_BCOPY    129       /* Should FPU bcopy be used on this machine? */
#define SGI_PHYSP      1011       /* Translate virtual into physical page. */

asmlinkage int irix_syssgi(struct pt_regs *regs)
{
	unsigned long cmd;
	int retval, base = 0;

	if (regs->regs[2] == 1000)
		base = 1;

	cmd = regs->regs[base + 4];
	switch(cmd) {
	case SGI_SYSID: {
		char __user *buf = (char __user *) regs->regs[base + 5];

		/* XXX Use ethernet addr.... */
		retval = clear_user(buf, 64) ? -EFAULT : 0;
		break;
	}
#if 0
	case SGI_RDNAME: {
		int pid = (int) regs->regs[base + 5];
		char __user *buf = (char __user *) regs->regs[base + 6];
		struct task_struct *p;
		char tcomm[sizeof(current->comm)];

		read_lock(&tasklist_lock);
		p = find_task_by_pid(pid);
		if (!p) {
			read_unlock(&tasklist_lock);
			retval = -ESRCH;
			break;
		}
		get_task_comm(tcomm, p);
		read_unlock(&tasklist_lock);

		/* XXX Need to check sizes. */
		retval = copy_to_user(buf, tcomm, sizeof(tcomm)) ? -EFAULT : 0;
		break;
	}

	case SGI_GETNVRAM: {
		char __user *name = (char __user *) regs->regs[base+5];
		char __user *buf = (char __user *) regs->regs[base+6];
		char *value;
		return -EINVAL;	/* til I fix it */
		value = prom_getenv(name);	/* PROM lock?  */
		if (!value) {
			retval = -EINVAL;
			break;
		}
		/* Do I strlen() for the length? */
		retval = copy_to_user(buf, value, 128) ? -EFAULT : 0;
		break;
	}

	case SGI_SETNVRAM: {
		char __user *name = (char __user *) regs->regs[base+5];
		char __user *value = (char __user *) regs->regs[base+6];
		return -EINVAL;	/* til I fix it */
		retval = prom_setenv(name, value);
		/* XXX make sure retval conforms to syssgi(2) */
		printk("[%s:%d] setnvram(\"%s\", \"%s\"): retval %d",
		       current->comm, current->pid, name, value, retval);
/*		if (retval == PROM_ENOENT)
		  	retval = -ENOENT; */
		break;
	}
#endif

	case SGI_SETPGID: {
#ifdef DEBUG_PROCGRPS
		printk("[%s:%d] setpgid(%d, %d) ",
		       current->comm, current->pid,
		       (int) regs->regs[base + 5], (int)regs->regs[base + 6]);
#endif
		retval = sys_setpgid(regs->regs[base + 5], regs->regs[base + 6]);

#ifdef DEBUG_PROCGRPS
		printk("retval=%d\n", retval);
#endif
	}

	case SGI_SYSCONF: {
		switch(regs->regs[base + 5]) {
		case 1:
			retval = (MAX_ARG_PAGES >> 4); /* XXX estimate... */
			goto out;
		case 2:
			retval = max_threads;
			goto out;
		case 3:
			retval = HZ;
			goto out;
		case 4:
			retval = NGROUPS_MAX;
			goto out;
		case 5:
			retval = NR_OPEN;
			goto out;
		case 6:
			retval = 1;
			goto out;
		case 7:
			retval = 1;
			goto out;
		case 8:
			retval = 199009;
			goto out;
		case 11:
			retval = PAGE_SIZE;
			goto out;
		case 12:
			retval = 4;
			goto out;
		case 25:
		case 26:
		case 27:
		case 28:
		case 29:
		case 30:
			retval = 0;
			goto out;
		case 31:
			retval = 32;
			goto out;
		default:
			retval = -EINVAL;
			goto out;
		};
	}

	case SGI_SETGROUPS:
		retval = sys_setgroups((int) regs->regs[base + 5],
		                       (gid_t __user *) regs->regs[base + 6]);
		break;

	case SGI_GETGROUPS:
		retval = sys_getgroups((int) regs->regs[base + 5],
		                       (gid_t __user *) regs->regs[base + 6]);
		break;

	case SGI_RUSAGE: {
		struct rusage __user *ru = (struct rusage __user *) regs->regs[base + 6];

		switch((int) regs->regs[base + 5]) {
		case 0:
			/* rusage self */
			retval = getrusage(current, RUSAGE_SELF, ru);
			goto out;

		case -1:
			/* rusage children */
			retval = getrusage(current, RUSAGE_CHILDREN, ru);
			goto out;

		default:
			retval = -EINVAL;
			goto out;
		};
	}

	case SGI_SSYNC:
		sys_sync();
		retval = 0;
		break;

	case SGI_GETSID:
#ifdef DEBUG_PROCGRPS
		printk("[%s:%d] getsid(%d) ", current->comm, current->pid,
		       (int) regs->regs[base + 5]);
#endif
		retval = sys_getsid(regs->regs[base + 5]);
#ifdef DEBUG_PROCGRPS
		printk("retval=%d\n", retval);
#endif
		break;

	case SGI_ELFMAP:
		retval = irix_mapelf((int) regs->regs[base + 5],
				     (struct elf_phdr __user *) regs->regs[base + 6],
				     (int) regs->regs[base + 7]);
		break;

	case SGI_TOSSTSAVE:
		/* XXX We don't need to do anything? */
		retval = 0;
		break;

	case SGI_FP_BCOPY:
		retval = 0;
		break;

	case SGI_PHYSP: {
		unsigned long addr = regs->regs[base + 5];
		int __user *pageno = (int __user *) (regs->regs[base + 6]);
		struct mm_struct *mm = current->mm;
		pgd_t *pgdp;
		pud_t *pudp;
		pmd_t *pmdp;
		pte_t *ptep;

		down_read(&mm->mmap_sem);
		pgdp = pgd_offset(mm, addr);
		pudp = pud_offset(pgdp, addr);
		pmdp = pmd_offset(pudp, addr);
		ptep = pte_offset(pmdp, addr);
		retval = -EINVAL;
		if (ptep) {
			pte_t pte = *ptep;

			if (pte_val(pte) & (_PAGE_VALID | _PAGE_PRESENT)) {
				/* b0rked on 64-bit */
				retval =  put_user((pte_val(pte) & PAGE_MASK) >>
				                   PAGE_SHIFT, pageno);
			}
		}
		up_read(&mm->mmap_sem);
		break;
	}

	case SGI_INVENT: {
		int  arg1    = (int)    regs->regs [base + 5];
		void __user *buffer = (void __user *) regs->regs [base + 6];
		int  count   = (int)    regs->regs [base + 7];

		switch (arg1) {
		case SGI_INV_SIZEOF:
			retval = sizeof (inventory_t);
			break;
		case SGI_INV_READ:
			retval = dump_inventory_to_user (buffer, count);
			break;
		default:
			retval = -EINVAL;
		}
		break;
	}

	default:
		printk("irix_syssgi: Unsupported command %d\n", (int)cmd);
		retval = -EINVAL;
		break;
	};

out:
	return retval;
}

asmlinkage int irix_gtime(struct pt_regs *regs)
{
	return get_seconds();
}

/*
 * IRIX is completely broken... it returns 0 on success, otherwise
 * ENOMEM.
 */
asmlinkage int irix_brk(unsigned long brk)
{
	unsigned long rlim;
	unsigned long newbrk, oldbrk;
	struct mm_struct *mm = current->mm;
	int ret;

	down_write(&mm->mmap_sem);
	if (brk < mm->end_code) {
		ret = -ENOMEM;
		goto out;
	}

	newbrk = PAGE_ALIGN(brk);
	oldbrk = PAGE_ALIGN(mm->brk);
	if (oldbrk == newbrk) {
		mm->brk = brk;
		ret = 0;
		goto out;
	}

	/*
	 * Always allow shrinking brk
	 */
	if (brk <= mm->brk) {
		mm->brk = brk;
		do_munmap(mm, newbrk, oldbrk-newbrk);
		ret = 0;
		goto out;
	}
	/*
	 * Check against rlimit and stack..
	 */
	rlim = current->signal->rlim[RLIMIT_DATA].rlim_cur;
	if (rlim >= RLIM_INFINITY)
		rlim = ~0;
	if (brk - mm->end_code > rlim) {
		ret = -ENOMEM;
		goto out;
	}

	/*
	 * Check against existing mmap mappings.
	 */
	if (find_vma_intersection(mm, oldbrk, newbrk+PAGE_SIZE)) {
		ret = -ENOMEM;
		goto out;
	}

	/*
	 * Ok, looks good - let it rip.
	 */
	if (do_brk(oldbrk, newbrk-oldbrk) != oldbrk) {
		ret = -ENOMEM;
		goto out;
	}
	mm->brk = brk;
	ret = 0;

out:
	up_write(&mm->mmap_sem);
	return ret;
}

asmlinkage int irix_getpid(struct pt_regs *regs)
{
	regs->regs[3] = current->real_parent->pid;
	return current->pid;
}

asmlinkage int irix_getuid(struct pt_regs *regs)
{
	regs->regs[3] = current->euid;
	return current->uid;
}

asmlinkage int irix_getgid(struct pt_regs *regs)
{
	regs->regs[3] = current->egid;
	return current->gid;
}

asmlinkage int irix_stime(int value)
{
	int err;
	struct timespec tv;

	tv.tv_sec = value;
	tv.tv_nsec = 0;
	err = security_settime(&tv, NULL);
	if (err)
		return err;

	write_seqlock_irq(&xtime_lock);
	xtime.tv_sec = value;
	xtime.tv_nsec = 0;
	ntp_clear();
	write_sequnlock_irq(&xtime_lock);

	return 0;
}

static inline void jiffiestotv(unsigned long jiffies, struct timeval *value)
{
	value->tv_usec = (jiffies % HZ) * (1000000 / HZ);
	value->tv_sec = jiffies / HZ;
}

static inline void getitimer_real(struct itimerval *value)
{
	register unsigned long val, interval;

	interval = current->it_real_incr;
	val = 0;
	if (del_timer(&current->real_timer)) {
		unsigned long now = jiffies;
		val = current->real_timer.expires;
		add_timer(&current->real_timer);
		/* look out for negative/zero itimer.. */
		if (val <= now)
			val = now+1;
		val -= now;
	}
	jiffiestotv(val, &value->it_value);
	jiffiestotv(interval, &value->it_interval);
}

asmlinkage unsigned int irix_alarm(unsigned int seconds)
{
	return alarm_setitimer(seconds);
}

asmlinkage int irix_pause(void)
{
	current->state = TASK_INTERRUPTIBLE;
	schedule();

	return -EINTR;
}

/* XXX need more than this... */
asmlinkage int irix_mount(char __user *dev_name, char __user *dir_name,
	unsigned long flags, char __user *type, void __user *data, int datalen)
{
	printk("[%s:%d] irix_mount(%p,%p,%08lx,%p,%p,%d)\n",
	       current->comm, current->pid,
	       dev_name, dir_name, flags, type, data, datalen);

	return sys_mount(dev_name, dir_name, type, flags, data);
}

struct irix_statfs {
	short f_type;
        long  f_bsize, f_frsize, f_blocks, f_bfree, f_files, f_ffree;
	char  f_fname[6], f_fpack[6];
};

asmlinkage int irix_statfs(const char __user *path,
	struct irix_statfs __user *buf, int len, int fs_type)
{
	struct nameidata nd;
	struct kstatfs kbuf;
	int error, i;

	/* We don't support this feature yet. */
	if (fs_type) {
		error = -EINVAL;
		goto out;
	}
	if (!access_ok(VERIFY_WRITE, buf, sizeof(struct irix_statfs))) {
		error = -EFAULT;
		goto out;
	}

	error = user_path_walk(path, &nd);
	if (error)
		goto out;

	error = vfs_statfs(nd.dentry, &kbuf);
	if (error)
		goto dput_and_out;

	error = __put_user(kbuf.f_type, &buf->f_type);
	error |= __put_user(kbuf.f_bsize, &buf->f_bsize);
	error |= __put_user(kbuf.f_frsize, &buf->f_frsize);
	error |= __put_user(kbuf.f_blocks, &buf->f_blocks);
	error |= __put_user(kbuf.f_bfree, &buf->f_bfree);
	error |= __put_user(kbuf.f_files, &buf->f_files);
	error |= __put_user(kbuf.f_ffree, &buf->f_ffree);
	for (i = 0; i < 6; i++) {
		error |= __put_user(0, &buf->f_fname[i]);
		error |= __put_user(0, &buf->f_fpack[i]);
	}

dput_and_out:
	path_release(&nd);
out:
	return error;
}

asmlinkage int irix_fstatfs(unsigned int fd, struct irix_statfs __user *buf)
{
	struct kstatfs kbuf;
	struct file *file;
	int error, i;

	if (!access_ok(VERIFY_WRITE, buf, sizeof(struct irix_statfs))) {
		error = -EFAULT;
		goto out;
	}

	if (!(file = fget(fd))) {
		error = -EBADF;
		goto out;
	}

	error = vfs_statfs(file->f_dentry, &kbuf);
	if (error)
		goto out_f;

	error = __put_user(kbuf.f_type, &buf->f_type);
	error |= __put_user(kbuf.f_bsize, &buf->f_bsize);
	error |= __put_user(kbuf.f_frsize, &buf->f_frsize);
	error |= __put_user(kbuf.f_blocks, &buf->f_blocks);
	error |= __put_user(kbuf.f_bfree, &buf->f_bfree);
	error |= __put_user(kbuf.f_files, &buf->f_files);
	error |= __put_user(kbuf.f_ffree, &buf->f_ffree);

	for (i = 0; i < 6; i++) {
		error |= __put_user(0, &buf->f_fname[i]);
		error |= __put_user(0, &buf->f_fpack[i]);
	}

out_f:
	fput(file);
out:
	return error;
}

asmlinkage int irix_setpgrp(int flags)
{
	int error;

#ifdef DEBUG_PROCGRPS
	printk("[%s:%d] setpgrp(%d) ", current->comm, current->pid, flags);
#endif
	if(!flags)
		error = process_group(current);
	else
		error = sys_setsid();
#ifdef DEBUG_PROCGRPS
	printk("returning %d\n", process_group(current));
#endif

	return error;
}

asmlinkage int irix_times(struct tms __user *tbuf)
{
	int err = 0;

	if (tbuf) {
		if (!access_ok(VERIFY_WRITE,tbuf,sizeof *tbuf))
			return -EFAULT;

		err = __put_user(current->utime, &tbuf->tms_utime);
		err |= __put_user(current->stime, &tbuf->tms_stime);
		err |= __put_user(current->signal->cutime, &tbuf->tms_cutime);
		err |= __put_user(current->signal->cstime, &tbuf->tms_cstime);
	}

	return err;
}

asmlinkage int irix_exec(struct pt_regs *regs)
{
	int error, base = 0;
	char *filename;

	if(regs->regs[2] == 1000)
		base = 1;
	filename = getname((char __user *) (long)regs->regs[base + 4]);
	error = PTR_ERR(filename);
	if (IS_ERR(filename))
		return error;

	error = do_execve(filename, (char __user * __user *) (long)regs->regs[base + 5],
	                  NULL, regs);
	putname(filename);

	return error;
}

asmlinkage int irix_exece(struct pt_regs *regs)
{
	int error, base = 0;
	char *filename;

	if (regs->regs[2] == 1000)
		base = 1;
	filename = getname((char __user *) (long)regs->regs[base + 4]);
	error = PTR_ERR(filename);
	if (IS_ERR(filename))
		return error;
	error = do_execve(filename, (char __user * __user *) (long)regs->regs[base + 5],
	                  (char __user * __user *) (long)regs->regs[base + 6], regs);
	putname(filename);

	return error;
}

asmlinkage unsigned long irix_gethostid(void)
{
	printk("[%s:%d]: irix_gethostid() called...\n",
	       current->comm, current->pid);

	return -EINVAL;
}

asmlinkage unsigned long irix_sethostid(unsigned long val)
{
	printk("[%s:%d]: irix_sethostid(%08lx) called...\n",
	       current->comm, current->pid, val);

	return -EINVAL;
}

asmlinkage int irix_socket(int family, int type, int protocol)
{
	switch(type) {
	case 1:
		type = SOCK_DGRAM;
		break;

	case 2:
		type = SOCK_STREAM;
		break;

	case 3:
		type = 9; /* Invalid... */
		break;

	case 4:
		type = SOCK_RAW;
		break;

	case 5:
		type = SOCK_RDM;
		break;

	case 6:
		type = SOCK_SEQPACKET;
		break;

	default:
		break;
	}

	return sys_socket(family, type, protocol);
}

asmlinkage int irix_getdomainname(char __user *name, int len)
{
	int err;

	down_read(&uts_sem);
	if (len > __NEW_UTS_LEN)
		len = __NEW_UTS_LEN;
	err = copy_to_user(name, system_utsname.domainname, len) ? -EFAULT : 0;
	up_read(&uts_sem);

	return err;
}

asmlinkage unsigned long irix_getpagesize(void)
{
	return PAGE_SIZE;
}

asmlinkage int irix_msgsys(int opcode, unsigned long arg0, unsigned long arg1,
			   unsigned long arg2, unsigned long arg3,
			   unsigned long arg4)
{
	switch (opcode) {
	case 0:
		return sys_msgget((key_t) arg0, (int) arg1);
	case 1:
		return sys_msgctl((int) arg0, (int) arg1,
		                  (struct msqid_ds __user *)arg2);
	case 2:
		return sys_msgrcv((int) arg0, (struct msgbuf __user *) arg1,
				  (size_t) arg2, (long) arg3, (int) arg4);
	case 3:
		return sys_msgsnd((int) arg0, (struct msgbuf __user *) arg1,
				  (size_t) arg2, (int) arg3);
	default:
		return -EINVAL;
	}
}

asmlinkage int irix_shmsys(int opcode, unsigned long arg0, unsigned long arg1,
			   unsigned long arg2, unsigned long arg3)
{
	switch (opcode) {
	case 0:
		return do_shmat((int) arg0, (char __user *) arg1, (int) arg2,
				 (unsigned long *) arg3);
	case 1:
		return sys_shmctl((int)arg0, (int)arg1,
		                  (struct shmid_ds __user *)arg2);
	case 2:
		return sys_shmdt((char __user *)arg0);
	case 3:
		return sys_shmget((key_t) arg0, (int) arg1, (int) arg2);
	default:
		return -EINVAL;
	}
}

asmlinkage int irix_semsys(int opcode, unsigned long arg0, unsigned long arg1,
			   unsigned long arg2, int arg3)
{
	switch (opcode) {
	case 0:
		return sys_semctl((int) arg0, (int) arg1, (int) arg2,
				  (union semun) arg3);
	case 1:
		return sys_semget((key_t) arg0, (int) arg1, (int) arg2);
	case 2:
		return sys_semop((int) arg0, (struct sembuf __user *)arg1,
				 (unsigned int) arg2);
	default:
		return -EINVAL;
	}
}

static inline loff_t llseek(struct file *file, loff_t offset, int origin)
{
	loff_t (*fn)(struct file *, loff_t, int);
	loff_t retval;

	fn = default_llseek;
	if (file->f_op && file->f_op->llseek)
        fn = file->f_op->llseek;
	lock_kernel();
	retval = fn(file, offset, origin);
	unlock_kernel();

	return retval;
}

asmlinkage int irix_lseek64(int fd, int _unused, int offhi, int offlow,
                            int origin)
{
	struct file * file;
	loff_t offset;
	int retval;

	retval = -EBADF;
	file = fget(fd);
	if (!file)
		goto bad;
	retval = -EINVAL;
	if (origin > 2)
		goto out_putf;

	offset = llseek(file, ((loff_t) offhi << 32) | offlow, origin);
	retval = (int) offset;

out_putf:
	fput(file);
bad:
	return retval;
}

asmlinkage int irix_sginap(int ticks)
{
	schedule_timeout_interruptible(ticks);
	return 0;
}

asmlinkage int irix_sgikopt(char __user *istring, char __user *ostring, int len)
{
	return -EINVAL;
}

asmlinkage int irix_gettimeofday(struct timeval __user *tv)
{
	time_t sec;
	long nsec, seq;
	int err;

	if (!access_ok(VERIFY_WRITE, tv, sizeof(struct timeval)))
		return -EFAULT;

	do {
		seq = read_seqbegin(&xtime_lock);
		sec = xtime.tv_sec;
		nsec = xtime.tv_nsec;
	} while (read_seqretry(&xtime_lock, seq));

	err = __put_user(sec, &tv->tv_sec);
	err |= __put_user((nsec / 1000), &tv->tv_usec);

	return err;
}

#define IRIX_MAP_AUTOGROW 0x40

asmlinkage unsigned long irix_mmap32(unsigned long addr, size_t len, int prot,
				     int flags, int fd, off_t offset)
{
	struct file *file = NULL;
	unsigned long retval;

	if (!(flags & MAP_ANONYMOUS)) {
		if (!(file = fget(fd)))
			return -EBADF;

		/* Ok, bad taste hack follows, try to think in something else
		 * when reading this.  */
		if (flags & IRIX_MAP_AUTOGROW) {
			unsigned long old_pos;
			long max_size = offset + len;

			if (max_size > file->f_dentry->d_inode->i_size) {
				old_pos = sys_lseek (fd, max_size - 1, 0);
				sys_write (fd, (void __user *) "", 1);
				sys_lseek (fd, old_pos, 0);
			}
		}
	}

	flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);

	down_write(&current->mm->mmap_sem);
	retval = do_mmap(file, addr, len, prot, flags, offset);
	up_write(&current->mm->mmap_sem);
	if (file)
		fput(file);

	return retval;
}

asmlinkage int irix_madvise(unsigned long addr, int len, int behavior)
{
	printk("[%s:%d] Wheee.. irix_madvise(%08lx,%d,%d)\n",
	       current->comm, current->pid, addr, len, behavior);

	return -EINVAL;
}

asmlinkage int irix_pagelock(char __user *addr, int len, int op)
{
	printk("[%s:%d] Wheee.. irix_pagelock(%p,%d,%d)\n",
	       current->comm, current->pid, addr, len, op);

	return -EINVAL;
}

asmlinkage int irix_quotactl(struct pt_regs *regs)
{
	printk("[%s:%d] Wheee.. irix_quotactl()\n",
	       current->comm, current->pid);

	return -EINVAL;
}

asmlinkage int irix_BSDsetpgrp(int pid, int pgrp)
{
	int error;

#ifdef DEBUG_PROCGRPS
	printk("[%s:%d] BSDsetpgrp(%d, %d) ", current->comm, current->pid,
	       pid, pgrp);
#endif
	if(!pid)
		pid = current->pid;

	/* Wheee, weird sysv thing... */
	if ((pgrp == 0) && (pid == current->pid))
		error = sys_setsid();
	else
		error = sys_setpgid(pid, pgrp);

#ifdef DEBUG_PROCGRPS
	printk("error = %d\n", error);
#endif

	return error;
}

asmlinkage int irix_systeminfo(int cmd, char __user *buf, int cnt)
{
	printk("[%s:%d] Wheee.. irix_systeminfo(%d,%p,%d)\n",
	       current->comm, current->pid, cmd, buf, cnt);

	return -EINVAL;
}

struct iuname {
	char sysname[257], nodename[257], release[257];
	char version[257], machine[257];
	char m_type[257], base_rel[257];
	char _unused0[257], _unused1[257], _unused2[257];
	char _unused3[257], _unused4[257], _unused5[257];
};

asmlinkage int irix_uname(struct iuname __user *buf)
{
	down_read(&uts_sem);
	if (copy_from_user(system_utsname.sysname, buf->sysname, 65)
	    || copy_from_user(system_utsname.nodename, buf->nodename, 65)
	    || copy_from_user(system_utsname.release, buf->release, 65)
	    || copy_from_user(system_utsname.version, buf->version, 65)
	    || copy_from_user(system_utsname.machine, buf->machine, 65)) {
		return -EFAULT;
	}
	up_read(&uts_sem);

	return 1;
}

#undef DEBUG_XSTAT

static int irix_xstat32_xlate(struct kstat *stat, void __user *ubuf)
{
	struct xstat32 {
		u32 st_dev, st_pad1[3], st_ino, st_mode, st_nlink, st_uid, st_gid;
		u32 st_rdev, st_pad2[2], st_size, st_pad3;
		u32 st_atime0, st_atime1;
		u32 st_mtime0, st_mtime1;
		u32 st_ctime0, st_ctime1;
		u32 st_blksize, st_blocks;
		char st_fstype[16];
		u32 st_pad4[8];
	} ub;

	if (!sysv_valid_dev(stat->dev) || !sysv_valid_dev(stat->rdev))
		return -EOVERFLOW;
	ub.st_dev     = sysv_encode_dev(stat->dev);
	ub.st_ino     = stat->ino;
	ub.st_mode    = stat->mode;
	ub.st_nlink   = stat->nlink;
	SET_UID(ub.st_uid, stat->uid);
	SET_GID(ub.st_gid, stat->gid);
	ub.st_rdev    = sysv_encode_dev(stat->rdev);
#if BITS_PER_LONG == 32
	if (stat->size > MAX_NON_LFS)
		return -EOVERFLOW;
#endif
	ub.st_size    = stat->size;
	ub.st_atime0  = stat->atime.tv_sec;
	ub.st_atime1  = stat->atime.tv_nsec;
	ub.st_mtime0  = stat->mtime.tv_sec;
	ub.st_mtime1  = stat->atime.tv_nsec;
	ub.st_ctime0  = stat->ctime.tv_sec;
	ub.st_ctime1  = stat->atime.tv_nsec;
	ub.st_blksize = stat->blksize;
	ub.st_blocks  = stat->blocks;
	strcpy (ub.st_fstype, "efs");

	return copy_to_user(ubuf, &ub, sizeof(ub)) ? -EFAULT : 0;
}

static int irix_xstat64_xlate(struct kstat *stat, void __user *ubuf)
{
	struct xstat64 {
		u32 st_dev; s32 st_pad1[3];
		unsigned long long st_ino;
		u32 st_mode;
		u32 st_nlink; s32 st_uid; s32 st_gid; u32 st_rdev;
		s32 st_pad2[2];
		long long st_size;
		s32 st_pad3;
		struct { s32 tv_sec, tv_nsec; } st_atime, st_mtime, st_ctime;
		s32 st_blksize;
		long long  st_blocks;
		char st_fstype[16];
		s32 st_pad4[8];
	} ks;

	if (!sysv_valid_dev(stat->dev) || !sysv_valid_dev(stat->rdev))
		return -EOVERFLOW;

	ks.st_dev = sysv_encode_dev(stat->dev);
	ks.st_pad1[0] = ks.st_pad1[1] = ks.st_pad1[2] = 0;
	ks.st_ino = (unsigned long long) stat->ino;
	ks.st_mode = (u32) stat->mode;
	ks.st_nlink = (u32) stat->nlink;
	ks.st_uid = (s32) stat->uid;
	ks.st_gid = (s32) stat->gid;
	ks.st_rdev = sysv_encode_dev (stat->rdev);
	ks.st_pad2[0] = ks.st_pad2[1] = 0;
	ks.st_size = (long long) stat->size;
	ks.st_pad3 = 0;

	/* XXX hackety hack... */
	ks.st_atime.tv_sec = (s32) stat->atime.tv_sec;
	ks.st_atime.tv_nsec = stat->atime.tv_nsec;
	ks.st_mtime.tv_sec = (s32) stat->mtime.tv_sec;
	ks.st_mtime.tv_nsec = stat->mtime.tv_nsec;
	ks.st_ctime.tv_sec = (s32) stat->ctime.tv_sec;
	ks.st_ctime.tv_nsec = stat->ctime.tv_nsec;

	ks.st_blksize = (s32) stat->blksize;
	ks.st_blocks = (long long) stat->blocks;
	memset(ks.st_fstype, 0, 16);
	ks.st_pad4[0] = ks.st_pad4[1] = ks.st_pad4[2] = ks.st_pad4[3] = 0;
	ks.st_pad4[4] = ks.st_pad4[5] = ks.st_pad4[6] = ks.st_pad4[7] = 0;

	/* Now write it all back. */
	return copy_to_user(ubuf, &ks, sizeof(ks)) ? -EFAULT : 0;
}

asmlinkage int irix_xstat(int version, char __user *filename, struct stat __user *statbuf)
{
	int retval;
	struct kstat stat;

#ifdef DEBUG_XSTAT
	printk("[%s:%d] Wheee.. irix_xstat(%d,%s,%p) ",
	       current->comm, current->pid, version, filename, statbuf);
#endif

	retval = vfs_stat(filename, &stat);
	if (!retval) {
		switch(version) {
			case 2:
				retval = irix_xstat32_xlate(&stat, statbuf);
				break;
			case 3:
				retval = irix_xstat64_xlate(&stat, statbuf);
				break;
			default:
				retval = -EINVAL;
		}
	}
	return retval;
}

asmlinkage int irix_lxstat(int version, char __user *filename, struct stat __user *statbuf)
{
	int error;
	struct kstat stat;

#ifdef DEBUG_XSTAT
	printk("[%s:%d] Wheee.. irix_lxstat(%d,%s,%p) ",
	       current->comm, current->pid, version, filename, statbuf);
#endif

	error = vfs_lstat(filename, &stat);

	if (!error) {
		switch (version) {
			case 2:
				error = irix_xstat32_xlate(&stat, statbuf);
				break;
			case 3:
				error = irix_xstat64_xlate(&stat, statbuf);
				break;
			default:
				error = -EINVAL;
		}
	}
	return error;
}

asmlinkage int irix_fxstat(int version, int fd, struct stat __user *statbuf)
{
	int error;
	struct kstat stat;

#ifdef DEBUG_XSTAT
	printk("[%s:%d] Wheee.. irix_fxstat(%d,%d,%p) ",
	       current->comm, current->pid, version, fd, statbuf);
#endif

	error = vfs_fstat(fd, &stat);
	if (!error) {
		switch (version) {
			case 2:
				error = irix_xstat32_xlate(&stat, statbuf);
				break;
			case 3:
				error = irix_xstat64_xlate(&stat, statbuf);
				break;
			default:
				error = -EINVAL;
		}
	}
	return error;
}

asmlinkage int irix_xmknod(int ver, char __user *filename, int mode, unsigned dev)
{
	int retval;
	printk("[%s:%d] Wheee.. irix_xmknod(%d,%s,%x,%x)\n",
	       current->comm, current->pid, ver, filename, mode, dev);

	switch(ver) {
	case 2:
		/* shouldn't we convert here as well as on stat()? */
		retval = sys_mknod(filename, mode, dev);
		break;

	default:
		retval = -EINVAL;
		break;
	};

	return retval;
}

asmlinkage int irix_swapctl(int cmd, char __user *arg)
{
	printk("[%s:%d] Wheee.. irix_swapctl(%d,%p)\n",
	       current->comm, current->pid, cmd, arg);

	return -EINVAL;
}

struct irix_statvfs {
	u32 f_bsize; u32 f_frsize; u32 f_blocks;
	u32 f_bfree; u32 f_bavail; u32 f_files; u32 f_ffree; u32 f_favail;
	u32 f_fsid; char f_basetype[16];
	u32 f_flag; u32 f_namemax;
	char	f_fstr[32]; u32 f_filler[16];
};

asmlinkage int irix_statvfs(char __user *fname, struct irix_statvfs __user *buf)
{
	struct nameidata nd;
	struct kstatfs kbuf;
	int error, i;

	printk("[%s:%d] Wheee.. irix_statvfs(%s,%p)\n",
	       current->comm, current->pid, fname, buf);
	if (!access_ok(VERIFY_WRITE, buf, sizeof(struct irix_statvfs)))
		return -EFAULT;

	error = user_path_walk(fname, &nd);
	if (error)
		goto out;
	error = vfs_statfs(nd.dentry, &kbuf);
	if (error)
		goto dput_and_out;

	error |= __put_user(kbuf.f_bsize, &buf->f_bsize);
	error |= __put_user(kbuf.f_frsize, &buf->f_frsize);
	error |= __put_user(kbuf.f_blocks, &buf->f_blocks);
	error |= __put_user(kbuf.f_bfree, &buf->f_bfree);
	error |= __put_user(kbuf.f_bfree, &buf->f_bavail);  /* XXX hackety hack... */
	error |= __put_user(kbuf.f_files, &buf->f_files);
	error |= __put_user(kbuf.f_ffree, &buf->f_ffree);
	error |= __put_user(kbuf.f_ffree, &buf->f_favail);  /* XXX hackety hack... */
#ifdef __MIPSEB__
	error |= __put_user(kbuf.f_fsid.val[1], &buf->f_fsid);
#else
	error |= __put_user(kbuf.f_fsid.val[0], &buf->f_fsid);
#endif
	for (i = 0; i < 16; i++)
		error |= __put_user(0, &buf->f_basetype[i]);
	error |= __put_user(0, &buf->f_flag);
	error |= __put_user(kbuf.f_namelen, &buf->f_namemax);
	for (i = 0; i < 32; i++)
		error |= __put_user(0, &buf->f_fstr[i]);

dput_and_out:
	path_release(&nd);
out:
	return error;
}

asmlinkage int irix_fstatvfs(int fd, struct irix_statvfs __user *buf)
{
	struct kstatfs kbuf;
	struct file *file;
	int error, i;

	printk("[%s:%d] Wheee.. irix_fstatvfs(%d,%p)\n",
	       current->comm, current->pid, fd, buf);

	if (!access_ok(VERIFY_WRITE, buf, sizeof(struct irix_statvfs)))
		return -EFAULT;

	if (!(file = fget(fd))) {
		error = -EBADF;
		goto out;
	}
	error = vfs_statfs(file->f_dentry, &kbuf);
	if (error)
		goto out_f;

	error = __put_user(kbuf.f_bsize, &buf->f_bsize);
	error |= __put_user(kbuf.f_frsize, &buf->f_frsize);
	error |= __put_user(kbuf.f_blocks, &buf->f_blocks);
	error |= __put_user(kbuf.f_bfree, &buf->f_bfree);
	error |= __put_user(kbuf.f_bfree, &buf->f_bavail); /* XXX hackety hack... */
	error |= __put_user(kbuf.f_files, &buf->f_files);
	error |= __put_user(kbuf.f_ffree, &buf->f_ffree);
	error |= __put_user(kbuf.f_ffree, &buf->f_favail); /* XXX hackety hack... */
#ifdef __MIPSEB__
	error |= __put_user(kbuf.f_fsid.val[1], &buf->f_fsid);
#else
	error |= __put_user(kbuf.f_fsid.val[0], &buf->f_fsid);
#endif
	for(i = 0; i < 16; i++)
		error |= __put_user(0, &buf->f_basetype[i]);
	error |= __put_user(0, &buf->f_flag);
	error |= __put_user(kbuf.f_namelen, &buf->f_namemax);
	error |= __clear_user(&buf->f_fstr, sizeof(buf->f_fstr)) ? -EFAULT : 0;

out_f:
	fput(file);
out:
	return error;
}

asmlinkage int irix_priocntl(struct pt_regs *regs)
{
	printk("[%s:%d] Wheee.. irix_priocntl()\n",
	       current->comm, current->pid);

	return -EINVAL;
}

asmlinkage int irix_sigqueue(int pid, int sig, int code, int val)
{
	printk("[%s:%d] Wheee.. irix_sigqueue(%d,%d,%d,%d)\n",
	       current->comm, current->pid, pid, sig, code, val);

	return -EINVAL;
}

asmlinkage int irix_truncate64(char __user *name, int pad, int size1, int size2)
{
	int retval;

	if (size1) {
		retval = -EINVAL;
		goto out;
	}
	retval = sys_truncate(name, size2);

out:
	return retval;
}

asmlinkage int irix_ftruncate64(int fd, int pad, int size1, int size2)
{
	int retval;

	if (size1) {
		retval = -EINVAL;
		goto out;
	}
	retval = sys_ftruncate(fd, size2);

out:
	return retval;
}

asmlinkage int irix_mmap64(struct pt_regs *regs)
{
	int len, prot, flags, fd, off1, off2, error, base = 0;
	unsigned long addr, pgoff, *sp;
	struct file *file = NULL;
	int err;

	if (regs->regs[2] == 1000)
		base = 1;
	sp = (unsigned long *) (regs->regs[29] + 16);
	addr = regs->regs[base + 4];
	len = regs->regs[base + 5];
	prot = regs->regs[base + 6];
	if (!base) {
		flags = regs->regs[base + 7];
		if (!access_ok(VERIFY_READ, sp, (4 * sizeof(unsigned long))))
			return -EFAULT;
		fd = sp[0];
		err = __get_user(off1, &sp[1]);
		err |= __get_user(off2, &sp[2]);
	} else {
		if (!access_ok(VERIFY_READ, sp, (5 * sizeof(unsigned long))))
			return -EFAULT;
		err = __get_user(flags, &sp[0]);
		err |= __get_user(fd, &sp[1]);
		err |= __get_user(off1, &sp[2]);
		err |= __get_user(off2, &sp[3]);
	}

	if (err)
		return err;

	if (off1 & PAGE_MASK)
		return -EOVERFLOW;

	pgoff = (off1 << (32 - PAGE_SHIFT)) | (off2 >> PAGE_SHIFT);

	if (!(flags & MAP_ANONYMOUS)) {
		if (!(file = fget(fd)))
			return -EBADF;

		/* Ok, bad taste hack follows, try to think in something else
		   when reading this */
		if (flags & IRIX_MAP_AUTOGROW) {
			unsigned long old_pos;
			long max_size = off2 + len;

			if (max_size > file->f_dentry->d_inode->i_size) {
				old_pos = sys_lseek (fd, max_size - 1, 0);
				sys_write (fd, (void __user *) "", 1);
				sys_lseek (fd, old_pos, 0);
			}
		}
	}

	flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);

	down_write(&current->mm->mmap_sem);
	error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
	up_write(&current->mm->mmap_sem);

	if (file)
		fput(file);

	return error;
}

asmlinkage int irix_dmi(struct pt_regs *regs)
{
	printk("[%s:%d] Wheee.. irix_dmi()\n",
	       current->comm, current->pid);

	return -EINVAL;
}

asmlinkage int irix_pread(int fd, char __user *buf, int cnt, int off64,
			  int off1, int off2)
{
	printk("[%s:%d] Wheee.. irix_pread(%d,%p,%d,%d,%d,%d)\n",
	       current->comm, current->pid, fd, buf, cnt, off64, off1, off2);

	return -EINVAL;
}

asmlinkage int irix_pwrite(int fd, char __user *buf, int cnt, int off64,
			   int off1, int off2)
{
	printk("[%s:%d] Wheee.. irix_pwrite(%d,%p,%d,%d,%d,%d)\n",
	       current->comm, current->pid, fd, buf, cnt, off64, off1, off2);

	return -EINVAL;
}

asmlinkage int irix_sgifastpath(int cmd, unsigned long arg0, unsigned long arg1,
				unsigned long arg2, unsigned long arg3,
				unsigned long arg4, unsigned long arg5)
{
	printk("[%s:%d] Wheee.. irix_fastpath(%d,%08lx,%08lx,%08lx,%08lx,"
	       "%08lx,%08lx)\n",
	       current->comm, current->pid, cmd, arg0, arg1, arg2,
	       arg3, arg4, arg5);

	return -EINVAL;
}

struct irix_statvfs64 {
	u32  f_bsize; u32 f_frsize;
	u64  f_blocks; u64 f_bfree; u64 f_bavail;
	u64  f_files; u64 f_ffree; u64 f_favail;
	u32  f_fsid;
	char f_basetype[16];
	u32  f_flag; u32 f_namemax;
	char f_fstr[32];
	u32  f_filler[16];
};

asmlinkage int irix_statvfs64(char __user *fname, struct irix_statvfs64 __user *buf)
{
	struct nameidata nd;
	struct kstatfs kbuf;
	int error, i;

	printk("[%s:%d] Wheee.. irix_statvfs64(%s,%p)\n",
	       current->comm, current->pid, fname, buf);
	if (!access_ok(VERIFY_WRITE, buf, sizeof(struct irix_statvfs64))) {
		error = -EFAULT;
		goto out;
	}

	error = user_path_walk(fname, &nd);
	if (error)
		goto out;
	error = vfs_statfs(nd.dentry, &kbuf);
	if (error)
		goto dput_and_out;

	error = __put_user(kbuf.f_bsize, &buf->f_bsize);
	error |= __put_user(kbuf.f_frsize, &buf->f_frsize);
	error |= __put_user(kbuf.f_blocks, &buf->f_blocks);
	error |= __put_user(kbuf.f_bfree, &buf->f_bfree);
	error |= __put_user(kbuf.f_bfree, &buf->f_bavail);  /* XXX hackety hack... */
	error |= __put_user(kbuf.f_files, &buf->f_files);
	error |= __put_user(kbuf.f_ffree, &buf->f_ffree);
	error |= __put_user(kbuf.f_ffree, &buf->f_favail);  /* XXX hackety hack... */
#ifdef __MIPSEB__
	error |= __put_user(kbuf.f_fsid.val[1], &buf->f_fsid);
#else
	error |= __put_user(kbuf.f_fsid.val[0], &buf->f_fsid);
#endif
	for(i = 0; i < 16; i++)
		error |= __put_user(0, &buf->f_basetype[i]);
	error |= __put_user(0, &buf->f_flag);
	error |= __put_user(kbuf.f_namelen, &buf->f_namemax);
	for(i = 0; i < 32; i++)
		error |= __put_user(0, &buf->f_fstr[i]);

dput_and_out:
	path_release(&nd);
out:
	return error;
}

asmlinkage int irix_fstatvfs64(int fd, struct irix_statvfs __user *buf)
{
	struct kstatfs kbuf;
	struct file *file;
	int error, i;

	printk("[%s:%d] Wheee.. irix_fstatvfs64(%d,%p)\n",
	       current->comm, current->pid, fd, buf);

	if (!access_ok(VERIFY_WRITE, buf, sizeof(struct irix_statvfs))) {
		error = -EFAULT;
		goto out;
	}
	if (!(file = fget(fd))) {
		error = -EBADF;
		goto out;
	}
	error = vfs_statfs(file->f_dentry, &kbuf);
	if (error)
		goto out_f;

	error = __put_user(kbuf.f_bsize, &buf->f_bsize);
	error |= __put_user(kbuf.f_frsize, &buf->f_frsize);
	error |= __put_user(kbuf.f_blocks, &buf->f_blocks);
	error |= __put_user(kbuf.f_bfree, &buf->f_bfree);
	error |= __put_user(kbuf.f_bfree, &buf->f_bavail);  /* XXX hackety hack... */
	error |= __put_user(kbuf.f_files, &buf->f_files);
	error |= __put_user(kbuf.f_ffree, &buf->f_ffree);
	error |= __put_user(kbuf.f_ffree, &buf->f_favail);  /* XXX hackety hack... */
#ifdef __MIPSEB__
	error |= __put_user(kbuf.f_fsid.val[1], &buf->f_fsid);
#else
	error |= __put_user(kbuf.f_fsid.val[0], &buf->f_fsid);
#endif
	for(i = 0; i < 16; i++)
		error |= __put_user(0, &buf->f_basetype[i]);
	error |= __put_user(0, &buf->f_flag);
	error |= __put_user(kbuf.f_namelen, &buf->f_namemax);
	error |= __clear_user(buf->f_fstr, sizeof(buf->f_fstr[i])) ? -EFAULT : 0;

out_f:
	fput(file);
out:
	return error;
}

asmlinkage int irix_getmountid(char __user *fname, unsigned long __user *midbuf)
{
	int err;

	printk("[%s:%d] irix_getmountid(%s, %p)\n",
	       current->comm, current->pid, fname, midbuf);
	if (!access_ok(VERIFY_WRITE, midbuf, (sizeof(unsigned long) * 4)))
		return -EFAULT;

	/*
	 * The idea with this system call is that when trying to determine
	 * 'pwd' and it's a toss-up for some reason, userland can use the
	 * fsid of the filesystem to try and make the right decision, but
	 * we don't have this so for now. XXX
	 */
	err = __put_user(0, &midbuf[0]);
	err |= __put_user(0, &midbuf[1]);
	err |= __put_user(0, &midbuf[2]);
	err |= __put_user(0, &midbuf[3]);

	return err;
}

asmlinkage int irix_nsproc(unsigned long entry, unsigned long mask,
			   unsigned long arg, unsigned long sp, int slen)
{
	printk("[%s:%d] Wheee.. irix_nsproc(%08lx,%08lx,%08lx,%08lx,%d)\n",
	       current->comm, current->pid, entry, mask, arg, sp, slen);

	return -EINVAL;
}

#undef DEBUG_GETDENTS

struct irix_dirent32 {
	u32  d_ino;
	u32  d_off;
	unsigned short  d_reclen;
	char d_name[1];
};

struct irix_dirent32_callback {
	struct irix_dirent32 __user *current_dir;
	struct irix_dirent32 __user *previous;
	int count;
	int error;
};

#define NAME_OFFSET32(de) ((int) ((de)->d_name - (char *) (de)))
#define ROUND_UP32(x) (((x)+sizeof(u32)-1) & ~(sizeof(u32)-1))

static int irix_filldir32(void *__buf, const char *name,
	int namlen, loff_t offset, ino_t ino, unsigned int d_type)
{
	struct irix_dirent32 __user *dirent;
	struct irix_dirent32_callback *buf = __buf;
	unsigned short reclen = ROUND_UP32(NAME_OFFSET32(dirent) + namlen + 1);
	int err = 0;

#ifdef DEBUG_GETDENTS
	printk("\nirix_filldir32[reclen<%d>namlen<%d>count<%d>]",
	       reclen, namlen, buf->count);
#endif
	buf->error = -EINVAL;	/* only used if we fail.. */
	if (reclen > buf->count)
		return -EINVAL;
	dirent = buf->previous;
	if (dirent)
		err = __put_user(offset, &dirent->d_off);
	dirent = buf->current_dir;
	err |= __put_user(dirent, &buf->previous);
	err |= __put_user(ino, &dirent->d_ino);
	err |= __put_user(reclen, &dirent->d_reclen);
	err |= copy_to_user((char __user *)dirent->d_name, name, namlen) ? -EFAULT : 0;
	err |= __put_user(0, &dirent->d_name[namlen]);
	dirent = (struct irix_dirent32 __user *) ((char __user *) dirent + reclen);

	buf->current_dir = dirent;
	buf->count -= reclen;

	return err;
}

asmlinkage int irix_ngetdents(unsigned int fd, void __user * dirent,
	unsigned int count, int __user *eob)
{
	struct file *file;
	struct irix_dirent32 __user *lastdirent;
	struct irix_dirent32_callback buf;
	int error;

#ifdef DEBUG_GETDENTS
	printk("[%s:%d] ngetdents(%d, %p, %d, %p) ", current->comm,
	       current->pid, fd, dirent, count, eob);
#endif
	error = -EBADF;
	file = fget(fd);
	if (!file)
		goto out;

	buf.current_dir = (struct irix_dirent32 __user *) dirent;
	buf.previous = NULL;
	buf.count = count;
	buf.error = 0;

	error = vfs_readdir(file, irix_filldir32, &buf);
	if (error < 0)
		goto out_putf;

	error = buf.error;
	lastdirent = buf.previous;
	if (lastdirent) {
		put_user(file->f_pos, &lastdirent->d_off);
		error = count - buf.count;
	}

	if (put_user(0, eob) < 0) {
		error = -EFAULT;
		goto out_putf;
	}

#ifdef DEBUG_GETDENTS
	printk("eob=%d returning %d\n", *eob, count - buf.count);
#endif
	error = count - buf.count;

out_putf:
	fput(file);
out:
	return error;
}

struct irix_dirent64 {
	u64            d_ino;
	u64            d_off;
	unsigned short d_reclen;
	char           d_name[1];
};

struct irix_dirent64_callback {
	struct irix_dirent64 __user *curr;
	struct irix_dirent64 __user *previous;
	int count;
	int error;
};

#define NAME_OFFSET64(de) ((int) ((de)->d_name - (char *) (de)))
#define ROUND_UP64(x) (((x)+sizeof(u64)-1) & ~(sizeof(u64)-1))

static int irix_filldir64(void *__buf, const char *name,
	int namlen, loff_t offset, ino_t ino, unsigned int d_type)
{
	struct irix_dirent64 __user *dirent;
	struct irix_dirent64_callback * buf = __buf;
	unsigned short reclen = ROUND_UP64(NAME_OFFSET64(dirent) + namlen + 1);
	int err = 0;

	if (!access_ok(VERIFY_WRITE, buf, sizeof(*buf)))
		return -EFAULT;

	if (__put_user(-EINVAL, &buf->error))	/* only used if we fail.. */
		return -EFAULT;
	if (reclen > buf->count)
		return -EINVAL;
	dirent = buf->previous;
	if (dirent)
		err = __put_user(offset, &dirent->d_off);
	dirent = buf->curr;
	buf->previous = dirent;
	err |= __put_user(ino, &dirent->d_ino);
	err |= __put_user(reclen, &dirent->d_reclen);
	err |= __copy_to_user((char __user *)dirent->d_name, name, namlen)
	       ? -EFAULT : 0;
	err |= __put_user(0, &dirent->d_name[namlen]);

	dirent = (struct irix_dirent64 __user *) ((char __user *) dirent + reclen);

	buf->curr = dirent;
	buf->count -= reclen;

	return err;
}

asmlinkage int irix_getdents64(int fd, void __user *dirent, int cnt)
{
	struct file *file;
	struct irix_dirent64 __user *lastdirent;
	struct irix_dirent64_callback buf;
	int error;

#ifdef DEBUG_GETDENTS
	printk("[%s:%d] getdents64(%d, %p, %d) ", current->comm,
	       current->pid, fd, dirent, cnt);
#endif
	error = -EBADF;
	if (!(file = fget(fd)))
		goto out;

	error = -EFAULT;
	if (!access_ok(VERIFY_WRITE, dirent, cnt))
		goto out_f;

	error = -EINVAL;
	if (cnt < (sizeof(struct irix_dirent64) + 255))
		goto out_f;

	buf.curr = (struct irix_dirent64 __user *) dirent;
	buf.previous = NULL;
	buf.count = cnt;
	buf.error = 0;
	error = vfs_readdir(file, irix_filldir64, &buf);
	if (error < 0)
		goto out_f;
	lastdirent = buf.previous;
	if (!lastdirent) {
		error = buf.error;
		goto out_f;
	}
	if (put_user(file->f_pos, &lastdirent->d_off))
		return -EFAULT;
#ifdef DEBUG_GETDENTS
	printk("returning %d\n", cnt - buf.count);
#endif
	error = cnt - buf.count;

out_f:
	fput(file);
out:
	return error;
}

asmlinkage int irix_ngetdents64(int fd, void __user *dirent, int cnt, int *eob)
{
	struct file *file;
	struct irix_dirent64 __user *lastdirent;
	struct irix_dirent64_callback buf;
	int error;

#ifdef DEBUG_GETDENTS
	printk("[%s:%d] ngetdents64(%d, %p, %d) ", current->comm,
	       current->pid, fd, dirent, cnt);
#endif
	error = -EBADF;
	if (!(file = fget(fd)))
		goto out;

	error = -EFAULT;
	if (!access_ok(VERIFY_WRITE, dirent, cnt) ||
	    !access_ok(VERIFY_WRITE, eob, sizeof(*eob)))
		goto out_f;

	error = -EINVAL;
	if (cnt < (sizeof(struct irix_dirent64) + 255))
		goto out_f;

	*eob = 0;
	buf.curr = (struct irix_dirent64 __user *) dirent;
	buf.previous = NULL;
	buf.count = cnt;
	buf.error = 0;
	error = vfs_readdir(file, irix_filldir64, &buf);
	if (error < 0)
		goto out_f;
	lastdirent = buf.previous;
	if (!lastdirent) {
		error = buf.error;
		goto out_f;
	}
	if (put_user(file->f_pos, &lastdirent->d_off))
		return -EFAULT;
#ifdef DEBUG_GETDENTS
	printk("eob=%d returning %d\n", *eob, cnt - buf.count);
#endif
	error = cnt - buf.count;

out_f:
	fput(file);
out:
	return error;
}

asmlinkage int irix_uadmin(unsigned long op, unsigned long func, unsigned long arg)
{
	int retval;

	switch (op) {
	case 1:
		/* Reboot */
		printk("[%s:%d] irix_uadmin: Wants to reboot...\n",
		       current->comm, current->pid);
		retval = -EINVAL;
		goto out;

	case 2:
		/* Shutdown */
		printk("[%s:%d] irix_uadmin: Wants to shutdown...\n",
		       current->comm, current->pid);
		retval = -EINVAL;
		goto out;

	case 4:
		/* Remount-root */
		printk("[%s:%d] irix_uadmin: Wants to remount root...\n",
		       current->comm, current->pid);
		retval = -EINVAL;
		goto out;

	case 8:
		/* Kill all tasks. */
		printk("[%s:%d] irix_uadmin: Wants to kill all tasks...\n",
		       current->comm, current->pid);
		retval = -EINVAL;
		goto out;

	case 256:
		/* Set magic mushrooms... */
		printk("[%s:%d] irix_uadmin: Wants to set magic mushroom[%d]...\n",
		       current->comm, current->pid, (int) func);
		retval = -EINVAL;
		goto out;

	default:
		printk("[%s:%d] irix_uadmin: Unknown operation [%d]...\n",
		       current->comm, current->pid, (int) op);
		retval = -EINVAL;
		goto out;
	};

out:
	return retval;
}

asmlinkage int irix_utssys(char __user *inbuf, int arg, int type, char __user *outbuf)
{
	int retval;

	switch(type) {
	case 0:
		/* uname() */
		retval = irix_uname((struct iuname __user *)inbuf);
		goto out;

	case 2:
		/* ustat() */
		printk("[%s:%d] irix_utssys: Wants to do ustat()\n",
		       current->comm, current->pid);
		retval = -EINVAL;
		goto out;

	case 3:
		/* fusers() */
		printk("[%s:%d] irix_utssys: Wants to do fusers()\n",
		       current->comm, current->pid);
		retval = -EINVAL;
		goto out;

	default:
		printk("[%s:%d] irix_utssys: Wants to do unknown type[%d]\n",
		       current->comm, current->pid, (int) type);
		retval = -EINVAL;
		goto out;
	}

out:
	return retval;
}

#undef DEBUG_FCNTL

#define IRIX_F_ALLOCSP 10

asmlinkage int irix_fcntl(int fd, int cmd, int arg)
{
	int retval;

#ifdef DEBUG_FCNTL
	printk("[%s:%d] irix_fcntl(%d, %d, %d) ", current->comm,
	       current->pid, fd, cmd, arg);
#endif
	if (cmd == IRIX_F_ALLOCSP){
		return 0;
	}
	retval = sys_fcntl(fd, cmd, arg);
#ifdef DEBUG_FCNTL
	printk("%d\n", retval);
#endif
	return retval;
}

asmlinkage int irix_ulimit(int cmd, int arg)
{
	int retval;

	switch(cmd) {
	case 1:
		printk("[%s:%d] irix_ulimit: Wants to get file size limit.\n",
		       current->comm, current->pid);
		retval = -EINVAL;
		goto out;

	case 2:
		printk("[%s:%d] irix_ulimit: Wants to set file size limit.\n",
		       current->comm, current->pid);
		retval = -EINVAL;
		goto out;

	case 3:
		printk("[%s:%d] irix_ulimit: Wants to get brk limit.\n",
		       current->comm, current->pid);
		retval = -EINVAL;
		goto out;

	case 4:
#if 0
		printk("[%s:%d] irix_ulimit: Wants to get fd limit.\n",
		       current->comm, current->pid);
		retval = -EINVAL;
		goto out;
#endif
		retval = current->signal->rlim[RLIMIT_NOFILE].rlim_cur;
		goto out;

	case 5:
		printk("[%s:%d] irix_ulimit: Wants to get txt offset.\n",
		       current->comm, current->pid);
		retval = -EINVAL;
		goto out;

	default:
		printk("[%s:%d] irix_ulimit: Unknown command [%d].\n",
		       current->comm, current->pid, cmd);
		retval = -EINVAL;
		goto out;
	}
out:
	return retval;
}

asmlinkage int irix_unimp(struct pt_regs *regs)
{
	printk("irix_unimp [%s:%d] v0=%d v1=%d a0=%08lx a1=%08lx a2=%08lx "
	       "a3=%08lx\n", current->comm, current->pid,
	       (int) regs->regs[2], (int) regs->regs[3],
	       regs->regs[4], regs->regs[5], regs->regs[6], regs->regs[7]);

	return -ENOSYS;
}
