Mail Archives: djgpp-workers/1999/05/03/09:29:30
On Mon, 3 May 1999, DJ Delorie wrote:
> I was hoping for something like this:
>
> fd = open(...);
> if (fd == -1)
> {
> if (errno == ESHARE)
> open(...,SH_DENYNO)
> else if (errno == ENOFILE)
> _creat(...);
The first version I wrote went something like that; but then I got scared
of introducing new bugs, because we don't actually know what kind of
weirdo errno values we could get in every situation.
Take the sharing violation, for example. We'd probably get the
ubiquitous EACCES; but who's to say it will be *always* EACCES? Maybe
we will have something exotic like EXDEV or EIO? Furthermore, if we do
get EACCES, does that mean DENY-NONE is the right thing to do?
Even the simpler ENOENT case might have its pitfalls. If you remember,
we had some Novell client that reported ENOENT inside `_rename' even
though the file actually existed (so we now have a special case just for
that). If we call `_creat' whenever we get ENOENT, we risk nuking the
file's contents in such cases.
So I got cold feet (this is just a bugfix release, right?) and opted for
a safer way:
- if it's EMFILE/ENFILE, there's nothing else to do but fail;
- if `__file_exist' says the file doesn't exist, call `_creat';
- else try DENY-NONE, unless we already tried some share bits.
- Raw text -