Re: Hard links

2009-02-08 Thread Paul Schulz
Hi David,

On Mon, Feb 9, 2009 at 2:54 PM, David Ryder  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

-- 
ubuntu-au mailing list
ubuntu-au@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-au


Hard links

2009-02-08 Thread David Ryder
Hi,
I have not been able to find an explanation why:
1. hard links are not allowed for directories, and
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?

Many thanks to anybody who can tell me why or point me to unix
documentation explaining why - it is very elusive to find, methinks.

David


-- 
ubuntu-au mailing list
ubuntu-au@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-au