From owner-freebsd-bugs Thu Sep 25 04:14:03 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id EAA11437 for bugs-outgoing; Thu, 25 Sep 1997 04:14:03 -0700 (PDT) Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.2.228.19]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id EAA11432 for ; Thu, 25 Sep 1997 04:13:56 -0700 (PDT) Received: (from bde@localhost) by godzilla.zeta.org.au (8.8.5/8.6.9) id VAA11673; Thu, 25 Sep 1997 21:03:24 +1000 Date: Thu, 25 Sep 1997 21:03:24 +1000 From: Bruce Evans Message-Id: <199709251103.VAA11673@godzilla.zeta.org.au> To: arnej@math.ntnu.no, freebsd-bugs@hub.freebsd.org Subject: Re: bin/4585: termcap search fails too early Sender: owner-freebsd-bugs@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk > > 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