[CLUE-Tech] Re: Finding all hard links to a file

Robert Woods rfwoods at maxbr.com
Tue May 18 09:42:12 MDT 2004


At 08:29 AM 5/18/2004, you wrote:
>Angelo Bertolli wrote:
>>>
>>>File names are kept in directories (which, at least originally, were 
>>>files).  The directory tells you the file name and the file's inode. 
>>>They are the only way the two are connected and they are optimized for 
>>>looking up inodes given a name (not the other way round).
>>I see... another reason to add this feature to the slocate db.  But would 
>>it be useful?
>
>It wouldn't be useful to me, I've never asked myself "which file names 
>point to the same file".  Why do you ask that question?
>
>Dave

Interestingly enough, I just utilized this information to great advantage.

The /usr/share/terminfo directory structure uses hard links, several to one 
file. The utilities to compile and write/build these files make the hard links.

I believe, that before they write/build a link, they do a delete (rm). What 
happens is the subtracts 1 form the inode link count. If it goes to 0 the 
actual binary file is deleted. Then the new file is written.

The problem comes in that adding a new a terminfo source file can change 
existing ones in ways you do not want. For example:

If the original source definition looked like:
viewpoint|addsviewpoint|adds viewpoint,  ... etc

and the new one looked like:
viewpoint|ad|adds viewpoint,   ... etc

and yet a third one looked like:
vp|av|vwpt|viewpoint|Adds viewpoint, ... etc

When you run tic to compile these source files, each would cause the 
viewpoint file to be written and others, but they are not all the same 
list. It is very easy to confuse this directory in subtle ways that will 
cause you hours to debug.

Bob Woods

btw: the syntax of the lines above is such that each word separated by the 
| symbol is written to the terminfo directory up to the string between the 
last one and the first comma. That would be the name displayed by the index 
command 'toe'.
Related commands tput, tic, toe, infocmp (untic), tset, reset, infotocap, 
captoinfo

Reference Essential System Administration; Third Edition; AEleen Frisch; 
O'Reilly
Pages 48 - 51 She has an excellent diagram explaining this. 




More information about the clue-tech mailing list