Re: How does chown(2) works with symlinks?

Zefram (A.Main@dcs.warwick.ac.uk)
Mon, 8 Jul 1996 10:46:59 +0100 (BST)


>The chown(2) syscall should follow the link(s). The OS provides another
>call, lchown(2), for operating directly on a symlink (some also
>provide a lchmod(2), such as SCO's OpenServer). There is also a
>lstat(2).

That does make some sense if one is starting from scratch, but we are
talking about Unix here. lchown(2) generally isn't available.
Consequently, if you want chown(1) -R to do something useful, chown(2)
can't follow the link. Like Linus said, use open(2) and fchown(2) if
you want that behaviour -- that's the portable way to do it.

-zefram