Subject: devname,daemon,err,uname(3),uname(1) and dev_mkdb(8) (#228 2 of 2) Index: libc/gen/{devname,daemon,err,uname}.c,usr.bin/uname,etc/dev_mkdb 2.11BSD Description: Several new C library routines and two new utility programs have been ported from 4.4-Lite to 2.11BSD. The 'welcome' program would print garbage if run between midnight and 0100 in the morning. The lastcomm program did not accept an alternate accounting file. Repeat-By: Not applicable. Fix: This started out as a port of one thing for a specific program. The devname.c module was going to be ported so that the fixed string in sysctl(8) could be removed. This is part 2 of 2. You should have unshar'd the file from part 1 (#227) at this point. The following files are updated in this part: /var /usr/include/paths.h /usr/src/lib/libc/gen/Makefile /usr/src/lib/libc/pdp/csu/crt0.s /usr/src/lib/libc/pdp/stdio/doprnt.s /usr/src/bin/sysctl/Makefile /usr/src/bin/sysctl/sysctl.c /usr/src/etc/Makefile /usr/src/local/welcome/welcome.c /usr/src/man/man1/lastcomm.1 /usr/src/man/man3/Makefile /usr/src/ucb/lastcomm.c /usr/src/usr.bin/Makefile /etc/rc /VERSION 1) /var/run must exist before 'dev_mkdb' can be run. There are a couple ways to do this, pick the one best suited to your system. a) mkdir -p /var/run; chmod 755 /var /var/run or b) mkdir /usr/run; chmod 755 /usr/run; ln -s /usr /var or c) mkdir -p /usr/var/run; chmod -R 755 /usr/var; ln -s /usr/var /var or d) have a spare filesystem handy and mount /var on a partition of its own. This is unlikely to be possible since most systems only have one or two drives. The basic idea is to make sure that /var/run is a valid path name. For now only the 'dev' database will be present. This database is about 4kb so it should fit on the root filesystem without difficulty. 2) Save the patch below into a file (/tmp/228) and then: patch -p0 < /tmp/228 3) cd /usr/src/lib/libc make make install make clean This will recreate and install the new C library and startup routine. Next we recompile and install various programs: 4) cd /usr/src/bin/sysctl make make install make clean cd /usr/src/local/welcome make make install make clean cd /usr/src/ucb make lastcomm install -s -m 755 lastcomm /usr/ucb cd /usr/src/etc/dev_mkdb make make install make clean cd /usr/src/usr.bin/uname make make install make clean cd /usr/src/man/man3 /usr/man/manroff daemon.3 > daemon.0 /usr/man/manroff devname.3 > devname.0 /usr/man/manroff err.3 > err.0 install -m 444 daemon.0 devname.0 err.0 /usr/man/cat3 cd /usr/src/man/man1 /usr/man/manroff lastcomm.1 > /usr/man/cat1/lastcomm.0 Lastly the 'dev' database is created: 5) /etc/dev_mkdb Doing "ls -l /var/run" should produce something like this: total 5 -rw-r--r-- 1 root 512 Feb 6 19:31 dev.dir -rw-r--r-- 1 root 4096 Feb 6 19:31 dev.pag ======================================cut here *** /usr/include/paths.h.old Tue May 11 21:47:18 1993 --- /usr/include/paths.h Fri Feb 3 21:02:25 1995 *************** *** 14,20 **** * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * ! * @(#)pathnames.h 5.3 (2.11BSD) 5/10/93 */ #define _PATH_BSHELL "/bin/sh" --- 14,20 ---- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * ! * @(#)pathnames.h 5.3.1 (2.11BSD) 2/3/95 */ #define _PATH_BSHELL "/bin/sh" *************** *** 21,26 **** --- 21,27 ---- #define _PATH_CSHELL "/bin/csh" #define _PATH_CP "/bin/cp" #define _PATH_RSH "/usr/ucb/rsh" + #define _PATH_DEVNULL "/dev/null" #define _PATH_TTY "/dev/tty" #define _PATH_DEV "/dev" #define _PATH_LASTLOG "/usr/adm/lastlog" *************** *** 27,29 **** --- 28,32 ---- #define _PATH_TMP "/tmp/" #define _PATH_VARTMP "/usr/tmp/" #define _PATH_SENDMAIL "/usr/lib/sendmail" + #define _PATH_DEVDB "/var/run/dev" + #define _PATH_VARRUN "/var/run/" *** /usr/src/lib/libc/gen/Makefile.old Sun Jan 15 22:19:03 1995 --- /usr/src/lib/libc/gen/Makefile Sat Feb 4 23:19:56 1995 *************** *** 3,27 **** # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # ! # @(#)Makefile 5.7.1 (2.11BSD GTE) 1/15/95 # # Several routines have been rewritten in assembly language for the VAX and # the PDP. If you are not running on a VAX or PDP, you should use the # original C sources which are included in this directory. # - #if !defined(vax) && !defined(pdp11) - #SRCS= ${STDSRC} ${VAXSRC} - #OBJS= ${STDOBJ} ${VAXOBJ} - #else SRCS= ${STDSRC} OBJS= ${STDOBJ} - #endif not vax && not pdp11 CFLAGS= -O ${DEFS} STDSRC= abort.c alarm.c atoi.c atol.c calloc.c closedir.c crypt.c \ ! ctime.c ctype_.c errlst.c execvp.c fakcu.c fstab.c gcvt.c getenv.c \ ! getgrent.c getgrgid.c getgrnam.c getlogin.c getpass.c getpwent.c \ ! getloadavg.c \ getttyent.c getttynam.c getusershell.c getwd.c \ initgroups.c isatty.c malloc.c mktemp.c ndbm.c nlist.c \ opendir.c perror.c popen.c psignal.c qsort.c random.c readdir.c \ --- 3,22 ---- # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # ! # @(#)Makefile 5.7.2 (2.11BSD GTE) 2/4/95 # # Several routines have been rewritten in assembly language for the VAX and # the PDP. If you are not running on a VAX or PDP, you should use the # original C sources which are included in this directory. # SRCS= ${STDSRC} OBJS= ${STDOBJ} CFLAGS= -O ${DEFS} STDSRC= abort.c alarm.c atoi.c atol.c calloc.c closedir.c crypt.c \ ! ctime.c ctype_.c daemon.c devname.c err.c errlst.c execvp.c fakcu.c \ ! fstab.c gcvt.c getenv.c getgrent.c getgrgid.c getgrnam.c getlogin.c \ ! getpass.c getpwent.c getloadavg.c \ getttyent.c getttynam.c getusershell.c getwd.c \ initgroups.c isatty.c malloc.c mktemp.c ndbm.c nlist.c \ opendir.c perror.c popen.c psignal.c qsort.c random.c readdir.c \ *************** *** 29,42 **** setenv.c seteuid.c setruid.c siglist.c signal.c siginterrupt.c \ sleep.c strcasecmp.c swab.c sysctl.c syslog.c system.c telldir.c \ time.c timezone.c ttyname.c ttyslot.c ualarm.c usleep.c valloc.c \ ! strdup.c strsep.c wait.c wait3.c waitpid.c ! VAXSRC= abs.c bcmp.c bcopy.c bzero.c fabs.c ffs.c frexp.c index.c insque.c \ ! rindex.c remque.c strcat.c strcmp.c strcpy.c strlen.c strncat.c \ ! strncmp.c strncpy.c STDOBJ= abort.o alarm.o atoi.o atol.o calloc.o closedir.o crypt.o \ ! ctime.o ctype_.o errlst.o execvp.o fakcu.o fstab.o gcvt.o getenv.o \ ! getgrent.o getgrgid.o getgrnam.o getlogin.o getpass.o getpwent.o \ ! getloadavg.o \ getttyent.o getttynam.o getusershell.o getwd.o \ initgroups.o isatty.o malloc.o mktemp.o ndbm.o nlist.o \ opendir.o perror.o popen.o psignal.o qsort.o random.o readdir.o \ --- 24,34 ---- setenv.c seteuid.c setruid.c siglist.c signal.c siginterrupt.c \ sleep.c strcasecmp.c swab.c sysctl.c syslog.c system.c telldir.c \ time.c timezone.c ttyname.c ttyslot.c ualarm.c usleep.c valloc.c \ ! strdup.c strsep.c uname.c wait.c wait3.c waitpid.c STDOBJ= abort.o alarm.o atoi.o atol.o calloc.o closedir.o crypt.o \ ! ctime.o ctype_.o daemon.o devname.o err.o errlst.o execvp.o fakcu.o \ ! fstab.o gcvt.o getenv.o getgrent.o getgrgid.o getgrnam.o getlogin.o \ ! getpass.o getpwent.o getloadavg.o \ getttyent.o getttynam.o getusershell.o getwd.o \ initgroups.o isatty.o malloc.o mktemp.o ndbm.o nlist.o \ opendir.o perror.o popen.o psignal.o qsort.o random.o readdir.o \ *************** *** 44,53 **** setenv.o seteuid.o setruid.o siglist.o signal.o siginterrupt.o \ sleep.o strcasecmp.o swab.o sysctl.o syslog.o system.o telldir.o \ time.o timezone.o ttyname.o ttyslot.o ualarm.o usleep.o valloc.o \ ! strdup.o strsep.o wait.o wait3.o waitpid.o ! VAXOBJ= abs.o bcmp.o bcopy.o bzero.o fabs.c ffs.o frexp.o index.o insque.o \ ! rindex.o remque.o strcat.o strcmp.o strcpy.o strlen.o strncat.o \ ! strncmp.o strncpy.o TAGSFILE=tags .c.o: --- 36,43 ---- setenv.o seteuid.o setruid.o siglist.o signal.o siginterrupt.o \ sleep.o strcasecmp.o swab.o sysctl.o syslog.o system.o telldir.o \ time.o timezone.o ttyname.o ttyslot.o ualarm.o usleep.o valloc.o \ ! strdup.o strsep.o uname.o wait.o wait3.o waitpid.o ! TAGSFILE=tags .c.o: *** /usr/src/lib/libc/pdp/csu/crt0.s.old Wed Jun 3 19:02:35 1987 --- /usr/src/lib/libc/pdp/csu/crt0.s Thu Feb 2 23:52:11 1995 *************** *** 5,11 **** */ #ifdef LIBC_SCCS ! <@(#)crt0.s 2.3 (Berkeley) 1/28/87\0> .even #endif LIBC_SCCS --- 5,11 ---- */ #ifdef LIBC_SCCS ! <@(#)crt0.s 2.4 (2.11BSD GTE) 2/02/95\0> .even #endif LIBC_SCCS *************** *** 55,72 **** .text /* * The following zero has a number of purposes - it serves as a null terminated * string for uninitialized string pointers on separate I&D machines for * instance. But we never would have put it here for that reason; programs ! * which use initialized pointer *should* die. The real reason it's here is * so you can declare "char blah[] = "foobar" at the start of a C program * and not have printf generate "(null)" when you try to print it because * blah is at address zero on separate I&D machines ... sick, sick, sick ... ! */ ! .data ! 0 ! .text .globl _exit, _main --- 55,83 ---- .text /* + * Paragraph below retained for historical purposes. + * * The following zero has a number of purposes - it serves as a null terminated * string for uninitialized string pointers on separate I&D machines for * instance. But we never would have put it here for that reason; programs ! * which use uninitialized pointer *should* die. The real reason it's here is * so you can declare "char blah[] = "foobar" at the start of a C program * and not have printf generate "(null)" when you try to print it because * blah is at address zero on separate I&D machines ... sick, sick, sick ... ! * ! * In porting bits and pieces of the 4.4-Lite C library the global program ! * name location '___progname' was needed. Rather than take up another two ! * bytes of D space the 0th location was used. The '(null)' string was ! * removed from doprnt.s so now when programs use uninitialized pointers ! * they will be rewarded with argv[0]. This is no sicker than before and ! * may cause bad programs to die sooner. ! */ ! .data ! .globl ___progname, _strrchr + ___progname: 0 + .text + .globl _exit, _main *************** *** 78,83 **** --- 89,95 ---- mov 4(sp),(r0)+ / copy argc down mov sp,(r0) / calculate position of arg pointers add $6,(r0) + mov *(r0),___progname mov (r0)+,(r0) / calculate position of env pointers add (sp),(r0) add (sp),(r0) *************** *** 100,105 **** --- 112,126 ---- #endif MCRT0 clr r5 / for adb and longjmp/rollback ... + mov $'/,-(sp) + mov ___progname,-(sp) + jsr pc,_strrchr + tst r0 + beq 1f + inc r0 + mov r0,___progname + 1: + cmp (sp)+,(sp)+ jsr pc,_main / call main mov r0,(sp) / and pass main's return value to _exit ... jsr pc,*$_exit *** /usr/src/lib/libc/pdp/stdio/doprnt.s.old Tue Aug 25 19:42:46 1992 --- /usr/src/lib/libc/pdp/stdio/doprnt.s Thu Feb 2 21:29:41 1995 *************** *** 6,12 **** #ifdef LIBC_SCCS /* <@(#)doprnt.s 5.4 (Berkeley) 1/25/87\0> */ ! <@(#)doprnt.s 5.5 (GTE) 8/25/92\0> .even #endif LIBC_SCCS --- 6,12 ---- #ifdef LIBC_SCCS /* <@(#)doprnt.s 5.4 (Berkeley) 1/25/87\0> */ ! <@(#)doprnt.s 5.6 (2.11BSD GTE) 2/02/95\0> .even #endif LIBC_SCCS *************** *** 19,28 **** */ #include "DEFS.h" ! .data ! nulstr: ! <(null)\0> ! .even swtab: decimal; 'd octal; 'o --- 19,25 ---- */ #include "DEFS.h" ! .data swtab: decimal; 'd octal; 'o *************** *** 252,261 **** mov ndigit(r5),r1 mov (r4),r2 mov r2,r3 - bne 1f - mov $nulstr,r2 - mov r2,r3 - mov r2,(r4) 1: tstb (r2)+ beq 1f --- 249,254 ---- *** /usr/src/bin/sysctl/Makefile.old Sun Jan 15 23:05:00 1995 --- /usr/src/bin/sysctl/Makefile Fri Feb 3 23:15:07 1995 *************** *** 1,7 **** # # Public Domain. 1/15/1995 - Steven Schultz # ! # @(#)Makefile 1.0 (2.11BSD GTE) 1/15/95 # CFLAGS= -O SEPFLAG= -i --- 1,7 ---- # # Public Domain. 1/15/1995 - Steven Schultz # ! # @(#)Makefile 1.1 (2.11BSD GTE) 2/3/95 # CFLAGS= -O SEPFLAG= -i *************** *** 25,31 **** depend: ${SRCS} mkdep ${CFLAGS} ${SRCS} ! install: sysctl install -c -o bin -g bin -m 444 ${MAN} ${DESTDIR}/usr/man/cat8 install -s -o root -g bin -m 755 sysctl ${DESTDIR}/bin/sysctl --- 25,31 ---- depend: ${SRCS} mkdep ${CFLAGS} ${SRCS} ! install: all install -c -o bin -g bin -m 444 ${MAN} ${DESTDIR}/usr/man/cat8 install -s -o root -g bin -m 755 sysctl ${DESTDIR}/bin/sysctl *** /usr/src/bin/sysctl/sysctl.c.old Thu Jan 19 21:32:22 1995 --- /usr/src/bin/sysctl/sysctl.c Fri Feb 3 23:10:32 1995 *************** *** 36,42 **** "@(#) Copyright (c) 1993\n\ The Regents of the University of California. All rights reserved.\n"; ! static char sccsid[] = "@(#)sysctl.c 8.1.1 (2.11BSD GTE) 1/12/95"; #endif /* not lint */ #include --- 36,42 ---- "@(#) Copyright (c) 1993\n\ The Regents of the University of California. All rights reserved.\n"; ! static char sccsid[] = "@(#)sysctl.c 8.1.2 (2.11BSD GTE) 2/3/95"; #endif /* not lint */ #include *************** *** 382,392 **** if (!nflag) fprintf(stdout, "%s = %s\n", string, - #ifdef notyet devname(dev, S_IFCHR)); - #else - "/dev/console"); - #endif else fprintf(stdout, "0x%x\n", dev); return; --- 382,388 ---- *** /usr/src/etc/Makefile.old Tue Jan 17 23:41:08 1995 --- /usr/src/etc/Makefile Fri Feb 3 22:12:18 1995 *************** *** 3,9 **** # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # ! # @(#)Makefile 5.14.1 (2.11BSD GTE) 1/17/95 # DESTDIR= CFLAGS= -O --- 3,9 ---- # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # ! # @(#)Makefile 5.14.2 (2.11BSD GTE) 2/3/95 # DESTDIR= CFLAGS= -O *************** *** 11,19 **** # Programs that live in subdirectories, and have makefiles of their own. # ! SUBDIR= chroot config dump fingerd fsck ftpd getty htable implog named restor \ ! routed talkd termcap tftpd timed tzone XNSrouted mkpasswd vipw \ ! rlogind rshd # Shell scripts that need only be installed and are never removed. # --- 11,19 ---- # Programs that live in subdirectories, and have makefiles of their own. # ! SUBDIR= chroot config dev_mkdb dump fingerd fsck ftpd getty htable implog \ ! named restor routed talkd termcap tftpd timed tzone XNSrouted \ ! mkpasswd vipw rlogind rshd # Shell scripts that need only be installed and are never removed. # *** /usr/src/local/welcome/welcome.c.old Fri Jan 20 23:19:40 1995 --- /usr/src/local/welcome/welcome.c Sun Feb 5 00:46:27 1995 *************** *** 52,58 **** } ap = "AP"[(det = localtime(&secs))->tm_hour >= 12]; ! if (det->tm_hour > 0 && det->tm_hour < 12) foo = ttime[0]; else if (det->tm_hour > 11 && det->tm_hour < 18) foo = ttime[1]; --- 52,58 ---- } ap = "AP"[(det = localtime(&secs))->tm_hour >= 12]; ! if (det->tm_hour >= 0 && det->tm_hour < 12) foo = ttime[0]; else if (det->tm_hour > 11 && det->tm_hour < 18) foo = ttime[1]; *** /usr/src/man/man1/lastcomm.1.old Sun Dec 14 15:06:10 1986 --- /usr/src/man/man1/lastcomm.1 Fri Feb 3 23:35:30 1995 *************** *** 2,19 **** .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" ! .\" @(#)lastcomm.1 6.2 (Berkeley) 1/5/86 .\" ! .TH LASTCOMM 1 "January 5, 1986" ! .UC .SH NAME lastcomm \- show last commands executed in reverse order .SH SYNOPSIS .B lastcomm ! [ command name ] ... [user name] ... [terminal name] ... .SH DESCRIPTION .I Lastcomm gives information on previously executed commands. With no arguments, .I lastcomm prints information about all the commands recorded --- 2,26 ---- .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" ! .\" @(#)lastcomm.1 6.2.1 (2.11BSD) 2/3/05 .\" ! .TH LASTCOMM 1 "February 3, 1995" ! .UC 4 .SH NAME lastcomm \- show last commands executed in reverse order .SH SYNOPSIS .B lastcomm ! [ -f file ] [ command name ] ... [user name] ... [terminal name] ... .SH DESCRIPTION .I Lastcomm gives information on previously executed commands. + .sp + Option: + .sp + .TP 10 + \-f \fIfile\fP + Read from \fIfile\fP rather than the default accounting file. + .PP With no arguments, .I lastcomm prints information about all the commands recorded *************** *** 22,30 **** matching command name, user name, or terminal name are printed. So, for example, .ti +0.5i lastcomm a.out root ttyd0 ! .br would produce a listing of all the executions of commands named .I a.out --- 29,38 ---- matching command name, user name, or terminal name are printed. So, for example, + .sp .ti +0.5i lastcomm a.out root ttyd0 ! .sp would produce a listing of all the executions of commands named .I a.out *************** *** 34,39 **** --- 42,48 ---- .IR ttyd0 . .PP For each process entry, the following are printed. + .sp .in +0.5i The name of the user who ran the process. .br *************** *** 56,62 **** --- 65,73 ---- .I core file, and ``X'' indicates the command was terminated with a signal. .SH FILES + .TP 20 /usr/adm/acct + Default accounting file. .SH "SEE ALSO" last(1), sigvec(2), *** /usr/src/man/man3/Makefile.old Sat Jan 21 20:09:02 1995 --- /usr/src/man/man3/Makefile Fri Feb 3 21:35:23 1995 *************** *** 14,25 **** # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. # ! # @(#)Makefile 5.4.1 (2.11BSD GTE) 1/15/95 # MDIR= /usr/man/cat3 SRCS1= abort.3 abs.3 alarm.3 asinh.3 assert.3 atof.3 bstring.3 byteorder.3 \ ! compat-sys5.3 crypt.3 ctime.3 ctype.3 curses.3 dbm.3 directory.3 \ ! ecvt.3 end.3 erf.3 execl.3 exit.3 exp.3 fclose.3 ferror.3 floor.3 \ fopen.3 fread.3 frexp.3 fseek.3 getc.3 getdisk.3 getenv.3 getfsent.3 \ getgrent.3 gethostbyname.3 getlogin.3 getnetent.3 getopt.3 getpass.3 \ getloadavg.3 \ --- 14,26 ---- # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. # ! # @(#)Makefile 5.4.2 (2.11BSD GTE) 2/3/95 # MDIR= /usr/man/cat3 SRCS1= abort.3 abs.3 alarm.3 asinh.3 assert.3 atof.3 bstring.3 byteorder.3 \ ! compat-sys5.3 crypt.3 ctime.3 ctype.3 curses.3 dbm.3 daemon.3 \ ! devname.3 directory.3 ecvt.3 end.3 erf.3 err.3 execl.3 exit.3 \ ! exp.3 fclose.3 ferror.3 floor.3 \ fopen.3 fread.3 frexp.3 fseek.3 getc.3 getdisk.3 getenv.3 getfsent.3 \ getgrent.3 gethostbyname.3 getlogin.3 getnetent.3 getopt.3 getpass.3 \ getloadavg.3 \ *************** *** 35,42 **** system.3 termcap.3 time.3 times.3 ttyname.3 ualarm.3 ungetc.3 \ usleep.3 utime.3 valloc.3 varargs.3 OBJS1= abort.0 abs.0 alarm.0 asinh.0 assert.0 atof.0 bstring.0 byteorder.0 \ ! compat-sys5.0 crypt.0 ctime.0 ctype.0 curses.0 dbm.0 directory.0 \ ! ecvt.0 end.0 erf.0 execl.0 exit.0 exp.0 fclose.0 ferror.0 floor.0 \ fopen.0 fread.0 frexp.0 fseek.0 getc.0 getdisk.0 getenv.0 getfsent.0 \ getgrent.0 gethostbyname.0 getlogin.0 getnetent.0 getopt.0 getpass.0 \ getprotoent.0 getpwent.0 gets.0 getservent.0 getttyent.0 \ --- 36,44 ---- system.3 termcap.3 time.3 times.3 ttyname.3 ualarm.3 ungetc.3 \ usleep.3 utime.3 valloc.3 varargs.3 OBJS1= abort.0 abs.0 alarm.0 asinh.0 assert.0 atof.0 bstring.0 byteorder.0 \ ! compat-sys5.0 crypt.0 ctime.0 ctype.0 curses.0 dbm.0 daemon.0 \ ! devname.0 directory.0 ecvt.0 end.0 erf.0 err.0 execl.0 exit.0 \ ! exp.0 fclose.0 ferror.0 floor.0 \ fopen.0 fread.0 frexp.0 fseek.0 getc.0 getdisk.0 getenv.0 getfsent.0 \ getgrent.0 gethostbyname.0 getlogin.0 getnetent.0 getopt.0 getpass.0 \ getprotoent.0 getpwent.0 gets.0 getservent.0 getttyent.0 \ *** /usr/src/ucb/lastcomm.c.old Mon Jan 10 22:39:11 1994 --- /usr/src/ucb/lastcomm.c Fri Feb 3 22:59:11 1995 *************** *** 9,19 **** "@(#) Copyright (c) 1980 Regents of the University of California.\n\ All rights reserved.\n"; ! static char sccsid[] = "@(#)lastcomm.c 5.2.1 (2.11BSD GTE) 1/1/94"; #endif /* ! * last command */ #include #include --- 9,19 ---- "@(#) Copyright (c) 1980 Regents of the University of California.\n\ All rights reserved.\n"; ! static char sccsid[] = "@(#)lastcomm.c 5.2.2 (2.11BSD GTE) 2/3/95"; #endif /* ! * lastcomm command */ #include #include *************** *** 33,51 **** char *getname(); char *getdev(); main(argc, argv) char *argv[]; { register int bn, cc; register struct acct *acp; ! int fd; struct stat sb; ! fd = open("/usr/adm/acct", O_RDONLY); ! if (fd < 0) { ! perror("/usr/adm/acct"); ! exit(1); ! } fstat(fd, &sb); for (bn = btodb(sb.st_size); bn >= 0; bn--) { lseek(fd, (off_t)dbtob(bn), L_SET); --- 33,69 ---- char *getname(); char *getdev(); + extern char *devname(), *optarg; + extern int optind; + main(argc, argv) char *argv[]; { register int bn, cc; register struct acct *acp; ! int fd, ch; struct stat sb; + char *acctfile = "/usr/adm/acct"; ! while ((ch = getopt(argc, argv, "f:")) != EOF) ! { ! switch (ch) ! { ! case 'f': ! acctfile = optarg; ! break; ! case '?': ! default: ! usage(); ! } ! } ! argc -= optind; ! argv += optind; ! ! fd = open(acctfile, O_RDONLY); ! if (fd < 0) ! err(1, "%s", acctfile); ! fstat(fd, &sb); for (bn = btodb(sb.st_size); bn >= 0; bn--) { lseek(fd, (off_t)dbtob(bn), L_SET); *************** *** 113,119 **** } ok(argc, argv, acp) ! register int argc; register char *argv[]; register struct acct *acp; { --- 131,137 ---- } ok(argc, argv, acp) ! int argc; register char *argv[]; register struct acct *acp; { *************** *** 158,251 **** return(cp->name); } - #include - - #define N_DEVS 43 /* hash value for device names */ - #define NDEVS 500 /* max number of file names in /dev */ - - struct devhash { - dev_t dev_dev; - char dev_name [fldsiz(utmp, ut_line) + 1]; - struct devhash * dev_nxt; - }; - struct devhash *dev_hash[N_DEVS]; - struct devhash *dev_chain; - #define HASH(d) (((int) d) % N_DEVS) - - setupdevs() - { - register DIR * fd; - register struct devhash * hashtab; - register ndevs = NDEVS; - struct direct * dp; - - if ((fd = opendir("/dev")) == NULL) { - perror("/dev"); - return; - } - hashtab = (struct devhash *)malloc(NDEVS * sizeof(struct devhash)); - if (hashtab == (struct devhash *)0) { - fprintf(stderr, "No mem for dev table\n"); - closedir(fd); - return; - } - while (dp = readdir(fd)) { - if (dp->d_ino == 0) - continue; - if (dp->d_name[0] != 't' && strcmp(dp->d_name, "console")) - continue; - strncpy(hashtab->dev_name, dp->d_name, fldsiz(utmp, ut_line)); - hashtab->dev_name[fldsiz(utmp, ut_line)] = 0; - hashtab->dev_nxt = dev_chain; - dev_chain = hashtab; - hashtab++; - if (--ndevs <= 0) - break; - } - closedir(fd); - } - char * getdev(dev) dev_t dev; { - register struct devhash *hp, *nhp; - struct stat statb; - char name[fldsiz(devhash, dev_name) + 6]; static dev_t lastdev = (dev_t) -1; static char *lastname; - static int init = 0; ! if (dev == NODEV) return ("__"); ! if (dev == lastdev) return (lastname); ! if (!init) { ! setupdevs(); ! init++; ! } ! for (hp = dev_hash[HASH(dev)]; hp; hp = hp->dev_nxt) ! if (hp->dev_dev == dev) { ! lastdev = dev; ! return (lastname = hp->dev_name); ! } ! for (hp = dev_chain; hp; hp = nhp) { ! nhp = hp->dev_nxt; ! strcpy(name, "/dev/"); ! strcat(name, hp->dev_name); ! if (stat(name, &statb) < 0) /* name truncated usually */ ! continue; ! if ((statb.st_mode & S_IFMT) != S_IFCHR) ! continue; ! hp->dev_dev = statb.st_rdev; ! hp->dev_nxt = dev_hash[HASH(hp->dev_dev)]; ! dev_hash[HASH(hp->dev_dev)] = hp; ! if (hp->dev_dev == dev) { ! dev_chain = nhp; ! lastdev = dev; ! return (lastname = hp->dev_name); ! } ! } ! dev_chain = (struct devhash *) 0; ! return ("??"); } --- 176,202 ---- return(cp->name); } char * getdev(dev) dev_t dev; { static dev_t lastdev = (dev_t) -1; static char *lastname; ! if (dev == NODEV) /* Special case */ return ("__"); ! if (dev == lastdev) /* One-element cache. */ return (lastname); ! lastdev = dev; ! lastname = devname(dev, S_IFCHR); ! return (lastname); } + + void + usage() + { + + (void)fprintf(stderr, + "lastcomm [ -f file ] [ command ...] [ user ...] [ tty ...]\n"); + exit(1); + } *** /usr/src/usr.bin/Makefile.old Fri Dec 31 19:38:55 1993 --- /usr/src/usr.bin/Makefile Sat Feb 4 23:34:23 1995 *************** *** 1,4 **** ! # Makefile 4.39.1.1 86/08/12 # DESTDIR= CFLAGS= -O --- 1,4 ---- ! # Makefile 4.39.1.2 95/02/4 # DESTDIR= CFLAGS= -O *************** *** 8,14 **** # SUBDIR= at calendar dc diction diff3 eqn f77 find graph learn lex lint \ m4 neqn plot prof ranlib ratfor refer roff spell struct tbl tip uucp \ ! yacc # Shell scripts that need only be installed and are never removed. # --- 8,14 ---- # SUBDIR= at calendar dc diction diff3 eqn f77 find graph learn lex lint \ m4 neqn plot prof ranlib ratfor refer roff spell struct tbl tip uucp \ ! uname yacc # Shell scripts that need only be installed and are never removed. # *** /etc/rc.old Thu Jan 12 20:38:24 1995 --- /etc/rc Sat Feb 4 00:19:33 1995 *************** *** 81,86 **** --- 81,89 ---- /etc/quotacheck -a -p >/dev/console 2>&1 echo ' done.' >/dev/console 2>&1 /etc/quotaon -a + + /etc/dev_mkdb + ps -U >/dev/console 2>&1 rm -f /etc/nologin rm -f /usr/spool/uucp/LCK.* *** /VERSION.old Tue Jan 31 21:43:19 1995 --- /VERSION Fri Feb 3 23:50:32 1995 *************** *** 1,4 **** ! Current Patch Level: 226 2.11 BSD ============ --- 1,4 ---- ! Current Patch Level: 228 2.11 BSD ============