Mail Archives: djgpp/2016/05/12/02:10:48
> From: "Wiktor S. (wswiktorSP AT Mpoczta DOT fm) [via djgpp AT delorie DOT com]" <djgpp AT delorie DOT com>
> Date: Wed, 11 May 2016 23:53:20 +0200
>
> > Can you debug the libc functions involved and see which one of them
> > fails?
>
> fopen() fails because open() fails because _open() fails.
>
> I haven't yet determined why. I have two theories.
> One is this (abbreviated) logic in open.c:
>
> fd = _open(real_name, oflag);
>
> /* Under multi-taskers, such as Windows, our file might be
> open by some other program with DENY-NONE sharing bit,
> which fails the `_open' call above. Try again with
> DENY-NONE bit set, unless some sharing bits were already
> set in the initial call. */
>
> if (fd == -1)
> fd = _open(real_name, oflag | SH_DENYNO);
>
> Both calls to _open() fail. So maybe there is a problem with access flags.
If we have problems with 'oflag' passed to '_open', this problem
probably cannot be solved at all, or at least not easily. So I
suggest to explore the other possibilities first.
> Another possibility is _open function itself. It contains convoluted logic
> of OS version checking, detecting LFN, falling back to SFN, then falling
> back to LFN again...
> Perhaps some assumptions are no longer true on exFAT and Windows 10.
That logic is as follows:
. If we are on NT family of Windows (which is your case), then:
. Produce the short 8+3 alias (SFN) of the long file name (LFN)
. If producing SFN succeeded, then:
. Open the file by its SFN
. Otherwise get file's attributes by its LFN
. If getting file's attributes succeeds, try opening by LFN, but
using the SFN variant of DOS OPEN function
. Otherwise, fail
So I think some of this logic doesn't work with exFat volumes, the
question is which one? E.g., I'm not sure exFAT support SFN as we
expect.
Thanks.
- Raw text -