[NTLUG:Discuss] symbolic links

Kenneth Loafman ken at lt.com
Wed Apr 16 12:43:17 CDT 2003


Eric Schnoebelen wrote:
> Kenneth Loafman writes:
> - Hard links cannot remain by themselves if the filesystem is operating 
> - properly.  The hard link is literally another name for the file and 
> - every operation on the hard link, remove included, is done to the file, 
> - and to its original directory entry.
> 
> 	?original directory entry?  Which one is that?

Sorry, shorthand.  Yes, the directory entries point to inodes, and the 
hard links are just pointers to the same inodes.  Instead of directory 
entries, I was thinking back to the user that wanted the timestamp on 
symbolic links to be the same as the target file.  With hard links you 
get that, the directory entry for the original file is the same as the 
directory entry for the hard link in the directory listing.

Thus, if you touch a file, you also touch its hard link, both in the 
inode on the filesystem, and in directory entry listings (ls -l).

One thing we were both wrong about... you can delete the original file 
and the hard link will keep the file inode active.  The following was 
run under Linux 2.4.18:

ken at crunch:/tmp/test$ cat > foo
test
ken at crunch:/tmp/test$ ll
total 4
-rw-rw-r--    1 ken      www-data        5 Apr 16 12:38 foo
ken at crunch:/tmp/test$ ln foo fee
ken at crunch:/tmp/test$ ll
total 8
-rw-rw-r--    2 ken      www-data        5 Apr 16 12:38 fee
-rw-rw-r--    2 ken      www-data        5 Apr 16 12:38 foo
ken at crunch:/tmp/test$ ln foo bar
ken at crunch:/tmp/test$ ll
total 12
-rw-rw-r--    3 ken      www-data        5 Apr 16 12:38 bar
-rw-rw-r--    3 ken      www-data        5 Apr 16 12:38 fee
-rw-rw-r--    3 ken      www-data        5 Apr 16 12:38 foo
ken at crunch:/tmp/test$ rm foo
ken at crunch:/tmp/test$ ll
total 8
-rw-rw-r--    2 ken      www-data        5 Apr 16 12:38 bar
-rw-rw-r--    2 ken      www-data        5 Apr 16 12:38 fee
ken at crunch:/tmp/test$ cat bar
test
ken at crunch:/tmp/test$ cat fee
test

...Ken





More information about the Discuss mailing list