brucee@runx.ips.oz (Bruce Evans) (11/16/88)
Here are some patches for Monty Walls' ps(1). The bugs fixed are (1) it didn't work with a separate I&D kernel (I use separate I&D for everything since it makes crashes less severe). (2) there was overflow in the calculation of mm_offset and fs_offset if their data segment was above 64K absolute (I run a very big kernel with FS starting at 150K. The standard kernel must be very near the border for FS). Warning: /dev/kmem is now used to locate the kernel proc table. You may need my bug fix for this too, posted at the same time as this article. It's the same bug as (2). #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of shell archive." # Contents: ps.c.cdif # Wrapped by local@besplex on Wed Nov 16 04:15:35 1988 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'ps.c.cdif' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'ps.c.cdif'\" else echo shar: Extracting \"'ps.c.cdif'\" \(1818 characters\) sed "s/^X//" >'ps.c.cdif' <<'END_OF_FILE' X*** r/ps.c Wed Nov 16 03:57:20 1988 X--- ps.c Wed Nov 16 02:45:14 1988 X*************** X*** 62,63 **** X--- 62,64 ---- X unsigned ptr; X+ struct proc kernel_proc; X struct proc fs_proc, mm_proc; X*************** X*** 96,98 **** X else X! _kproc = ptr + KERNELBASE; X } X--- 97,99 ---- X else X! _kproc = ptr; X } X*************** X*** 108,110 **** X else X! _aout = ptr + KERNELBASE; X } X--- 109,111 ---- X else X! _aout = ptr; X } X*************** X*** 146,155 **** X } X! X! if ((fd = fopen(KERNEL,"r")) != NULL) { X! /* compute the mem offsets for mm and fs */ X! getblock(fd, _kproc+(MM_SLOT)*sizeof(struct proc), &mm_proc, sizeof(struct proc)); X! getblock(fd, _kproc+(FS_SLOT)*sizeof(struct proc), &fs_proc, sizeof(struct proc)); X! mm_offset = _mproc+mm_proc.p_map[D].mem_phys*CLICK_SIZE; X! fs_offset = _fproc+fs_proc.p_map[D].mem_phys*CLICK_SIZE; X! X print_hdr(stdout,opt); X--- 147,167 ---- X } X! X! if ((fd = fopen("/dev/kmem","r")) != NULL) { X! /* Compute the mem offsets for kernel, mm and fs. X! * _kproc starts relative to kmem, ends relative to mem. X! */ X! getblock(fd, _kproc+(SYSTASK+NR_TASKS)*sizeof(struct proc), X! &kernel_proc, sizeof(struct proc)); X! getblock(fd, _kproc+(MM_SLOT)*sizeof(struct proc), &mm_proc, sizeof(struct proc)); X! getblock(fd, _kproc+(FS_SLOT)*sizeof(struct proc), &fs_proc, sizeof(struct proc)); X! _kproc += (phys_bytes)kernel_proc.p_map[D].mem_phys*CLICK_SIZE; X! _aout += (phys_bytes)kernel_proc.p_map[D].mem_phys*CLICK_SIZE; X! mm_offset = _mproc+(phys_bytes)mm_proc.p_map[D].mem_phys*CLICK_SIZE; X! fs_offset = _fproc+(phys_bytes)fs_proc.p_map[D].mem_phys*CLICK_SIZE; X! fclose(fd); X! if ((fd = fopen(KERNEL,"r")) == NULL) { X! perror(argv[0]); X! exit(2); X! } X! X print_hdr(stdout,opt); END_OF_FILE if test 1818 -ne `wc -c <'ps.c.cdif'`; then echo shar: \"'ps.c.cdif'\" unpacked with wrong size! fi # end of 'ps.c.cdif' fi echo shar: End of shell archive. exit 0 Bruce Evans Internet: brucee@runx.ips.oz.au UUCP: uunet!runx.ips.oz.au!brucee