PREV INDEX NEXT

Author: Stan Eisenstat
Subject: Re: [Cs323] stat() fails = do lstat()?
Date: Wednesday, 16 Sep 2020, 17:27:32


    > Message Posted By: Unknown
    >
    > how is fiend expected to respond to the different errno numbers when stat
    > fails?

Only ELOOP is of concern.
=====

    > if stat() fails, do we always check lstat()? ...

No.  For example,

  % fiend nonexistent-file
=====

    >                                         ...  I am specifically looking at
    > the Tango file in the Root file. I notice that for this file, I get an
    > error with stat() but not lstat() ...

tango is a symbolic link to a file that does not exist.
stat() failss since the file that tango links to does
not exist; lstat() succeeds because tango does exist.
=====

    >                               ... but it seems like the
    > /c/cs323/Hwk1/fiend does not throw an error regardless of whether it is a
    > -L or -P tag.

As stated in the man page for find:

  -L Follow symbolic links.  When find examines or prints information about
     files, the information used shall be taken from the properties of the
     file to which the link points, not from the link itself (unless it is a
     broken symbolic link or find is unable to examine the file to which the
     link points).  ...

which explains the behavior with -L.

--Stan-
PREV INDEX NEXT