From: dnichols@d-and-d.com (DoN. Nichols)
Subject: Re: link vs ln on the 3b1: what gives?
Organization: D and D Data, Vienna VA
Date: Sat, 23 Jan 1993 20:58:36 GMT

In article <96804@rphroy.ph.gmr.com> tkacik@hobbes.hobbes.cs.gmr.com writes:
>In article 18394@colorado.edu, wouk@alumni.cs.colorado.edu (Arthur Wouk writes:
>> ln -s does not work.
>
>The -s is to create soft links.  Soft links are a BSD addition, and do not
>exist on the 3b1, (or any other SYS5 Unix, unless they were added by the vendor).

	Soft links are also known as symbolic links.  I believe that they
are among the BSD-isms which were incorporated into SysVr4, but we can't get
that for our machine, either.

>> ln a b just creates two copies of the same file with different names.
>
>ln does not create a second copy of the file.  It gives the single file a second
>name.  If after doing 'ln a b', you change the contents of b, you will see that
>a has also changes.

	Also, if you use 'ls -l', you see the count of the number of links to
a file immediately to the right of the modes e.g.:

-rw-r--r--  2 root    root       6960 Apr 26  1992 libndir.a
-rw-rw-rw-  1 bin     bin       76950 Jul 27  1991 libnet.a
-rw-r--r--  1 bin     bin        9074 Jul 27  1991 libplot.a
-rw-r--r--  1 bin     bin       44660 Jul 26  1992 libresolv.a
-rw-r--r--  1 root    root       9266 Feb  8  1992 libsyslog.a
-rw-r--r--  1 bin     bin      127294 Jul 27  1991 libtam.a
-rw-r--r--  2 bin     bin      127248 Jul 27  1991 libtam.a.OLD
-rw-r--r--  2 bin     bin        5002 Jul 27  1991 libtermcap.a
-rw-r--r--  2 bin     bin        5002 Jul 27  1991 libtermlib.a
            ^
            |
            +-- These are the link counts.

	If you add an 'i', so that it is 'ls -li', you also get the inode
associated with the file, so you can *see* for sure which are the same, e.g.:

 1414 -rw-r--r--  1 bin     bin      127294 Jul 27  1991 libtam.a
 1098 -rw-r--r--  2 bin     bin      127248 Jul 27  1991 libtam.a.OLD
 1099 -rw-r--r--  2 bin     bin        5002 Jul 27  1991 libtermcap.a
 1099 -rw-r--r--  2 bin     bin        5002 Jul 27  1991 libtermlib.a
 3311 -rw-r--r--  1 bin     bin        4780 Apr 26  1992 libtomb.a

where libtam.a.OLD, libtermcap.a and libtermlib.a *all* have two links (so
they can't all be the same file, only two of them.  The fact that both
libtermcap.a and libtermlib.a both use inode 1099 is proof that they are the
same, as long as they are on the same disk partition.  (Hard links can't
cross disk partitions, because they are simply two directory entries
pointing to the same inode.  In case you didn't know, the directory entry
only contains the filename and the inode number, everything else is stored
in the inode.  With hard links, everytime a link is deleted, the link count
in the inode is decremented, and the file only vanishes from the disk when
the link count goes to zero, *and* the last process that has it open closes
it.

	A symbolic link requires the expandable directory slot (the SysV one
always occupies 16 bytes, 2 for the inode, and 14 for the name.  In BSD
systems, a filename can expand up to 255 bytes.  In the case of a symbolic
link, the directory entry contains information saying "I really mean *this*
path (which follows in the directory data space).  I don't know whether the
fact of a symbolic link is flagged by an illegal inode number (such as 0),
or by information in the inode.  I think the latter, and I think that the
actual path to the file may be held in the inode if necessary.

>> is this a bug or a feature?:-)
>
>That is the way the SYS5 version of ln has always worked, so I guess that
>it's a feature.

	Or at least earlier versions of Sys5.  As I mentioned above, I think
that the symlink is present in SysVr4.

>> this is a very unsatisfactory state of affairs. how do we create soft
>> links on the 3b1?
>
>The only way to get soft links is to get a different machine, as they do not
>exist on the 3b1.

	Well, we *could* re-start the "How do I port BSD to the 3B1?" -
"Can't" - "Can too" - "Where will you find enough memory to hold the kernel?"
debates. :-)

	If you can't live without symlinks, then you have several choices.
Two of them are:
1)	Move to BSD486 with new hardware - OS is free, hardware is new and
	relatively expensive.
2)	Get an older workstation running a BSD variant.  I have several Suns
	here (2/120, 3/140, 3/60, and SPARC 4/60 clone).  The 3/140 cost
	less than my first 3B1 (really a 7300), considering that the Sun
	came with the development system, 141MB hard drive, and 60MB tape
	backup unit.  The general philosophy with Suns is:  "If you have the
	hardware, you have a license to run the OS", so it is possible to
	upgrade by borrowing the distribution media from someone who already
	has it.  I believe that the price charged by Sun is nominally for the
	distribution media, not the SunOs.  (This is all changing with the
	move to Solaris 2.?, which is a Sys5r4 merged with most of Suns
	BSD-based add-ons.  I haven't had a chance to use it at work yet, so
	I don't know too much about it, but I do know that the development
	system is no longer bundled once you hit Solaris 2.? (also known as
	SunOs 5.?)).

	Good Luck
		DoN.
-- 
 Email:   <dnichols@d-and-d.com>  |  ...!uunet!ceilidh!dnichols 
		 <dnichols@ceilidh.beartrack.com>
 Donald Nichols (DoN.)  |   Voice (Days): (703) 704-2280 (Eves): (703) 938-4564
	--- Black Holes are where God is dividing by zero ---