root/arch/mips/kernel/sysmips.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. strnlen_user
  2. get_max_hostname
  3. sys_sysmips
  4. sys_cachectl

   1 /*
   2  * MIPS specific syscalls
   3  *
   4  * This file is subject to the terms and conditions of the GNU General Public
   5  * License.  See the file "COPYING" in the main directory of this archive
   6  * for more details.
   7  *
   8  * Copyright (C) 1995 by Ralf Baechle
   9  */
  10 #include <linux/errno.h>
  11 #include <linux/linkage.h>
  12 #include <linux/mm.h>
  13 #include <linux/sched.h>
  14 #include <linux/string.h>
  15 #include <linux/utsname.h>
  16 
  17 #include <asm/cachectl.h>
  18 #include <asm/segment.h>
  19 #include <asm/sysmips.h>
  20 
  21 static inline size_t
  22 strnlen_user(const char *s, size_t count)
     /* [previous][next][first][last][top][bottom][index][help] */
  23 {
  24         return strnlen(s, count);
  25 }
  26 
  27 /*
  28  * How long a hostname can we get from user space?
  29  *  -EFAULT if invalid area or too long
  30  *  0 if ok
  31  *  >0 EFAULT after xx bytes
  32  */
  33 static inline int
  34 get_max_hostname(unsigned long address)
     /* [previous][next][first][last][top][bottom][index][help] */
  35 {
  36         struct vm_area_struct * vma;
  37 
  38         vma = find_vma(current, address);
  39         if (!vma || vma->vm_start > address || !(vma->vm_flags & VM_READ))
  40                 return -EFAULT;
  41         address = vma->vm_end - address;
  42         if (address > PAGE_SIZE)
  43                 return 0;
  44         if (vma->vm_next && vma->vm_next->vm_start == vma->vm_end &&
  45            (vma->vm_next->vm_flags & VM_READ))
  46                 return 0;
  47         return address;
  48 }
  49 
  50 asmlinkage int
  51 sys_sysmips(int cmd, int arg1, int arg2, int arg3)
     /* [previous][next][first][last][top][bottom][index][help] */
  52 {
  53         int     *p;
  54         char    *name;
  55         int     flags, len, retval = -EINVAL;
  56 
  57         switch(cmd)
  58         {
  59         case SETNAME:
  60                 if (!suser())
  61                         return -EPERM;
  62                 name = (char *) arg1;
  63                 len = get_max_hostname((unsigned long)name);
  64                 if (retval < 0)
  65                         return len;
  66                 len = strnlen_user(name, retval);
  67                 if (len == 0 || len > __NEW_UTS_LEN)
  68                         return -EINVAL;
  69                 memcpy_fromfs(system_utsname.nodename, name, len);
  70                 system_utsname.nodename[len] = '\0';
  71                 return 0;
  72         case MIPS_ATOMIC_SET:
  73                 p = (int *) arg1;
  74                 retval = verify_area(VERIFY_WRITE, p, sizeof(*p));
  75                 if(retval)
  76                         return -EINVAL;
  77                 save_flags(flags);
  78                 cli();
  79                 retval = *p;
  80                 *p = arg2;
  81                 restore_flags(flags);
  82                 return retval;
  83         case MIPS_FIXADE:
  84                 if (arg1)
  85                         current->tss.mflags |= MF_FIXADE;
  86                 else
  87                         current->tss.mflags |= MF_FIXADE;
  88                 retval = 0;
  89                 break;
  90         case FLUSH_CACHE:
  91                 sys_cacheflush(0, ~0, BCACHE);
  92                 break;
  93         }
  94 
  95         return retval;
  96 }
  97 
  98 /*
  99  * No implemented yet ...
 100  */
 101 asmlinkage int
 102 sys_cachectl(char *addr, int nbytes, int op)
     /* [previous][next][first][last][top][bottom][index][help] */
 103 {
 104         return -ENOSYS;
 105 }

/* [previous][next][first][last][top][bottom][index][help] */