From: David van Moolenbroek Date: Mon, 2 Nov 2009 23:04:52 +0000 (+0000) Subject: Various small IS, TTY, isofs fixes X-Git-Tag: v3.1.6~225 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/man.rndc.html?a=commitdiff_plain;h=56d485c1d688751c211459bdafe2c567e67d2420;p=minix.git Various small IS, TTY, isofs fixes IS: - do not use p_getfrom_e for a process that is sending - register with TTY only function keys that are used - various header and formatting fixes - proper shutdown code TTY: - restore proper Ctrl+F1 dump contents isofs: - don't even try to call sys_exit() --- diff --git a/drivers/tty/Makefile b/drivers/tty/Makefile index accf12908..c1d15301a 100644 --- a/drivers/tty/Makefile +++ b/drivers/tty/Makefile @@ -14,7 +14,7 @@ d = .. # programs, flags, etc. MAKE = exec make CC = exec cc -CPPFLAGS = -I$i +CPPFLAGS = -I../../kernel/arch/$(ARCH)/include -I$i CFLAGS = $(CPPFLAGS) LDFLAGS = -i LIBS = -lsys -ltimers diff --git a/drivers/tty/keyboard.c b/drivers/tty/keyboard.c index db1a70614..ea5de57cf 100644 --- a/drivers/tty/keyboard.c +++ b/drivers/tty/keyboard.c @@ -14,10 +14,15 @@ #include #include #include +#include #include #include #include #include "tty.h" +#include "../../kernel/const.h" +#include "../../kernel/config.h" +#include "../../kernel/type.h" +#include "../../kernel/proc.h" u16_t keymap[NR_SCAN_CODES * MAP_COLS] = { #include "keymaps/us-std.src" @@ -1186,17 +1191,33 @@ int scode; /* scan code for a function key */ *===========================================================================*/ PRIVATE void show_key_mappings() { - int i; + int i,s; + struct proc proc; + printf("\n"); printf("System information. Known function key mappings to request debug dumps:\n"); printf("-------------------------------------------------------------------------\n"); for (i=0; i<12; i++) { printf(" %sF%d: ", i+1<10? " ":"", i+1); - printf("%-14.14s", ""); + if (fkey_obs[i].proc_nr != NONE) { + if ((s = sys_getproc(&proc, fkey_obs[i].proc_nr))!=OK) + printf("%-14.14s", ""); + else + printf("%-14.14s", proc.p_name); + } else { + printf("%-14.14s", ""); + } printf(" %sShift-F%d: ", i+1<10? " ":"", i+1); - printf("%-14.14s", ""); + if (sfkey_obs[i].proc_nr != NONE) { + if ((s = sys_getproc(&proc, sfkey_obs[i].proc_nr))!=OK) + printf("%-14.14s", ""); + else + printf("%-14.14s", proc.p_name); + } else { + printf("%-14.14s", ""); + } printf("\n"); } printf("\n"); diff --git a/servers/is/dmp.c b/servers/is/dmp.c index 5294de241..75618a0f3 100644 --- a/servers/is/dmp.c +++ b/servers/is/dmp.c @@ -4,7 +4,8 @@ * corresponding dump procedure is called. * * The entry points into this file are - * handle_fkey: handle a function key pressed notification + * map_unmap_fkeys: register or unregister function key maps with TTY + * do_fkey_pressed: handle a function key pressed notification */ #include "inc.h" @@ -40,6 +41,31 @@ struct hook_entry { */ #define NHOOKS (sizeof(hooks)/sizeof(hooks[0])) +/*===========================================================================* + * map_unmap_keys * + *===========================================================================*/ +PUBLIC void map_unmap_fkeys(map) +int map; +{ + int fkeys, sfkeys; + int h, s; + + fkeys = sfkeys = 0; + + for (h = 0; h < NHOOKS; h++) { + if (hooks[h].key >= F1 && hooks[h].key <= F12) + bit_set(fkeys, hooks[h].key - F1 + 1); + else if (hooks[h].key >= SF1 && hooks[h].key <= SF12) + bit_set(sfkeys, hooks[h].key - SF1 + 1); + } + + if (map) s = fkey_map(&fkeys, &sfkeys); + else s = fkey_unmap(&fkeys, &sfkeys); + + if (s != OK) + report("IS", "warning, fkey_ctl failed:", s); +} + /*===========================================================================* * handle_fkey * *===========================================================================*/ diff --git a/servers/is/dmp_fs.c b/servers/is/dmp_fs.c index 8eafb20e8..05ddbec82 100644 --- a/servers/is/dmp_fs.c +++ b/servers/is/dmp_fs.c @@ -35,13 +35,13 @@ PUBLIC void fproc_dmp() fp = &fproc[i]; if (fp->fp_pid <= 0) continue; if (++n > 22) break; - printf("%3d %4d %2d/%d 0x%05x %2d (%d) %2d (%d) %3d %3d %3d ", + printf("%3d %4d %2d/%d 0x%05x %2d (%2d) %2d (%2d) %3d %3d %3d ", i, fp->fp_pid, ((fp->fp_tty>>MAJOR)&BYTE), ((fp->fp_tty>>MINOR)&BYTE), fp->fp_umask, fp->fp_realuid, fp->fp_effuid, fp->fp_realgid, fp->fp_effgid, fp->fp_sesldr, - fp->fp_blocked_on, fp->fp_revived + fp->fp_blocked_on, !!fp->fp_revived ); if (fp->fp_blocked_on == FP_BLOCKED_ON_OTHER) printf("%4d\n", fp->fp_task); diff --git a/servers/is/dmp_kernel.c b/servers/is/dmp_kernel.c index e5c2cc3dd..d9ba0abae 100644 --- a/servers/is/dmp_kernel.c +++ b/servers/is/dmp_kernel.c @@ -18,9 +18,10 @@ #define PRINTRTS(rp) { \ char *procname = ""; \ printf(" %s", p_rts_flags_str(rp->p_rts_flags)); \ - if (rp->p_rts_flags & (SENDING|RECEIVING)) { \ + if (rp->p_rts_flags & SENDING) \ + procname = proc_name(_ENDPOINT_P(rp->p_sendto_e)); \ + else if (rp->p_rts_flags & RECEIVING) \ procname = proc_name(_ENDPOINT_P(rp->p_getfrom_e)); \ - } \ printf(" %-7.7s", procname); \ } @@ -312,7 +313,7 @@ PUBLIC void privileges_dmp() return; } - printf("\n--nr-id-name---- -flags- -traps- grants -ipc_to-- -ipc_sr-- -system calls--\n"); + printf("\n--nr-id-name---- -flags- -traps- grants -ipc_to-- -system calls--\n"); PROCLOOP(rp, oldrp) r = -1; @@ -372,7 +373,7 @@ PUBLIC void proctab_dmp() return; } - printf("\n-nr-----gen---endpoint-name--- -prior-quant- -user----sys--rts flags\n"); + printf("\n-nr-----gen---endpoint-name--- -prior-quant- -user----sys-rtsflags-from/to-\n"); PROCLOOP(rp, oldrp) text = rp->p_memmap[T].mem_phys; @@ -380,7 +381,7 @@ PUBLIC void proctab_dmp() size = rp->p_memmap[T].mem_len + ((rp->p_memmap[S].mem_phys + rp->p_memmap[S].mem_len) - data); printf(" %5d %10d ", _ENDPOINT_G(rp->p_endpoint), rp->p_endpoint); - printf("%-8.8s %02u/%02u %02d/%02u %6lu %6lu", + printf("%-8.8s %02u/%02u %02d/%02u %6lu %6lu ", rp->p_name, rp->p_priority, rp->p_max_priority, rp->p_ticks_left, rp->p_quantum_size, diff --git a/servers/is/dmp_pm.c b/servers/is/dmp_pm.c index 2c8071901..b566f5595 100644 --- a/servers/is/dmp_pm.c +++ b/servers/is/dmp_pm.c @@ -82,15 +82,15 @@ PUBLIC void sigaction_dmp() getsysinfo(PM_PROC_NR, SI_PROC_TAB, mproc); getuptime(&uptime); - printf("-process- -nr- --ignore- --catch- --block- -tomess-- -pending-- -alarm---\n"); + printf("-process- -nr- --ignore- --catch- --block- -tomess- -pending- -alarm---\n"); for (i=prev_i; imp_pid == 0 && i != PM_PROC_NR) continue; if (++n > 22) break; printf("%8.8s %3d ", mp->mp_name, i); - printf(" 0x%06x 0x%06x 0x%06x 0x%06x ", + printf(" %08x %08x %08x %08x ", mp->mp_ignore, mp->mp_catch, mp->mp_sigmask, mp->mp_sig2mess); - printf("0x%06x ", mp->mp_sigpending); + printf("%08x ", mp->mp_sigpending); if (mp->mp_flags & ALARM_ON) printf("%8u", mp->mp_timer.tmr_exp_time-uptime); else printf(" -"); printf("\n"); diff --git a/servers/is/dmp_rs.c b/servers/is/dmp_rs.c index 3602beadb..4b2904b22 100644 --- a/servers/is/dmp_rs.c +++ b/servers/is/dmp_rs.c @@ -28,7 +28,7 @@ PUBLIC void rproc_dmp() getsysinfo(RS_PROC_NR, SI_PROC_TAB, rproc); printf("Reincarnation Server (RS) system process table dump\n"); - printf("-----proc---pid-flag--dev- -T---checked----alive-starts-backoff-label command-\n"); + printf("-endpoint-flag--dev- -T---checked----alive-starts-backoff-label command-\n"); for (i=prev_i; ir_flags & RS_IN_USE) continue; diff --git a/servers/is/main.c b/servers/is/main.c index 63996e502..15f2b5ee0 100644 --- a/servers/is/main.c +++ b/servers/is/main.c @@ -20,6 +20,7 @@ extern int errno; /* error number set by system library */ /* Declare some local functions. */ FORWARD _PROTOTYPE(void init_server, (int argc, char **argv) ); +FORWARD _PROTOTYPE(void sig_handler, (void) ); FORWARD _PROTOTYPE(void get_work, (void) ); FORWARD _PROTOTYPE(void reply, (int whom, int result) ); @@ -54,8 +55,8 @@ PUBLIC int main(int argc, char **argv) } continue; case PM_PROC_NR: - result = EDONTREPLY; - break; + sig_handler(); + continue; case TTY_PROC_NR: result = do_fkey_pressed(&m_in); break; @@ -84,8 +85,6 @@ PUBLIC int main(int argc, char **argv) PRIVATE void init_server(int argc, char **argv) { /* Initialize the information service. */ - int fkeys, sfkeys; - int i, s; struct sigaction sigact; /* Install signal handler. Ask PM to transform signal into message. */ @@ -95,12 +94,27 @@ PRIVATE void init_server(int argc, char **argv) if (sigaction(SIGTERM, &sigact, NULL) < 0) report("IS","warning, sigaction() failed", errno); - /* Set key mappings. IS takes all of F1-F12 and Shift+F1-F10. */ - fkeys = sfkeys = 0; - for (i=1; i<=12; i++) bit_set(fkeys, i); - for (i=1; i<=10; i++) bit_set(sfkeys, i); - if ((s=fkey_map(&fkeys, &sfkeys)) != OK) - report("IS", "warning, fkey_map failed:", s); + /* Set key mappings. */ + map_unmap_fkeys(TRUE /*map*/); +} + +/*===========================================================================* + * sig_handler * + *===========================================================================*/ +PRIVATE void sig_handler() +{ + sigset_t sigset; + + /* Try to obtain signal set from PM. */ + if (getsigset(&sigset) != 0) return; + + /* Only check for termination signal. */ + if (!sigismember(&sigset, SIGTERM)) return; + + /* Shutting down. Unset key mappings, and quit. */ + map_unmap_fkeys(FALSE /*map*/); + + exit(0); } /*===========================================================================* diff --git a/servers/is/proto.h b/servers/is/proto.h index 6d70aa34f..fbc531869 100644 --- a/servers/is/proto.h +++ b/servers/is/proto.h @@ -1,12 +1,13 @@ /* Function prototypes. */ /* main.c */ -_PROTOTYPE( int main, (int argc, char **argv) ); +_PROTOTYPE( int main, (int argc, char **argv) ); /* dmp.c */ +_PROTOTYPE( void map_unmap_fkeys, (int map) ); _PROTOTYPE( int do_fkey_pressed, (message *m) ); _PROTOTYPE( void mapping_dmp, (void) ); -_PROTOTYPE( void vm_dmp, (void) ); +_PROTOTYPE( void vm_dmp, (void) ); /* dmp_kernel.c */ _PROTOTYPE( void proctab_dmp, (void) ); diff --git a/servers/iso9660fs/utility.c b/servers/iso9660fs/utility.c index 6f4a676ae..85da41e9e 100644 --- a/servers/iso9660fs/utility.c +++ b/servers/iso9660fs/utility.c @@ -33,5 +33,5 @@ int num; /* number to go with it */ printf("FS panic (%s): %s ", who, mess); if (num != NO_NUM) printf("%d",num); - sys_exit(SELF); + exit(1); }