patch-2.1.44 linux/arch/mips/kernel/sysmips.c

Next file: linux/arch/mips/kernel/time.c
Previous file: linux/arch/mips/kernel/sysirix.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.43/linux/arch/mips/kernel/sysmips.c linux/arch/mips/kernel/sysmips.c
@@ -5,7 +5,9 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (C) 1995 by Ralf Baechle
+ * Copyright (C) 1995, 1996, 1997 by Ralf Baechle
+ *
+ * $Id: sysmips.c,v 1.4 1997/06/30 15:52:37 ralf Exp $
  */
 #include <linux/errno.h>
 #include <linux/linkage.h>
@@ -17,14 +19,9 @@
 #include <linux/utsname.h>
 
 #include <asm/cachectl.h>
-#include <asm/segment.h>
+#include <asm/pgtable.h>
 #include <asm/sysmips.h>
-
-static inline size_t
-strnlen_user(const char *s, size_t count)
-{
-	return strnlen(s, count);
-}
+#include <asm/uaccess.h>
 
 /*
  * How long a hostname can we get from user space?
@@ -37,7 +34,7 @@
 {
 	struct vm_area_struct * vma;
 
-	vma = find_vma(current, address);
+	vma = find_vma(current->mm, address);
 	if (!vma || vma->vm_start > address || !(vma->vm_flags & VM_READ))
 		return -EFAULT;
 	address = vma->vm_end - address;
@@ -54,51 +51,62 @@
 {
 	int	*p;
 	char	*name;
-	int	flags, len, retval = -EINVAL;
+	int	flags, tmp, len, retval;
 
 	lock_kernel();
 	switch(cmd)
 	{
 	case SETNAME:
-		retval = -EPERM;
-		if (!suser())
+		if (!suser()) {
+			retval = -EPERM;
 			goto out;
+		}
 		name = (char *) arg1;
-		len = get_max_hostname((unsigned long)name);
-		retval = len;
+		len = strlen_user(name);
 		if (len < 0)
+			retval = len;
 			goto out;
-		len = strnlen_user(name, retval);
-		retval = -EINVAL;
 		if (len == 0 || len > __NEW_UTS_LEN)
+			retval = -EINVAL;
 			goto out;
-		memcpy_fromfs(system_utsname.nodename, name, len);
+		copy_from_user(system_utsname.nodename, name, len);
 		system_utsname.nodename[len] = '\0';
 		retval = 0;
 		goto out;
+
 	case MIPS_ATOMIC_SET:
+		/* This is broken in case of page faults and SMP ...
+		   Risc/OS fauls after maximum 20 tries with EAGAIN.  */
 		p = (int *) arg1;
-		retval = -EINVAL;
-		if(verify_area(VERIFY_WRITE, p, sizeof(*p)))
+		retval = verify_area(VERIFY_WRITE, p, sizeof(*p));
+		if (retval)
 			goto out;
-		save_flags(flags);
-		cli();
+		save_and_cli(flags);
 		retval = *p;
 		*p = arg2;
 		restore_flags(flags);
 		goto out;
+
 	case MIPS_FIXADE:
-		if (arg1)
-			current->tss.mflags |= MF_FIXADE;
-		else
-			current->tss.mflags |= MF_FIXADE;
+		tmp = current->tss.mflags & ~3;
+		current->tss.mflags = tmp | (arg1 & 3);
 		retval = 0;
 		goto out;
+
 	case FLUSH_CACHE:
-		sys_cacheflush(0, ~0, BCACHE);
+		flush_cache_all();
 		retval = 0;
 		goto out;
+
+	case MIPS_RDNVRAM:
+		retval = -EIO;
+		goto out;
+
+	default:
+		retval = -EINVAL;
+		goto out;
 	}
+
 out:
 	unlock_kernel();
 	return retval;

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov