patch-2.3.48 linux/arch/mips/kernel/sysirix.c
Next file: linux/arch/mips/kernel/sysmips.c
Previous file: linux/arch/mips/kernel/syscalls.h
Back to the patch index
Back to the overall index
- Lines: 269
- Date:
Thu Feb 24 22:52:30 2000
- Orig file:
v2.3.47/linux/arch/mips/kernel/sysirix.c
- Orig date:
Fri Jun 25 17:40:12 1999
diff -u --recursive --new-file v2.3.47/linux/arch/mips/kernel/sysirix.c linux/arch/mips/kernel/sysirix.c
@@ -1,4 +1,4 @@
-/* $Id: sysirix.c,v 1.20 1999/06/17 13:25:48 ralf Exp $
+/* $Id: sysirix.c,v 1.24 2000/02/05 06:47:08 ralf Exp $
*
* sysirix.c: IRIX system call emulation.
*
@@ -27,13 +27,15 @@
#include <asm/ptrace.h>
#include <asm/page.h>
-#include <asm/pgtable.h>
+#include <asm/pgalloc.h>
#include <asm/uaccess.h>
#include <asm/sgialib.h>
#include <asm/inventory.h>
/* 2,526 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 */
@@ -45,7 +47,6 @@
int base = 0;
int error = 0;
- lock_kernel();
if(regs->regs[2] == 1000)
base = 1;
cmd = regs->regs[base + 4];
@@ -55,8 +56,7 @@
break;
case MP_NPROCS:
case MP_NAPROCS:
- error = 1;
- error = NR_CPUS;
+ error = smp_num_cpus;
break;
default:
printk("SYSMP[%s:%ld]: Unsupported opcode %d\n",
@@ -65,7 +65,6 @@
break;
}
- unlock_kernel();
return error;
}
@@ -100,7 +99,7 @@
case PR_MAXPROCS:
printk("irix_prctl[%s:%ld]: Wants PR_MAXPROCS\n",
current->comm, current->pid);
- error = NR_TASKS;
+ error = max_threads;
break;
case PR_ISBLOCKED: {
@@ -113,7 +112,7 @@
error = -ESRCH;
break;
}
- error = (task->next_run ? 0 : 1);
+ error = (task->run_list.next != NULL);
/* Can _your_ OS find this out that fast? */
break;
}
@@ -359,7 +358,7 @@
retval = (MAX_ARG_PAGES >> 4); /* XXX estimate... */
goto out;
case 2:
- retval = NR_TASKS;
+ retval = max_threads;
goto out;
case 3:
retval = HZ;
@@ -1104,26 +1103,27 @@
struct file *file = NULL;
unsigned long retval;
- down(¤t->mm->mmap_sem);
lock_kernel();
- if(!(flags & MAP_ANONYMOUS)) {
- if(!(file = fget(fd))) {
+ if (!(flags & MAP_ANONYMOUS)) {
+ if (!(file = fget(fd))) {
retval = -EBADF;
goto out;
}
- /* Ok, bad taste hack follows, try to think in something else when reading this */
- if (flags & IRIX_MAP_AUTOGROW){
+
+ /* 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){
+ if (max_size > file->f_dentry->d_inode->i_size) {
old_pos = sys_lseek (fd, max_size - 1, 0);
sys_write (fd, "", 1);
sys_lseek (fd, old_pos, 0);
}
}
}
-
+
flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
retval = do_mmap(file, addr, len, prot, flags, offset);
@@ -1132,7 +1132,7 @@
out:
unlock_kernel();
- up(¤t->mm->mmap_sem);
+
return retval;
}
@@ -1684,23 +1684,24 @@
return retval;
}
-extern asmlinkage unsigned long sys_mmap(unsigned long addr, size_t len, int prot,
- int flags, int fd, off_t offset);
+extern asmlinkage unsigned long
+sys_mmap(unsigned long addr, size_t len, int prot, int flags, int fd,
+ off_t offset);
asmlinkage int irix_mmap64(struct pt_regs *regs)
{
int len, prot, flags, fd, off1, off2, error, base = 0;
- unsigned long addr, *sp;
- struct file *file;
-
+ unsigned long addr, pgoff, *sp;
+ struct file *file = NULL;
+
lock_kernel();
- if(regs->regs[2] == 1000)
+ 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) {
+ if (!base) {
flags = regs->regs[base + 7];
error = verify_area(VERIFY_READ, sp, (4 * sizeof(unsigned long)));
if(error)
@@ -1717,63 +1718,72 @@
__get_user(off1, &sp[2]);
__get_user(off2, &sp[3]);
}
- if(off1) {
- error = -EINVAL;
+
+ if (off1 & PAGE_MASK) {
+ error = -EOVERFLOW;
goto out;
}
- if(!(flags & MAP_ANONYMOUS)) {
- if(!(file = fcheck(fd))) {
+ pgoff = (off1 << (32 - PAGE_SHIFT)) | (off2 >> PAGE_SHIFT);
+
+ if (!(flags & MAP_ANONYMOUS)) {
+ if (!(file = fcheck(fd))) {
error = -EBADF;
goto out;
}
-
- /* Ok, bad taste hack follows, try to think in something else when reading this */
- if (flags & IRIX_MAP_AUTOGROW){
+
+ /* 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){
+
+ if (max_size > file->f_dentry->d_inode->i_size) {
old_pos = sys_lseek (fd, max_size - 1, 0);
sys_write (fd, "", 1);
sys_lseek (fd, old_pos, 0);
}
}
}
-
- error = sys_mmap(addr, (size_t) len, prot, flags, fd, off2);
+
+ flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
+
+ down(¤t->mm->mmap_sem);
+ error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
+ up(¤t->mm->mmap_sem);
+
+ if (file)
+ fput(file);
out:
unlock_kernel();
+
return error;
}
asmlinkage int irix_dmi(struct pt_regs *regs)
{
- lock_kernel();
printk("[%s:%ld] Wheee.. irix_dmi()\n",
current->comm, current->pid);
- unlock_kernel();
+
return -EINVAL;
}
asmlinkage int irix_pread(int fd, char *buf, int cnt, int off64,
int off1, int off2)
{
- lock_kernel();
printk("[%s:%ld] Wheee.. irix_pread(%d,%p,%d,%d,%d,%d)\n",
current->comm, current->pid, fd, buf, cnt, off64, off1, off2);
- unlock_kernel();
+
return -EINVAL;
}
asmlinkage int irix_pwrite(int fd, char *buf, int cnt, int off64,
int off1, int off2)
{
- lock_kernel();
printk("[%s:%ld] Wheee.. irix_pwrite(%d,%p,%d,%d,%d,%d)\n",
current->comm, current->pid, fd, buf, cnt, off64, off1, off2);
- unlock_kernel();
+
return -EINVAL;
}
@@ -1781,12 +1791,11 @@
unsigned long arg2, unsigned long arg3,
unsigned long arg4, unsigned long arg5)
{
- lock_kernel();
printk("[%s:%ld] Wheee.. irix_fastpath(%d,%08lx,%08lx,%08lx,%08lx,"
"%08lx,%08lx)\n",
current->comm, current->pid, cmd, arg0, arg1, arg2,
arg3, arg4, arg5);
- unlock_kernel();
+
return -EINVAL;
}
@@ -2414,12 +2423,10 @@
asmlinkage int irix_unimp(struct pt_regs *regs)
{
- lock_kernel();
printk("irix_unimp [%s:%ld] 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]);
- unlock_kernel();
return -ENOSYS;
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)