Date: Thu, 25 Sep 1997 21:03:24 +1000 From: Bruce Evans <bde@zeta.org.au> To: arnej@math.ntnu.no, freebsd-bugs@hub.freebsd.org Subject: Re: bin/4585: termcap search fails too early Message-ID: <199709251103.VAA11673@godzilla.zeta.org.au>
next in thread | raw e-mail | index | archive | help
> > Why would it be wrong to make it continue only in the ENOENT and > > EACCES? Maybe ELOOP, too. Something like EMFILE or ENFILE should for > > sure be treated as an error in the first place. > > For simplicity, I think just continuing is best; if there's a > "permanent" error like EMFILE it will happen again on the next > file tried so the correct error code will get returned. On > Solaris open(2) lists 20 possible error codes, ... > > Of course, my immediate problem would be solved by just adding > EACCES, but I'd hate to leave even more rare instances of this > problem for later. (Like EISDIR or maybe ENXIO?) Especially since I'm trying to fix execvp() to do what sh should do according to POSIX.2. This has similar problems and one more: the search is usually optimized/ de-raced using execve() insted of open(), and the error codes for execve() are slightly different than for open(); in particular, execve() returns EACCES if there a path prefix is inaccessible or the file is non-executable, but according to POSIX.2, the search should terminate when a non-executable file is found, so these cases must be distinguished. I hope to distinguish them using stat() if execve() fails in an ambiguous way (including if it sets errno to an undocumented value). A similar method should be good for termcap: if open() fails with an ambiguous errno, then stat() the file, and continue searching unless the file exists but is inaccessible (non-readable). There is a race between the open() and the stat(). Too bad. It only affects the decision about continuing the search. Non-ambiguous errno's for open() include: ELOOP, ENAMETOOLONG, ENOENT, ENOTDIR (stat() would also fail unless there is a race); EMFILE, ENFILE (a subsequent open() would fail). Ambiguous errno's include: EACCES (the seach should continue if a path component is inaccessible, but not if the file exists and is unreadable). To optimized for simplicitly, treat all errno's as ambiguous. Bruce
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199709251103.VAA11673>