Mail Archives: djgpp-workers/2018/05/19/14:05:45
OFYI, I have commited the patch below.
The bottom line of all this is that for the operating systems
inspected by me, if the OS does not create a SFN alias then
the only valid LFN is a SFN. A SFN has to be understood as
a valid MSDOS file name.
Regards,
Juan M. Guerrero
Index: djgpp/src/docs/kb/wc206.txi
===================================================================
RCS file: /cvs/djgpp/djgpp/src/docs/kb/wc206.txi,v
retrieving revision 1.11
diff -p -U 5 -r1.11 wc206.txi
--- djgpp/src/docs/kb/wc206.txi 2 Feb 2018 20:00:05 -0000 1.11
+++ djgpp/src/docs/kb/wc206.txi 19 May 2018 14:26:09 -0000
@@ -53,5 +53,10 @@ The low-level @code{_put_path} procedure
[/\\]dev[/\\] instead of only /dev/ in file names.
@cindex Compatibility with new gcc versions
Compatibility with gcc-6 and newer versions achieved by using proper
@option{-fno-builtin-*} compiler flags where needed in library builds.
+
+@findex open AT r{, and failure on file systems without SFN alias}
+@code{open} will no longer fail when trying to open a file that has no
+short file name alias. This used to happen for the NTFS and the exFAT
+file systems.
Index: djgpp/src/libc/dos/io/_open.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/dos/io/_open.c,v
retrieving revision 1.12
diff -p -U 5 -r1.12 _open.c
--- djgpp/src/libc/dos/io/_open.c 12 Mar 2014 22:58:31 -0000 1.12
+++ djgpp/src/libc/dos/io/_open.c 19 May 2018 14:26:09 -0000
@@ -1,13 +1,15 @@
+/* Copyright (C) 2018 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 2014 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 2011 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 2001 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <libc/stubs.h>
#include <stdarg.h>
+#include <stdbool.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <go32.h>
#include <dpmi.h>
@@ -21,10 +23,11 @@ int
_open(const char* filename, int oflag)
{
__dpmi_regs r;
int rv;
int use_lfn = _USE_LFN;
+ bool retry_with_lfn = false;
if (filename == 0)
{
errno = EINVAL;
return -1;
@@ -48,10 +51,11 @@ _open(const char* filename, int oflag)
r.x.es = __tb_segment;
r.x.di = __tb_offset + _put_path(filename); /* Short name destination */
__dpmi_int(0x21, &r);
if (!(r.x.flags & 1)) /* Get short name success */
{
+ retry_with_lfn = true;
r.x.ax = 0x6c00;
r.x.bx = (oflag & 0xff);
r.x.dx = 1; /* Open existing file */
r.x.si = r.x.di;
goto do_open;
@@ -81,10 +85,11 @@ _open(const char* filename, int oflag)
Permission? Readonly file? We should quit.
Let it fall through to the LFN open which should succeed. */
}
}
}
+fallback:
if (use_lfn)
{
r.x.flags = 1; /* Always set CF before calling a 0x71NN function. */
r.x.ax = 0x716c;
r.x.bx = (oflag & 0xff);
@@ -134,10 +139,19 @@ do_open:
r.x.dx = __tb_offset;
goto do_open;
}
else if (r.x.flags & 1)
{
+ if ((r.x.ax == 2 || r.x.ax == 3) && retry_with_lfn)
+ {
+ /* On partitions like NTFS and exFAT, files and paths with long names
+ do not have 8.3 aliases. If an attempt to open the file with short
+ name failed with "file not found" or "path not found", retry with
+ the LFN API. */
+ retry_with_lfn = false;
+ goto fallback;
+ }
errno = __doserr_to_errno(r.x.ax);
return -1;
}
do_hset:
__file_handle_set(r.x.ax, O_BINARY);
- Raw text -