[techtalk] partitioning security (was lilo)

Andrew Wendt awendt at putergeek.com
Wed Jul 25 20:50:32 EST 2001


On July 25, 2001 20:22, Jenny Brown (was Gable) wrote:
> I can't give a real 'official' definition, but a hard link
> makes a copy of the file, where as a soft link (using -s) just
> points to the original.  Hard links result in an actual increase
> in disk space used.  I don't have much experience with them except
> by accidentally forgetting the -s option to ln, though; so I can't
> help much on their exact security effects.

Hard links just point to the original file also, so no extra disk space is 
used apart from the new directory entry. The difference is just the way they 
point to the file that they are a link of.

A soft link or a symlink points by filename, and a hard link points by inode 
number. That's the reason you can't hard link to a file on a different 
filesystem... each fs has its own set of inode numbers.

A good way to think of a file with a hard link is just "One file with two 
names". Files and file names are somewhat distinct in that files can have 
multiple names (via hard links) or even no names (all file names deleted but 
some process still has the file open).

That number after the permissions in the "ls -l" list is just the number of 
hard links to that file, or the number of file names it has.

Normal files start with 1 name, but directories will start with 2, one for 
"/home/bob/mydir" and one for "/home/bob/mydir/.". If you then make a 
directory "/home/bob/mydir/test" then the link count goes to 3, because the 
directory now has a new name "/home/bob/mydir/test/..".

This hard link stuff is the reason that the system call to delete a file is 
named unlink(). It gets rid of one of the hard links to the file, and if that 
happened to be the last hard link, also deletes the data in the file (which 
was shared between all the links).

TTFN
Andy




More information about the Techtalk mailing list