Carlos, On Sunday 10 April 2005 15:40, Carlos E. R. wrote:
The Wednesday 2005-04-06 at 13:54 +0200, Roland Kuhn wrote:
Ah, I see. So it is not easy as well to know if a file somewhere is hardlinked somewhere else, except by comparing all inode entries in all directory lists from the same partition/disk.
No, there's also the link count (see man 3 stat, struct stat->st_nlink), which is displayed e.g. by ls -l.
Ah, I see, I hadn't noticed. Except for directories, it must mean something else. I don't see it in "man ls".
It's not that it means something different, but the range of observed values of the link count is somewhat constrained relative to that for other file system entities. Because of the "." and ".." links and because of the link in the parent directory that gives each directory inode its name, directories always have an inode count of 2 + the number of subdirectories the directory contains. Non-directory file system entities have values greater than or equal to zero. They can only be observed to have count zero when they're being held open or are otherwise in use by some process but have had all their referring directory entries removed (via the "unlink" system call). The fact that a file can be in this sense anonymous (have no directory entry referring to it) but still exist and exist precisely as long as it remains in use by at least one process is the fundamental reason why you can do so much software updating on Linux or Unix systems without having to restart the system. In essence both the old and the new versions of a resource can coexist and the old resource will be reclaimed when the last active use of it concludes.
...
-- Cheers, Carlos Robinson
Randall Schulz