Subject: Object file symbols limited to 8 characters [+FIX] (#160 - #3 of 19) Index: cc,as,ld,ar,ranlib,nm,nlist,adb,... (2.11BSD) Description: For some time now (seem like eons;-)) the object file format used by Unix for the PDP-11 has restricted symbols to 8 significant characters (actually 7 due to the C compiler prefixing symbols with a leading tilde (~) or underscore (_)). Aside from the "creative constraints" this imposes on the programmer there was the continuing problem of 'name collisions', especially when porting applications from machines whose object file format permitted longer symbol names. Numerous workarounds have been employed in the past. The most common one relied on a combination of a name collision detection program ('shortc') and the flexname capability of the C preprocessor ('cpp'). This served to mask the problem while making debugging difficult due to mangled/synthetic symbol names. Repeat-By: Attempt to compile the following program: int this_is_a_long_name; int this_is_a_long_name_too; main() { exit(0)}; Fix: This section is repeated in each of the 19 parts which make up the update kit. You should read it perhaps once or twice, but then skip over it (how to do that is mentioned below). Taking a "hint" from the a.out(5) man page: "The compiler will note name collisions when they occur within a single file... There is really little that can be done about this. Some thought is being given to modifying the loader to flag detectable collisions, but the real solution would be to change over to the 4BSD a.out format. This would involve modifying the compiler, assembler and adb and then simply porting the 4.3BSD ld, nm, ranlib, strip and nlist. Or perhaps simply porting the entire 4.3BSD suite might be best ... Anyone interested in a project?" This I have done. No more volunteers for the project need apply ;-) The new limit on symbol length is 32 characters! There is still a limit (but it is _much_ more reasonable now) simply because of address space constraints - it needs to be possible to hold at least one of the 'symbol' or 'string' tables in memory in many cases (nice to hold both, but - i know, get a 486;-)). It must be noted though that it is almost trivial now to raise the limit if that is desired - the programs which need to know the maximum length of a symbol string all have an easily changed #define statement now (usually MAXSYMLEN but there are a couple exceptions). The 'string table' format itself doesn't care how long the strings are. The actual a.out format won't have to change again to accomodate a higher limit on symbol name length! The "string table" object file format has been ported and all the necessary changes made throughout the entire system. The changes were *massive* and widespread. Programs affected of course included the assembler and compiler. Other programs affected were anything which accessed a symbol table entry either via nlist(3) [ps, pstat, fstat, vmstat, etc] or by reading object files [ld, ranlib, nm, adb, strip, etc]. The actual changes to the compiler and assembler were minor because those programs had already been modified earlier (updates #142, 143, 152, 153). The compiler only needed to have the maximum size of a symbol name raised. The assembler already knew how to generate 'string table' object files - all that needed to be done in 'as' was to flip a bit telling it to generate the new object format instead of the old style. +++++++++++++++ And now for a bit of a narrative about what was done. The detailed instructions for applying this part (#3 of 19) of the update kit follow the 'story' below. This started out as a semi-organized accounting of what was done but then devolved into a semi-rambling tale due to the sheer bulk of the changes. You can skip to the details for applying #160 by searching for the string "=======" below - this header is replicated in all parts of this kit. +++++++++++++++ Alas, the remaining changes were not so simple. Complete replacements for ranlib(1), ar(1), nlist(3) were ported from the Net-2 release. Other programs such as symorder(1) and two new programs 'symcompact' and 'strcompact' (used to compress/compact symbol and string tables) were written from scratch. Perhaps the two hardest parts of the whole effort were rewriting the linker 'ld' and making *large* modifications to the debugger 'adb'. This was a very difficult job. 'ld needed to scan new style ranlib archives, as well as using the "virtual memory" facility (the 'libvmf' routines posted earlier) for symbol table management and so on. 'adb' was a MESS (having been written in a pseudo block structured macro language). Since the new symbol table entry could be so much larger than the old it was no longer possible for adb to hold as much of the symbol table in memory - an alternate method took a while to develope and implement, more on that in the patch which deals with adb (actually the changes to adb are so large there are two substantial parts of this update kit just for adb!). After the basic programs (ar, ld, ranlib, etc) were running the system had to be completely recompiled from sources, beginning with the object libraries. After those were done the process of recompiling the rest of the system could proceed. Guess what happens when you recreate libc.a with a buggy linker? Yep - the system is rendered useless until backup copies of everything can be reloaded. Don't let this happen to you - be sure (and i'll repeat the point later) to back up the system (or at least key executables and .a files) before installing this upgrade. In all there were about 330 files modified during the change of object file format. Some of these were not directly related to the new object file format. There were a number of (obsolete) references to "BSD2_10" lingering in the system. Those have been replaced with "pdp11" and the 'BSD2_10' define has been removed from the C preprocessor (cpp). DO NOT use 'BSD2_10' to #ifdef pdp-11 sensitive code, use "pdp11" instead. During the recompile of the libraries a fairly large number of "shortened" names were lengthened - these included syscall routines such as "gethostname" which no longer had to be munged into "gethname". Also a surprising number of typographical errors were uncovered (mainly in the Fortran libraries) where an extra character (beyond the 7th character) was left off or accidentally added. These were all fixed and eventually, after a couple evenings, the libraries were built and installed. After the libraries were done it was the application programs' turn to be recompiled. This took the better part of a couple weeks to finally make it thru due to (as it turned out) the iterative nature of the task. A symbol would come up undefined and have to be tracked down exactly where the wrong definition/use was coming from. Finally, however, the task was done and it was time to move on to the kernel. The kernel proved to be suprisingly easy - no real complications arose except when it came time to reboot, a bug had been introduced into 'autoconfig' (who uses 'nlist' to scan the kernel symbol table). Ouch! That was another couple late nights. Since the compiler supports unsigned longs now a number of small changes which ifdef'd 'u_long' to 'long' were removed. REMEMBER - you need to recompile 'autoconfig' and install it before rebooting the new kernel ;-) The performance of 'ps' though (and anything else which used nlist(3), 'fstat', 'w' are good examples) was unacceptably slow. So, amidst other delays (real work, the earthquake - which almost tossed the disc drive to the floor, etc) the "symorder" program was written (with ideas borrowed from the Net-2 version). The symorder(1) program rather insists on holding both the symbol and string tables in memory - this was a problem (or could be if the kernel symbol table grows much more) so two new and original programs were written: 'symcompact' and 'strcompact'. The first program compacts the symbol table by removing 'register' local variables (they're of no use to anyone - the debugger doesn't/can't do anything with them) and redundant global text symbols (symbols in an overlaid program which are in the root segment do not need both the '~' and '_' symbols present). The second program 'strcompact' is one that any 'string table' based object file system can use. It implements "shared strings" for symbols - if a program has many references to 'error' as a local symbol, why store the string 'error' more than once? Simply store one instance and then update the symbol table entries to all point to the same string! Using both 'strcompact' and 'symcompact' on the /unix image resulted in a file that was 15kb smaller. Running 'symorder' then puts the most frequently used symbols at the front of the symbol table, the performance of 'w', 'pstat', and other programs which nlist(3) the kernel was now acceptable. Some of the parts of this kit are large. The large patch files have been split into pieces which the 'patch' will handle, other parts (the replacement 'ar' sources) were left as a single 'shar' file rather than split them up. Each part of this kit consists of: a 'patchfile' - this is used with the "patch" program to update files. an optional 'script' - this is run ("sh script") to perform initialization, remove files, create directories and so on. an optional 'new.sources' - this is a "shar" file containing complete sources for a program. ALL pathnames are _absolute_ - this way you do not have to "cd" around the system, you should be able to apply all the patches while you are in /tmp (or /usr/tmp - wherever you have the most free space). Be sure that you have at least 40mb free on /usr before rebuilding the system - if you do not then building in stages will be necessary. Part 19 contains the detailed instructions for rebuilding the system _after_ the previous 18 patches have been applied. The patches (#158 thru #175) should be applied in order following the directions in each part. DO NOT recompile anything once the patching has begun until requested to do so in part 19. Many of the system include files are modified and the object file format is being changed - recompilation will not be possible until the transformation of the system and object libraries is complete. AT A MINIMUM you will want to back up the following files (unless you have a known good backup already made) in case you need to recompile something before part 19 is done: /bin/ar /bin/ld /bin/nm /bin/as /usr/bin/ranlib /lib/c0 /lib/crt0.o /lib/mcrt0.o /lib/libc.a /bin/nm /usr/include/*.h /usr/include/sys/*.h In part 19 there is a *complete* list of all files affected (all 336 of them) - you may wish to back those up also. And now the common header ('boilerplate') is over (at last ;-)), let the installation guide begin. As always, the complete 2.11BSD updates are available via anonymous FTP to 'ftp.iipo.gtegsc.com' in the directory /pub/2.11BSD ========== #160 (Part #3 of 19) This part updates the following files. BACK THESE UP if you have any worries about the proceedure or do not have a bootable backup already at hand. /usr/src/bin/csh/sh.time.c /usr/src/bin/csh/sh.h /usr/src/bin/csh/shortnames.h /usr/src/bin/make/doname.c /usr/src/bin/make/files.c /usr/src/bin/make/Makefile /usr/src/bin/diff/diffreg.c /usr/src/bin/as/as0.s /usr/src/bin/login/login.c /usr/src/bin/ld.c /usr/src/bin/who.c /usr/src/bin/nm.c /usr/src/bin/adb /usr/src/bin/Makefile /usr/src/bin/ar.c /usr/src/bin/mail.c /usr/src/bin/write.c /usr/src/bin/hostname.c /usr/src/bin/wall.c /usr/src/bin/df.c /usr/src/bin/hostid.c /usr/src/bin/strip.c /usr/src/bin/size.c /usr/src/bin/ps.c 0) Be in a temp directory ("cd /tmp" or "cd /usr/tmp") 1) Save the following shar archive to a file (/tmp/160 for example) 2) Unpack the archive: sh 160 3) Run the script: ./script 4) Patch the files: patch -p0 < patchfile 5) rm 160 script patchfile Part 3 of 19 is done. DO NOT rebuild or compile _anything_ at this point! ============cut here #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create: # script # patchfile # This archive created: Sat Feb 5 23:34:24 1994 export PATH; PATH=/bin:/usr/bin:$PATH if test -f 'script' then echo shar: "will not over-write existing file 'script'" else sed 's/^X//' << \SHAR_EOF > 'script' X#! /bin/sh X Xrm -f /usr/src/bin/csh/shortnames.h Xrm -f /usr/src/bin/ar.c Xrm -f /usr/src/bin/ld.c Xrm -f /usr/src/bin/adb/dummy.c /usr/src/bin/adb/mac.h Xrm -f /usr/src/bin/adb/machine.h /usr/src/bin/adb/mode.h Xrm -rf /usr/src/bin/nm rm /usr/src/bin/ld /usr/src/bin/ar X Xmkdir /usr/src/bin/nm /usr/src/bin/ld /usr/src/bin/ar Xchmod 755 /usr/src/bin/nm /usr/src/bin/ld /usr/src/bin/ar Xmv /usr/src/bin/nm.c /usr/src/bin/nm/nm.c X Xcat > /usr/src/bin/nm/Makefile <<'_MAKEFILE_' XSRCS= nm.c XOBJS= nm.o XCFLAGS= -O -I../ar X Xall: nm X Xnm: ${OBJS} X cc -z -o nm ${OBJS} X Xinstall: X install -c -s -o bin -g bin -m 755 nm ${DESTDIR}/bin/nm X Xlint: X lint -havx -I../ar ${SRCS} X Xclean: X rm -f *.o *.0 nm X_MAKEFILE_ X Xchmod 644 /usr/src/bin/nm/Makefile /usr/src/bin/ld/Makefile SHAR_EOF chmod 755 'script' fi if test -f 'patchfile' then echo shar: "will not over-write existing file 'patchfile'" else sed 's/^X//' << \SHAR_EOF > 'patchfile' X*** /usr/src/bin/nm/nm.c.old Wed Dec 19 10:25:58 1990 X--- /usr/src/bin/nm/nm.c Sat Feb 5 23:17:33 1994 X*************** X*** 1,39 **** X! #ifndef lint X! /* static char sccsid[] = "@(#)nm.c 4.7 5/19/86"; */ X! static char sccsid[] = "@(#)nm.c 2.11BSD 11/24/90"; X #endif X /* X! * nm - print name list; VAX string table version X */ X #include X #include X #include X #include X #include X X! #define SELECT archive ? archdr.ar_name : *xargv X X! int aflg, gflg, nflg, oflg, pflg, uflg; X! int rflg = 1; X! char **xargv; X! int archive; X! struct ar_hdr archdr; X! union { X! char mag_armag[SARMAG+1]; X! struct exec mag_exp; X! } mag_un; X! #define OARMAG 0177545 X! FILE *fi; X! off_t off; X! off_t ftell(); X! char *malloc(); X! long atol(); X! int compare(); X! int narg; X! int errs; X X main(argc, argv) X! char **argv; X { X X if (--argc>0 && argv[1][0]=='-' && argv[1][1]!=0) { X--- 1,40 ---- X! #if !defined(lint) && !defined(DOSCCS) X! static char sccsid[] = "@(#)nm.c 2.11BSD 1/22/94"; X #endif X /* X! * nm - print name list. string table version X */ X #include X+ #include X #include X #include X #include X #include X+ #include X+ #include "archive.h" X+ #include X X! CHDR chdr; X X! #define SELECT archive ? chdr.name : *xargv X X+ char aflg, gflg, nflg, oflg, pflg, uflg, rflg = 1, archive; X+ char **xargv; X+ char *strp; X+ union { X+ char mag_armag[SARMAG+1]; X+ struct xexec mag_exp; X+ } mag_un; X+ X+ off_t off, skip(); X+ extern off_t ftell(); X+ extern char *malloc(); X+ extern long strtol(); X+ int compare(), narg, errs; X+ X main(argc, argv) X! int argc; X! char **argv; X { X X if (--argc>0 && argv[1][0]=='-' && argv[1][1]!=0) { X*************** X*** 83,89 **** X X namelist() X { X! register int j; X X archive = 0; X fi = fopen(*xargv, "r"); X--- 84,91 ---- X X namelist() X { X! char ibuf[BUFSIZ]; X! register FILE *fi; X X archive = 0; X fi = fopen(*xargv, "r"); X*************** X*** 91,109 **** X error(0, "cannot open"); X return; X } X! off = SARMAG; X fread((char *)&mag_un, 1, sizeof(mag_un), fi); X! if (mag_un.mag_exp.a_magic == OARMAG) { X! error(0, "old archive"); X! goto out; X! } X! if (strncmp(mag_un.mag_armag, ARMAG, SARMAG)==0) X archive++; X! else if (N_BADMAG(mag_un.mag_exp)) { X error(0, "bad format"); X goto out; X } X! fseek(fi, 0L, 0); X if (archive) { X nextel(fi); X if (narg > 1) X--- 93,112 ---- X error(0, "cannot open"); X return; X } X! setbuf(fi, ibuf); X! X! off = 0; X fread((char *)&mag_un, 1, sizeof(mag_un), fi); X! if (strncmp(mag_un.mag_armag, ARMAG, SARMAG)==0) { X archive++; X! off = SARMAG; X! } X! else if (N_BADMAG(mag_un.mag_exp.e)) { X error(0, "bad format"); X goto out; X } X! rewind(fi); X! X if (archive) { X nextel(fi); X if (narg > 1) X*************** X*** 110,148 **** X printf("\n%s:\n", *xargv); X } X do { X! off_t o; X! register i, n, c; X struct nlist *symp = NULL; X! struct nlist sym; X! unsigned ovsizes[NOVL+1]; X X! fread((char *)&mag_un.mag_exp, 1, sizeof(struct exec), fi); X! if (N_BADMAG(mag_un.mag_exp)) X continue; X X! if (mag_un.mag_exp.a_magic == A_MAGIC5 || X! mag_un.mag_exp.a_magic == A_MAGIC6) { X! fread((char *)ovsizes, 1, sizeof(ovsizes), fi); X! o = 0L; X! for (i = 1; i <= NOVL; i++) X! o += (long)ovsizes[i]; X! fseek(fi, o, 1); X! } X! X! o = (long)mag_un.mag_exp.a_text + mag_un.mag_exp.a_data; X! if ((mag_un.mag_exp.a_flag & 01) == 0) X! o *= 2; X! fseek(fi, o, 1); X! n = mag_un.mag_exp.a_syms / sizeof(struct nlist); X if (n == 0) { X error(0, "no name list"); X continue; X } X X- o = ftell(fi); X i = 0; X while (--n >= 0) { X fread((char *)&sym, 1, sizeof(sym), fi); X if (gflg && (sym.n_type & N_EXT) == 0) X continue; X if (uflg && (sym.n_type & N_TYPE) == N_UNDF && sym.n_value) X--- 113,144 ---- X printf("\n%s:\n", *xargv); X } X do { X! off_t o, curpos, stroff; X! long strsiz; X! register i, n; X struct nlist *symp = NULL; X! struct nlist sym; X X! curpos = ftell(fi); X! fread((char *)&mag_un.mag_exp, 1, sizeof(struct xexec), fi); X! if (N_BADMAG(mag_un.mag_exp.e)) X continue; X X! o = N_SYMOFF(mag_un.mag_exp); X! fseek(fi, curpos + o, L_SET); X! n = mag_un.mag_exp.e.a_syms / sizeof(struct nlist); X if (n == 0) { X error(0, "no name list"); X continue; X } X X i = 0; X+ if (strp) X+ free(strp), strp = 0; X while (--n >= 0) { X fread((char *)&sym, 1, sizeof(sym), fi); X+ if (sym.n_un.n_strx == 0) X+ continue; X if (gflg && (sym.n_type & N_EXT) == 0) X continue; X if (uflg && (sym.n_type & N_TYPE) == N_UNDF && sym.n_value) X*************** X*** 150,163 **** X i++; X } X X! fseek(fi, o, 0); X symp = (struct nlist *)malloc(i * sizeof (struct nlist)); X if (symp == 0) X error(1, "out of memory"); X i = 0; X! n = mag_un.mag_exp.a_syms / sizeof(struct nlist); X while (--n >= 0) { X fread((char *)&sym, 1, sizeof(sym), fi); X if (gflg && (sym.n_type & N_EXT) == 0) X continue; X if (uflg && (sym.n_type & N_TYPE) == N_UNDF && sym.n_value) X--- 146,161 ---- X i++; X } X X! fseek(fi, curpos + o, L_SET); X symp = (struct nlist *)malloc(i * sizeof (struct nlist)); X if (symp == 0) X error(1, "out of memory"); X i = 0; X! n = mag_un.mag_exp.e.a_syms / sizeof(struct nlist); X while (--n >= 0) { X fread((char *)&sym, 1, sizeof(sym), fi); X+ if (sym.n_un.n_strx == 0) X+ continue; X if (gflg && (sym.n_type & N_EXT) == 0) X continue; X if (uflg && (sym.n_type & N_TYPE) == N_UNDF && sym.n_value) X*************** X*** 164,169 **** X--- 162,179 ---- X continue; X symp[i++] = sym; X } X+ stroff = curpos + N_STROFF(mag_un.mag_exp); X+ fseek(fi, stroff, L_SET); X+ if (fread(&strsiz, sizeof (long), 1, fi) != 1) X+ error(1, "no string table"); X+ strp = (char *)malloc((int)strsiz); X+ if (strp == NULL || strsiz > 48 * 1024L) X+ error(1, "ran out of memory"); X+ if (fread(strp+sizeof(strsiz),(int)strsiz-sizeof(strsiz),1,fi) != 1) X+ error(1, "error reading strings"); X+ for (n = 0; n < i; n++) X+ symp[n].n_un.n_name = strp + (int)symp[n].n_un.n_strx; X+ X if (pflg==0) X qsort(symp, i, sizeof(struct nlist), compare); X if ((archive || narg>1) && oflg==0) X*************** X*** 170,176 **** X printf("\n%s:\n", SELECT); X psyms(symp, i); X if (symp) X! free((char *)symp), symp = 0; X } while(archive && nextel(fi)); X out: X fclose(fi); X--- 180,188 ---- X printf("\n%s:\n", SELECT); X psyms(symp, i); X if (symp) X! free((char *)symp), symp = NULL; X! if (strp) X! free((char *)strp), strp = NULL; X } while(archive && nextel(fi)); X out: X fclose(fi); X*************** X*** 228,246 **** X printf(N_FORMAT, symp[n].n_value); X printf(" %c ", c); X } X! if (symp[n].n_type & 0xff00) X! printf("%-8.8s %d\n", symp[n].n_name, X! (symp[n].n_type >> 8) & 0xff); X else X! printf("%.8s\n", symp[n].n_name); X! l1: ; X } X } X X compare(p1, p2) X! struct nlist *p1, *p2; X { X- register i; X X if (nflg) { X if (p1->n_value > p2->n_value) X--- 240,256 ---- X printf(N_FORMAT, symp[n].n_value); X printf(" %c ", c); X } X! if (symp[n].n_ovly) X! printf("%s %d\n", symp[n].n_un.n_name, X! symp[n].n_ovly & 0xff); X else X! printf("%s\n", symp[n].n_un.n_name); X } X } X X compare(p1, p2) X! register struct nlist *p1, *p2; X { X X if (nflg) { X if (p1->n_value > p2->n_value) X*************** X*** 248,274 **** X if (p1->n_value < p2->n_value) X return(-rflg); X } X! return (rflg * strcmp(p1->n_name, p2->n_name)); X } X X nextel(af) X FILE *af; X { X! register char *cp; X! register r; X! long arsize; X! X! fseek(af, off, 0); X! r = fread((char *)&archdr, 1, sizeof(struct ar_hdr), af); X! if (r != sizeof(struct ar_hdr)) X return(0); X! for (cp = archdr.ar_name; cp < &archdr.ar_name[sizeof(archdr.ar_name)]; cp++) X! if (*cp == ' ') X! *cp = '\0'; X! arsize = atol(archdr.ar_size); X! if (arsize & 1) X! ++arsize; X! off = ftell(af) + arsize; /* beginning of next element */ X return(1); X } X X--- 258,275 ---- X if (p1->n_value < p2->n_value) X return(-rflg); X } X! return (rflg * strcmp(p1->n_un.n_name, p2->n_un.n_name)); X } X X nextel(af) X FILE *af; X { X! X! fseek(af, off, L_SET); X! if (get_arobj(af) < 0) X return(0); X! off += (sizeof (struct ar_hdr) + chdr.size + X! (chdr.size + chdr.lname & 1)); X return(1); X } X X*************** X*** 277,283 **** X { X fprintf(stderr, "nm: %s:", *xargv); X if (archive) { X! fprintf(stderr, "(%s)", archdr.ar_name); X fprintf(stderr, ": "); X } else X fprintf(stderr, " "); X--- 278,284 ---- X { X fprintf(stderr, "nm: %s:", *xargv); X if (archive) { X! fprintf(stderr, "(%s)", chdr.name); X fprintf(stderr, ": "); X } else X fprintf(stderr, " "); X*************** X*** 285,288 **** X--- 286,364 ---- X if (n) X exit(2); X errs = 1; X+ } X+ X+ /* X+ * "borrowed" from 'ar' because we didn't want to drag in everything else X+ * from 'ar'. The error checking was also ripped out, basically if any X+ * of the criteria for being an archive are not met then a -1 is returned X+ * and the rest of 'ld' figures out what to do. X+ */ X+ X+ typedef struct ar_hdr HDR; X+ static char hb[sizeof(HDR) + 1]; /* real header */ X+ X+ /* Convert ar header field to an integer. */ X+ #define AR_ATOI(from, to, len, base) { \ X+ bcopy(from, buf, len); \ X+ buf[len] = '\0'; \ X+ to = strtol(buf, (char **)NULL, base); \ X+ } X+ X+ /* X+ * read the archive header for this member. Use a file pointer X+ * rather than a file descriptor. X+ */ X+ get_arobj(fp) X+ FILE *fp; X+ { X+ HDR *hdr; X+ register int len, nr; X+ register char *p; X+ char buf[20]; X+ X+ nr = fread(hb, 1, sizeof(HDR), fp); X+ if (nr != sizeof(HDR)) X+ return(-1); X+ X+ hdr = (HDR *)hb; X+ if (strncmp(hdr->ar_fmag, ARFMAG, sizeof(ARFMAG) - 1)) X+ return(-1); X+ X+ /* Convert the header into the internal format. */ X+ #define DECIMAL 10 X+ #define OCTAL 8 X+ X+ AR_ATOI(hdr->ar_date, chdr.date, sizeof(hdr->ar_date), DECIMAL); X+ AR_ATOI(hdr->ar_uid, chdr.uid, sizeof(hdr->ar_uid), DECIMAL); X+ AR_ATOI(hdr->ar_gid, chdr.gid, sizeof(hdr->ar_gid), DECIMAL); X+ AR_ATOI(hdr->ar_mode, chdr.mode, sizeof(hdr->ar_mode), OCTAL); X+ AR_ATOI(hdr->ar_size, chdr.size, sizeof(hdr->ar_size), DECIMAL); X+ X+ /* Leading spaces should never happen. */ X+ if (hdr->ar_name[0] == ' ') X+ return(-1); X+ X+ /* X+ * Long name support. Set the "real" size of the file, and the X+ * long name flag/size. X+ */ X+ if (!bcmp(hdr->ar_name, AR_EFMT1, sizeof(AR_EFMT1) - 1)) { X+ chdr.lname = len = atoi(hdr->ar_name + sizeof(AR_EFMT1) - 1); X+ if (len <= 0 || len > MAXNAMLEN) X+ return(-1); X+ nr = fread(chdr.name, 1, (size_t)len, fp); X+ if (nr != len) X+ return(-1); X+ chdr.name[len] = 0; X+ chdr.size -= len; X+ } else { X+ chdr.lname = 0; X+ bcopy(hdr->ar_name, chdr.name, sizeof(hdr->ar_name)); X+ X+ /* Strip trailing spaces, null terminate. */ X+ for (p = chdr.name + sizeof(hdr->ar_name) - 1; *p == ' '; --p); X+ *++p = '\0'; X+ } X+ return(1); X } X*** /usr/src/bin/csh/sh.time.c.old Sat Aug 31 00:12:32 1991 X--- /usr/src/bin/csh/sh.time.c Mon Jan 10 21:37:42 1994 X*************** X*** 5,11 **** X */ X X #if !defined(lint) && defined(DOSCCS) X! static char *sccsid = "@(#)sh.time.c 5.4 (Berkeley) 5/13/86"; X #endif X X #include "sh.h" X--- 5,11 ---- X */ X X #if !defined(lint) && defined(DOSCCS) X! static char *sccsid = "@(#)sh.time.c 5.4.1 (2.11BSD GTE) 12/31/93"; X #endif X X #include "sh.h" X*************** X*** 89,99 **** X long ms = X (e->tv_sec-b->tv_sec)*100 + (e->tv_usec-b->tv_usec)/10000; X X! #ifdef BSD2_10 X cp = "%Uu %Ss %E %P %I+%Oio %Vov %Wsw"; X! #else !BSD2_10 X cp = "%Uu %Ss %E %P %X+%Dk %I+%Oio %Fpf+%Ww"; X! #endif BSD2_10 X if (vp && vp->vec[0] && vp->vec[1]) X cp = vp->vec[1]; X for (; *cp; cp++) X--- 89,99 ---- X long ms = X (e->tv_sec-b->tv_sec)*100 + (e->tv_usec-b->tv_usec)/10000; X X! #ifdef pdp11 X cp = "%Uu %Ss %E %P %I+%Oio %Vov %Wsw"; X! #else X cp = "%Uu %Ss %E %P %X+%Dk %I+%Oio %Fpf+%Ww"; X! #endif X if (vp && vp->vec[0] && vp->vec[1]) X cp = vp->vec[1]; X for (; *cp; cp++) X*************** X*** 117,127 **** X printf("%d%%", (int) (t*100 / ((ms ? ms : 1)))); X break; X X! #ifdef BSD2_10 X case 'V': X printf("%ld", r1->ru_ovly - r0->ru_ovly); X break; X! #endif BSD2_10 X X case 'W': X i = r1->ru_nswap - r0->ru_nswap; X--- 117,127 ---- X printf("%d%%", (int) (t*100 / ((ms ? ms : 1)))); X break; X X! #ifdef pdp11 X case 'V': X printf("%ld", r1->ru_ovly - r0->ru_ovly); X break; X! #endif X X case 'W': X i = r1->ru_nswap - r0->ru_nswap; X*** /usr/src/bin/csh/sh.h.old Sun Dec 25 11:17:09 1988 X--- /usr/src/bin/csh/sh.h Mon Jan 10 21:38:15 1994 X*************** X*** 3,15 **** X * All rights reserved. The Berkeley Software License Agreement X * specifies the terms and conditions for redistribution. X * X! * @(#)sh.h 5.3 (Berkeley) 3/29/86 X */ X X- #ifdef BSD2_10 X- #include "shortnames.h" X- #endif BSD2_10 X- X #include X #include X #include X--- 3,11 ---- X * All rights reserved. The Berkeley Software License Agreement X * specifies the terms and conditions for redistribution. X * X! * @(#)sh.h 5.3.1 (2.11BSD GTE) 1/1/94 X */ X X #include X #include X #include X*************** X*** 340,346 **** X * A reasonable limit on number of arguments would seem to be X * the maximum number of characters in an arg list / 6. X */ X! #ifdef BSD2_10 X #define GAVSIZ NCARGS / 12 X #else X #define GAVSIZ NCARGS / 6 X--- 336,342 ---- X * A reasonable limit on number of arguments would seem to be X * the maximum number of characters in an arg list / 6. X */ X! #ifdef pdp11 X #define GAVSIZ NCARGS / 12 X #else X #define GAVSIZ NCARGS / 6 X*** /usr/src/bin/make/doname.c.old Wed Aug 14 05:32:46 1991 X--- /usr/src/bin/make/doname.c Mon Jan 10 21:38:45 1994 X*************** X*** 1,4 **** X! /* static char *sccsid = "@(#)doname.c 4.9 (Berkeley) 87/06/18"; */ X #include "defs" X #include X #include X--- 1,4 ---- X! /* static char *sccsid = "@(#)doname.c 4.9.1 (2.11BSD GTE) 1/1/94"; */ X #include "defs" X #include X #include X*************** X*** 12,18 **** X p->done = 3 file make failed X */ X X! extern char *sys_siglist[], arfile[], arfname[]; X X doname(p, reclevel, tval) X register struct nameblock *p; X--- 12,18 ---- X p->done = 3 file make failed X */ X X! extern char *sys_siglist[], arfile[], *arfname; X X doname(p, reclevel, tval) X register struct nameblock *p; X*************** X*** 29,35 **** X struct shblock *implcom, *explcom; X register struct lineblock *lp; X struct lineblock *lp1, *lp2; X! #ifdef BSD2_10 X /* temp and sourcename are mutually exclusive - save 254 bytes of stack by X * reusing sourcename's buffer X */ X--- 29,35 ---- X struct shblock *implcom, *explcom; X register struct lineblock *lp; X struct lineblock *lp1, *lp2; X! #ifdef pdp11 X /* temp and sourcename are mutually exclusive - save 254 bytes of stack by X * reusing sourcename's buffer X */ X*** /usr/src/bin/make/files.c.old Wed Aug 14 05:40:03 1991 X--- /usr/src/bin/make/files.c Mon Jan 10 21:39:02 1994 X*************** X*** 1,10 **** X! /* static char *sccsid = "@(#)files.c 4.16 (Berkeley) 87/06/18"; */ X #include X #include X X /* UNIX DEPENDENT PROCEDURES */ X X- X /* DEFAULT RULES FOR UNIX */ X X char *builtin[] = X--- 1,9 ---- X! /* static char *sccsid = "@(#)files.c 4.16.1 (2.11BSD) 1/3/94"; */ X #include X #include X X /* UNIX DEPENDENT PROCEDURES */ X X /* DEFAULT RULES FOR UNIX */ X X char *builtin[] = X*************** X*** 406,491 **** X #endif X X X! /* look inside archives for notations a(b) and a((b)) X a(b) is file member b in archive a X- a((b)) is entry point _b in object archive a X */ X X! #ifdef ASCARCH X! # include X! #else X! # include X! #endif X! #include X X! static long arflen; X! static long arfdate; X! struct ar_hdr arhead; X! char arfile[MAXPATHLEN]; X! char arfname[sizeof(arhead.ar_name)]; X! FILE *arfd; X! long int arpos, arlen; X X- X TIMETYPE lookarch(filename) X! char *filename; X! { X! char *p, *q, *send, s[MAXNAMLEN + 1]; X! int nc, objarch; X X! for(p = filename; *p!= '(' ; ++p) X! ; X! *p = '\0'; X! openarch(filename); X! *p++ = '('; X X! if(*p == '(') X! { X! objarch = YES; X! #ifdef pdp X! nc = 8; X! #else X! nc = (int)index(p, ')') - (int)p; X! #endif X! ++p; X! } X! else X! { X! objarch = NO; X! nc = sizeof(arfname); X! } X! send = s + nc; X X! for( q = s ; q X! #include "archive.h" /* from 'ar's directory */ X X! char arfile[MAXPATHLEN]; X! CHDR chdr; X! char *arfname = chdr.name; X! FILE *arfd; X! off_t arpos; X X TIMETYPE lookarch(filename) X! char *filename; X! { X! char *p, *q, *send, s[MAXNAMLEN + 1]; X X! for (p = filename; *p!= '(' ; ++p) X! ; X! *p = '\0'; X! strcpy(arfile, filename); X! openarch(filename); X! *p++ = '('; X X! send = s + sizeof(s); X X! for( q = s; q < send && *p!='\0' && *p!=')' ; *q++ = *p++) X! ; X! *q++ = '\0'; X! while (getarch()) X { X! if (!strcmp(arfname, s)) X { X clarch(); X! return(chdr.date); X } X+ arpos += (chdr.size + (chdr.size + chdr.lname & 1)); X+ arpos += sizeof (struct ar_hdr); X } X! strcpy(chdr.name, s); X! clarch(); X! return(0L); X } X X X clarch() X { X if (arfd) X*************** X*** 495,643 **** X X openarch(f) X register char *f; X! { X! #ifdef ASCARCH X! char magic[SARMAG]; X! #endif X! int word; X! #include X! struct stat buf; X X! strcpy(arfile, f); X! stat(f, &buf); X! arlen = buf.st_size; X X- arfd = fopen(f, "r"); X- if(arfd == NULL) X- return; X- X- fread( (char *) &word, sizeof(word), 1, arfd); X- #ifdef ASCARCH X fseek(arfd, 0L, 0); X fread(magic, SARMAG, 1, arfd); X arpos = SARMAG; X! if( ! eqstr(magic, ARMAG, SARMAG) ) X! #else X! arpos = sizeof(word); X! if(word != ARMAG) X! #endif X fatal1("%s is not an archive", f); X X! arflen = 0; X! } X X X X getarch() X { X struct ar_hdr arhead; X! long atol(); X! char *cc; X X! if (!arfd) X! return(0); X! arpos += (arflen + 1) & ~1L; /* round archived file length up to even */ X! if(arpos >= arlen) X! return(0); X! fseek(arfd, arpos, 0); X X! fread( (char *) &arhead, sizeof(arhead), 1, arfd); X! arpos += sizeof(arhead); X! #ifdef ASCARCH X! arflen = atol(arhead.ar_size); X! arfdate = atol(arhead.ar_date); X! #else X! arflen = arhead.ar_size; X! arfdate = arhead.ar_date; X! #endif X! strncpy(arfname, arhead.ar_name, sizeof(arhead.ar_name)); X! for (cc = arfname + sizeof(arfname) - 1; cc > arfname; --cc) X! if (*cc == '\0' || *cc == ' ') X! *cc = '\0'; X! else X! break; X! return(1); X! } X X X! getobj(s) X! char *s; X! { X! char *calloc(); X! struct exec objhead; X! long int off; X! #ifdef BSD2_10 X! struct nlist objentry; X! #else X! long int ret = 0, strsize; X! struct nlist *zz; X! char *ss = 0; X! #endif X! int i, nsym; X X! off = ftell(arfd); X! fread( (char *) &objhead, sizeof(objhead), 1, arfd); X! if (N_BADMAG(objhead)) X! return (0); X! nsym = objhead.a_syms / sizeof(struct nlist); X! if (nsym <= 0) return (0); X! #ifdef BSD2_10 X! off = objhead.a_text + objhead.a_data; X! if(! objhead.a_flag ) X! off *= 2; X! fseek(arfd, off, 1); X! #else X! zz = (struct nlist *)calloc(nsym, sizeof(struct nlist)); X! if (!zz) return (0); X! fseek(arfd, off + N_SYMOFF(objhead), 0); X! if(fread( (char *) zz, sizeof(struct nlist), nsym, arfd) != nsym) X! goto freeall; X! fseek(arfd, off + N_STROFF(objhead), 0); X! if (fread((char *)&strsize, sizeof(strsize), 1, arfd) != 1) X! goto freeall; X! ss = calloc(1, strsize - 4); X! if (!ss) goto freeall; X! if (fread(ss, strsize - 4, 1, arfd) != 1) X! goto freeall; X! #endif X! for (i = 0; i < nsym; ++i) X! #ifdef BSD2_10 X! { X! if (fread(&objentry, sizeof(objentry), 1, arfd) != 1) X! return (0); X! if ((objentry.n_type == (N_EXT | N_TEXT)) && X! !strncmp(objentry.n_name, s, 8)) X! return (1); X! } X! #else X! if( (zz[i].n_type == N_EXT | N_TEXT && X! !strcmp(ss + zz[i].n_un.n_strx - 4, s))) X! { X! ret = 1; X! goto freeall; X! } X! #endif X! #ifdef BSD2_10 X! return (0); X! #else X! freeall: X! if (zz) free(zz); X! if (ss) free(ss); X! return (ret); X! #endif X! } X X! eqstr(a,b,n) X! register char *a, *b; X! int n; X! { X! register int i; X! for(i = 0 ; i < n ; ++i) X! if(*a++ != *b++) X! return(NO); X! return(YES); X! } X X X /* X * findfl(name) (like execvp, but does path search and finds files) X--- 460,555 ---- X X openarch(f) X register char *f; X! { X! char magic[SARMAG]; X X! arfd = fopen(f, "r"); X! if (arfd == NULL) X! return; X X fseek(arfd, 0L, 0); X fread(magic, SARMAG, 1, arfd); X arpos = SARMAG; X! if (strncmp(magic, ARMAG, SARMAG)) X fatal1("%s is not an archive", f); X+ } X X! /* X! * "borrowed" from 'ld' because we didn't want to drag in everything X! * from 'ar'. The error checking was also ripped out, basically if any X! * of the criteria for being an archive are not met then a -1 is returned X! * and the rest of 'make' figures out what to do (bails out). X! */ X X+ typedef struct ar_hdr HDR; X+ extern long strtol(); X X+ /* Convert ar header field to an integer. */ X+ #define AR_ATOI(from, to, len, base) { \ X+ bcopy(from, buf, len); \ X+ buf[len] = '\0'; \ X+ to = strtol(buf, (char **)NULL, base); \ X+ } X X getarch() X { X+ char hb[sizeof(HDR) + 1]; /* real header */ X struct ar_hdr arhead; X! register HDR *hdr; X! register int len; X! int nr; X! register char *p; X! char buf[20]; X X! if (!arfd) X! return(0); X! fseek(arfd, arpos, 0); X X! nr = fread(hb, 1, sizeof(HDR), arfd); X! if (nr != sizeof(HDR)) X! return(0); X X+ hdr = (HDR *)hb; X+ if (strncmp(hdr->ar_fmag, ARFMAG, sizeof(ARFMAG) - 1)) X+ return(0); X X! /* Convert the header into the internal format. */ X! #define DECIMAL 10 X! #define OCTAL 8 X X! AR_ATOI(hdr->ar_date, chdr.date, sizeof(hdr->ar_date), DECIMAL); X! AR_ATOI(hdr->ar_uid, chdr.uid, sizeof(hdr->ar_uid), DECIMAL); X! AR_ATOI(hdr->ar_gid, chdr.gid, sizeof(hdr->ar_gid), DECIMAL); X! AR_ATOI(hdr->ar_mode, chdr.mode, sizeof(hdr->ar_mode), OCTAL); X! AR_ATOI(hdr->ar_size, chdr.size, sizeof(hdr->ar_size), DECIMAL); X X! /* Leading spaces should never happen. */ X! if (hdr->ar_name[0] == ' ') X! return(-1); X X+ /* X+ * Long name support. Set the "real" size of the file, and the X+ * long name flag/size. X+ */ X+ if (!bcmp(hdr->ar_name, AR_EFMT1, sizeof(AR_EFMT1) - 1)) { X+ chdr.lname = len = atoi(hdr->ar_name + sizeof(AR_EFMT1) - 1); X+ if (len <= 0 || len > MAXNAMLEN) X+ return(-1); X+ nr = fread(chdr.name, 1, (size_t)len, arfd); X+ if (nr != len) X+ return(0); X+ chdr.name[len] = 0; X+ chdr.size -= len; X+ } else { X+ chdr.lname = 0; X+ bcopy(hdr->ar_name, chdr.name, sizeof(hdr->ar_name)); X+ X+ /* Strip trailing spaces, null terminate. */ X+ for (p = chdr.name + sizeof(hdr->ar_name) - 1; *p == ' '; --p); X+ *++p = '\0'; X+ } X+ return(1); X+ } X X /* X * findfl(name) (like execvp, but does path search and finds files) X*** /usr/src/bin/make/Makefile.old Mon Jan 18 08:45:21 1993 X--- /usr/src/bin/make/Makefile Thu Jan 6 20:22:23 1994 X*************** X*** 1,13 **** X # Description file for the Make command X! # Makefile 4.4 85/04/16 X X OBJECTS=ident.o main.o doname.o misc.o files.o dosys.o gram.o X LIBES= X LINT= lint -ps X XSTR= /usr/ucb/xstr X! # 2.11BSD uses the newer ascii format archives, not the old binary format X! CFLAGS= -O -DASCARCH -I. X! # CFLAGS= -O -I. X SEPFLAG= -i X X # Special massaging of C files for sharing of strings X--- 1,11 ---- X # Description file for the Make command X! # Makefile 4.5 94/1/3 X X OBJECTS=ident.o main.o doname.o misc.o files.o dosys.o gram.o X LIBES= X LINT= lint -ps X XSTR= /usr/ucb/xstr X! CFLAGS= -O -I. -I../ar X SEPFLAG= -i X X # Special massaging of C files for sharing of strings X*************** X*** 31,37 **** X install -s make ${DESTDIR}/bin/make X X lint : dosys.c doname.c files.c main.c misc.c ident.c gram.c X! ${LINT} -DASCARCH dosys.c doname.c files.c main.c misc.c ident.c gram.c X rm -f gram.c X X gram.c: gram.y X--- 29,35 ---- X install -s make ${DESTDIR}/bin/make X X lint : dosys.c doname.c files.c main.c misc.c ident.c gram.c X! ${LINT} dosys.c doname.c files.c main.c misc.c ident.c gram.c X rm -f gram.c X X gram.c: gram.y X*** /usr/src/bin/diff/diffreg.c.old Tue Nov 12 12:31:37 1991 X--- /usr/src/bin/diff/diffreg.c Mon Jan 10 21:39:33 1994 X*************** X*** 1,5 **** X #if !defined(lint) && defined(DOSCCS) X! static char sccsid[] = "@(#)diffreg.c 4.16 3/29/86"; X #endif X X #include "diff.h" X--- 1,5 ---- X #if !defined(lint) && defined(DOSCCS) X! static char sccsid[] = "@(#)diffreg.c 4.16.1 (2.11BSD) 1/1/94"; X #endif X X #include "diff.h" X*************** X*** 666,678 **** X if (anychange && opt == D_CONTEXT) X dump_context_vec(); X } X- X- #ifdef BSD2_10 X- #define context_vec c_vec /* 7 char name conflict with */ X- #define context_vec_start c_vec_s /* context in diff.h */ X- #define context_vec_end c_vec_e X- #define context_vec_ptr c_vec_p X- #endif BSD2_10 X X /* X * The following struct is used to record change information when X--- 666,671 ---- X*** /usr/src/bin/as/as0.s.old Wed Sep 1 19:44:55 1993 X--- /usr/src/bin/as/as0.s Wed Sep 15 19:26:30 1993 X*************** X*** 32,38 **** X / }; X X .data X! Newsym: 0 X .text X X PSTENTSZ = 6. X--- 32,38 ---- X / }; X X .data X! Newsym: 1 X .text X X PSTENTSZ = 6. X*** /usr/src/bin/login/login.c.old Sun Jul 22 15:33:56 1990 X--- /usr/src/bin/login/login.c Mon Jan 10 21:40:07 1994 X*************** X*** 15,29 **** X * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. X */ X X! #ifndef lint X char copyright[] = X "@(#) Copyright (c) 1980, 1987, 1988 The Regents of the University of California.\n\ X All rights reserved.\n"; X- #endif /* not lint */ X X! #ifndef lint X! static char sccsid[] = "@(#)login.c 5.40 (Berkeley) 5/9/89"; X! #endif /* not lint */ X X /* X * login [ name ] X--- 15,27 ---- X * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. X */ X X! #if defined(DOSCCS) && !defined(lint) X char copyright[] = X "@(#) Copyright (c) 1980, 1987, 1988 The Regents of the University of California.\n\ X All rights reserved.\n"; X X! static char sccsid[] = "@(#)login.c 5.40.1 (2.11BSD GTE) 1/1/94"; X! #endif X X /* X * login [ name ] X*************** X*** 53,62 **** X #include X #include X #include "pathnames.h" X- X- #ifdef BSD2_10 X- #define getloginname _gtlgnnm X- #endif X X #ifdef KERBEROS X #include X--- 51,56 ---- X*** /usr/src/bin/who.c.old Mon Feb 16 02:06:01 1987 X--- /usr/src/bin/who.c Mon Jan 10 21:40:29 1994 X*************** X*** 4,26 **** X * specifies the terms and conditions for redistribution. X */ X X! #ifndef lint X char copyright[] = X "@(#) Copyright (c) 1980 Regents of the University of California.\n\ X All rights reserved.\n"; X- #endif not lint X X! #ifndef lint X! static char sccsid[] = "@(#)who.c 5.1 (Berkeley) 5/2/85"; X! #endif not lint X X /* X * who X */ X- X- #ifdef BSD2_10 X- #include X- #endif BSD2_10 X X #include X #include X--- 4,20 ---- X * specifies the terms and conditions for redistribution. X */ X X! #if defined(DOSCCS) && !defined(lint) X char copyright[] = X "@(#) Copyright (c) 1980 Regents of the University of California.\n\ X All rights reserved.\n"; X X! static char sccsid[] = "@(#)who.c 5.1.1 (2.11BSD GTE) 12/31/93"; X! #endif X X /* X * who X */ X X #include X #include X*** /usr/src/bin/Makefile.old Mon Jan 18 08:45:15 1993 X--- /usr/src/bin/Makefile Sat Jan 15 23:41:35 1994 X*************** X*** 3,9 **** X # All rights reserved. The Berkeley software License Agreement X # specifies the terms and conditions for redistribution. X # X! # @(#)Makefile 5.19 (Berkeley) 5/22/86 X # X DESTDIR= X CFLAGS= -O X--- 3,9 ---- X # All rights reserved. The Berkeley software License Agreement X # specifies the terms and conditions for redistribution. X # X! # @(#)Makefile 5.19.2 (2.11BSD GTE) 1/15/94 X # X DESTDIR= X CFLAGS= -O X*************** X*** 11,17 **** X X # Programs that live in subdirectories, and have makefiles of their own. X # X! SUBDIR= adb as awk chpass csh diff login make passwd sed sh tp X X # Shell scripts that need only be installed and are never removed. X # X--- 11,17 ---- X X # Programs that live in subdirectories, and have makefiles of their own. X # X! SUBDIR= adb ar as awk chpass csh diff ld login make nm passwd sed sh tp X X # Shell scripts that need only be installed and are never removed. X # X*************** X*** 20,28 **** X # C programs that live in the current directory and do not need X # explicit make lines. X # X! STD= ar cat cc chgrp chmod cmp cp date dd du echo ed grep hostid \ X! hostname kill ld ln ls mkdir mt mv nice nm od pagesize pr \ X! pwd rm rmail rmdir size strip stty sync tar tee test time who X X # C programs that live in the current directory and need explicit make lines. X # X--- 20,28 ---- X # C programs that live in the current directory and do not need X # explicit make lines. X # X! STD= cat cc chgrp chmod cmp cp date dd du echo ed grep hostid \ X! hostname kill ln ls mkdir mt mv nice od pagesize pr \ X! pwd rm rmail rmdir size stty sync tar tee test time who X X # C programs that live in the current directory and need explicit make lines. X # X*************** X*** 44,50 **** X # X TTY= wall write X X! BINS= ${STD} ${NSTD} ${SETUID} ${OPERATOR} ${KMEM} ${TTY} X X all: ${SUBDIR} ${BINS} X X--- 44,53 ---- X # X TTY= wall write X X! # 'strip' is handled specially because 'install -s' now uses 'strip' and X! # thus we can't do a 'install -s strip /bin/strip' without an error. X! # X! BINS= ${STD} ${NSTD} ${SETUID} ${OPERATOR} ${KMEM} ${TTY} strip X X all: ${SUBDIR} ${BINS} X X*************** X*** 54,60 **** X FRC: X X X! ${STD} ${SETUID} ${OPERATOR} ${TTY}: X ${CC} ${CFLAGS} ${SEPFLAG} -o $@ $@.c X X install: ${BINS} X--- 57,63 ---- X FRC: X X X! ${STD} ${SETUID} ${KMEM} ${OPERATOR} ${TTY} strip: X ${CC} ${CFLAGS} ${SEPFLAG} -o $@ $@.c X X install: ${BINS} X*************** X*** 70,75 **** X--- 73,80 ---- X (install -g kmem -m 2751 -s $$i ${DESTDIR}/bin/$$i); done X -for i in ${TTY}; do \ X (install -g tty -m 2751 -s $$i ${DESTDIR}/bin/$$i); done X+ -install -s -m 751 -g staff strip ${DESTDIR}/bin/xstrip X+ -mv ${DESTDIR}/bin/xstrip ${DESTDIR}/bin/strip X rm -f ${DESTDIR}/bin/[; ln ${DESTDIR}/bin/test ${DESTDIR}/bin/[ X rm -f ${DESTDIR}/bin/e; ln ${DESTDIR}/bin/ed ${DESTDIR}/bin/e X X*************** X*** 99,107 **** X X expr: expr.o X ${CC} ${CFLAGS} ${SEPFLAG} -o expr expr.o X- X- ps: X- ${CC} ${CFLAGS} ${SEPFLAG} -o ps ps.c -lm X X # DO NOT DELETE THIS LINE -- make depend uses it X X--- 104,109 ---- X*** /usr/src/bin/mail.c.old Sun Jul 3 16:29:40 1988 X--- /usr/src/bin/mail.c Fri Dec 31 21:59:28 1993 X*************** X*** 1,9 **** X #ifndef lint X! static char sccsid[] = "@(#)mail.c 4.33 (Berkeley) 2/27/88"; X! #endif X! X! #ifdef BSD2_10 X! #include X #endif X X #include X--- 1,5 ---- X #ifndef lint X! static char sccsid[] = "@(#)mail.c 4.33.1 (2.11BSD GTE) 12/31/93"; X #endif X X #include X*** /usr/src/bin/write.c.old Mon Jan 22 23:07:36 1990 X--- /usr/src/bin/write.c Fri Dec 31 21:59:56 1993 X*************** X*** 1,13 **** X #ifndef lint X! static char *sccsid = "@(#)write.c 4.13 3/13/86"; X #endif X /* X * write to another user X */ X- X- #ifdef BSD2_10 X- #include X- #endif BSD2_10 X X #include X #include X--- 1,9 ---- X #ifndef lint X! static char *sccsid = "@(#)write.c 4.13.1 12/31/93"; X #endif X /* X * write to another user X */ X X #include X #include X*** /usr/src/bin/hostname.c.old Mon Feb 16 02:06:39 1987 X--- /usr/src/bin/hostname.c Fri Dec 31 22:00:56 1993 X*************** X*** 4,25 **** X * specifies the terms and conditions for redistribution. X */ X X! #ifndef lint X char copyright[] = X "@(#) Copyright (c) 1983 Regents of the University of California.\n\ X All rights reserved.\n"; X- #endif not lint X X! #ifndef lint X! static char sccsid[] = "@(#)hostname.c 5.1 (Berkeley) 4/30/85"; X! #endif not lint X X /* X * hostname -- get (or set hostname) X */ X- #ifdef BSD2_10 X- #include X- #endif BSD2_10 X X #include X X--- 4,20 ---- X * specifies the terms and conditions for redistribution. X */ X X! #if defined(DOSCCS) && !defined(lint) X char copyright[] = X "@(#) Copyright (c) 1983 Regents of the University of California.\n\ X All rights reserved.\n"; X X! static char sccsid[] = "@(#)hostname.c 5.1.1 (2.11BSD GTE) 12/31/93"; X! #endif X X /* X * hostname -- get (or set hostname) X */ X X #include X X*** /usr/src/bin/wall.c.old Thu Jul 27 09:24:31 1989 X--- /usr/src/bin/wall.c Fri Dec 31 22:01:42 1993 X*************** X*** 4,18 **** X * specifies the terms and conditions for redistribution. X */ X X! #ifndef lint X char copyright[] = X "@(#) Copyright (c) 1980 Regents of the University of California.\n\ X All rights reserved.\n"; X- #endif not lint X X! #ifndef lint X! static char sccsid[] = "@(#)wall.c 5.3 (Berkeley) 4/20/86"; X! #endif not lint X X /* X * wall.c - Broadcast a message to all users. X--- 4,16 ---- X * specifies the terms and conditions for redistribution. X */ X X! #if defined(DOSCCS) && !defined(lint) X char copyright[] = X "@(#) Copyright (c) 1980 Regents of the University of California.\n\ X All rights reserved.\n"; X X! static char sccsid[] = "@(#)wall.c 5.3.1 (2.11BSD GTE) 12/31/93"; X! #endif X X /* X * wall.c - Broadcast a message to all users. X*************** X*** 20,29 **** X * This program is not related to David Wall, whose Stanford Ph.D. thesis X * is entitled "Mechanisms for Broadcast and Selective Broadcast". X */ X- X- #ifdef BSD2_10 X- #include X- #endif BSD2_10 X X #include X #include X--- 18,23 ---- X*** /usr/src/bin/df.c.old Wed Feb 11 22:30:17 1987 X--- /usr/src/bin/df.c Mon Jan 10 21:43:14 1994 X*************** X*** 4,18 **** X * specifies the terms and conditions for redistribution. X */ X X! #ifndef lint X char copyright[] = X "@(#) Copyright (c) 1980 Regents of the University of California.\n\ X All rights reserved.\n"; X- #endif not lint X X! #ifndef lint X! static char sccsid[] = "@(#)df.c 5.1 (Berkeley) 4/30/85"; X! #endif not lint X X #include X #include X--- 4,16 ---- X * specifies the terms and conditions for redistribution. X */ X X! #if defined(DOSCCS) && !defined(lint) X char copyright[] = X "@(#) Copyright (c) 1980 Regents of the University of California.\n\ X All rights reserved.\n"; X X! static char sccsid[] = "@(#)df.c 5.1.1 (2.11BSD GTE) 1/1/94"; X! #endif X X #include X #include X*************** X*** 133,139 **** X return; X } X printf("%-12.12s", file); X! #ifdef BSD2_10 X totalblks = (long) sblock.fs_fsize - (long)sblock.fs_isize; X free = sblock.fs_tfree; X used = totalblks - free; X--- 131,137 ---- X return; X } X printf("%-12.12s", file); X! #ifdef pdp11 X totalblks = (long) sblock.fs_fsize - (long)sblock.fs_isize; X free = sblock.fs_tfree; X used = totalblks - free; X*************** X*** 144,150 **** X iused = inodes - sblock.fs_tinode; X printf("%8u%8u%7.0f%%", iused, sblock.fs_tinode, X inodes ? (float)iused / (float)inodes * 100.0 : 0.0); X! #else !BSD2_10 X totalblks = sblock.fs_dsize; X free = sblock.fs_cstotal.cs_nbfree * sblock.fs_frag + X sblock.fs_cstotal.cs_nffree; X--- 142,148 ---- X iused = inodes - sblock.fs_tinode; X printf("%8u%8u%7.0f%%", iused, sblock.fs_tinode, X inodes ? (float)iused / (float)inodes * 100.0 : 0.0); X! #else X totalblks = sblock.fs_dsize; X free = sblock.fs_cstotal.cs_nbfree * sblock.fs_frag + X sblock.fs_cstotal.cs_nffree; X*************** X*** 160,166 **** X used = inodes - sblock.fs_cstotal.cs_nifree; X printf("%8ld%8ld%6.0f%% ", used, sblock.fs_cstotal.cs_nifree, X inodes == 0 ? 0.0 : (double)used / (double)inodes * 100.0); X! #endif BSD2_10 X } else X printf(" "); X printf(" %s\n", mpath(file)); X--- 158,164 ---- X used = inodes - sblock.fs_cstotal.cs_nifree; X printf("%8ld%8ld%6.0f%% ", used, sblock.fs_cstotal.cs_nifree, X inodes == 0 ? 0.0 : (double)used / (double)inodes * 100.0); X! #endif X } else X printf(" "); X printf(" %s\n", mpath(file)); X*** /usr/src/bin/hostid.c.old Sat Jun 12 00:22:35 1993 X--- /usr/src/bin/hostid.c Sun Jan 2 14:26:39 1994 X*************** X*** 8,14 **** X char copyright[] = X "@(#) Copyright (c) 1983 Regents of the University of California.\n\ X All rights reserved.\n"; X! static char sccsid[] = "@(#)hostid.c 1.1 (2.11BSD GTE) 6/12/93"; X #endif X X #include X--- 8,14 ---- X char copyright[] = X "@(#) Copyright (c) 1983 Regents of the University of California.\n\ X All rights reserved.\n"; X! static char sccsid[] = "@(#)hostid.c 1.2 (2.11BSD GTE) 1/1/94"; X #endif X X #include X*************** X*** 18,24 **** X X extern char *index(); X extern unsigned long inet_addr(); X- extern long gethostid(); X X main(argc, argv) X int argc; X--- 18,23 ---- X*************** X*** 30,36 **** X struct hostent *hp; X X if (argc < 2) { X! #ifdef BSD2_10 X { X long val; X if (val = gethostid()) X--- 29,35 ---- X struct hostent *hp; X X if (argc < 2) { X! #ifdef pdp11 X { X long val; X if (val = gethostid()) X*************** X*** 38,46 **** X else X puts("0"); X } X! #else !BSD2_10 X printf("%#lx\n", gethostid()); X! #endif BSD2_10 X exit(0); X } X X--- 37,45 ---- X else X puts("0"); X } X! #else X printf("%#lx\n", gethostid()); X! #endif X exit(0); X } X X*** /usr/src/bin/strip.c.old Thu Feb 12 08:57:14 1987 X--- /usr/src/bin/strip.c Mon Jan 10 21:42:57 1994 X*************** X*** 4,18 **** X * specifies the terms and conditions for redistribution. X */ X X! #ifndef lint X char copyright[] = X "@(#) Copyright (c) 1983 Regents of the University of California.\n\ X All rights reserved.\n"; X- #endif not lint X X! #ifndef lint X! static char sccsid[] = "@(#)strip.c 5.1 (Berkeley) 4/30/85"; X! #endif not lint X X #include X #include X--- 4,16 ---- X * specifies the terms and conditions for redistribution. X */ X X! #if defined(DOSCCS) && !defined(lint) X char copyright[] = X "@(#) Copyright (c) 1983 Regents of the University of California.\n\ X All rights reserved.\n"; X X! static char sccsid[] = "@(#)strip.c 5.1.1 (2.11BSD GTE) 1/1/94"; X! #endif X X #include X #include X*************** X*** 19,30 **** X #include X #include X X! struct exec head; X! #ifdef BSD2_10 X! struct ovlhdr ovlhdr; X! #endif BSD2_10 X int status; X- int pagesize; X X main(argc, argv) X char *argv[]; X--- 17,24 ---- X #include X #include X X! struct xexec head; X int status; X X main(argc, argv) X char *argv[]; X*************** X*** 31,37 **** X { X register i; X X- pagesize = getpagesize(); X signal(SIGHUP, SIG_IGN); X signal(SIGINT, SIG_IGN); X signal(SIGQUIT, SIG_IGN); X--- 25,30 ---- X*************** X*** 55,100 **** X status = 1; X goto out; X } X! if (read(f, (char *)&head, sizeof (head)) < 0 || N_BADMAG(head)) { X printf("strip: %s not in a.out format\n", name); X status = 1; X goto out; X } X! #ifdef BSD2_10 X! if ((head.a_syms == 0) && ((head.a_flag & 1) != 0)) { X! #else !BSD2_10 X! if ((head.a_syms == 0) && (head.a_trsize == 0) && (head.a_drsize ==0)) { X! #endif BSD2_10 X! printf("strip: %s already stripped\n", name); X goto out; X! } X! size = (long)head.a_text + head.a_data; X! #ifdef BSD2_10 X! head.a_syms = 0; X! head.a_flag |= 1; X! if (head.a_magic == A_MAGIC5 || head.a_magic == A_MAGIC6) { X! int i; X! if (read(f, (char *)&ovlhdr, sizeof (ovlhdr)) < 0) { X! printf("strip: %s not in a.out format\n", name); X! status = 1; X! goto out; X! } X! for (i = 0; i < NOVL; i++) X! size += ovlhdr.ov_siz[i]; X! size += sizeof (ovlhdr); X! } X! #else !BSD2_10 X! head.a_syms = head.a_trsize = head.a_drsize = 0; X! if (head.a_magic == ZMAGIC) X! size += pagesize - sizeof (head); X! #endif BSD2_10 X! if (ftruncate(f, size + sizeof (head)) < 0) { X fprintf("strip: "); perror(name); X status = 1; X goto out; X } X (void) lseek(f, (long)0, L_SET); X! (void) write(f, (char *)&head, sizeof (head)); X out: X close(f); X } X--- 48,71 ---- X status = 1; X goto out; X } X! if (read(f, (char *)&head, sizeof (head)) < 0 || N_BADMAG(head.e)) { X printf("strip: %s not in a.out format\n", name); X status = 1; X goto out; X } X! if ((head.e.a_syms == 0) && ((head.e.a_flag & 1) != 0)) X goto out; X! X! size = N_DATOFF(head) + head.e.a_data; X! head.e.a_syms = 0; X! head.e.a_flag |= 1; X! if (ftruncate(f, size) < 0) { X fprintf("strip: "); perror(name); X status = 1; X goto out; X } X (void) lseek(f, (long)0, L_SET); X! (void) write(f, (char *)&head.e, sizeof (head.e)); X out: X close(f); X } X*** /usr/src/bin/size.c.old Sun Feb 8 14:30:26 1987 X--- /usr/src/bin/size.c Mon Jan 10 21:44:05 1994 X*************** X*** 1,4 **** X! static char *sccsid = "@(#)size.c 4.4 (Berkeley) 4/22/85"; X /* X * size X */ X--- 1,7 ---- X! #if defined(DOSCCS) && !defined(lint) X! static char *sccsid = "@(#)size.c 4.4.1 (2.11BSD GTE) 1/1/94"; X! #endif X! X /* X * size X */ X*************** X*** 16,26 **** X int gorp,i; X int err = 0; X FILE *f; X! #ifdef BSD2_10 X struct ovlhdr ovlbuf; /* overlay structure */ X long coresize; /* total text size */ X short skip; /* skip over overlay sizes of 0 */ X! #endif BSD2_10 X X if (argc==1) { X *argv = "a.out"; X--- 19,29 ---- X int gorp,i; X int err = 0; X FILE *f; X! #ifdef pdp11 X struct ovlhdr ovlbuf; /* overlay structure */ X long coresize; /* total text size */ X short skip; /* skip over overlay sizes of 0 */ X! #endif X X if (argc==1) { X *argv = "a.out"; X*************** X*** 51,57 **** X printf("%ld\t%lx", sum, sum); X if (gorp>2) X printf("\t%s", *argv); X! #ifdef BSD2_10 X if (buf.a_magic == A_MAGIC5 || buf.a_magic == A_MAGIC6) { X fread(&ovlbuf,sizeof(ovlbuf),1,f); X coresize = buf.a_text; X--- 54,60 ---- X printf("%ld\t%lx", sum, sum); X if (gorp>2) X printf("\t%s", *argv); X! #ifdef pdp11 X if (buf.a_magic == A_MAGIC5 || buf.a_magic == A_MAGIC6) { X fread(&ovlbuf,sizeof(ovlbuf),1,f); X coresize = buf.a_text; X*************** X*** 70,76 **** X printf("%u", ovlbuf.ov_siz[i]); X } X } X! #endif BSD2_10 X printf("\n"); X fclose(f); X } X--- 73,79 ---- X printf("%u", ovlbuf.ov_siz[i]); X } X } X! #endif X printf("\n"); X fclose(f); X } X*** /usr/src/bin/ps.c.old Sun Jan 24 00:00:51 1993 X--- /usr/src/bin/ps.c Sat Jan 22 22:34:50 1994 X*************** X*** 1,8 **** X /* X * ps - process status X- * This is the augmented UCB ps for 2.10BSD PDP-11 Unix. X- * It is system dependent, knowing the format of an a.out symbol table. X- * Examine and print certain things about processes X * Usage: ps [ acgklnrtuwxU# ] [ corefile [ swapfile [ system ] ] ] X */ X X--- 1,7 ---- X /* X+ * 1/7/93 - Heavily revised when the symbol table format changed - sms X+ * X * ps - process status X * Usage: ps [ acgklnrtuwxU# ] [ corefile [ swapfile [ system ] ] ] X */ X X*************** X*** 9,17 **** X #include X #include X #include X! #include X #include X #include X #include X #include X #include X--- 8,18 ---- X #include X #include X #include X! #include X #include X #include X+ #include X+ #include X #include X #include X #include X*************** X*** 18,127 **** X #include X #include X X- #define N_BADMAG(x) \ X- (((x).a_magic)!=A_MAGIC1 && ((x).a_magic)!=A_MAGIC2 && \ X- ((x).a_magic)!=A_MAGIC3 && ((x).a_magic)!=A_MAGIC4 && \ X- ((x).a_magic)!=A_MAGIC5 && ((x).a_magic)!=A_MAGIC6) X- X- #define N_TXTOFF(x) \ X- ((x).a_magic==A_MAGIC5 || (x).a_magic==A_MAGIC6 ? \ X- sizeof (struct ovlhdr) + sizeof (struct exec) : sizeof (struct exec)) X- X- #define equal !strcmp X- #define exists(x) (stat ((x), &stbuf) == 0) X #define within(x,y,z) (((unsigned)(x) >= (y)) && ((unsigned)(x) < (z))) X! #define round(x,y) ((long) ((((long) (x) + (long) (y) - 1L) / (long) (y)) * (long) (y))) X X! struct nlist nl[] = { X! { "_proc" , 0, 0}, X #define X_PROC 0 X- { "_nproc", 0, 0}, X #define X_NPROC 1 X- { "_hz", 0, 0}, X #define X_HZ 2 X- 0 X- }; X- #define NNAMESIZ (sizeof nl[0].n_name) X X! struct proc *mproc, proc [8]; X! struct user u; X! struct stat stbuf; X X! int hz; X! int chkpid = 0; X! int aflg; /* -a: all processes, not just mine */ X! int cflg; /* -c: not complete listing of args, just comm. */ X! int gflg; /* -g: complete listing including group headers, etc */ X! int kflg; /* -k: read from core file instead of real memory */ X! int lflg; /* -l: long listing form */ X! int nflg; /* -n: numeric wchans */ X! int rflg; /* -r: raw output in style */ X! int uflg; /* -u: user name */ X! int wflg; /* -w[w]: wide terminal */ X! int xflg; /* -x: ALL processes, even those without ttys */ X! int Uflg; /* -U: update the private list */ X! char *tptr, *mytty; X! char *nlistf, *uname; X! int file; X! int nproc; X! off_t tell; X! int nchans; X! int nttys; X! int nsyms; X! int ismem; X #ifndef PSFILE X! char *psdb = "/etc/psdatabase"; X #else X! char *psdb = PSFILE; X #endif X X /* X * Structure for the unix wchan table X */ X typedef struct wchan { X! char cname [NNAMESIZ]; X unsigned caddr; X! } WCHAN; X! WCHAN *wchanhd; X X! char *calloc (), *malloc (), *realloc (); X! char *gettty (), *getptr (), *getchan (); X! char *ttyname (); X! int pscomp (); X! int wchancomp(); X! off_t lseek (); X X! #ifndef MAXTTYS X! #define MAXTTYS 256 X! #endif X! struct ttys { X! char name[16]; /* MAXNAMLEN uses too much memory, besides */ X! /* device names tend towards the very short */ X! /* to begin with */ X dev_t ttyd; X! } allttys[MAXTTYS]; X X! struct map { X off_t b1, e1; off_t f1; X off_t b2, e2; off_t f2; X! }; X! struct map datmap; X X! struct psout *outargs; /* info for first npr processes */ X! int npr; /* number of processes found so far */ X! int twidth; /* terminal width */ X! int cmdstart; /* starting position for command field */ X X- char *memf; /* name of kernel memory file to use */ X- char *kmemf; /* name of physical memory file to use */ X- char *swapf; /* name of swap file to use */ X- char *nlistf; /* name of symbol table file to use */ X- int kmem, mem, swap; X- char pbuf[BUFSIZ]; X- #ifdef TERMCAP X- char *getenv (); X- #endif X- X main (argc, argv) X char **argv; X { X--- 19,117 ---- X #include X #include X X #define within(x,y,z) (((unsigned)(x) >= (y)) && ((unsigned)(x) < (z))) X! #define round(x,y) ((long) ((((long) (x) + (long) (y) - 1L) / (long) (y)) * (long) (y))) X X! struct nlist nl[4]; X #define X_PROC 0 X #define X_NPROC 1 X #define X_HZ 2 X X! /* X! * This is no longer the size of a symbol's name, symbols can be much X! * larger now. This define says how many characters of a symbol's name X! * to save in the wait channel name. A new define has been created to X! * limit the size of symbol string read from the string table. X! */ X! #define NNAMESIZ 8 X! #define MAXSYMLEN 32 X X! struct proc *mproc, proc[8]; X! struct user u; X! int hz; X! int chkpid = 0; X! char aflg; /* -a: all processes, not just mine */ X! char cflg; /* -c: not complete listing of args, just comm. */ X! char gflg; /* -g: complete listing including group headers, etc */ X! char kflg; /* -k: read from core file instead of real memory */ X! char lflg; /* -l: long listing form */ X! char nflg; /* -n: numeric wchans */ X! char rflg; /* -r: raw output in style */ X! char uflg; /* -u: user name */ X! char wflg; /* -w[w]: wide terminal */ X! char xflg; /* -x: ALL processes, even those without ttys */ X! char Uflg; /* -U: update the private list */ X! char *tptr, *mytty; X! char *uname; X! int file; X! int nproc; X! int nchans; X! int nttys; X #ifndef PSFILE X! char *psdb = "/etc/psdatabase"; X #else X! char *psdb = PSFILE; X #endif X+ int npr; /* number of processes found so far */ X+ int twidth; /* terminal width */ X+ int cmdstart; /* start position for command field */ X+ char *memf; /* name of kernel memory file */ X+ char *kmemf = "/dev/kmem"; /* name of physical memory file */ X+ char *swapf; /* name of swap file to use */ X+ char *nlistf; /* name of symbol table file to use */ X+ int kmem, mem, swap; X X /* X * Structure for the unix wchan table X */ X typedef struct wchan { X! char cname[NNAMESIZ]; X unsigned caddr; X! } WCHAN; X X! WCHAN *wchand; X X! extern char *calloc(), *malloc(), *realloc(), *ttyname(); X! char *gettty(), *getptr(), *getchan(); X! int pscomp(), wchancomp(); X! extern off_t lseek(); X! X! /* X! * 256 terminals was not only wasteful but unrealistic. For one thing X! * 2.11BSD uses bit 7 of the minor device (for almost all terminal interfaces) X! * to indicate direct/modem status - this means that 128 terminals is X! * a better maximum number of terminals, for another thing the system can't X! * support 256 terminals - other resources (memory, files, processes) will X! * have been exhausted long ago. If 'ps' complains about too many terminals X! * it is time to clean up /dev! X! */ X! #define MAXTTYS 160 /* 128 plus a few extra */ X! X! struct ttys { X! char name[14]; /* MAXNAMLEN uses too much memory, besides */ X! /* device names tend to be very short */ X dev_t ttyd; X! } allttys[MAXTTYS]; X X! struct map { X off_t b1, e1; off_t f1; X off_t b2, e2; off_t f2; X! }; X X! struct winsize ws; X! struct map datmap; X! struct psout *outargs; /* info for first npr processes */ X X main (argc, argv) X char **argv; X { X*************** X*** 129,148 **** X register int i, j; X char *ap; X register struct proc *procp; X- #ifdef TERMCAP X- char *termp, capbuf [1024]; X- #endif X X! #ifdef TERMCAP X! if ((termp = getenv ("TERM")) != (char *) NULL) X! if (tgetent (capbuf, termp) == 1) X! twidth = tgetnum ("co"); X! else ; X else X! #endif X! twidth = 80; X X- setbuf (stdout, pbuf); X argc--, argv++; X if (argc > 0) { X ap = argv [0]; X--- 119,141 ---- X register int i, j; X char *ap; X register struct proc *procp; X X! /* X! * Can't initialize unions and we need the macros from a.out.h, so the X! * namelist is set up at run time. X! */ X! nl[X_PROC].n_un.n_name = "_proc"; X! nl[X_NPROC].n_un.n_name = "_nproc"; X! nl[X_HZ].n_un.n_name = "_hz"; X! X! if ((ioctl(fileno(stdout), TIOCGWINSZ, &ws) != -1 && X! ioctl(fileno(stderr), TIOCGWINSZ, &ws) != -1 && X! ioctl(fileno(stdin), TIOCGWINSZ, &ws) != -1) || X! ws.ws_col == 0) X! twidth = 80; X else X! twidth = ws.ws_col; X X argc--, argv++; X if (argc > 0) { X ap = argv [0]; X*************** X*** 206,214 **** X break; X X case 'w': X! if (twidth == 80) X twidth = 132; X- else twidth = BUFSIZ; X wflg++; X break; X X--- 199,208 ---- X break; X X case 'w': X! if (wflg) X! twidth = BUFSIZ; X! else if (twidth < 132) X twidth = 132; X wflg++; X break; X X*************** X*** 217,226 **** X break; X X default: X! if (!isdigit (ap[-1])) X break; X! chkpid = atoi (--ap); X! *ap = '\0'; X aflg++; X xflg++; X break; X--- 211,220 ---- X break; X X default: X! if (!isdigit(ap[-1])) X break; X! chkpid = atoi(--ap); X! *ap = '\0'; X aflg++; X xflg++; X break; X*************** X*** 227,247 **** X } X } X X! openfiles (argc, argv); X! getkvars (argc, argv); X! uid = getuid (); X! euid = geteuid (); X! mytty = ttyname(0); X if (!strncmp(mytty,"/dev/",5)) mytty += 5; X if (!strncmp(mytty,"tty",3)) mytty += 3; X printhdr(); X for (i = 0; i < nproc; i += 8) { X! j = nproc - i; X if (j > 8) X! j = 8; X! j *= sizeof (struct proc); X! if ((nread = read (kmem, (char *) proc, j)) != j) { X! cantread ("proc table", kmemf); X if (nread == -1) X break; X } X--- 221,242 ---- X } X } X X! openfiles(argc, argv); X! getkvars(argc, argv); X! lseek(kmem,(off_t)nl[X_PROC].n_value,0); X! uid = getuid(); X! euid = geteuid(); X! mytty = ttyname(0); X if (!strncmp(mytty,"/dev/",5)) mytty += 5; X if (!strncmp(mytty,"tty",3)) mytty += 3; X printhdr(); X for (i = 0; i < nproc; i += 8) { X! j = nproc - i; X if (j > 8) X! j = 8; X! j *= sizeof (struct proc); X! if ((nread = read(kmem, (char *) proc, j)) != j) { X! cantread("proc table", kmemf); X if (nread == -1) X break; X } X*************** X*** 263,329 **** X if ((uid != puid && euid != puid && aflg == 0) || X (chkpid != 0 && chkpid != procp->p_pid)) X continue; X! if (savcom (puid)) X npr++; X } X } X! fixup (npr); X! for (i = 0; i < npr; i++) { X! #ifdef TERMCAP X! register cmdwidth = twidth - cmdstart - 2; X! #endif X! register struct psout *a = &outargs[i]; X X! if (rflg) { X! if (write (1, (char *) a, sizeof (struct psout)) != sizeof (struct psout)) X! perror ("write"); X continue; X } X else if (lflg) X! lpr (a); X else if (uflg) X! upr (a); X! else spr (a); X! #ifdef TERMCAP X if (cmdwidth < 0) X! cmdwidth = 80 - cmdstart - 2; X! #endif X if (a->o_stat == SZOMB) X! #ifdef TERMCAP X! printf ("%.*s", cmdwidth, " "); X! #else X! printf (" "); X! #endif X! else if (a->o_pid == 0) X! #ifdef TERMCAP X! printf ("%.*s", cmdwidth, " swapper"); X! #else X! printf (" swapper"); X! #endif X! else printf (" %.*s", twidth - cmdstart - 2, cflg ? a->o_comm : a->o_args); X! putchar ('\n'); X } X! exit (!npr); X } X X- struct direct *dbuf; X- int dialbase; X- X getdev() X { X register DIR *df; X X if (chdir("/dev") < 0) { X perror("/dev"); X exit(1); X } X- dialbase = -1; X if ((df = opendir(".")) == NULL) { X fprintf(stderr, "Can't open . in /dev\n"); X exit(1); X } X! while ((dbuf = readdir(df)) != NULL) X! maybetty(); X closedir(df); X } X X--- 258,311 ---- X if ((uid != puid && euid != puid && aflg == 0) || X (chkpid != 0 && chkpid != procp->p_pid)) X continue; X! if (savcom(puid)) X npr++; X } X } X! fixup(npr); X! for (i = 0; i < npr; i++) { X! register int cmdwidth = twidth - cmdstart - 2; X! register struct psout *a = &outargs[i]; X X! if (rflg) { X! if (write(1, (char *) a, sizeof (*a)) != sizeof (*a)) X! perror("write"); X continue; X } X else if (lflg) X! lpr(a); X else if (uflg) X! upr(a); X! else X! spr(a); X if (cmdwidth < 0) X! cmdwidth = 80 - cmdstart - 2; X if (a->o_stat == SZOMB) X! printf("%.*s", cmdwidth, " "); X! else if (a->o_pid == 0) X! printf("%.*s", cmdwidth, " swapper"); X! else X! printf(" %.*s", twidth - cmdstart - 2, cflg ? a->o_comm : a->o_args); X! putchar('\n'); X } X! exit(!npr); X } X X getdev() X { X register DIR *df; X+ register struct direct *dbuf; X X if (chdir("/dev") < 0) { X perror("/dev"); X exit(1); X } X if ((df = opendir(".")) == NULL) { X fprintf(stderr, "Can't open . in /dev\n"); X exit(1); X } X! while (dbuf = readdir(df)) X! maybetty(dbuf->d_name); X closedir(df); X } X X*************** X*** 333,352 **** X * know that r(hp|up|mt) are unlikely as are different mem's, X * floppy, null, tty, etc. X */ X! maybetty() X { X- register char *cp = dbuf->d_name; X register struct ttys *dp; X- int x; X struct stat stb; X X switch (cp[0]) { X X case 'c': X! if (!strcmp(cp, "co")) { X! x = 0; X! goto donecand; X! } X /* cu[la]? are possible!?! don't rule them out */ X break; X X--- 315,331 ---- X * know that r(hp|up|mt) are unlikely as are different mem's, X * floppy, null, tty, etc. X */ X! maybetty(cp) X! register char *cp; X { X register struct ttys *dp; X struct stat stb; X X switch (cp[0]) { X X case 'c': X! if (!strcmp(cp, "console")) X! break; X /* cu[la]? are possible!?! don't rule them out */ X break; X X*************** X*** 361,387 **** X break; X X case 'k': X! cp++; X! if (*cp == 'U') X! cp++; X! goto trymem; X X case 'r': X! cp++; X! #define is(a,b) cp[0] == 'a' && cp[1] == 'b' X! if (is(h,p) || is(r,a) || is(u,p) || is(h,k) X! || is(r,b) || is(m,t)) { X! cp += 2; X! if (isdigit(*cp) && cp[2] == 0) X return; X } X break; X X case 'm': X! trymem: X! if (cp[0] == 'm' && cp[1] == 'e' && cp[2] == 'm' && cp[3] == 0) X return; X! if (cp[0] == 'm' && cp[1] == 't') X return; X break; X X--- 340,364 ---- X break; X X case 'k': X! if (!strcmp(cp, "kUmem") || !strcmp(cp, "kmem")) X! return; X! if (!strcmp(cp, "klog")) X! return; X! break; X X case 'r': X! #define is(a,b) cp[1] == 'a' && cp[2] == 'b' X! if (is(h,p) || is(r,a) || is(u,p) || is(h,k) || is(x,p) X! || is(r,b) || is(r,l) || is(m,t)) { X! if (isdigit(cp[3])) X return; X } X break; X X case 'm': X! if (!strcmp("mem", cp)) X return; X! if (cp[1] == 't') X return; X break; X X*************** X*** 393,441 **** X break; X X case 'p': X! if (cp[1] && cp[1] == 't' && cp[2] == 'y') X return; X break; X- X- case 'v': X- if ((cp[1] == 'a' || cp[1] == 'p') && isdigit(cp[2]) && X- cp[3] == 0) X- return; X- break; X } X- cp = dbuf->d_name + dbuf->d_namlen - 1; X- x = 0; X- if (cp[-1] == 'd') { X- if (dialbase == -1) { X- if (stat("ttyd0", &stb) == 0) X- dialbase = stb.st_rdev & 017; X- else X- dialbase = -2; X- } X- if (dialbase == -2) X- x = 0; X- else X- x = 11; X- } X- if (cp > dbuf->d_name && isdigit(cp[-1]) && isdigit(*cp)) X- x += 10 * (cp[-1] - ' ') + cp[0] - '0'; X- else if (*cp >= 'a' && *cp <= 'f') X- x += 10 + *cp - 'a'; X- else if (isdigit(*cp)) X- x += *cp - '0'; X- else X- x = -1; X- donecand: X if (nttys >= MAXTTYS) { X fprintf(stderr, "ps: tty table overflow\n"); X exit(1); X } X dp = &allttys[nttys++]; X! (void)strcpy(dp->name, dbuf->d_name); X if (Uflg) { X if (stat(dp->name, &stb) == 0 && X (stb.st_mode&S_IFMT)==S_IFCHR) X! dp->ttyd = x = stb.st_rdev; X else { X nttys--; X return; X--- 370,389 ---- X break; X X case 'p': X! if (cp[1] == 't' && cp[2] == 'y') X return; X break; X } X if (nttys >= MAXTTYS) { X fprintf(stderr, "ps: tty table overflow\n"); X exit(1); X } X dp = &allttys[nttys++]; X! (void)strcpy(dp->name, cp); X if (Uflg) { X if (stat(dp->name, &stb) == 0 && X (stb.st_mode&S_IFMT)==S_IFCHR) X! dp->ttyd = stb.st_rdev; X else { X nttys--; X return; X*************** X*** 444,464 **** X dp->ttyd = -1; X } X X! savcom (puid) X { X char *tp; X off_t addr; X off_t daddr, saddr; X! register struct psout *a; X! register struct proc *procp = mproc; X! register struct user *up = &u; X long txtsiz, datsiz, stksiz; X int septxt; X X if (procp->p_flag & SLOAD) { X! addr = ctob ((off_t) procp->p_addr); X! daddr = ctob ((off_t) procp->p_daddr); X! saddr = ctob ((off_t) procp->p_saddr); X file = mem; X } X else { X--- 392,412 ---- X dp->ttyd = -1; X } X X! savcom(puid) X { X char *tp; X off_t addr; X off_t daddr, saddr; X! register struct psout *a; X! register struct proc *procp = mproc; X! register struct user *up = &u; X long txtsiz, datsiz, stksiz; X int septxt; X X if (procp->p_flag & SLOAD) { X! addr = ctob((off_t) procp->p_addr); X! daddr = ctob((off_t) procp->p_daddr); X! saddr = ctob((off_t) procp->p_saddr); X file = mem; X } X else { X*************** X*** 468,486 **** X file = swap; X } X lseek(file, addr, 0); X! if (read(file, (char *) up, sizeof (struct user)) != sizeof (struct user)) X return(0); X X! txtsiz = ctob (up->u_tsize); /* set up address maps for user pcs */ X! datsiz = ctob (up->u_dsize); X! stksiz = ctob (up->u_ssize); X septxt = up->u_sep; X! datmap.b1 = (septxt ? 0 : round (txtsiz, TXTRNDSIZ)); X datmap.e1 = datmap.b1 + datsiz; X datmap.f1 = daddr; X datmap.f2 = saddr; X! datmap.b2 = stackbas (stksiz); X! datmap.e2 = stacktop (stksiz); X tp = gettty(); X if ((tptr && strncmp(tptr,tp,2)) || (strncmp(mytty, tp, 2) && !aflg)) X return(0); X--- 416,434 ---- X file = swap; X } X lseek(file, addr, 0); X! if (read(file, (char *) up, sizeof (u)) != sizeof (u)) X return(0); X X! txtsiz = ctob(up->u_tsize); /* set up address maps for user pcs */ X! datsiz = ctob(up->u_dsize); X! stksiz = ctob(up->u_ssize); X septxt = up->u_sep; X! datmap.b1 = (septxt ? 0 : round(txtsiz, TXTRNDSIZ)); X datmap.e1 = datmap.b1 + datsiz; X datmap.f1 = daddr; X datmap.f2 = saddr; X! datmap.b2 = stackbas(stksiz); X! datmap.e2 = stacktop(stksiz); X tp = gettty(); X if ((tptr && strncmp(tptr,tp,2)) || (strncmp(mytty, tp, 2) && !aflg)) X return(0); X*************** X*** 518,524 **** X } X X char * X! gettty () X { X register int tty_step; X register char *p; X--- 466,472 ---- X } X X char * X! gettty() X { X register int tty_step; X register char *p; X*************** X*** 537,547 **** X /* X * fixup figures out everybodys name and sorts into a nice order. X */ X! fixup (np) X! register np; X { X! register i; X! register struct passwd *pw; X X if (uflg) { X /* X--- 485,495 ---- X /* X * fixup figures out everybodys name and sorts into a nice order. X */ X! fixup(np) X! register int np; X { X! register int i; X! register struct passwd *pw; X X if (uflg) { X /* X*************** X*** 550,560 **** X * In case of multiple entries in /etc/passwd, we believe X * the first one (same thing ls does). X */ X! while ((pw = getpwent ()) != (struct passwd *) NULL) { X for (i = 0; i < np; i++) X! if (outargs[i].o_uid == pw->pw_uid) { X if (outargs[i].o_uname[0] == 0) X! strcpy (outargs[i].o_uname, pw->pw_name); X } X } X } X--- 498,508 ---- X * In case of multiple entries in /etc/passwd, we believe X * the first one (same thing ls does). X */ X! while ((pw = getpwent()) != (struct passwd *) NULL) { X for (i = 0; i < np; i++) X! if (outargs[i].o_uid == pw->pw_uid) { X if (outargs[i].o_uname[0] == 0) X! strcpy(outargs[i].o_uname, pw->pw_name); X } X } X } X*************** X*** 561,730 **** X qsort(outargs, np, sizeof (outargs[0]), pscomp); X } X X! pscomp (x1, x2) X! register struct psout *x1, *x2; X { X! register c; X X! c = (x1)->o_ttyd - (x2)->o_ttyd; X if (c == 0) X! c = (x1)->o_pid - (x2)->o_pid; X! return (c); X } X X! wchancomp (x1, x2) X! register WCHAN *x1, X! *x2; X { X if (x1->caddr > x2->caddr) X! return (1); X! else if (x1->caddr == x2->caddr) X! return (0); X! else return (-1); X } X X char * X! getptr (adr) X char **adr; X { X! char *ptr; X! register char *p, *pa; X! register i; X X! ptr = 0; X! pa = (char *)adr; X! p = (char *)&ptr; X for (i = 0; i < sizeof (ptr); i++) X! *p++ = getbyte (pa++); X! return (ptr); X } X X! getbyte (adr) X! register char *adr; X { X! register struct map *amap = &datmap; X char b; X off_t saddr; X X! if (!within (adr, amap->b1, amap->e1)) X! if (within (adr, amap->b2, amap->e2)) X! saddr = (unsigned) adr + amap->f2 - amap->b2; X! else return (0); X else saddr = (unsigned) adr + amap->f1 - amap->b1; X! if (lseek (file, saddr, 0) == (off_t) -1 || read (file, &b, 1) < 1) X! return (0); X! return ((unsigned) b); X } X X! addchan (name, caddr) X! char *name; X! unsigned caddr; X! { X! register int nc = nchans; X! register WCHAN *wp = wchanhd; X X! if (!nc) X! wp = (WCHAN *)malloc(sizeof(WCHAN)); X! else X! wp = (WCHAN *)realloc(wp, sizeof(WCHAN) * (nc + 1)); X! if (!wp) { X! fputs("Too many symbols\n",stderr); X! exit(1); X } X- strncpy (wp[nc].cname, name, NNAMESIZ - 1); X- wp[nc].cname[NNAMESIZ-1] = '\0'; X- wp[nc].caddr = caddr; X- wchanhd = wp; X- nchans++; X- } X X char * X! getchan (chan) X! register unsigned chan; X { X! register i; X! register char *prevsym; X X prevsym = ""; X if (chan) X for (i = 0; i < nchans; i++) { X! if (wchanhd[i].caddr > chan) X return (prevsym); X! prevsym = wchanhd[i].cname; X } X! return (prevsym); X } X X nlist() X! { X register FILE *nlistf_fp; X register struct nlist *nnn; X struct nlist nbuf; X! struct exec hbuf; X int nllen; X! off_t sa; X X nllen = sizeof(nl) / sizeof(struct nlist); X! if (!(nlistf_fp = fopen(nlistf,"r"))) X perrexit(nlistf); X! if (fread(&hbuf,sizeof(hbuf),1,nlistf_fp) != 1) { X fputs("Invalid symbol table\n",stderr); X exit(1); X! } X! if (N_BADMAG(hbuf)) { X! fprintf(stderr,"%s: not in object file format\n",nlistf); X exit(1); X! } X! if (hbuf.a_magic == A_MAGIC5 || hbuf.a_magic == A_MAGIC6) { X! register int novl_step; X! struct ovlhdr ovlbuf; X X! fread((char *)&ovlbuf,1,sizeof(ovlbuf),nlistf_fp); X! for (sa = novl_step = 0;novl_step < NOVL;++novl_step) X! sa += (off_t)(ovlbuf.ov_siz)[novl_step]; X! fseek(nlistf_fp,sa,1); X! } X! sa = (off_t)hbuf.a_text + hbuf.a_data; X! if (!(hbuf.a_flag & 01)) X! sa *= (off_t)2; X! fseek(nlistf_fp,sa,1); X! nsyms = 0; X! while (fread(&nbuf,sizeof(nbuf),1,nlistf_fp) == 1) { X! register int flag; X X! nsyms++; X! if (nbuf.n_name[0] != '_' ) X continue; X! flag = nbuf.n_type & (N_TYPE | N_EXT); X! /* X! * Skip over anything which isn't an external data or bss X! * symbol, except "_u". The exception is tacky, but if X! * we let all N_ABS symbols through we match on symbols X! * inserted during the unix/netnix cross binding. X! */ X! if (!(flag == (N_EXT | N_DATA) || flag == (N_EXT | N_BSS) X! || (nbuf.n_name[0] == '_' && nbuf.n_name[1] == 'u' X! && nbuf.n_name[2] == '\0'))) X! continue; X! if (!nflg) X! addchan(nbuf.n_name + 1,(unsigned)(nbuf.n_value)); X! if (nllen) X! for (nnn = nl;*nnn->n_name;nnn++) X! if (!strncmp(nnn->n_name,nbuf.n_name,NNAMESIZ)) { X nnn->n_value = nbuf.n_value; X nnn->n_type = nbuf.n_type; X --nllen; X break; X } X! } X! if (nsyms == 0) { X! fprintf(stderr,"%s: no symbol table\n",nlistf); X! exit(1); X! } X fclose(nlistf_fp); X! if (!nflg) X! qsort(wchanhd,nchans,sizeof(WCHAN),wchancomp); X! } X X perrexit(msg) X char *msg; X--- 509,702 ---- X qsort(outargs, np, sizeof (outargs[0]), pscomp); X } X X! pscomp(x1, x2) X! register struct psout *x1, *x2; X { X! register int c; X X! c = (x1)->o_ttyd - (x2)->o_ttyd; X if (c == 0) X! c = (x1)->o_pid - (x2)->o_pid; X! return(c); X } X X! wchancomp(x1, x2) X! register WCHAN *x1, *x2; X { X if (x1->caddr > x2->caddr) X! return(1); X! else if (x1->caddr == x2->caddr) X! return(0); X! else X! return(-1); X } X X char * X! getptr(adr) X char **adr; X { X! char *ptr = 0; X! register char *p, *pa; X! register int i; X X! pa = (char *)adr; X! p = (char *)&ptr; X for (i = 0; i < sizeof (ptr); i++) X! *p++ = getbyte(pa++); X! return(ptr); X } X X! getbyte(adr) X! register char *adr; X { X! register struct map *amap = &datmap; X char b; X off_t saddr; X X! if (!within(adr, amap->b1, amap->e1)) X! if (within(adr, amap->b2, amap->e2)) X! saddr = (unsigned) adr + amap->f2 - amap->b2; X! else return(0); X else saddr = (unsigned) adr + amap->f1 - amap->b1; X! if (lseek(file, saddr, 0) == (off_t) -1 || read (file, &b, 1) < 1) X! return(0); X! return((unsigned) b); X } X X! addchan(name, caddr) X! char *name; X! unsigned caddr; X! { X! static int left = 0; X! register WCHAN *wp; X X! if (left == 0) X! { X! if (wchand) X! { X! left = 50; X! wchand = (WCHAN *)realloc(wchand, (nchans + left) * X! sizeof (struct wchan)); X! } X! else X! { X! left = 300; X! wchand = (WCHAN *)malloc(left * sizeof (struct wchan)); X! } X! if (!wchand) X! { X! fprintf(stderr, "ps: out of wait channel memory\n"); X! nflg++; X! return; X! } X! } X! wp = &wchand[nchans++]; X! left--; X! strncpy(wp->cname, name, NNAMESIZ - 1); X! wp->cname[NNAMESIZ-1] = '\0'; X! wp->caddr = caddr; X } X X char * X! getchan(chan) X! register unsigned int chan; X { X! register int i; X! register char *prevsym; X X prevsym = ""; X if (chan) X for (i = 0; i < nchans; i++) { X! if (wchand[i].caddr > chan) X return (prevsym); X! prevsym = wchand[i].cname; X } X! return(prevsym); X } X X nlist() X! { X register FILE *nlistf_fp; X+ FILE *strfp; X register struct nlist *nnn; X+ int flag, nsyms; X struct nlist nbuf; X! struct xexec hbuf; X! char name[MAXSYMLEN + 2]; X int nllen; X! off_t sa, stroff; X X+ bzero(name, sizeof (name)); X nllen = sizeof(nl) / sizeof(struct nlist); X! if (!(nlistf_fp = fopen(nlistf,"r"))) X perrexit(nlistf); X! strfp = fopen(nlistf, "r"); X! if (fread(&hbuf,sizeof(hbuf),1,nlistf_fp) != 1) X! { X fputs("Invalid symbol table\n",stderr); X exit(1); X! } X! if (N_BADMAG(hbuf.e)) X! { X! fprintf(stderr,"%s: bad magic number\n",nlistf); X exit(1); X! } X! nsyms = hbuf.e.a_syms / sizeof (struct nlist); X! if (nsyms == 0) X! { X! fprintf(stderr,"%s: no symbols\n",nlistf); X! exit(1); X! } X! sa = N_SYMOFF(hbuf); X! stroff = N_STROFF(hbuf); X! fseek(nlistf_fp, sa, L_SET); X X! addchan("u", 0140000); /* XXX - see comment below */ X! while (nsyms--) X! { X! fread(&nbuf,sizeof(nbuf),1,nlistf_fp); X! if ((nbuf.n_type & N_EXT) == 0) X! continue; X! flag = nbuf.n_type & N_TYPE; X! /* X! * Now read the symbol string. Can't rely on having enough memory to X! * hold the entire string table, so we do a seek+read for each name. Luckily X! * this is only done for global symbols, which cuts down the work done. X! */ X! fseek(strfp, nbuf.n_un.n_strx + stroff, L_SET); X! fread(name, MAXSYMLEN, 1, strfp); X X! /* X! * Skip over anything which isn't an external data or bss symbol. X! * Advantage was taken of the facts that 1) 'ps' is highly machine X! * dependent and 2) _u on a pdp-11 is not likely to change _ever_. X! * The reason behind this is to avoid matching on absolute symbols created X! * during the unix/netnix cross binding. X! */ X! if (!(flag == N_DATA || flag == N_BSS)) X continue; X! if (!nflg) X! addchan(name + 1, nbuf.n_value); X! if (nllen) X! { X! for (nnn = nl; *nnn->n_un.n_name; nnn++) X! { X! if (!strcmp(nnn->n_un.n_name, name)) X! { X nnn->n_value = nbuf.n_value; X nnn->n_type = nbuf.n_type; X+ nnn->n_ovly = nbuf.n_ovly; X --nllen; X break; X+ } X } X! } X! } X fclose(nlistf_fp); X! fclose(strfp); X! if (!nflg) X! qsort(wchand,nchans,sizeof(WCHAN),wchancomp); X! } X X perrexit(msg) X char *msg; X*************** X*** 742,748 **** X if (!(fp = fopen (psdb, "w"))) X perrexit(psdb); X else X! chmod(psdb,0644); X nllen = sizeof(nl) / sizeof(struct nlist); X fwrite(nlistf,strlen(nlistf) + 1,1,fp); X fwrite((char *)&nllen,sizeof(nllen),1,fp); X--- 714,720 ---- X if (!(fp = fopen (psdb, "w"))) X perrexit(psdb); X else X! fchmod(fileno(fp),0644); X nllen = sizeof(nl) / sizeof(struct nlist); X fwrite(nlistf,strlen(nlistf) + 1,1,fp); X fwrite((char *)&nllen,sizeof(nllen),1,fp); X*************** X*** 750,813 **** X fwrite((char *)&nchans,sizeof(nchans),1,fp); X fwrite((char *)nl,sizeof(struct nlist),nllen,fp); X fwrite((char *)allttys,sizeof(struct ttys),nttys,fp); X! fwrite((char *)wchanhd,sizeof(WCHAN),nchans,fp); X fclose(fp); X } X X char * X! readpsdb () X { X register int i; X register FILE *fp; X register WCHAN *ccc; X! static char unamebuf[BUFSIZ]; X char *p = unamebuf; X int nllen; X X! if ((fp = fopen (psdb, "r")) == NULL) X! perrexit (psdb); X X! while ((*p= getc (fp)) != '\0') X p++; X! fread (&nllen, sizeof nllen, 1, fp); X! fread (&nttys, sizeof nttys, 1, fp); X! fread (&nchans, sizeof nchans, 1, fp); X! fread (nl, sizeof (struct nlist), nllen, fp); X! fread (allttys, sizeof (struct ttys), nttys, fp); X if (!nflg) X! if (!(wchanhd = (WCHAN *)calloc(nchans, sizeof(WCHAN)))) { X fputs("Too many symbols\n",stderr); X exit(1); X } X! else for (i = 0, ccc = wchanhd; i < nchans; i++) { X! fread ((char *) ccc, sizeof(WCHAN), 1, fp); X ccc++; X } X! return (unamebuf); X } X X! openfiles (argc, argv) X char **argv; X { X- kmemf = "/dev/kmem"; X- X if (kflg) X! kmemf = argc > 1 ? argv[1] : "/usr/sys/core"; X! kmem = open (kmemf, 0); X if (kmem < 0) X! perrexit (kmemf); X! if (!kflg) { X! memf = "/dev/mem"; X! ismem++; X! } X! else memf = kmemf; X! mem = open (memf, 0); X if (mem < 0) X! perrexit (memf); X! swapf = argc > 2 ? argv[2] : "/dev/swap"; X! swap = open (swapf, 0); X if (swap < 0) X! perrexit (swapf); X } X X getkvars(argc,argv) X--- 722,782 ---- X fwrite((char *)&nchans,sizeof(nchans),1,fp); X fwrite((char *)nl,sizeof(struct nlist),nllen,fp); X fwrite((char *)allttys,sizeof(struct ttys),nttys,fp); X! fwrite((char *)wchand,sizeof(WCHAN),nchans,fp); X fclose(fp); X } X X char * X! readpsdb() X { X register int i; X register FILE *fp; X register WCHAN *ccc; X! static char unamebuf[MAXPATHLEN + 1]; X char *p = unamebuf; X int nllen; X X! if ((fp = fopen(psdb, "r")) == NULL) X! perrexit(psdb); X X! while ((*p= getc(fp)) != '\0') X p++; X! fread(&nllen, sizeof nllen, 1, fp); X! fread(&nttys, sizeof nttys, 1, fp); X! fread(&nchans, sizeof nchans, 1, fp); X! fread(nl, sizeof (struct nlist), nllen, fp); X! fread(allttys, sizeof (struct ttys), nttys, fp); X if (!nflg) X! if (!(wchand = (WCHAN *)calloc(nchans, sizeof(WCHAN)))) { X fputs("Too many symbols\n",stderr); X exit(1); X } X! else for (i = 0, ccc = wchand; i < nchans; i++) { X! fread((char *) ccc, sizeof(WCHAN), 1, fp); X ccc++; X } X! return(unamebuf); X } X X! openfiles(argc, argv) X char **argv; X { X if (kflg) X! kmemf = argc > 1 ? argv[1] : "/usr/sys/core"; X! kmem = open(kmemf, 0); X if (kmem < 0) X! perrexit(kmemf); X! if (!kflg) X! memf = "/dev/mem"; X! else X! memf = kmemf; X! mem = open(memf, 0); X if (mem < 0) X! perrexit(memf); X! swapf = argc > 2 ? argv[2] : "/dev/swap"; X! swap = open(swapf, 0); X if (swap < 0) X! perrexit(swapf); X } X X getkvars(argc,argv) X*************** X*** 814,819 **** X--- 783,790 ---- X int argc; X char **argv; X { X+ struct stat st; X+ X nlistf = argc > 3 ? argv[3] : "/unix"; X if (Uflg) { X nlist(); X*************** X*** 821,834 **** X writepsdb(); X exit(0); X } X! else if (exists(psdb)) { X uname = readpsdb(); X! if (!equal(uname,nlistf)) { X /* X * Let addchan() do the work. X */ X nchans = 0; X! free((char *)wchanhd); X nlist(); X } X } X--- 792,805 ---- X writepsdb(); X exit(0); X } X! else if (stat(psdb, &st) == 0) { X uname = readpsdb(); X! if (strcmp(uname,nlistf)) { X /* X * Let addchan() do the work. X */ X nchans = 0; X! free((char *)wchand); X nlist(); X } X } X*************** X*** 858,867 **** X /* find value of hz */ X lseek(kmem,(off_t)nl[X_HZ].n_value,0); X read(kmem,(char *)&hz,sizeof(hz)); X- X- /* locate proc table */ X- lseek(kmem,(off_t)nl[X_PROC].n_value,0); X- tell = (off_t)nl[X_PROC].n_value; X } X X X--- 829,834 ---- X*************** X*** 881,887 **** X ptime(a); X } X X! char *lhdr = " F S UID PID PPID CPU PRI NICE ADDR SZ WCHAN TTY TIME"; X lpr(a) X register struct psout *a; X { X--- 848,854 ---- X ptime(a); X } X X! char *lhdr = " F S UID PID PPID CPU PRI NICE ADDR SZ WCHAN TTY TIME"; X lpr(a) X register struct psout *a; X { X*************** X*** 892,901 **** X a->o_ppid,a->o_cpu & 0377,a->o_pri,a->o_nice,a->o_addr0,a->o_size); X if (nflg) X if (a->o_wchan) X! printf("%7o",a->o_wchan); X else X fputs(" ",stdout); X! else printf(" %-6.6s",getchan(a->o_wchan)); X printf(" %-2.2s",a->o_tty); X ptime(a); X } X--- 859,869 ---- X a->o_ppid,a->o_cpu & 0377,a->o_pri,a->o_nice,a->o_addr0,a->o_size); X if (nflg) X if (a->o_wchan) X! printf("%*.*o",NNAMESIZ, NNAMESIZ, a->o_wchan); X else X fputs(" ",stdout); X! else X! printf(" %-*.*s",NNAMESIZ, NNAMESIZ, getchan(a->o_wchan)); X printf(" %-2.2s",a->o_tty); X ptime(a); X } X*************** X*** 917,952 **** X { X /* amount of top of stack to examine for args */ X #define ARGLIST (1024/sizeof(int)) X! register *ip; X! register char *cp, *cp1; X char c, **ap; X int cc, nbad, abuf [ARGLIST]; X X! a->o_args[0] = 0; /* in case of early return */ X! addr += ctob ((off_t) mproc->p_ssize) - ARGLIST*sizeof(int); X X /* look for sh special */ X! lseek (file, addr + ARGLIST*sizeof(int) - sizeof (char **), 0); X! if (read (file, (char *) &ap, sizeof (char *)) != sizeof (char *)) X return (1); X if (ap) { X char b[82]; X char *bp = b; X! while ((cp = getptr (ap++)) && cp && (bp < b+sizeof (a->o_args)) ) { X nbad = 0; X! while ((c = getbyte (cp++)) && (bp < b+sizeof (a->o_args))) { X! if (c<' ' || c > '~') { X if (nbad++ > 3) X break; X continue; X } X! *bp++ = c; X } X! *bp++ = ' '; X } X! *bp++ = 0; X (void)strcpy(a->o_args, b); X! return (1); X } X X lseek(file, addr, 0); X--- 885,920 ---- X { X /* amount of top of stack to examine for args */ X #define ARGLIST (1024/sizeof(int)) X! register int *ip; X! register char *cp, *cp1; X char c, **ap; X int cc, nbad, abuf [ARGLIST]; X X! a->o_args[0] = 0; /* in case of early return */ X! addr += ctob((off_t) mproc->p_ssize) - ARGLIST*sizeof(int); X X /* look for sh special */ X! lseek(file, addr + ARGLIST*sizeof(int) - sizeof (char **), 0); X! if (read(file, (char *) &ap, sizeof (char *)) != sizeof (char *)) X return (1); X if (ap) { X char b[82]; X char *bp = b; X! while ((cp = getptr(ap++)) && cp && (bp < b+sizeof (a->o_args)) ) { X nbad = 0; X! while ((c = getbyte(cp++)) && (bp < b+sizeof (a->o_args))) { X! if (c<' ' || c > '~') { X if (nbad++ > 3) X break; X continue; X } X! *bp++ = c; X } X! *bp++ = ' '; X } X! *bp++ = 0; X (void)strcpy(a->o_args, b); X! return(1); X } X X lseek(file, addr, 0); X*************** X*** 955,995 **** X abuf[ARGLIST-1] = 0; X for (ip = &abuf[ARGLIST-2]; ip > abuf;) { X if (*--ip == -1 || *ip == 0) { X! cp = (char *) (ip + 1); X if (*cp == '\0') X cp++; X! nbad = 0; X for (cp1 = cp; cp1 < (char *) &abuf[ARGLIST]; cp1++) { X! cc = *cp1 & 0177; X if (cc == 0) X! *cp1 = ' '; X else if (cc < ' ' || cc > 0176) { X if (++nbad >= 5) { X *cp1++ = ' '; X break; X } X! *cp1 = '?'; X } else if (cc == '=') { X! *cp1 = '\0'; X while (cp1 > cp && *--cp1 != ' ') X! *cp1 = '\0'; X break; X } X } X while (*--cp1 == ' ') X! *cp1 = 0; X (void)strcpy(a->o_args, cp); X garbage: X! cp = a->o_args; X if (cp[0] == '-' && cp[1] <= ' ' || cp[0] == '?' || cp[0] <= ' ') { X! strcat (cp, " ("); X! strcat (cp, u.u_comm); X! strcat (cp, ")"); X } X! cp[63] = 0; /* max room in psout is 64 chars */ X if (xflg || gflg || tptr || cp[0] != '-') X! return (1); X! return (0); X } X } X goto garbage; X--- 923,963 ---- X abuf[ARGLIST-1] = 0; X for (ip = &abuf[ARGLIST-2]; ip > abuf;) { X if (*--ip == -1 || *ip == 0) { X! cp = (char *) (ip + 1); X if (*cp == '\0') X cp++; X! nbad = 0; X for (cp1 = cp; cp1 < (char *) &abuf[ARGLIST]; cp1++) { X! cc = *cp1 & 0177; X if (cc == 0) X! *cp1 = ' '; X else if (cc < ' ' || cc > 0176) { X if (++nbad >= 5) { X *cp1++ = ' '; X break; X } X! *cp1 = '?'; X } else if (cc == '=') { X! *cp1 = '\0'; X while (cp1 > cp && *--cp1 != ' ') X! *cp1 = '\0'; X break; X } X } X while (*--cp1 == ' ') X! *cp1 = 0; X (void)strcpy(a->o_args, cp); X garbage: X! cp = a->o_args; X if (cp[0] == '-' && cp[1] <= ' ' || cp[0] == '?' || cp[0] <= ' ') { X! strcat(cp, " ("); X! strcat(cp, u.u_comm); X! strcat(cp, ")"); X } X! cp[63] = 0; /* max room in psout is 64 chars */ X if (xflg || gflg || tptr || cp[0] != '-') X! return(1); X! return(0); X } X } X goto garbage; X*************** X*** 997,1004 **** X X printhdr() X { X! register char *hdr, X! *cmdstr = " COMMAND"; X X if (rflg) X return; X--- 965,971 ---- X X printhdr() X { X! register char *hdr, *cmdstr = " COMMAND"; X X if (rflg) X return; X*************** X*** 1009,1020 **** X hdr = lflg ? lhdr : (uflg ? uhdr : shdr); X fputs(hdr,stdout); X cmdstart = strlen(hdr); X- #ifdef TERMCAP X if (cmdstart + strlen(cmdstr) >= twidth) X! puts(" CMD"); X! #else !TERMCAP X! puts(cmdstr); X! #endif TERMCAP X fflush(stdout); X } X X--- 976,984 ---- X hdr = lflg ? lhdr : (uflg ? uhdr : shdr); X fputs(hdr,stdout); X cmdstart = strlen(hdr); X if (cmdstart + strlen(cmdstr) >= twidth) X! cmdstr = " CMD"; X! printf("%s\n", cmdstr); X fflush(stdout); X } X SHAR_EOF chmod 640 'patchfile' fi exit 0 # End of shell archive