Mail Archives: djgpp-workers/1997/09/14/14:54:16
This causes fstat to use a DOS call to get to the PSP instead of accessing
the DJGPP stubinfo field (which might bring incorrect info under a
debugger).
diff -c src/libc/posix/sys/stat/fstat.c~7 src/libc/posix/sys/stat/fstat.c
*** src/libc/posix/sys/stat/fstat.c~7 Sun Aug 31 18:31:32 1997
--- src/libc/posix/sys/stat/fstat.c Fri Apr 4 18:41:40 1997
***************
*** 168,173 ****
--- 168,176 ----
restarted programs (emacs). */
static int fstat_count = -1;
+ /* The address of the PSP of the caller. */
+ static unsigned long psp_addr;
+
/* Initialization routine, called once per program run.
* Finds DOS version, SFT entry size and addresses of
* program handle table and first SFT sub-table.
***************
*** 197,204 ****
* calling INT 21h/AX=67h to enlarge the maximum number of file
* handles.
*/
! htbl_ptr_addr = (_go32_info_block.linear_address_of_original_psp & 0xfffff)
! + 0x34;
/*
* Find the pointer to the first subtable in the list of SFT's.
--- 200,206 ----
* calling INT 21h/AX=67h to enlarge the maximum number of file
* handles.
*/
! htbl_ptr_addr = psp_addr + 0x34;
/*
* Find the pointer to the first subtable in the list of SFT's.
***************
*** 247,252 ****
--- 249,255 ----
unsigned short sft_off;
unsigned long htbl_addr;
short sft_idx, retval;
+ __dpmi_regs regs;
_djstat_fail_bits = fstat_init_bits;
***************
*** 257,262 ****
--- 260,270 ----
dos_major = 0;
}
+ /* Find the PSP address of the current process. */
+ regs.h.ah = 0x62; /* Get PSP address */
+ __dpmi_int(0x21, ®s);
+ psp_addr = ( (unsigned long)regs.x.bx << 4 ) & 0xfffff;
+
/* If first time called, initialize. */
if (!dos_major && !fstat_init())
{
***************
*** 268,281 ****
* For DOS 3.x and later, the number of possible file handles
* is at offset 32h in the PSP; for prior versions, it is 20.
*/
! if (fhandle < 0 ||
! fhandle >=
! (_osmajor < 3 ?
! 20 :
! _farpeekw(dos_mem_base,
! (_go32_info_block.linear_address_of_original_psp & 0xfffff)
! + 0x32)))
! return -1;
/* Linear address of the handle table. */
htbl_addr = MK_FOFF(_farpeekw(dos_mem_base, htbl_ptr_addr + 2),
--- 276,286 ----
* For DOS 3.x and later, the number of possible file handles
* is at offset 32h in the PSP; for prior versions, it is 20.
*/
! if (fhandle < 0
! || fhandle >= (_osmajor < 3 ?
! 20
! : _farpeekw(dos_mem_base, psp_addr + 0x32)))
! return -1;
/* Linear address of the handle table. */
htbl_addr = MK_FOFF(_farpeekw(dos_mem_base, htbl_ptr_addr + 2),
- Raw text -