*BSD News Article 5257


Return to BSD News archive

Newsgroups: comp.unix.bsd
Path: sserve!manuel!munnari.oz.au!spool.mu.edu!caen!hellgate.utah.edu!fcom.cc.utah.edu!cs.weber.edu!terry
From: terry@cs.weber.edu (A Wizard of Earth C)
Subject: Re: How can I print on my parallel printer?
Message-ID: <1992Sep18.191648.3920@fcom.cc.utah.edu>
Sender: news@fcom.cc.utah.edu
Organization: Weber State University  (Ogden, UT)
References: <BuB0yD.An3@ibmpcug.co.uk> <BuI1qF.H0r@obiwan.uucp> <527G02a722mv01@JUTS.ccc.amdahl.com>
Date: Fri, 18 Sep 92 19:16:48 GMT
Lines: 102

In article <527G02a722mv01@JUTS.ccc.amdahl.com> gpw10@phoenixcd.amdahl.com (Gary Ward) writes:
>In article <BuI1qF.H0r@obiwan.uucp>, bob@obiwan.uucp (Bob Willcox) writes:
>> In article <BuB0yD.An3@ibmpcug.co.uk> adrian@ibmpcug.co.uk (Adrian
>> Hall) writes:
>> >You need to make the /dev/lp and /dev/lpt1 nodes.
>> >
>> >	mknod /dev/lpt1 c 15 64
>> >	ln -s /dev/lpt1 /dev/lp
>> 
>> Coming from a mostly System V world (prior to Vr4) I feel like I must
>> be
>> missing something here (i.e., I have little experience with symbolic
>> links).  My question is why would one want to use a symbolic link (as
>> indicated) in the above situation rather than simply a hard link?  Is
>> there some problem with hard links in this situation?  Seems to me
>> that
>> a symbolic link here simply requires an extra inode, some additional
>> disk space, and slows down access to the /dev/lpt1 device.  What am I
>> missing???
>> 
>I myself did use a hard link here.  I believe that many "BSD-ers" just
>get into the habit of always typing "ln -s" since that always works, and
>hard links only work on the same file system.  The symbolic link will
>use a little bit of disk space and be slower than a hard link, but if it
>uses any more inodes than the hard link does, then *I* am missing
>something...


You are missing something.  The way a symbolic link is defined is as
sufficient data blocks hung off the link associated with the inode to
describe the path to the linked-to object.  This is eiter 1 or two
blocks, since blocks are 512 bytes and the path can be from 1 to 1024
characters.

A hard link:

Directory 1				  Directory 2 (on same device)
,--------------------.                    ,-------------------.
|  ... |1035| ...    |			  |  ... |1035| ...   |
`--------------------'			  `-------------------'
	|					   |
	|					   |
	+----------------------+ +-----------------+
			       | |
			       v v
			,------------.
			| inode 1035 |
			`------------'
			      |
			      v
			,------------.
			| File data  |
			`------------'

A symbolic link:
Directory 1				  Directory 2 (on any device)
,--------------------.                    ,-------------------.
|  ... |1075| ...    |			  |  ... |1035| ...   |
`--------------------'			  `-------------------'
	|					   |
	|					   |
	+------------+                        +----+
		     |                        |
		     v                        v
		,------------.		,------------.
		| inode 1075 |		| inode 1035 |
		`------------'		`------------'
		     |			      |
		     v			      v
		,------------.		,------------.
		| File data  |		| File data  |
		`------------'		`------------'
Contains path (relative or absolute)
to directory entry in directory 2.


When the look up in directory 1 decides that the file is a symbolic link
(based on a flag in the inode), the data block(s) pointed to by the inodee
contain the information to look up the inode that contains the actual data.

Thus a sybolic link takes an additional inode (to point to the link data)
and one or two data blocks (containing the link data itself).  A hard link
consists of an additional directory entry pointing to the same inode, and
an increment of the "reference count" for a particular inode.

If you "ls -li" two files that are linked symbolically and two files that
are linked phisically, the actual inode number and reference count become
apparent.



					Terry Lambert
					terry_lambert@gateway.novell.com
					terry@icarus.weber.edu
---
Any opinions in this posting are my own and not those of my present
or previous employers.
-- 
-------------------------------------------------------------------------------
                                        "I have an 8 user poetic license" - me
 Get the 386bsd FAQ from agate.berkeley.edu:/pub/386BSD/386bsd-0.1/unofficial
-------------------------------------------------------------------------------