From: David van Moolenbroek Date: Fri, 20 Sep 2013 22:58:46 +0000 (+0200) Subject: Rename SYSCTL kernel call to DIAGCTL X-Git-Tag: v3.3.0~560 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/verify-sign/tz-link.htm?a=commitdiff_plain;h=de975579a44a6940bca35c08c844942c083117aa;p=minix.git Rename SYSCTL kernel call to DIAGCTL Change-Id: I1b17373f01808d887dcbeab493838946fbef4ef6 --- diff --git a/include/minix/com.h b/include/minix/com.h index e0985618f..8534feb7d 100644 --- a/include/minix/com.h +++ b/include/minix/com.h @@ -283,7 +283,8 @@ # define SYS_SETTIME (KERNEL_CALL + 40) /* sys_settime() */ # define SYS_VMCTL (KERNEL_CALL + 43) /* sys_vmctl() */ -# define SYS_SYSCTL (KERNEL_CALL + 44) /* sys_sysctl() */ + +# define SYS_DIAGCTL (KERNEL_CALL + 44) /* sys_diagctl() */ # define SYS_VTIMER (KERNEL_CALL + 45) /* sys_vtimer() */ # define SYS_RUNCTL (KERNEL_CALL + 46) /* sys_runctl() */ @@ -309,7 +310,7 @@ #define SYS_BASIC_CALLS \ SYS_EXIT, SYS_SAFECOPYFROM, SYS_SAFECOPYTO, SYS_VSAFECOPY, SYS_GETINFO, \ SYS_TIMES, SYS_SETALARM, SYS_SETGRANT, \ - SYS_PROFBUF, SYS_SYSCTL, SYS_STATECTL, SYS_SAFEMEMSET + SYS_PROFBUF, SYS_DIAGCTL, SYS_STATECTL, SYS_SAFEMEMSET /* Field names for SYS_MEMSET. */ #define MEM_PTR m2_p1 /* base */ @@ -582,12 +583,12 @@ #define VMCTL_CLEARMAPCACHE 32 #define VMCTL_BOOTINHIBIT_CLEAR 33 -/* Codes and field names for SYS_SYSCTL. */ -#define SYSCTL_CODE m1_i1 /* SYSCTL_CODE_* below */ -#define SYSCTL_ARG1 m1_p1 -#define SYSCTL_ARG2 m1_i2 -#define SYSCTL_CODE_DIAG 1 /* Print diagnostics. */ -#define SYSCTL_CODE_STACKTRACE 2 /* Print process stack. */ +/* Codes and field names for SYS_DIAGCTL. */ +#define DIAGCTL_CODE m1_i1 /* DIAGCTL_CODE_* below */ +#define DIAGCTL_ARG1 m1_p1 +#define DIAGCTL_ARG2 m1_i2 +#define DIAGCTL_CODE_DIAG 1 /* Print diagnostics. */ +#define DIAGCTL_CODE_STACKTRACE 2 /* Print process stack. */ #define DIAG_BUFSIZE (80*25) /* Field names for SYS_VTIMER. */ diff --git a/include/minix/syslib.h b/include/minix/syslib.h index 3d1d1084b..dad156080 100644 --- a/include/minix/syslib.h +++ b/include/minix/syslib.h @@ -69,8 +69,8 @@ int sys_vmctl_enable_paging(void * data); int sys_readbios(phys_bytes address, void *buf, size_t size); int sys_settime(int now, clockid_t clk_id, time_t sec, long nsec); int sys_stime(time_t boottime); -int sys_sysctl(int ctl, char *arg1, int arg2); -int sys_sysctl_stacktrace(endpoint_t who); +int sys_diagctl(int ctl, char *arg1, int arg2); +int sys_diagctl_stacktrace(endpoint_t who); int sys_vmctl_get_mapping(int index, phys_bytes *addr, phys_bytes *len, int *flags); int sys_vmctl_reply_mapping(int index, vir_bytes addr); diff --git a/kernel/proto.h b/kernel/proto.h index 6ebe443b4..ac2b55625 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -137,8 +137,8 @@ void hook_ipc_clear(struct proc *proc); int verify_grant(endpoint_t, endpoint_t, cp_grant_id_t, vir_bytes, int, vir_bytes, vir_bytes *, endpoint_t *); -/* system/do_sysctl.c */ -int do_sysctl(struct proc * caller, message *m); +/* system/do_diagctl.c */ +int do_diagctl(struct proc * caller, message *m); #if SPROFILE /* profile.c */ diff --git a/kernel/system.c b/kernel/system.c index 3e1eff6ed..084d47760 100644 --- a/kernel/system.c +++ b/kernel/system.c @@ -241,7 +241,7 @@ void system_init(void) /* System control. */ map(SYS_ABORT, do_abort); /* abort MINIX */ map(SYS_GETINFO, do_getinfo); /* request system information */ - map(SYS_SYSCTL, do_sysctl); /* misc system manipulation */ + map(SYS_DIAGCTL, do_diagctl); /* diagnostics-related functionality */ /* Profiling. */ map(SYS_SPROF, do_sprofile); /* start/stop statistical profiling */ diff --git a/kernel/system/Makefile.inc b/kernel/system/Makefile.inc index e90b47640..431bbe584 100644 --- a/kernel/system/Makefile.inc +++ b/kernel/system/Makefile.inc @@ -25,7 +25,7 @@ SRCS+= \ do_privctl.c \ do_safecopy.c \ do_safememset.c \ - do_sysctl.c \ + do_diagctl.c \ do_getksig.c \ do_endksig.c \ do_kill.c \ diff --git a/kernel/system/do_sysctl.c b/kernel/system/do_diagctl.c similarity index 55% rename from kernel/system/do_sysctl.c rename to kernel/system/do_diagctl.c index 5bc6b100a..a75051b9d 100644 --- a/kernel/system/do_sysctl.c +++ b/kernel/system/do_diagctl.c @@ -1,35 +1,35 @@ /* The kernel call implemented in this file: - * m_type: SYS_SYSCTL + * m_type: SYS_DIAGCTL * * The parameters for this kernel call are: - * SYSCTL_CODE request - * and then request-specific arguments in SYSCTL_ARG1 and SYSCTL_ARG2. + * DIAGCTL_CODE request + * and then request-specific arguments in DIAGCTL_ARG1 and DIAGCTL_ARG2. */ #include "kernel/system.h" /*===========================================================================* - * do_sysctl * + * do_diagctl * *===========================================================================*/ -int do_sysctl(struct proc * caller, message * m_ptr) +int do_diagctl(struct proc * caller, message * m_ptr) { vir_bytes len, buf; static char mybuf[DIAG_BUFSIZE]; int s, i, proc_nr; - switch (m_ptr->SYSCTL_CODE) { - case SYSCTL_CODE_DIAG: - buf = (vir_bytes) m_ptr->SYSCTL_ARG1; - len = (vir_bytes) m_ptr->SYSCTL_ARG2; + switch (m_ptr->DIAGCTL_CODE) { + case DIAGCTL_CODE_DIAG: + buf = (vir_bytes) m_ptr->DIAGCTL_ARG1; + len = (vir_bytes) m_ptr->DIAGCTL_ARG2; if(len < 1 || len > DIAG_BUFSIZE) { - printf("do_sysctl: diag for %d: len %d out of range\n", + printf("do_diagctl: diag for %d: len %d out of range\n", caller->p_endpoint, len); return EINVAL; } if((s=data_copy_vmcheck(caller, caller->p_endpoint, buf, KERNEL, (vir_bytes) mybuf, len)) != OK) { - printf("do_sysctl: diag for %d: len %d: copy failed: %d\n", + printf("do_diagctl: diag for %d: len %d: copy failed: %d\n", caller->p_endpoint, len, s); return s; } @@ -37,13 +37,13 @@ int do_sysctl(struct proc * caller, message * m_ptr) kputc(mybuf[i]); kputc(END_OF_KMESS); return OK; - case SYSCTL_CODE_STACKTRACE: - if(!isokendpt(m_ptr->SYSCTL_ARG2, &proc_nr)) + case DIAGCTL_CODE_STACKTRACE: + if(!isokendpt(m_ptr->DIAGCTL_ARG2, &proc_nr)) return EINVAL; proc_stacktrace(proc_addr(proc_nr)); return OK; default: - printf("do_sysctl: invalid request %d\n", m_ptr->SYSCTL_CODE); + printf("do_diagctl: invalid request %d\n", m_ptr->DIAGCTL_CODE); return(EINVAL); } } diff --git a/lib/libsys/Makefile b/lib/libsys/Makefile index 5d5759730..ba6d96018 100644 --- a/lib/libsys/Makefile +++ b/lib/libsys/Makefile @@ -38,6 +38,7 @@ SRCS+= \ sys_abort.c \ sys_clear.c \ sys_cprof.c \ + sys_diagctl.c \ sys_endsig.c \ sys_exec.c \ sys_exit.c \ @@ -66,7 +67,6 @@ SRCS+= \ sys_sprof.c \ sys_statectl.c \ sys_stime.c \ - sys_sysctl.c \ sys_times.c \ sys_trace.c \ sys_umap.c \ diff --git a/lib/libsys/kputc.c b/lib/libsys/kputc.c index 9e7301272..5e3fbbf40 100644 --- a/lib/libsys/kputc.c +++ b/lib/libsys/kputc.c @@ -20,7 +20,7 @@ void kputc(int c) static int buf_count; /* # characters in the buffer */ if ((c == 0 && buf_count > 0) || buf_count == sizeof(print_buf)) { - sys_sysctl(SYSCTL_CODE_DIAG, print_buf, buf_count); + sys_diagctl(DIAGCTL_CODE_DIAG, print_buf, buf_count); buf_count = 0; } if (c != 0) { diff --git a/lib/libsys/sys_diagctl.c b/lib/libsys/sys_diagctl.c new file mode 100644 index 000000000..a74777c49 --- /dev/null +++ b/lib/libsys/sys_diagctl.c @@ -0,0 +1,19 @@ + +#include "syslib.h" + +int sys_diagctl(int code, char *arg1, int arg2) +{ + message m; + + m.DIAGCTL_CODE = code; + m.DIAGCTL_ARG1 = arg1; + m.DIAGCTL_ARG2 = arg2; + + return(_kernel_call(SYS_DIAGCTL, &m)); +} + +int sys_diagctl_stacktrace(endpoint_t ep) +{ + return sys_diagctl(DIAGCTL_CODE_STACKTRACE, NULL, ep); +} + diff --git a/lib/libsys/sys_sysctl.c b/lib/libsys/sys_sysctl.c deleted file mode 100644 index 443a9cc97..000000000 --- a/lib/libsys/sys_sysctl.c +++ /dev/null @@ -1,20 +0,0 @@ - -#include "syslib.h" - -int sys_sysctl(int code, char *arg1, int arg2) -{ - message m; - - m.SYSCTL_CODE = code; - m.SYSCTL_ARG1 = arg1; - m.SYSCTL_ARG2 = arg2; - - return(_kernel_call(SYS_SYSCTL, &m)); - -} - -int sys_sysctl_stacktrace(endpoint_t ep) -{ - return sys_sysctl(SYSCTL_CODE_STACKTRACE, NULL, ep); -} - diff --git a/servers/is/dmp_kernel.c b/servers/is/dmp_kernel.c index 6c6a318b2..159927821 100644 --- a/servers/is/dmp_kernel.c +++ b/servers/is/dmp_kernel.c @@ -370,7 +370,7 @@ void procstack_dmp() PROCLOOP(rp, oldrp) PRINTRTS(rp); printf("\n"); pagelines++; - sys_sysctl_stacktrace(rp->p_endpoint); + sys_diagctl_stacktrace(rp->p_endpoint); } } diff --git a/servers/pm/misc.c b/servers/pm/misc.c index 40291a53c..579024f6b 100644 --- a/servers/pm/misc.c +++ b/servers/pm/misc.c @@ -142,7 +142,7 @@ int do_getsysinfo() { printf("PM: unauthorized call of do_getsysinfo by proc %d '%s'\n", mp->mp_endpoint, mp->mp_name); - sys_sysctl_stacktrace(mp->mp_endpoint); + sys_diagctl_stacktrace(mp->mp_endpoint); return EPERM; } @@ -190,7 +190,7 @@ int do_getprocnr() printf("PM: unauthorized call of do_getprocnr by proc %d\n", mp->mp_endpoint); - sys_sysctl_stacktrace(mp->mp_endpoint); + sys_diagctl_stacktrace(mp->mp_endpoint); return EPERM; } @@ -267,7 +267,7 @@ int do_getepinfo_o() if (mp->mp_effuid != 0) { printf("PM: unauthorized call of do_getepinfo_o by proc %d\n", mp->mp_endpoint); - sys_sysctl_stacktrace(mp->mp_endpoint); + sys_diagctl_stacktrace(mp->mp_endpoint); return EPERM; } diff --git a/servers/pm/signal.c b/servers/pm/signal.c index 43122caab..fd35304c7 100644 --- a/servers/pm/signal.c +++ b/servers/pm/signal.c @@ -380,7 +380,7 @@ int ksig; /* non-zero means signal comes from kernel */ /* Print stacktrace if necessary. */ if(SIGS_IS_STACKTRACE(signo)) { - sys_sysctl_stacktrace(rmp->mp_endpoint); + sys_diagctl_stacktrace(rmp->mp_endpoint); } if(!SIGS_IS_TERMINATION(signo)) { @@ -475,7 +475,7 @@ int signo; /* signal that caused termination */ if(!(rmp->mp_flags & PRIV_PROC)) { printf("PM: coredump signal %d for %d / %s\n", signo, rmp->mp_pid, rmp->mp_name); - sys_sysctl_stacktrace(rmp->mp_endpoint); + sys_diagctl_stacktrace(rmp->mp_endpoint); } exit_proc(rmp, 0, TRUE /*dump_core*/); } diff --git a/servers/rs/main.c b/servers/rs/main.c index dc1caf797..0201fe1b0 100644 --- a/servers/rs/main.c +++ b/servers/rs/main.c @@ -540,7 +540,7 @@ static int sef_cb_signal_manager(endpoint_t target, int signo) /* Print stacktrace if necessary. */ if(SIGS_IS_STACKTRACE(signo)) { - sys_sysctl_stacktrace(target); + sys_diagctl_stacktrace(target); } /* In case of termination signal handle the event. */ diff --git a/servers/vfs/pipe.c b/servers/vfs/pipe.c index e21536e06..135891e3b 100644 --- a/servers/vfs/pipe.c +++ b/servers/vfs/pipe.c @@ -567,7 +567,7 @@ void unpause(void) panic("file descriptor out-of-range"); f = fp->fp_filp[fild]; if(!f) { - sys_sysctl_stacktrace(fp->fp_endpoint); + sys_diagctl_stacktrace(fp->fp_endpoint); panic("process %d blocked on empty fd %d", fp->fp_endpoint, fild); } diff --git a/servers/vm/mem_file.c b/servers/vm/mem_file.c index 023e0f968..2588cdbea 100644 --- a/servers/vm/mem_file.c +++ b/servers/vm/mem_file.c @@ -125,7 +125,7 @@ static int mappedfile_pagefault(struct vmproc *vmp, struct vir_region *region, if(!cb) { printf("VM: mem_file: no callback, returning EFAULT\n"); - sys_sysctl_stacktrace(vmp->vm_endpoint); + sys_diagctl_stacktrace(vmp->vm_endpoint); return EFAULT; } diff --git a/servers/vm/mmap.c b/servers/vm/mmap.c index d05c37d39..8985fcdcd 100644 --- a/servers/vm/mmap.c +++ b/servers/vm/mmap.c @@ -182,7 +182,7 @@ static void mmap_file_cont(struct vmproc *vmp, message *replymsg, void *cbarg, if(replymsg->VMV_RESULT != OK) { #if 0 /* Noisy diagnostic for mmap() by ld.so */ printf("VM: VFS reply failed (%d)\n", replymsg->VMV_RESULT); - sys_sysctl_stacktrace(vmp->vm_endpoint); + sys_diagctl_stacktrace(vmp->vm_endpoint); #endif result = origmsg->VMV_RESULT; } else { @@ -532,7 +532,7 @@ int do_munmap(message *m) if(!(vr = map_lookup(vmp, addr, NULL))) { printf("VM: unmap: address 0x%lx not found in %d\n", addr, target); - sys_sysctl_stacktrace(target); + sys_diagctl_stacktrace(target); return EFAULT; } len = vr->length; diff --git a/servers/vm/pagefaults.c b/servers/vm/pagefaults.c index 6ae166a68..1cba5e2e9 100644 --- a/servers/vm/pagefaults.c +++ b/servers/vm/pagefaults.c @@ -87,7 +87,7 @@ static void handle_pagefault(endpoint_t ep, vir_bytes addr, u32_t err, int retry assert(PFERR_NOPAGE(err)); printf("VM: pagefault: SIGSEGV %d bad addr 0x%lx; %s\n", ep, addr, pf_errstr(err)); - sys_sysctl_stacktrace(ep); + sys_diagctl_stacktrace(ep); } if((s=sys_kill(vmp->vm_endpoint, SIGSEGV)) != OK) panic("sys_kill failed: %d", s);