Re: [busybox/utility.c:recursiveAction] ? - followLinks, stat, lstat
On Mon Jan 24, 2000 at 02:57:03AM -0800, Karl M. Hegbloom wrote:
>
> Tell me if I'm wrong... but:
>
> 8<------------------------------------------------------------>8
> if (followLinks == TRUE)
> status = stat (fileName, &statbuf);
> else
> status = lstat (fileName, &statbuf);
>
> /* ####? -karlheg status = lstat (fileName, &statbuf); */
> 8<------------------------------------------------------------>8
You seem to imply that this code fragment snipped from busybox
recursiveAction is incorrect. From the stat(2) manpage:
stat stats the file pointed to by file_name and fills in
buf.
lstat is identical to stat, only the link itself is stat
ted, not the file that is obtained by tracing the links.
So when following symlinks, it is necessary to use stat. For example
if ./foo is a symlink to ./bar, and we want to follow the symlink
from ./foo to ./bar, stat dereferences the symlink, and returns the
stat information for whatever ./bar is.
To _not_ follow symlinks, it is necessary to use lstat.
What exactly is it you needed to know was wrong? This looks
perfectly correct to me,
-Erik
--
Erik B. Andersen Web: http://www.xmission.com/~andersen/
email: andersee@debian.org
--This message was written using 73% post-consumer electrons--
Reply to: