This source file includes following definitions.
- strnlen_user
- get_max_hostname
- sys_sysmips
- sys_cachectl
1
2
3
4
5
6
7
8
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)
23 {
24 return strnlen(s, count);
25 }
26
27
28
29
30
31
32
33 static inline int
34 get_max_hostname(unsigned long address)
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)
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
100
101 asmlinkage int
102 sys_cachectl(char *addr, int nbytes, int op)
103 {
104 return -ENOSYS;
105 }