This source file includes following definitions.
- sys_reboot
- __stack_smash_handler
- scdebug_call
- scdebug_ret
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 #include <sys/param.h>
36 #include <sys/systm.h>
37 #include <sys/kernel.h>
38 #include <sys/proc.h>
39 #include <sys/reboot.h>
40 #include <uvm/uvm_extern.h>
41 #include <sys/sysctl.h>
42 #include <sys/mount.h>
43 #include <sys/syscallargs.h>
44
45
46 int
47 sys_reboot(struct proc *p, void *v, register_t *retval)
48 {
49 struct sys_reboot_args
50
51 *uap = v;
52 int error;
53
54 if ((error = suser(p, 0)) != 0)
55 return (error);
56 boot(SCARG(uap, opt));
57 return (0);
58 }
59
60 #if !defined(NO_PROPOLICE)
61 void __stack_smash_handler(char [], int __attribute__((unused)));
62
63 void
64 __stack_smash_handler(char func[], int damaged)
65 {
66 panic("smashed stack in %s", func);
67 }
68 #endif
69
70 #ifdef SYSCALL_DEBUG
71 #define SCDEBUG_CALLS 0x0001
72 #define SCDEBUG_RETURNS 0x0002
73 #define SCDEBUG_ALL 0x0004
74 #define SCDEBUG_SHOWARGS 0x0008
75
76 int scdebug = SCDEBUG_CALLS|SCDEBUG_RETURNS|SCDEBUG_SHOWARGS;
77
78 void
79 scdebug_call(struct proc *p, register_t code, register_t args[])
80 {
81 struct sysent *sy;
82 struct emul *em;
83 int i;
84
85 if (!(scdebug & SCDEBUG_CALLS))
86 return;
87
88 em = p->p_emul;
89 sy = &em->e_sysent[code];
90 if (!(scdebug & SCDEBUG_ALL || code < 0 || code >= em->e_nsysent ||
91 sy->sy_call == sys_nosys))
92 return;
93
94 printf("proc %d (%s): %s num ", p->p_pid, p->p_comm, em->e_name);
95 if (code < 0 || code >= em->e_nsysent)
96 printf("OUT OF RANGE (%d)", code);
97 else {
98 printf("%d call: %s", code, em->e_syscallnames[code]);
99 if (scdebug & SCDEBUG_SHOWARGS) {
100 printf("(");
101 for (i = 0; i < sy->sy_argsize / sizeof(register_t);
102 i++)
103 printf("%s0x%lx", i == 0 ? "" : ", ",
104 (long)args[i]);
105 printf(")");
106 }
107 }
108 printf("\n");
109 }
110
111 void
112 scdebug_ret(struct proc *p, register_t code, int error, register_t retval[])
113 {
114 struct sysent *sy;
115 struct emul *em;
116
117 if (!(scdebug & SCDEBUG_RETURNS))
118 return;
119
120 em = p->p_emul;
121 sy = &em->e_sysent[code];
122 if (!(scdebug & SCDEBUG_ALL || code < 0 || code >= em->e_nsysent ||
123 sy->sy_call == sys_nosys))
124 return;
125
126 printf("proc %d (%s): %s num ", p->p_pid, p->p_comm, em->e_name);
127 if (code < 0 || code >= em->e_nsysent)
128 printf("OUT OF RANGE (%d)", code);
129 else
130 printf("%d ret: err = %d, rv = 0x%lx,0x%lx", code,
131 error, (long)retval[0], (long)retval[1]);
132 printf("\n");
133 }
134 #endif