patch-2.4.0-test3 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
- Lines: 97
- Date:
Sun Jul 9 22:18:15 2000
- Orig file:
v2.4.0-test2/linux/arch/mips/kernel/sysmips.c
- Orig date:
Tue May 23 15:31:33 2000
diff -u --recursive --new-file v2.4.0-test2/linux/arch/mips/kernel/sysmips.c linux/arch/mips/kernel/sysmips.c
@@ -5,9 +5,7 @@
* License. See the file "COPYING" in the main directory of this archive
* for more details.
*
- * Copyright (C) 1995, 1996, 1997 by Ralf Baechle
- *
- * $Id: sysmips.c,v 1.8 2000/02/05 06:47:08 ralf Exp $
+ * Copyright (C) 1995, 1996, 1997, 2000 by Ralf Baechle
*/
#include <linux/errno.h>
#include <linux/linkage.h>
@@ -51,45 +49,48 @@
{
int *p;
char *name;
- int flags, tmp, len, retval;
+ int flags, tmp, len, retval, errno;
+
+ switch(cmd) {
+ case SETNAME: {
+ char nodename[__NEW_UTS_LEN + 1];
- lock_kernel();
- switch(cmd)
- {
- case SETNAME:
- retval = -EPERM;
if (!capable(CAP_SYS_ADMIN))
- goto out;
+ return -EPERM;
name = (char *) arg1;
- len = strlen_user(name);
-
- retval = len;
- if (len < 0)
- goto out;
-
- retval = -EINVAL;
- if (len == 0 || len > __NEW_UTS_LEN)
- goto out;
- /* Fiiiixmeeee... */
- copy_from_user(system_utsname.nodename, name, len);
- system_utsname.nodename[len] = '\0';
- retval = 0;
- goto out;
+ len = strncpy_from_user(nodename, name, sizeof(nodename));
+ if (len < 0)
+ return -EFAULT;
+
+ down_write(&uts_sem);
+ strncpy(system_utsname.nodename, name, len);
+ up_write(&uts_sem);
+ system_utsname.nodename[len] = '\0';
+ return 0;
+ }
- case MIPS_ATOMIC_SET:
+ case MIPS_ATOMIC_SET: {
/* This is broken in case of page faults and SMP ...
- Risc/OS fauls after maximum 20 tries with EAGAIN. */
+ Risc/OS faults after maximum 20 tries with EAGAIN. */
+ unsigned int tmp;
+
p = (int *) arg1;
- retval = verify_area(VERIFY_WRITE, p, sizeof(*p));
- if (retval)
- goto out;
+ errno = verify_area(VERIFY_WRITE, p, sizeof(*p));
+ if (errno)
+ return errno;
+ errno = 0;
save_and_cli(flags);
- retval = *p;
- *p = arg2;
+ errno |= __get_user(tmp, p);
+ errno |= __put_user(arg2, p);
restore_flags(flags);
- goto out;
+
+ if (errno)
+ return tmp;
+
+ return tmp; /* This is broken ... */
+ }
case MIPS_FIXADE:
tmp = current->thread.mflags & ~3;
@@ -112,7 +113,6 @@
}
out:
- unlock_kernel();
return retval;
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)