Article 13468 of alt.sources: Submitted-by: ljp@tiac.net Archive-name: orion-1.0/part03 ---- Cut Here and feed the following to sh ---- #!/bin/sh # This is `orion.03' (part 3 of orion-1.0). # Do not concatenate these parts, unpack them in order with `/bin/sh'. # File `orion-1.0/pis/pis.c' is being continued... # save_IFS="${IFS}" IFS="${IFS}:" gettext_dir=FAILED locale_dir=FAILED first_param="$1" for dir in $PATH do if test "$gettext_dir" = FAILED && test -f $dir/gettext \ && ($dir/gettext --version >/dev/null 2>&1) then set `$dir/gettext --version 2>&1` if test "$3" = GNU then gettext_dir=$dir fi fi if test "$locale_dir" = FAILED && test -f $dir/shar \ && ($dir/shar --print-text-domain-dir >/dev/null 2>&1) then locale_dir=`$dir/shar --print-text-domain-dir` fi done IFS="$save_IFS" if test "$locale_dir" = FAILED || test "$gettext_dir" = FAILED then echo=echo else TEXTDOMAINDIR=$locale_dir export TEXTDOMAINDIR TEXTDOMAIN=sharutils export TEXTDOMAIN echo="$gettext_dir/gettext -s" fi if test ! -r _sh05649/seq; then $echo 'Please unpack part 1 first!' exit 1 fi shar_sequence=`cat _sh05649/seq` if test "$shar_sequence" != 3; then $echo 'Please unpack part' "$shar_sequence" 'next!' exit 1 fi if test ! -f _sh05649/new; then $echo 'x -' 'STILL SKIPPING' 'orion-1.0/pis/pis.c' else $echo 'x -' 'continuing file' 'orion-1.0/pis/pis.c' sed 's/^X//' << 'SHAR_EOF' >> orion-1.0/pis/pis.c && X */ X#if !defined(SUN5) X globalProfile.p_hz = HZ; X#else X if( !memFetch(globalProfile.p_fdKMem,PIS_VAR_HZ, X &globalProfile.p_hz,sizeof(globalProfile.p_hz)) ) X { X fputs( "Can not fetch \"hz\".\n", stdout ); X return 0; X } X#endif X X /* X ** Add children of requested processes, if appropriate. X ** X ** See the comment ahead of the definition for an explanation X ** on SunOS 5. X */ X#if !defined(SUN5) X if( globalProfile.res_ppid ) X follow_child( maxslot, proctab ); X#endif X X /* X ** Iterate through the process structures. On some platforms we X ** traverse the table backwards. The system processes appear at X ** the tail of the linked list headed by practive. X */ X X#if defined(ORION_FEAT_PROCTAB) X for( slot=0; slot=0; --slot ) X#endif X { X proc_p = &proctab[slot]; X X /* X ** Only occupied process slots. X */ X X#if defined(ORION_FEAT_PROCTAB) X if( proc_p->p_stat == 0 ) X#else X if( proc_p->p_flag == 0 ) X#endif X continue; X X /* X ** Get the pid. SunOS 5 does not keep the process id X ** directly in the process record. X */ X#if defined(ORION_FEAT_PROCTAB) X pid = proc_p->p_pid; X#endif X#if defined(SVR4) || defined(UW2) X pid = proc_p->p_epid; X#endif X#if defined(SUN5) X if( !memRead(globalProfile.p_fdKMem,proc_p->p_pidp, X &recPid,sizeof(recPid)) ) X { X continue; X } X pid = recPid.pid_id; X#endif X X#if defined(SUN5) X if( globalProfile.res_ppid ) X { X for( j=0; jp_ppid == globalProfile.tab_rppid[j] ) X break; X if( pid == globalProfile.tab_rppid[j] ) X break; X } X if( j >= globalProfile.cnt_ppid ) X continue; X } X#endif X X /* X ** Ignore processes which the user did not ask for. X */ X if( globalProfile.res_pid ) X { X for( j=0; j= PIS_MAX_RPIDS ) X continue; X } X X /* X ** Only VENIX real time processes. X */ X X#if defined(VENIX32) X if( globalProfile.res_rtx ) X { X if( !(proc_p->p_flag&RTX_SRTPRI) ) X continue; X } X#endif X X /* X ** If only looking at system processes (processes whose parent X ** is pid zero), ignore init. X */ X if( globalProfile.res_sys && pid==1 ) X continue; X X /* X ** Only system processes. This is defined as all process X ** except init whose parent is pid zero. init is pruned X ** above. X */ X if( globalProfile.res_sys ) X { X if( proc_p->p_ppid !=0 ) X continue; X } X X /* X ** Only processes which are locked in memory. X */ X X if( globalProfile.res_lock ) X { X#if defined(UW2) X if( !(proc_p->p_flag&P_NOSWAP) ) X continue; X#endif X#if defined(SUN5) X if( !(proc_p->p_flag&SLOCK) ) X continue; X#endif X#if defined(ORION_FEAT_PROCTAB) || defined(SVR4) X if( !(proc_p->p_flag&SSYS) ) X continue; X#endif X } X X /* X ** Fetch the credentials record for the process. This will X ** contain the user id of the process. X */ X#if defined(ORION_FEAT_PROCLIST) X if( !memRead(globalProfile.p_fdKMem,proc_p->p_cred, X &recCred,sizeof(recCred)) ) X { X continue; X } X#endif X X /* X ** Only given user ids. X */ X X if( globalProfile.res_uid ) X { X for( j=0; jp_uid == globalProfile.tab_ruid[j] ) X break; X#endif X#if defined(ORION_FEAT_PROCLIST) X if( recCred.cr_uid == globalProfile.tab_ruid[j] ) X break; X#endif X } X if( j >= PIS_MAX_RUIDS ) X continue; X } X X /* X ** Fetch the user block for this process. Detail X ** and list modes require different amounts of X ** the block (the user block is larger than the X ** definition of "struct user"). X */ X /* X ** Can't get sysi86() to work under SCO 3.2v4. The returned X ** ublock is incomplete. ttyd and other fields are X ** empty. X */ X#if defined(ORION_FEAT_UBLOCK) X if( proc_p->p_stat != SZOMB ) X { X int amount; X X#if defined(SCO4) || defined(SCO5) X amount = sizeof(struct user); X amount += (sizeof(struct file*)+1) * X globalProfile.kern_var.v_nofiles; X amount = (amount+1) & ~1; X amount += sizeof(gid_t) * (1+globalProfile.kern_var.v_ngroups); X#else X amount = sizeof(struct user); X amount += ( globalProfile.mode==PIS_MODE_LIST ? 0 : 4096 ); X#endif X X if( sysi86(RDUBLK,pid,&recU,amount) == -1 ) X { X /* X ** EINVAL occurs if the process has since departed. X */ X if( errno==EINVAL || errno==ESRCH ) X continue; X X fprintf( stdout, "Bad sysi86() for pid %d. %s.\n", X proc_p->p_pid, sys_errlist[errno] ); X return 0; X } X } X#endif X X#if 0 X /* X ** The following code can be in used in place of the above X ** call to sysi86(). It requires file descriptors to X ** physical memory and the swap slice. X */ X#if defined(ORION_FEAT_UBLOCK) X if( proc_p->p_flag & SULOAD ) X { X char *ptr; X unsigned size; X int i; X caddr_t addr; X X size = sizeof(struct user); X ptr = (char*)&recU; X X for( i=0; ip_usize; ++i ) X { X if( !proc_p->p_ubptbl[i].pgm.pg_pres ) X { X fputs( "ublock page not present.\n", stdout ); X break; X } X addr = (caddr_t)(proc_p->p_ubptbl[i].pgm.pg_pfn*NBPP); X if( !memRead(globalProfile.p_fdMem,addr,(void*)ptr, X (sizep_ubdbd.dbd_blkno * NBPSCTR; X if( lseek(globalProfile.p_fdSwap,addr,0) == -1 ) X { X fprintf( stdout, "Bad lseek() on swap. %s.\n", X sys_errlist[errno] ); X } X X if( !read(globalProfile.p_fdSwap,&recU,sizeof(struct user)) ) X { X fprintf( stdout, "Bad read() on \"%s\". %s.\n", X S_PathSwap, sys_errlist[errno] ); X } X } X#endif X#endif X X /* X ** Get the process info record from the proc filesystem. X ** This is the offical means of obtaining process information. X */ X#if defined(ORION_FEAT_PROCFS) X X#if defined(UW2) X sprintf( fullpath, "%s/%d/psinfo", S_PathProc, pid ); X#else X sprintf( fullpath, "%s/%d", S_PathProc, pid ); X#endif X X if( (fd=open(fullpath,O_RDONLY)) == -1 ) X { X if( globalProfile.p_debug ) X fprintf( stdout, "Bad open(). %s.\n", sys_errlist[errno] ); X continue; X } X X#if defined(UW2) X if( read(fd,&recInfo,sizeof(recInfo)) == -1 ) X continue; X#else X if( ioctl(fd,PIOCPSINFO,&recInfo) == -1 ) X { X if( globalProfile.p_debug ) X fprintf( stdout, "Bad ioctl(). %s.\n", sys_errlist[errno] ); X continue; X } X#endif X X close( fd ); X X#endif /* ORION_FEAT_PROCFS */ X X /* X ** Only processes whose argument list contains X ** the grep string. X */ X if( grep != NULL ) X { X#if defined(VENIX32) || defined(SVR3) X if( !dogrep(grep,((struct user*)recU)->u_psargs) ) X continue; X#endif X#if defined(SVR4) || defined(UW2) || defined(SUN5) X if( strstr(recInfo.pr_psargs,grep) == NULL ) X continue; X#endif X#if defined(SCO4) || defined(SCO5) X if( strstr(((struct user*)recU)->u_psargs,grep) == NULL ) X continue; X#endif X } X X /* X ** The process has survived all of the restrictions. Call X ** the appropriate display routine. X */ X if( globalProfile.mode == PIS_MODE_LIST ) X { X#if defined(ORION_FEAT_UBLOCK) X dolist( slot, proc_p, (struct user*)recU ); X #endif X #if defined(SVR4) || defined(UW2) X dolist( proc_p, &recCred, &recInfo ); X #endif X #if defined(SUN5) X dolist( proc_p, &recPid, &recCred, &recInfo ); X #endif X } X else X { X #if defined(ORION_FEAT_UBLOCK) X dodetail( slot, proc_p, patab[slot], (struct user*)recU ); X #endif X #if defined(SVR4) || defined(UW2) X dodetail( proc_p, patab[slot], &recCred, &recInfo ); X #endif X #if defined(SUN5) X dodetail( proc_p, patab[slot], &recPid, &recCred, &recInfo ); X #endif X } X } X X return 1; X } X X /* X ** getAddr() X ** X ** Given a kernel variable constant (LSAR_VAR_*), return the address X ** of that variable in kernel memory. X */ X caddr_t getAddr( unsigned var ) X { X int i; X X /* X ** The following globals are used in the lookup. X ** X ** tableOffsets : Array of records indexed by LSAR_VAR_* constants. X ** recNlist : Pointer to array of nlist structures. X */ X X for( i=0; tableOffsets[i].var!=PIS_VAR_NULL; ++i ) X { X if( tableOffsets[i].var == var ) X break; X } X if( tableOffsets[i].var == PIS_VAR_NULL ) X return 0; X X return (caddr_t)(recNlistPis[tableOffsets[i].off].n_value); X } X X /* X ** addUid() X ** X ** Given a user id or user name, add it to the global list of user ids. X */ X static void addUid( const char *strUid ) X { X int i; X X if( globalProfile.cnt_uid >= PIS_MAX_RUIDS ) X { X fprintf( stdout, "Too many user ids to track. Ignoring %s.\n", X strUid ); X return; X } X X if( isdigit(strUid[0]) ) X { X uid_t uid; X X uid = (uid_t)atoi( strUid ); X globalProfile.tab_ruid[globalProfile.cnt_uid] = uid; X ++globalProfile.cnt_uid; X return; X } X X for( i=0; i= PIS_MAX_RUIDS ) X { X fprintf( stdout, X "Too many user ids to track. Ignoring %d.\n", uid ); X } X } X } X } X X /* X ** addPid() X ** X ** Given a process id, add it to the global list of process ids. X */ X static int addPid( pid_t pid ) X { X int i; X X for( i=0; i= PIS_MAX_RPPIDS ) X { X fprintf( stdout, "Too many processes to track. Ignoring %d.\n", pid ); X return; X } X globalProfile.tab_rppid[globalProfile.cnt_ppid] = pid; X ++globalProfile.cnt_ppid; X } X X #if defined(ORION_FEAT_PROCTAB) X #define PIS_PID(st) (proctab[(st)].p_pid) X #define PIS_PPID(st) (proctab[(st)].p_ppid) X #endif X X #if defined(SVR4) || defined(UW2) X #define PIS_PID(st) (proctab[(st)].p_epid) X #define PIS_PPID(st) (proctab[(st)].p_ppid) X #endif X X /* X ** follow_child() X ** X ** Add children of the designated processes to the list of processes X ** to display. The process table is passed in. X ** X ** This routine is not called on the SunOS 5 platform because SunOS X ** does not keep the process or parent process id in the process X ** record. X */ X #if !defined(SUN5) X void follow_child( unsigned maxslot, struct proc *proctab ) X { X int i, slot; X X globalProfile.res_pid = 1; X X for( i=0; i]... [-detail] [-grep ]\n", X S_Command ); X fputs( X "\t-v Print debug information.\n", X stdout ); X#ifdef VENIX32 X fputs( X "\t-prio Set VENIX real-time priority.\n", X stdout ); X#endif X fputs( X "\t-nopager Do not pipe output to pager.\n", X stdout ); X fputs( X "\t-p Show given process (specify pid).\n", X stdout ); X fputs( X "\t-u Show processes for user (specify uid).\n", X stdout ); X fputs( X "\t-sys Show only system processes.\n", X stdout ); X#ifdef VENIX32 X fputs( X "\t-rtx Show only VENIX real-time processes.\n", X stdout ); X fputs( X "\t-lock Show only processes locked in memory.\n", X stdout ); X#endif X fputs( X "\t-grep Show processes with given string in arglist.\n", X stdout ); X fputs( X "\t-detail Show more data on each process.\n", X stdout ); X fputs( X "\t-mkdb Remake uid/tty database.\n", X stdout ); X} SHAR_EOF $echo 'File' 'orion-1.0/pis/pis.c' 'is complete' && chmod 0664 'orion-1.0/pis/pis.c' || $echo 'restore of' 'orion-1.0/pis/pis.c' 'failed' if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'orion-1.0/pis/pis.c:' 'MD5 check failed' 805531f649eaf8bd7230be74f22734a0 orion-1.0/pis/pis.c SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'orion-1.0/pis/pis.c'`" test 31164 -eq "$shar_count" || $echo 'orion-1.0/pis/pis.c:' 'original size' '31164,' 'current size' "$shar_count!" fi fi # ============= orion-1.0/pis/tty.c ============== if test -f 'orion-1.0/pis/tty.c' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'orion-1.0/pis/tty.c' '(file already exists)' rm -f _sh05649/new else > _sh05649/new $echo 'x -' extracting 'orion-1.0/pis/tty.c' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'orion-1.0/pis/tty.c' && X X/* X** ---------------------------------------------------------------- X** X** Copyright (c) 1994,1995,1996 by Larry Plona X** X** This file is part of the Orion software package. The Orion X** software package is copyright by its author, Larry Plona. This X** software, both source code and prepared binaries, may be X** freely distributed as long as all copyright notices remain X** intact and this software is not sold or packaged with other X** commercial software. X** X** No warranty of any kind attached with this software. It is X** supplied as is. X** X** ---------------------------------------------------------------- X*/ X X/* X** tty.c module of pis. X** X** Accumulates TTY data for pis database. X*/ X X#include X#include"mkpis.h" X X/* X** Callback to ftw(3c). Walks "/dev". X*/ X#if defined(SVR3) || defined(VENIX32) || defined(SCO4) Xstatic int walk( char*, struct stat*, int ); X#else Xstatic int walk( const char*, const struct stat*, int ); X#endif X X#if defined(SUN5) Xstatic char *getdev( char *line ); X#endif X X/* X** Table of majors numbers of TTY devices. X*/ Xstatic dev_t *tab_major; Xstatic unsigned cnt_majors; X Xstatic unsigned cnt_tty; Xstatic struct cntltty tab_tty[PIS_MAX_TTYMIN]; X X#if defined(SUN5) Xstatic char tab_names[PIS_MAX_TTYMAJ][PIS_MAX_TTYNAME+1]; Xstatic int cnt_names; X#endif X X#if defined(ORION_FEAT_MDEVICE) Xstatic const char * const S_PathMdevice = "/etc/conf/cf.d/mdevice"; Xstatic const char * const S_FmtMdevice = "%s %*s %s %*s %*s %s"; X#endif X#if defined(SVR4) || defined(UW2) Xstatic const char * const S_PathMdeviced = "/etc/conf/mdevice.d"; Xstatic const char * const S_PathResMajor = "/etc/conf/cf.d/res_major"; Xstatic const char * const S_FmtMdevice = "%s %*s %s"; Xstatic const char * const S_FmtResMajors = "%*s %s %s"; X#endif X#if defined(SUN5) Xstatic const char * const S_PathDevlink = "/etc/devlink.tab"; X#endif X X/* X** ttyWrite() X** X** Given a file descriptor to an open pis database file, write out X** the tty section of the database. Create the database information X** by looking for TTY nodes in "/dev". On some platforms we know X** exactly which nodes these are, on others we have to live with X** a super-set of devices. X** X** Since some platforms leave us no clue as to which drivers can be X* used as controlling terminals, it may be better to use a human X** editable config file to determine the drivers to seek out. I'm X** currently rejecting this solution on the philosophy that most admins X** demand that software "just works". X*/ Xint ttyWrite( int fd ) X{ X int rc; X X cnt_majors = 0; X if( (tab_major=(dev_t*)malloc(sizeof(dev_t)*PIS_MAX_TTYMAJ)) X == NULL ) X { X fputs( "Bad malloc().\n", stdout ); X return 0; X } X X /* X ** Platform specific routine to collect devices which may X ** be used as controlling terminals. X */ X if( flagDebug ) X { X fputs( "Searching for TTY drivers.\n", stdout ); X } X (void)ttyBuild(); X X /* X ** Walk device directory, saving the nodenames of all nodes with X ** a major number in the table made above. X */ X if( flagDebug ) X { X fputs( "Searching for TTY nodes.\n", stdout ); X } X cnt_tty = 0; X if( (rc=ftw(S_PathDev,walk,3)) == -1 ) X { X fprintf( stdout, "Bad ftw() on \"%s\".\n", S_PathDev ); X free( (void*)tab_major ); X return 0; X } X free( (void*)tab_major ); X X if( flagDebug ) X { X fprintf( stdout, X "Found %d potential tty nodes in \"%s\".\n", X cnt_tty, S_PathDev ); X } X X#if 0 X for( i=0; i= PIS_MAX_TTYMAJ ) X { X fputs( "Too many potential TTY drivers, ignoring some.\n", X stdout ); X break; X } X } X fclose( fp ); X X if( flagDebug ) X fprintf( stdout, "Found %d potential TTY drivers.\n", cnt_majors ); X X return 1; X} X#endif X X/* X** ttyBuild() X** X** UnixWare 2 version. Read the mdevice files, looking for all X** STREAMS drivers or modules. Cross reference the device name X** found in the this file with the name in the res_major file X** to get the device's major number. X*/ X#if defined(UW2) Xint ttyBuild( void ) X{ X char line[PIS_MAX_MDEVLINE+1]; X char devname[6]; X char dummy[PIS_MAX_MDEVLINE+1]; X char charac[PIS_MAX_MDEVLINE+1]; X char names[PIS_MAX_TTYMAJ][64]; X int i; X int cnt_names; X int rc; X X /* X ** Create a list of the names of all potential tty devices. X */ X { X char name[127+1]; X char flags[127+1]; X char line[127+1]; X char fullpath[127+1]; X struct dirent *recDir; X DIR *dp; X FILE *fp; X X cnt_names = 0; X X if( (dp=opendir(S_PathMdeviced)) == NULL ) X { X fputs( "Bad opendir().\n", stdout ); X free( (void*)tab_major ); X return 0; X } X X while( (recDir=readdir(dp)) != NULL ) X { X if( recDir->d_name[0] == '.' ) X continue; X sprintf( fullpath, "%s/%s", S_PathMdeviced, recDir->d_name ); X if( (fp=fopen(fullpath,"r")) == NULL ) X continue; X line[0] = '\0'; X while( fgets(line,127,fp) != NULL ) X { X if( line[0]=='\n' || line[0]=='$' || line[0]=='#' ) X continue; X break; X } X fclose( fp ); X if( (rc=sscanf(line,S_FmtMdevice,name,flags)) != 2 ) X { X continue; X } X if( strchr(flags,'S') == NULL ) X continue; X strcpy( names[cnt_names++], name ); X X if( cnt_names > PIS_MAX_TTYMAJ ) X { X if( flagDebug ) X fputs( "Too many TTY drivers, ignoring some.\n", stdout ); X break; X } X } X X closedir( dp ); X X if( flagDebug ) X { X fprintf( stdout, "Found %d potential TTY drivers.\n", X cnt_names ); X } X } X X /* X ** Create a list of major numbers for the drivers collected above. X */ X { X char name[127+1]; X char strMajor[PIS_MAX_MDEVLINE+1]; X FILE *fp; X X if( (fp=fopen(S_PathResMajor,"r")) == NULL ) X { X fprintf( stdout, "Could not open \"%s\".\n", S_PathResMajor ); X free( (void*)tab_major ); X return 0; X } X cnt_majors = 0; X while( (fgets(line,PIS_MAX_RESLINE,fp)) != NULL ) X { X /* Skip leading whitespace. */ X for( i=0; line[i]==' '||line[i]=='\t'; ++i ); X X /* Skip comment lines. */ X if( line[i] == '#' ) X continue; X X /* Only character devices. */ X if( line[i] != 'c' ) X continue; X X /* Parse the line. */ X if( sscanf(&line[i],S_FmtResMajors,strMajor,name) != 2 ) X { X continue; X } X X /* Ignore devices not in list. */ X for( i=0; i= PIS_MAX_TTYMAJ ) X { X if( flagDebug ) X { X fputs( "Too many potential TTY drivers, ignoring some.\n", X stdout ); X } X break; X } X } X fclose( fp ); X } X X return 1; X} X#endif X X/* X** ttyBuild() X** X** SunOS 5 version. Retreive the names of all of the serial and X** pseudo devices in the devlink.tab file. Cross reference the X** names in the X*/ X#if defined(SUN5) Xint ttyBuild( void ) X{ X char line[PIS_MAX_MDEVLINE+1]; X char devname[6]; X char dummy[PIS_MAX_MDEVLINE+1]; X char charac[PIS_MAX_MDEVLINE+1]; X int i; X int rc; X X /* X ** Create a list of the names of all potential tty devices. X */ X { X char *name; X char flags[127+1]; X char line[127+1]; X char fullpath[127+1]; X FILE *fp; X X cnt_names = 0; X X if( (fp=fopen(S_PathDevlink,"r")) == NULL ) X { X fputs( "Bad fopen().\n", stdout ); X free( (void*)tab_major ); X return 0; X } X X while( fgets(line,127,fp) != NULL ) X { X if( line[0]=='\n' || line[0]=='#' ) X continue; X X name = NULL; X if( !strncmp("type=ddi_pseudo",line,15) ) X name = getdev(line); X else if( !strncmp("type=ddi_serial",line,15) ) X name = getdev(line); X X if( name != NULL ) X { X strcpy( tab_names[cnt_names++], name ); X X if( flagDebug ) X { X fprintf( stdout, " Driver \"%s\"\n", name ); X } X } X X if( cnt_names > PIS_MAX_TTYMAJ ) X { X if( flagDebug ) X fputs( "Too many TTY drivers, ignoring some.\n", stdout ); X break; X } X } X X fclose( fp ); X X if( flagDebug ) X { X fprintf( stdout, "Found %d potential TTY drivers.\n", X cnt_names ); X } X } X X return 1; X} X#endif X X#if defined(SUN5) Xstatic char *getdev( char *line ) X{ X static char buffer[PIS_MAX_TTYNAME+1]; X char *p, *start; X X /* Skip "type" pair. */ X for( p=line; (*p!=';')&&(*p!='\0'); ++p ); X X if( *p == '\0' ) X return NULL; X X ++p; X if( *p == '\0' ) X return NULL; X X p += strlen("name="); X X start = p; X X /* Find the end of the value to "name". */ X for( ; (*p!=';')&&(*p!='\t')&&(*p!='\0'); ++p ); X X strncpy( buffer, start, (unsigned)(p-start) ); X buffer[(unsigned)(p-start)] = '\0'; X X return buffer; X} X#endif X X/* X** walk() X** X** Callback to ftw(). X*/ X#if defined(SVR3) || defined(VENIX32) || defined(SCO4) Xstatic int walk( char *object, struct stat *stat, int type ) X#else Xstatic int walk( const char *object, const struct stat *stat, int type ) X#endif X{ X int i; X unsigned curs, len, last; X X if( type==FTW_D || type==FTW_NS || type==FTW_DNR ) X return 0; X X /* Error. */ X if( type != FTW_F ) X return 1; X X /* Only look at character devices. */ X if( (stat->st_mode&S_IFMT) != S_IFCHR ) X return 0; X X /* X ** Ignore non tty devices. SunOS checks the file name, other X ** platforms check the major number of the device node. X */ X X#if !defined(SUN5) X for( i=0; ist_rdev) ) X break; X } X if( i >= cnt_majors ) X return 0; X#else X /* X ** Under SunOS, we check against select "dev" names taken from the X ** devlink.tab file. We save any node which has one of these names X ** somewhere in the pathname. X */ X for( i=0; i= cnt_names ) X return 0; X#endif X X if( flagDebug ) X { X fprintf( stdout, " Node %d %d \"%s\"\n", X major(stat->st_rdev), X minor(stat->st_rdev), X object ); X } X X /* X ** Copy an appropriate amount of the path into the saved X ** table. Starting at the end of the path, back up segment X ** by segment copying until the buffer is full. X */ X pathAdjust( object+4, tab_tty[cnt_tty].path, X PIS_MAX_TTYNAME ); X X tab_tty[cnt_tty].dev = stat->st_rdev; X ++cnt_tty; X X if( cnt_tty >= PIS_MAX_TTYMIN ) X { X fputs( "Found too many potential TTY nodes, ignoring some.\n", X stdout ); X return 1; X } X X return 0; X} SHAR_EOF chmod 0664 'orion-1.0/pis/tty.c' || $echo 'restore of' 'orion-1.0/pis/tty.c' 'failed' if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'orion-1.0/pis/tty.c:' 'MD5 check failed' 7cd1706930b8e6ff641f96f457f11037 orion-1.0/pis/tty.c SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'orion-1.0/pis/tty.c'`" test 12643 -eq "$shar_count" || $echo 'orion-1.0/pis/tty.c:' 'original size' '12643,' 'current size' "$shar_count!" fi fi # ============= orion-1.0/pis/db.c ============== if test -f 'orion-1.0/pis/db.c' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'orion-1.0/pis/db.c' '(file already exists)' rm -f _sh05649/new else > _sh05649/new $echo 'x -' extracting 'orion-1.0/pis/db.c' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'orion-1.0/pis/db.c' && X X/* X** ---------------------------------------------------------------- X** X** Copyright (c) 1994,1995,1996 by Larry Plona X** X** This file is part of the Orion software package. The Orion X** software package is copyright by its author, Larry Plona. This X** software, both source code and prepared binaries, may be X** freely distributed as long as all copyright notices remain X** intact and this software is not sold or packaged with other X** commercial software. X** X** No warranty of any kind attached with this software. It is X** supplied as is. X** X** ---------------------------------------------------------------- X*/ X X#include"pis.h" X X/* X** Local string table. X*/ Xconst char * const S_SleepChild = "child"; Xconst char * const S_SleepMsgq = "message queue"; Xconst char * const S_SleepQueue = "queue"; Xconst char * const S_CmdMkpis = "mkpis"; Xconst char * const S_PathMkpis = "/usr/local/bin/mkpis"; Xstatic const char * const S_PathDb = "/tmp/pisdata"; X X/* X** dbFetch() X** X** Load the uid/tty database. Create the database if it X** does not already exist, or if the given flag is set. X*/ Xint dbFetch( unsigned force ) X{ X int fd; X X if( force || (access(S_PathDb,R_OK)==-1) ) X { X /* X ** Quick and dirty execution of mkpis. We don't try too hard to X ** find the executable, or check the exit status. X */ X fputs( "Creating database.\n", stdout ); X if( !fork() ) X { X if( execlp(S_CmdMkpis,S_CmdMkpis,"-mkdb",NULL)==-1 && X execl(S_PathMkpis,S_CmdMkpis,"-mkdb",NULL)==-1 ) X { X fprintf( stdout, "Can not execute \"%s\".\n", X S_CmdMkpis ); X return 0; X } X } X else X { X if( wait(NULL) == -1 ) X { X fprintf( stdout, "Bad wait(). %s.\n", sys_errlist[errno] ); X return 0; X } X } X } X X if( (fd=open(S_PathDb,O_RDONLY)) == -1 ) X { X fprintf( stdout, "Bad open(2) of \"%s\". %s.\n", X S_PathDb, sys_errlist[errno] ); X unlink( S_PathDb ); X return 0; X } X X if( !ttyRead(fd) ) X { X close( fd ); X unlink( S_PathDb ); X return 0; X } X X if( !uidRead(fd) ) X { X close( fd ); X unlink( S_PathDb ); X return 0; X } X X#if defined(VENIX32) || defined(SVR3) || defined(SCO5) || defined(SCO4) X if( !sleepRead(fd) ) X { X close( fd ); X unlink( S_PathDb ); X return 0; X } X#endif X X close( fd ); X X return 1; X} X X/* X** uidRead() X** X** Read the username portion of the pis database. X*/ Xint uidRead( int fd ) X{ X int i, rc; X struct passwd *pw; X X globalProfile.cnt_uid = 0; X X /* X ** The section begins with a record count. X */ X if( (rc=read(fd,&(globalProfile.cnt_uid), X sizeof(globalProfile.cnt_uid))) == -1 ) X { X fputs( "Could not read uid record count from database.\n", X stdout ); X fprintf( stdout, "Bad read(2). %s.\n", sys_errlist[errno] ); X return 0; X } X if( rc != sizeof(globalProfile.cnt_uid) ) X { X fputs( "Incomplete read of uid count.\n", stdout ); X return 0; X } X X if( globalProfile.cnt_uid > PIS_MAX_UID ) X globalProfile.cnt_uid = PIS_MAX_UID; X X if( (rc=read(fd,globalProfile.tab_uid, X sizeof(globalProfile.tab_uid[0])* X globalProfile.cnt_uid)) == -1 ) X { X fputs( "Could not read uid records into database.\n", X stdout ); X fprintf( stdout, "Bad write(2). %s.\n", sys_errlist[errno] ); X return 0; X } X if( rc != sizeof(globalProfile.tab_uid[0])*globalProfile.cnt_uid ) X { X fputs( "Incomplete read of uid table.\n", stdout ); X return 0; X } X X if( globalProfile.p_debug ) X { X fprintf( stdout, "Read %d uid records.\n", X globalProfile.cnt_uid ); X } X X return 1; X} X X/* X** uidFind() X** X** Given a uid, find the name associated with it. X*/ Xconst char *uidFind( uid_t uid ) X{ X int i; X X for( i=0; i= globalProfile.cnt_uid ) X return NULL; X return globalProfile.tab_uid[i].name; X} X X/* X** uidFindName() X** X** Given a username, find the uid associated with it. X*/ Xint uidFindName( const char *name, uid_t *uid ) X{ X int i; X X for( i=0; i= globalProfile.cnt_uid ) X return 0; X X *uid = globalProfile.tab_uid[i].uid; X return 1; X} X X/* X** ttyRead() X** X** Read the tty portion of the pis database. X*/ Xint ttyRead( int fd ) X{ X int rc; X int diff; X X if( (rc=read(fd,&(globalProfile.cnt_tty), X sizeof(globalProfile.cnt_tty))) == -1 ) X { X fprintf( stdout, "Bad read(2). %s.\n", sys_errlist[errno] ); X return 0; X } X X if( globalProfile.cnt_tty > PIS_MAX_TTYMIN ) X { X if( globalProfile.p_debug ) X { X fprintf( stdout, "Too many TTY records, ignoring %d.\n", X globalProfile.cnt_tty-PIS_MAX_TTYMIN ); X } X diff = (globalProfile.cnt_tty-PIS_MAX_TTYMIN) * sizeof(struct cntltty); X globalProfile.cnt_tty = PIS_MAX_TTYMIN; X } X else X diff = 0; X X if( (rc=read(fd,globalProfile.tab_tty, X sizeof(globalProfile.tab_tty[0])* X globalProfile.cnt_tty)) == -1 ) X { X fprintf( stdout, "Bad read(2). %s.\n", sys_errlist[errno] ); X return 0; X } X if( rc != sizeof(struct cntltty)*globalProfile.cnt_tty ) X { X fputs( "Incomplete read of TTY table.\n", stdout ); X return 0; X } X if( diff > 0 ) X { X if( globalProfile.p_debug ) X { X fprintf( stdout, "Skipping over %d bytes of TTY records.\n", X diff ); X } X if( lseek(fd,diff,SEEK_CUR) == -1 ) X { X fprintf( stdout, "Bad lseek(2). %s.\n", sys_errlist[errno] ); X return 0; X } X } X X if( globalProfile.p_debug ) X { X fprintf( stdout, "Read %d tty records.\n", X globalProfile.cnt_tty ); X } X X return 1; X} X X/* X** ttyFind() X** X** Given a device (major/minor pair), try to find a device node in X** the pis database. X*/ Xconst char *ttyFind( dev_t dev ) X{ X int i; X X for( i=0; i= globalProfile.cnt_tty ) X return NULL; X return globalProfile.tab_tty[i].path; X} X X#if defined(VENIX32) || defined(SVR3) || defined(SCO4) || defined(SCO5) X/* X** sleepRead() X** X** Read the sleep address portion of the pis database. X** SVR4 platforms do not have this section of the database. X*/ Xint sleepRead( int fd ) X{ X int rc; X X if( (rc=read(fd,&(globalProfile.cnt_sleep), X sizeof(globalProfile.cnt_sleep))) == -1 ) X { X fprintf( stdout, "Bad read(2). %s.\n", sys_errlist[errno] ); X return 0; X } X X if( globalProfile.cnt_sleep > PIS_MAX_SLEEP ) X globalProfile.cnt_sleep = PIS_MAX_SLEEP; X X if( (rc=read(fd,globalProfile.tab_sleep, X sizeof(globalProfile.tab_sleep[0])* X globalProfile.cnt_sleep)) == -1 ) X { X fprintf( stdout, "Bad read(2). %s.\n", sys_errlist[errno] ); X return 0; X } X if( rc != sizeof(struct recSleep)*globalProfile.cnt_sleep ) X { X fputs( "Bad recSleep array.\n", stdout ); X return 0; X } X X if( globalProfile.p_debug ) X { X fprintf( stdout, "Read %d sleep records.\n", X globalProfile.cnt_sleep ); X } X X return 1; X} X#endif X X/* X** sleepFind() X** X** Given a sleep address, try to find a sleep reason (a string) in X** the pis database. The address of the relevant process record is X** also passed in. This function performs some other operations to X** determine why a process is sleeping on a given address. Some of X** its investigation involves the address of the process record. X*/ Xconst char *sleepFind( caddr_t procaddr, caddr_t addr ) X{ X#if defined(VENIX32) || defined(SVR3) || defined(SCO4) || defined(SCO5) X static caddr_t msgtab = 0; X static caddr_t emsgtab = 0; X static caddr_t queuetab = 0; X static caddr_t equeuetab = 0; X int i; X#endif X#if defined(SVR4) || defined(UW2) X static char buffer[MAXSYMNMLEN+8+1]; X#endif X X#if defined(VENIX32) || defined(SVR3) || defined(SCO4) || defined(SCO5) X if( msgtab == 0 ) X { X struct msginfo recMsg; X X msgtab = getAddr( PIS_VAR_MSGQUE ); X queuetab = getAddr( PIS_VAR_QUEUE ); X X /* X ** Determine the size of the message queue table. X */ X addr = getAddr( PIS_VAR_MSGINFO ); X memRead( globalProfile.p_fdKMem, addr, &recMsg, sizeof(recMsg) ); X emsgtab = msgtab + (recMsg.msgmni*sizeof(struct msqid_ds)); X X /* X ** Determine the size of the queue table. X */ X equeuetab = queuetab + (globalProfile.kern_var.v_nqueue* X sizeof(struct queue)); X } X#endif X X /* X ** If the address is the start of the proc record, X ** then the process is waiting on a child. X */ X#if !defined(SUN5) X if( addr == procaddr ) X return S_SleepChild; X#endif X X /* X ** If the address is the p_cv field of the process record, X ** then the process is waiting on a child. X */ X#if defined(SUN5) X { X struct proc *p; X X p = (struct proc*)procaddr; X if( addr == (caddr_t)&p->p_cv ) X return S_SleepChild; X X if( addr == (caddr_t)&p->p_user.u_cv ) X return "pause"; X } X#endif X X /* X ** If the address is 12 bytes into a slot into the X ** the message queue table, the process is blocked X ** on a message queue. X */ X#if defined(VENIX32) || defined(SVR3) || defined(SCO4) || defined(SCO5) X if( addr>=msgtab && addr=queuetab && addr= globalProfile.cnt_sleep ) X return NULL; X X return globalProfile.tab_sleep[i].name; X#endif X X /* X ** Try this library routine. Due to the dynamic loading paradigm, X ** there is no table of fixes addresses as on the SVR3 platforms. X ** This routine is likely to return nothing since so many records X ** exist in dynamically allocated space. X */ X#if defined(SVR4) || defined(UW2) X { X char symname[MAXSYMNMLEN+1]; X unsigned long diff; X X if( getksym(symname,(unsigned long*)&addr,&diff) != -1 ) X { X if( diff > 0 ) X sprintf( buffer, "%s+%lu", symname, diff ); X else X sprintf( buffer, "%s", symname ); X return (const char*)buffer; X } X } X#endif X X return NULL; X} SHAR_EOF chmod 0664 'orion-1.0/pis/db.c' || $echo 'restore of' 'orion-1.0/pis/db.c' 'failed' if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'orion-1.0/pis/db.c:' 'MD5 check failed' cfbf6c96a6242737b622041fdc518186 orion-1.0/pis/db.c SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'orion-1.0/pis/db.c'`" test 10179 -eq "$shar_count" || $echo 'orion-1.0/pis/db.c:' 'original size' '10179,' 'current size' "$shar_count!" fi fi # ============= orion-1.0/pis/uid.c ============== if test -f 'orion-1.0/pis/uid.c' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'orion-1.0/pis/uid.c' '(file already exists)' rm -f _sh05649/new else > _sh05649/new $echo 'x -' extracting 'orion-1.0/pis/uid.c' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'orion-1.0/pis/uid.c' && X X/* X** ---------------------------------------------------------------- X** X** Copyright (c) 1994,1995,1996 by Larry Plona X** X** This file is part of the Orion software package. The Orion X** software package is copyright by its author, Larry Plona. This X** software, both source code and prepared binaries, may be X** freely distributed as long as all copyright notices remain X** intact and this software is not sold or packaged with other X** commercial software. X** X** No warranty of any kind attached with this software. It is X** supplied as is. X** X** ---------------------------------------------------------------- X*/ X X#include X#include"mkpis.h" X X/* X** uidWrite() X*/ Xint uidWrite( int fd ) X{ X int i, rc; X off_t offset; X struct passwd *pw; X struct urec tab_uid[PIS_MAX_UID]; X X if( flagDebug ) X { X fputs( "Searching for users.\n", stdout ); X } X for( i=0; (pw=getpwent())!=NULL; ++i ) X { X strncpy( tab_uid[i].name, pw->pw_name, PIS_MAX_USERNAME ); X tab_uid[i].name[PIS_MAX_USERNAME] = '\0'; X tab_uid[i].uid = pw->pw_uid; X if( flagDebug ) X { X fprintf( stdout, " User \"%s\", %d.\n", X tab_uid[i].name, tab_uid[i].uid ); X } X } X endpwent(); X X offset = lseek( fd, 0, SEEK_CUR ); X if( (rc=write(fd,&i,sizeof(i))) == -1 ) X { X fputs( "Could not write uid record count to database.\n", X stdout ); X fprintf( stdout, "Bad write(2). %s.\n", stdout ); X return 0; X } X if( rc != sizeof(i) ) X { X fputs( "Incomplete write of uid count.\n", stdout ); X return 0; X } X X if( (rc=write(fd,tab_uid,sizeof(tab_uid[0])*i)) == -1 ) X { X fputs( "Could not write uid records to database.\n", X stdout ); X fprintf( stdout, "Bad write(2). %s.\n", stdout ); X return 0; X } X if( rc != sizeof(tab_uid[0])*i ) X { X fputs( "Incomplete write of uid table.\n", stdout ); X return 0; X } X X if( flagDebug ) X { X fprintf( stdout, "Wrote %d uid records to database (%d bytes).\n", X i, sizeof(tab_uid[0])*i ); X fprintf( stdout, X "Uid record count written at offset %ld.\n", offset ); X } X X return 1; X} SHAR_EOF chmod 0664 'orion-1.0/pis/uid.c' || $echo 'restore of' 'orion-1.0/pis/uid.c' 'failed' if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'orion-1.0/pis/uid.c:' 'MD5 check failed' f77f131a3326d3b82a7bc91a4a698353 orion-1.0/pis/uid.c SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'orion-1.0/pis/uid.c'`" test 2080 -eq "$shar_count" || $echo 'orion-1.0/pis/uid.c:' 'original size' '2080,' 'current size' "$shar_count!" fi fi # ============= orion-1.0/pis/util.c ============== if test -f 'orion-1.0/pis/util.c' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'orion-1.0/pis/util.c' '(file already exists)' rm -f _sh05649/new else > _sh05649/new $echo 'x -' extracting 'orion-1.0/pis/util.c' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'orion-1.0/pis/util.c' && X X/* X** ---------------------------------------------------------------- X** X** Copyright (c) 1994,1995,1996 by Larry Plona X** X** This file is part of the Orion software package. The Orion X** software package is copyright by its author, Larry Plona. This X** software, both source code and prepared binaries, may be X** freely distributed as long as all copyright notices remain X** intact and this software is not sold or packaged with other X** commercial software. X** X** No warranty of any kind attached with this software. It is X** supplied as is. X** X** ---------------------------------------------------------------- X*/ X X#include"pis.h" X Xstatic const char *mkftype( unsigned, dev_t ); X X/* X** tableSigs X** X** Table of default actions for signals. Indexed by signal number. X** There must be (NSIG-1) entries in the table. X** X** Beyond signal 19, the signals and their default dispositions are X** pretty non-standard. X*/ Xstatic struct entrySig tableSigs[] = X{ X { "HUP", PIS_SIG_DIE }, /* 1 */ X { "INT", PIS_SIG_DIE }, /* 2 */ X { "QUIT", PIS_SIG_DUMP }, /* 3 */ X { "ILL", PIS_SIG_DUMP }, /* 4 */ X { "TRAP", PIS_SIG_DUMP }, /* 5 */ X { "ABRT", PIS_SIG_DUMP }, /* 6 */ X { "EMT", PIS_SIG_DUMP }, /* 7 */ X { "FPE", PIS_SIG_DUMP }, /* 8 */ X { "KILL", PIS_SIG_DIE }, /* 9 */ X { "BUS", PIS_SIG_DUMP }, /* 10 */ X { "SEGV", PIS_SIG_DUMP }, /* 11 */ X { "SYS", PIS_SIG_DUMP }, /* 12 */ X { "PIPE", PIS_SIG_DIE }, /* 13 */ X { "ALRM", PIS_SIG_DIE }, /* 14 */ X { "TERM", PIS_SIG_DIE }, /* 15 */ X { "USR1", PIS_SIG_DIE }, /* 16 */ X { "USR2", PIS_SIG_DIE }, /* 17 */ X { "CLD", PIS_SIG_IGNORE }, /* 18 */ X { "PWR", PIS_SIG_IGNORE }, /* 19 */ X/* SCO does not define anything for signal 21. */ X#if defined(VENIX32) || defined(SVR3) || defined(SCO4) || defined(SCO5) X { "WINCH", PIS_SIG_DIE }, /* 20 */ X { "URG", PIS_SIG_DIE }, /* 21 */ X#endif X#if defined(SVR4) || defined(UW2) || defined(SUN5) X { "WINCH", PIS_SIG_IGNORE }, /* 20 */ X { "URG", PIS_SIG_IGNORE }, /* 21 */ X#endif X#if defined(UW2) X { "POLL", PIS_SIG_IGNORE }, /* 22 */ X#else X { "POLL", PIS_SIG_DIE }, /* 22 */ X#endif X#if defined(VENIX32) X { "AIO", PIS_SIG_DIE }, /* 23 */ X { "EXSTK", PIS_SIG_DIE }, /* 24 */ X { "EXDAT", PIS_SIG_DIE }, /* 25 */ /* VENIX32. Must equal NSIG-1. */ X#endif X#if defined(SVR3) X { "CONT", PIS_SIG_IGNORE }, /* 23 */ X { "STOP", PIS_SIG_IGNORE }, /* 24 */ X { "TSTP", PIS_SIG_IGNORE }, /* 25 */ X { "TTIN", PIS_SIG_IGNORE }, /* 26 */ X { "TTOU", PIS_SIG_IGNORE } /* 27 */ /* SVR3. Must equal NSIG-1. */ X#endif X#if !defined(SVR3) && !defined(VENIX32) X { "STOP", PIS_SIG_STOP }, /* 23 */ X { "TSTP", PIS_SIG_STOP }, /* 24 */ X { "CONT", PIS_SIG_IGNORE }, /* 25 */ X { "TTIN", PIS_SIG_STOP }, /* 26 */ X { "TTOU", PIS_SIG_STOP }, /* 27 */ X { "VTALRM", PIS_SIG_DIE }, /* 28 */ X { "PROF", PIS_SIG_DIE }, /* 29 */ /* SCO4. Must equal NSIG-1. */ X#endif X#if defined(SVR4) || defined(UW2) || defined(SUN5) || defined(SCO5) X { "XCPU", PIS_SIG_DUMP }, /* 30 */ X { "XFSZ", PIS_SIG_DUMP }, /* 31 */ /* SCO5. Must equal NSIG-1. */ X#endif X#if defined(SVR4) || defined(UW2) || defined(SUN5) X { "WAITING", PIS_SIG_IGNORE }, /* 32 */ X { "LWP", PIS_SIG_IGNORE }, /* 33 */ X#endif X#if defined(SVR4) || defined(UW2) X { "AIO", PIS_SIG_IGNORE } /* 34 */ /* UW2. Must equal NSIG-1. */ X#endif X#if defined(SUN5) X { "FREEZE", PIS_SIG_IGNORE }, /* 34 */ X { "THAW", PIS_SIG_IGNORE }, /* 35 */ X { "RT1", PIS_SIG_DIE }, /* 36 */ X { "RT2", PIS_SIG_DIE }, /* 37 */ X { "RT3", PIS_SIG_DIE }, /* 38 */ X { "RT4", PIS_SIG_DIE }, /* 39 */ X { "RT5", PIS_SIG_DIE }, /* 40 */ X { "RT6", PIS_SIG_DIE }, /* 41 */ X { "RT7", PIS_SIG_DIE }, /* 42 */ X { "RT8", PIS_SIG_DIE } /* 43 */ /* SUN5. NSIG-1. */ X#endif X}; X X/* X** dispBasic() X** X** Print basic process information for detail mode. A platform independant X** collectionof data is passed in. X*/ Xvoid dispBasic( struct pisinfo *recPis ) X{ X const char *ptr; X char username[PIS_MAX_LUSERNAME+1]; X char args[PIS_MAX_ARGV+1]; X char buf[63+1]; X const char *devname; X X /* X ** Try to find a username for the incoming user id. On SVR3 and X ** SCO 5, zombies only have a real and a saved uid. X */ X if( !(recPis->flags&PIS_INF_ZOMB) ) X { X if( (ptr=uidFind(recPis->uid)) == NULL ) X strcpy( username, S_Empty ); X else X { X strncpy( username, ptr, PIS_MAX_LUSERNAME ); X username[PIS_MAX_LUSERNAME] = '\0'; X } X X /* X ** Try to find a device node for the incoming controlling terminal. X */ X if( (recPis->tty==NODEV) || (devname=ttyFind(recPis->tty)) == NULL ) X devname = S_Empty; X X /* X ** Limit the size of the command line arguments. X */ X strncpy( args, recPis->args, PIS_MAX_ARGV ); X args[PIS_MAX_ARGV] = '\0'; X X } X else X { X args[0] = '\0'; X devname = S_Empty; X } X X fprintf( stdout, "PID %d (slot %u) %s\n", X recPis->pid, X recPis->slot, X args ); X X if( !(recPis->flags&PIS_INF_SYS) ) X { X fprintf( stdout, " parent %d", recPis->ppid ); X if( recPis->grp != recPis->pid ) X fprintf( stdout, ", leader %d", recPis->grp ); X if( devname[0] != '\0' ) X fprintf( stdout, " TTY %s", devname ); X fputc( (int)'\n', stdout ); X X if( !(recPis->flags&PIS_INF_ZOMB) ) X { X fprintf( stdout, " uid %d (%s)", recPis->uid, username ); X if( recPis->uid != recPis->ruid ) X fprintf( stdout, ", ruid %d", recPis->ruid ); X fprintf( stdout, ", gid %d", recPis->gid ); X if( recPis->gid != recPis->rgid ) X fprintf( stdout, ", rgid %d", recPis->rgid ); X fputc( (int)'\n', stdout ); X } X } X X buf[0] = '\0'; X if( recPis->flags&PIS_INF_SYS ) X strcat( buf, "System process. " ); X if( recPis->flags&PIS_INF_ZOMB ) X strcat( buf, "Zombie state. " ); X if( recPis->flags&PIS_INF_TRACE ) X strcat( buf, "Being traced. " ); X if( recPis->flags&PIS_INF_LOCK ) X strcat( buf, "Locked. " ); X if( buf[0] != '\0' ) X fprintf( stdout, " %s\n", buf ); X X fprintf( stdout, " Time %s.\n", X secFormat(recPis->time/globalProfile.p_hz) ); X X if( !(recPis->flags&(PIS_INF_ZOMB|PIS_INF_SYS)) ) X { X fprintf( stdout, " Size: %d pages\n", recPis->size ); X X /* Not all platforms have these. */ X if( recPis->heap != -1 ) X fprintf( stdout, " Heap size %s", fmtByte(recPis->heap) ); X if( recPis->heap != -1 ) X fprintf( stdout, " Stack size %s\n", fmtByte(recPis->stk) ); X } X X if( recPis->flags&PIS_INF_SLEEP && !(recPis->flags&PIS_INF_ZOMB) ) X { X fprintf( stdout, " Sleeping on 0x%x", X recPis->sleep ); X X if( (ptr=sleepFind((caddr_t)recPis->proc,recPis->sleep)) != NULL ) X fprintf( stdout, " (%s)", ptr ); X X fputc( (int)'\n', stdout ); X } X X if( recPis->pri[0] != '\0' ) X fprintf( stdout, " Priority: %s\n", recPis->pri ); X X if( !(recPis->flags&(PIS_INF_ZOMB|PIS_INF_SYS)) ) X { X fprintf( stdout, " umask: %03o", recPis->cmask ); X if( recPis->ulimit[0] != '\0' ) X fprintf( stdout, ", ulimit %s", recPis->ulimit ); X fputc( (int)'\n', stdout ); X X fprintf( stdout, " Started %s\n", X startFormat(&recPis->start) ); X X if( recPis->nshm > 0 ) X { X fprintf( stdout, " Attached shared memory segments: %d\n", X recPis->nshm ); X } X X /* X ** Not all platforms have this. And we only print for those X ** processes with more than one LWP. X */ X if( recPis->nlwp > 1 ) X fprintf( stdout, " Number of LWPs: %d\n", recPis->nlwp ); X } X} X X/* X** dispSigs() X** X** Print the dispositions of the signals for a process. The mechanism is X** pretty consistent throughout system V. The array of dispositions is X** passed in. X*/ X#if defined(UW2) Xvoid dispSigs( sigstate_t signals[] ) X#else Xvoid dispSigs( void (*signals[])() ) X#endif X{ X void (*handler)(); X const char *ptr; X int i; X X fputs( " Signals:\n", stdout ); X X /* X ** Loop through all of the signals. Note that signal one is array X ** element zero. X */ X for( i=0; i is the inode id (for inode based platforms). are X** the file flags. is the inode or vnode type. is the X** device for character and block devices. is the device on X** which the descriptor endpoint resides. This is only available on X** inode based platforms. X*/ Xvoid dispFd( int fd, long id, int flags, int type, dev_t rdev, dev_t dev ) X{ X const char *path; X X /* X ** Print the descriptor number and the file flags. X */ X fprintf( stdout, " fd%-2d: %-4s", fd, mkfcntl(flags) ); SHAR_EOF : || $echo 'restore of' 'orion-1.0/pis/util.c' 'failed' fi $echo 'End of' 'orion-1.0' 'part' '3' $echo 'File' 'orion-1.0/pis/util.c' 'is continued in part' '4' echo 4 > _sh05649/seq exit 0