Hard links

David Ryder davaweb at bigpond.net.au
Mon Feb 9 22:06:49 GMT 2009


Hi Paul,
Thanks for replying.

>At a file system level, a directory contains a list of inodes, which
> then point to file data.
> A hardlink is a duplicate inode, which points to the same file data as
> another inode.
> ...
> Notes:
> [1] Oddly enough, I did actually manage to create what looked like a
> hard link to a directory in SunOS as the result of a 'fsck'.
> Unfortunately 'rm' didn't work. The OS error was something along the
> lines of.. "you can't remove this as hard linked directories don't
> exist'. I ended up just moving it out of the way...
Despite the reference you gave me (thanks, it is a good guide), on
mainframes (going back to the 70's [hey, I heard that:)] once the
target inode was to be deleted our Unix system on Univacs did do a (time
consuming) task of listing all other duplicates as a precaution of
programmers deleting inodes without knowing what they were affecting.
It also helped as we had two Univac 1100s in parallel and made
tracing/tracking the links a lot easier as well as repsairing file
structures.
>
> 
> Directories are not inodes, so can't be 'hard linked'. [1]
> Remembering back to 'the good old days' of Unix on mainframes
As you may have discovered (below), it was (then) possible to duplicate
inode entries for folders - they were used to make real-time exact
copies of the data.
I am not arguing with you - only explaining why I had confusion. In our
application this was a safeguard of the highest need.
I often struggle with linux because so much has changed since the good times!
>
>
>The underlying reason is that a softlink is a 'reference in a
> directory' to another 'directory entry'. When you delete a file or
> directory, the filesystem has no 'local' record of who else may be
> pointing to (referencing it). So, it stops there, rather than scanning
> the entire filesystem when you delete each file to look for possible
> floating softlinks.
Much like Microsoft then. I thought a table was kept in linux.

Is there a way to list broken symlinks?

Thanks for explaining it to me, I very much appreciate your help.

David

>On Mon, 2009-02-09 at 15:51 +1030, Paul Schulz wrote:
> Hi David,
> 
> On Mon, Feb 9, 2009 at 2:54 PM, David Ryder <davaweb at bigpond.net.au> wrote:
> > Hi,
> > I have not been able to find an explanation why:
> > 1. hard links are not allowed for directories, and
> 
> At a file system level, a directory contains a list of inodes, which
> then point to file data.
> A hardlink is a duplicate inode, which points to the same file data as
> another inode.
> 
> Directories are not inodes, so can't be 'hard linked'. [1]
> 
> > 2. soft links to directories are not automatically removed if the target
> > is deleted. The link to the directory remains and is obviously useless
> > so why doesn't 'nix delete them too?
> 
> Um.. good question. Same goes for softlinks to files.
> 
> The underlying reason is that a softlink is a 'reference in a
> directory' to another 'directory entry'. When you delete a file or
> directory, the filesystem has no 'local' record of who else may be
> pointing to (referencing it). So, it stops there, rather than scanning
> the entire filesystem when you delete each file to look for possible
> floating softlinks.
> 
> > Many thanks to anybody who can tell me why or point me to unix
> > documentation explaining why - it is very elusive to find, methinks.
> 
> The following might be useful.. see "The File System" section
> http://tldp.org/LDP/tlk/tlk.html
> 
> Notes:
> [1] Oddly enough, I did actually manage to create what looked like a
> hard link to a directory in SunOS as the result of a 'fsck'.
> Unfortunately 'rm' didn't work. The OS error was something along the
> lines of.. "you can't remove this as hard linked directories don't
> exist'. I ended up just moving it out of the way...
> 
> 
> > David
> 
> Paul




More information about the ubuntu-au mailing list