sys.c: in _dos_findfirst set DTA rather than copying from PSP:80h

Running prior to this commit, a /K switch with a name at a certain
position will write all-blanks into the boot sector loader. If that
happens, lDOS instsect will not detect a valid load file name:

C:\>sys a: /bootonly /k ldos.com
System transferred.

C:\>instsect /bo a:
Detected FAT12 FS.
Keeping original sector loader.
Sector valid, FS ID match and proper jump.
Type heuristic: "FreeDOS (FreeDOS)"
No name detected.
Unit selection code not found in sector. Keeping as is.
Part info code not found in sector. Keeping as is.
Query geometry code not found in sector. Keeping as is.
Auto LBA detection (HDD only) found in sector. Keeping as is.
Previous geometry: 2 CHS Heads, 18 CHS Sectors, 0 Hidden
Writing boot sector to sector.
C:\>

Running after this commit sets the name as desired:

C:\>sys a: /bootonly /k ldos.com
System transferred.

C:\>instsect /bo a:
Detected FAT12 FS.
Keeping original sector loader.
Sector valid, FS ID match and proper jump.
Type heuristic: "FreeDOS (FreeDOS)"
1st name: "LDOS.COM"
Unit selection code not found in sector. Keeping as is.
Part info code not found in sector. Keeping as is.
Query geometry code not found in sector. Keeping as is.
Auto LBA detection (HDD only) found in sector. Keeping as is.
Previous geometry: 2 CHS Heads, 18 CHS Sectors, 0 Hidden
Writing boot sector to sector.
C:\>

For reference, the libi86 implementation of _dos_findfirst also
sets the DTA to the user buffer rather than copying around the
resulting search record. So it is likely that Turbo C or Watcom
do it similarly to this:

3ecc416499/host-gcc/dos/dos-findfirst.c (L43)
This commit is contained in:
E. C. Masloch 2025-10-10 18:52:13 +02:00 committed by Kenneth J Davis
parent 383c05a3fd
commit 86db573347

View File

@ -197,13 +197,19 @@ int _dos_findfirst(const char *file_name, unsigned int attr,
struct find_t *find_tbuf) struct find_t *find_tbuf)
{ {
union REGS in, out; union REGS in, out;
struct SREGS sr;
in.h.ah = 0x1A; /* set DTA */
in.x.dx = FP_OFF(find_tbuf);
sr.ds = FP_SEG(find_tbuf);
intdosx(&in, &out, &sr);
in.h.ah = 0x4e; in.h.ah = 0x4e;
in.x.dx = FP_OFF(file_name); in.x.dx = FP_OFF(file_name);
in.x.cx = attr; in.x.cx = attr;
intdos(&in, &out); intdos(&in, &out);
if (out.x.cflag) if (out.x.cflag)
return out.x.ax; return out.x.ax;
memcpy(find_tbuf, (void *)0x80, sizeof(*find_tbuf)); /* memcpy(find_tbuf, (void *)0x80, sizeof(*find_tbuf)); */
/* did set DTA to find_tbuf prior */
return 0; return 0;
} }
#else #else