This is the mail archive of the libc-hacker@sourceware.cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: several changes today


Roland McGrath <roland@frob.com> writes:

> 1003.1-1996 requires that opendir detect a nondirectory and return ENOTDIR.
> It is not optional.  Unless the check is known for sure to be done by the
> kernel at the particular time, libc must check with fstat to be correct.
> As well as violating POSIX, allowing the possibility of failing to check 
> would be a subtly incompatible change that might affect existing programs
> in obscure ways.

Roland, did you took a look at the code?  There still is a stat, but
it is before the open.  This stat is necessary since otherwise you
could open, say, /dev/st0, and rewind a tape or so.

What is left out in the case when O_DIRECTORY is defined is the second
fstat call, right after the open.  Note, it is still there for systems
which don't provide O_DIRECTORY but I've removed it otherwise since it
is in any case no real solution.  If somebody can replace the
directory tested with the initial stat() call with something which is
no directory in the time between the stat and the open, s/he can as
well replace it with a symlink to /dev/st0 or so.  Therefore the only
100% solution is to not let the kernel open something which is no
directory and then the second fstat is not necessary.

-- 
---------------.      drepper at gnu.org  ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Cygnus Solutions `--' drepper at cygnus.com   `------------------------


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]