[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Symlinks vs. hardlinks [was: Prevent shutdown with systemctl]



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tue, Jan 05, 2016 at 09:19:57AM -0600, David Wright wrote:
> On Tue 05 Jan 2016 at 09:04:19 (+0100), tomas@tuxteam.de wrote:
> > On Mon, Jan 04, 2016 at 04:43:05PM -0500, Gary Dale wrote:
> > >          If that is a problem with symlinks, shouldn't it also be with
> > > hardlinks?
> > 
> > No, because of above:
> > 
> >   - symlink: permissions of linked-to file apply. Symlink has no "own"
> >     permissions. When linked-to file is removed, symlink is dangling.
> > 
> >   - hardlink: each has its own metadata (permissions, etc.). All hardlinks
> >     are equivalent. When last link to a file's data is removed, storage
> >     is recycled.
> 
> That could be interpreted ambiguously. To clarify, the metadata is
> stored in the inode, so all the hard links to a particular file/inode
> share the same information, thus:

You are too polite. What I wrote is plainly wrong on a second look.
Sorry. Yes, the metadata is in the inode and not in the directory
entry.

> 07:45 $ touch foo
> 07:45 $ ls -li [fb]*
> 488715 -rw-r----- 1 david david 0 Jan  5 07:45 foo
> 07:45 $ ln foo bar
> 07:55 $ ls -li [fb]*
> 488715 -rw-r----- 2 david david 0 Jan  5 07:45 bar
> 488715 -rw-r----- 2 david david 0 Jan  5 07:45 foo
> 07:55 $ chmod a+r bar
> 07:57 $ ls -li [fb]*
> 488715 -rw-r--r-- 2 david david 0 Jan  5 07:45 bar
> 488715 -rw-r--r-- 2 david david 0 Jan  5 07:45 foo
> 07:57 $ touch bar
> 07:57 $ ls -li [fb]*
> 488715 -rw-r--r-- 2 david david 0 Jan  5 07:57 bar
> 488715 -rw-r--r-- 2 david david 0 Jan  5 07:57 foo
> 07:57 $ ls -li [fb]*
> 488715 -rw-r--r-- 2 david david 0 Jan  5 07:57 bar
> 488715 -rw-r--r-- 2 david david 0 Jan  5 07:57 foo
> 07:58 $ 
> 
> # chown nobody /tmp/bar
> 
> 07:58 $ ls -li [fb]*
> 488715 -rw-r--r-- 2 nobody david 0 Jan  5 07:57 bar
> 488715 -rw-r--r-- 2 nobody david 0 Jan  5 07:57 foo
> 07:59 $ 
> 
> Each symlink has its own metadata in its inode, but most of it
> is ignored most of the time (eg ownership), or can't be changed
> (eg permissions).

Spot on. Thanks for the correction (and for your politeness :)

regards
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAlaL2TEACgkQBcgs9XrR2kY9KQCffkTMtTA1gt0qLt94NUM9subh
VBoAn195zfUGSv9DVwjFmZCstTQTKSRZ
=mjYZ
-----END PGP SIGNATURE-----


Reply to: