Subject: Re: sysv ps(1) implementation [was: ps(1) sysv silliness]
To: None <tech-userlevel@netbsd.org>
From: Greg A. Woods <woods@weird.com>
List: tech-userlevel
Date: 06/08/2000 18:04:44
[ On Thursday, June 8, 2000 at 13:07:01 (-0700), Greywolf wrote: ]
> Subject: Re: sysv ps(1) implementation [was: ps(1) sysv silliness]
>
> [historical note:  mv/cp/ln/rm (I forget which three of them) were
>  hard links at one point; and I seem to remember (erroneously) perhaps
>  mkdir being linked to mknod (prior to mkdir(2) being implemented...)]

[historical details: ]

$ cd /archive/v5/root/usr/source
$ ls -l */cp.c */ln.c */mkdir.s */mknod.c */mv.c */rm.c
-rw-r--r--  1 woods  staff  1332 Nov 26  1974 s1/cp.c
-rw-r--r--  1 woods  staff   686 Nov 26  1974 s1/ln.c
-rw-r--r--  1 woods  staff  1088 Nov 26  1974 s2/mkdir.s
-rw-r--r--  1 woods  staff   563 Nov 26  1974 s2/mknod.c
-rw-r--r--  1 woods  staff  2982 Nov 26  1974 s2/mv.c
-rw-r--r--  1 woods  staff  1456 Nov 26  1974 s2/rm.c
$ cd /archive/v6/root/usr/source
$ ls -l */cp.c */ln.c */mkdir.s */mknod.c */mv.c */rm.c
-rw-r--r--  1 woods  staff  1063 May 13  1975 s1/cp.c
-rw-r--r--  1 woods  staff   686 May 13  1975 s1/ln.c
-rw-r--r--  1 woods  staff  1088 May 13  1975 s2/mkdir.s
-rw-r--r--  1 woods  staff   563 May 13  1975 s2/mknod.c
-rw-r--r--  1 woods  staff  2996 May 13  1975 s2/mv.c
-rw-r--r--  1 woods  staff  1483 May 13  1975 s2/rm.c
$ cd /archive/v7/root/usr/src/cmd
$ ls -l cp.c ln.c mkdir.c mknod.c mv.c rm.c 
-rw-r--r--  1 woods  staff  1674 Jan 10  1979 cp.c
-rw-r--r--  1 woods  staff   980 Jan 10  1979 ln.c
-rw-r--r--  1 woods  staff  1221 Jan 10  1979 mkdir.c
-rw-r--r--  1 woods  staff   562 Jan 10  1979 mknod.c
-rw-r--r--  1 woods  staff  6296 Jan 10  1979 mv.c
-rw-r--r--  1 woods  staff  2569 Jan 10  1979 rm.c
$ cd /archive/32V/root/usr/src/cmd
[342] $ ls -l cp.c ln.c mkdir.c mknod.c mv.c rm.c        
-rw-r--r--  1 woods  staff  1674 Nov  5  1978 cp.c
-rw-r--r--  1 woods  staff   980 Jan 19  1979 ln.c
-rw-r--r--  1 woods  staff  1221 Jan 19  1979 mkdir.c
-rw-r--r--  1 woods  staff   562 Nov  5  1978 mknod.c
-rw-r--r--  1 woods  staff  6296 Jan 19  1979 mv.c
-rw-r--r--  1 woods  staff  2569 Dec 10  1978 rm.c
$ cd /archive/sysIII/root/usr/src/cmd
$ ls -l cp.c ln.c mkdir.c mknod.c mv.c rm.c           
ls: cp.c: No such file or directory
ls: ln.c: No such file or directory
-rw-r--r--  1 woods  staff  1224 Apr 11  1980 mkdir.c
-rw-r--r--  1 woods  staff  1054 Apr 11  1980 mknod.c
-rw-r--r--  1 woods  staff  4985 Apr 11  1980 mv.c
-rw-r--r--  1 woods  staff  2422 Apr 11  1980 rm.c

and in sysIII's mv.c we find:

/*
** Combined mv/cp/ln command:
**      mv file1 file2
**      mv dir1 dir2
**      mv file1 ... filen dir1
*/
[[....]]
	if (!EQ(cmd, "cp") && !EQ(cmd, "mv") && !EQ(cmd, "ln")) {
		fprintf(stderr, "%s: command must be named cp|mv|ln--defaults to `cp'\n", cmd);
		cmd = "cp";
	}

So you can blame it all on the AT&T USG group....   ;-)

(I think they were all separate in 4.2BSD too, but I've only the
AT&T-free 4.3 distributions online at the moment.)

Note how small those programs are too!  ;-)  And note that V7 had more
error checking in mv.c than sysIII.

> In the above cases, it makes a LOT of sense to have the hooks
> in a single binary, otherwise code is duplicated, space is wasted,
> cache is lost (if you think cache isn't important, you have never had
> to run a shell script which did a lot of chown/chgrp and other linked-
> binary stuff on a BIG tree or a lot of files, and you had the script
> handy but no time to write another one).

There are at least two kinds of code sharing and I really do not like
the one you describe above where everything is linked together.  If I
wanted that then I'd run some big monolithic system (like Multics! ;-).

Shared libraries are bad enough but shared static binaries are horrid
hacks suitable only for extreme situations like the boot floppy or
embedded systems!

-- 
							Greg A. Woods

+1 416 218-0098      VE3TCP      <gwoods@acm.org>      <robohack!woods>
Planix, Inc. <woods@planix.com>; Secrets of the Weird <woods@weird.com>