mkfs: move directory entry manipulation
[minix.git] / kernel / system / do_sysctl.c
blob5bc6b100a711c56fbc8727fc13184b347eedc27a
1 /* The kernel call implemented in this file:
2 * m_type: SYS_SYSCTL
4 * The parameters for this kernel call are:
5 * SYSCTL_CODE request
6 * and then request-specific arguments in SYSCTL_ARG1 and SYSCTL_ARG2.
7 */
9 #include "kernel/system.h"
12 /*===========================================================================*
13 * do_sysctl *
14 *===========================================================================*/
15 int do_sysctl(struct proc * caller, message * m_ptr)
17 vir_bytes len, buf;
18 static char mybuf[DIAG_BUFSIZE];
19 int s, i, proc_nr;
21 switch (m_ptr->SYSCTL_CODE) {
22 case SYSCTL_CODE_DIAG:
23 buf = (vir_bytes) m_ptr->SYSCTL_ARG1;
24 len = (vir_bytes) m_ptr->SYSCTL_ARG2;
25 if(len < 1 || len > DIAG_BUFSIZE) {
26 printf("do_sysctl: diag for %d: len %d out of range\n",
27 caller->p_endpoint, len);
28 return EINVAL;
30 if((s=data_copy_vmcheck(caller, caller->p_endpoint, buf, KERNEL,
31 (vir_bytes) mybuf, len)) != OK) {
32 printf("do_sysctl: diag for %d: len %d: copy failed: %d\n",
33 caller->p_endpoint, len, s);
34 return s;
36 for(i = 0; i < len; i++)
37 kputc(mybuf[i]);
38 kputc(END_OF_KMESS);
39 return OK;
40 case SYSCTL_CODE_STACKTRACE:
41 if(!isokendpt(m_ptr->SYSCTL_ARG2, &proc_nr))
42 return EINVAL;
43 proc_stacktrace(proc_addr(proc_nr));
44 return OK;
45 default:
46 printf("do_sysctl: invalid request %d\n", m_ptr->SYSCTL_CODE);
47 return(EINVAL);