X-Authentication-Warning: new-smtp1.ihug.com.au: Host p8-max51.syd.ihug.com.au [203.173.144.200] claimed to be acceleron Message-ID: <009e01c12709$bc3a70a0$0a02a8c0@acceleron> From: "Andrew Cottrell" To: "Eli Zaretskii" Cc: , References: <003001c12702$4df56430$0a02a8c0 AT acceleron> <4331-Fri17Aug2001131335+0300-eliz AT is DOT elta DOT co DOT il> Subject: Re: Fstat.c patch Date: Fri, 17 Aug 2001 20:45:29 +1000 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_009B_01C1275D.8CED7AA0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700 Reply-To: djgpp-workers AT delorie DOT com This is a multi-part message in MIME format. ------=_NextPart_000_009B_01C1275D.8CED7AA0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit > > The changes are: > > 1) Replace dos_mem_base with _dos_ds > > 2) Replace our_mem_base with _my_ds() > > 3) Change if clause for the 71a6 call to execute if LFN is enabled, don't > > care about DOS version anymore. > > This is okay, but please take the call to _my_ds out of the loop. > Instead, call it once, and then use the result in the loop body. I have have re-worked _my_ds() in the attached updated patch. Andrew ------=_NextPart_000_009B_01C1275D.8CED7AA0 Content-Type: application/octet-stream; name="fstat_17AUG2001_B.dif" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="fstat_17AUG2001_B.dif" *** fstatold.c Wed Aug 15 21:34:42 2001 --- fstat.c Fri Aug 17 20:43:38 2001 *************** *** 1,3 **** --- 1,4 ---- + /* Copyright (C) 2001 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */ *************** *** 139,147 **** * came with ``Undocumented DOS'', 1st edition. */ =20 - /* Selectors for conventional memory and our program's memory. */ - static unsigned short dos_mem_base, our_mem_base; -=20 /* Array of SFT entry sizes as function of DOS version. */ static size_t sft_size_list[] =3D {0, 0x28, 0x35, 0x3b}; =20 --- 140,145 ---- *************** *** 187,196 **** int sft_ptr_addr; unsigned short true_dos_version; =20 - /* Selectors for _farXXX() functions. */ - dos_mem_base =3D _dos_ds; - our_mem_base =3D _my_ds(); -=20 /* Each DOS program has a table of file handles which are used by * DOS open() call. This table holds, for each handle which is in * use, the index into the System File Tables' list which contains --- 185,190 ---- *************** *** 236,243 **** } =20 /* Segment and offset of start of SFT list. */ ! sft_start_off =3D _farpeekw(dos_mem_base, sft_ptr_addr); ! sft_start_seg =3D _farpeekw(dos_mem_base, sft_ptr_addr + 2); =20 return 1; } --- 230,237 ---- } =20 /* Segment and offset of start of SFT list. */ ! sft_start_off =3D _farpeekw(_dos_ds, sft_ptr_addr); ! sft_start_seg =3D _farpeekw(_dos_ds, sft_ptr_addr + 2); =20 return 1; } *************** *** 254,261 **** unsigned short sft_off; unsigned long htbl_addr; short sft_idx, retval; ! __dpmi_regs regs; =20 _djstat_fail_bits =3D fstat_init_bits; =20 /* Force initialization if we were restarted (emacs). */ --- 248,256 ---- unsigned short sft_off; unsigned long htbl_addr; short sft_idx, retval; ! unsigned short _my_ds_base =3D _my_ds(); =20 + __dpmi_regs regs; _djstat_fail_bits =3D fstat_init_bits; =20 /* Force initialization if we were restarted (emacs). */ *************** *** 284,298 **** if (fhandle < 0 || fhandle >=3D (_osmajor < 3 ? 20 ! : _farpeekw(dos_mem_base, psp_addr + 0x32))) return -1; =20 /* Linear address of the handle table. */ ! htbl_addr =3D MK_FOFF(_farpeekw(dos_mem_base, htbl_ptr_addr + 2), ! _farpeekw(dos_mem_base, htbl_ptr_addr)); =20 /* Index of the entry for our file handle in the SFT array. */ ! retval =3D sft_idx =3D _farpeekb(dos_mem_base, htbl_addr + fhandle); =20 if (sft_idx < 0) /* invalid file handle or bad handle table */ { --- 279,293 ---- if (fhandle < 0 || fhandle >=3D (_osmajor < 3 ? 20 ! : _farpeekw(_dos_ds, psp_addr + 0x32))) return -1; =20 /* Linear address of the handle table. */ ! htbl_addr =3D MK_FOFF(_farpeekw(_dos_ds, htbl_ptr_addr + 2), ! _farpeekw(_dos_ds, htbl_ptr_addr)); =20 /* Index of the entry for our file handle in the SFT array. */ ! retval =3D sft_idx =3D _farpeekb(_dos_ds, htbl_addr + fhandle); =20 if (sft_idx < 0) /* invalid file handle or bad handle table */ { *************** *** 316,330 **** while (sft_off !=3D 0xFFFF) { unsigned long entry_addr =3D sft_seg + sft_off; ! short subtable_len =3D _farpeekw(dos_mem_base, = entry_addr + 4); =20 if (sft_idx < subtable_len) { /* Our target is in this sub-table. Pull in the entire * SFT entry for use by fstat_assist(). */ ! movedata(dos_mem_base, entry_addr + 6 + sft_idx * sft_size, ! our_mem_base, (unsigned int)sft_buf, sft_size); return retval; } /* Our target not in this subtable. --- 311,325 ---- while (sft_off !=3D 0xFFFF) { unsigned long entry_addr =3D sft_seg + sft_off; ! short subtable_len =3D _farpeekw(_dos_ds, entry_addr + 4); =20 if (sft_idx < subtable_len) { /* Our target is in this sub-table. Pull in the entire * SFT entry for use by fstat_assist(). */ ! movedata(_dos_ds, entry_addr + 6 + sft_idx * sft_size, ! _my_ds_base, (unsigned int)sft_buf, sft_size); return retval; } /* Our target not in this subtable. *************** *** 332,339 **** * index of our entry, and proceed to next sub-table. */ sft_idx -=3D subtable_len; ! sft_off =3D _farpeekw(dos_mem_base, entry_addr); ! sft_seg =3D MK_FOFF(_farpeekw(dos_mem_base, entry_addr + 2), = 0); } =20 /* Get here only by error, which probably means unsupported DOS = version. */ --- 327,334 ---- * index of our entry, and proceed to next sub-table. */ sft_idx -=3D subtable_len; ! sft_off =3D _farpeekw(_dos_ds, entry_addr); ! sft_seg =3D MK_FOFF(_farpeekw(_dos_ds, entry_addr + 2), 0); } =20 /* Get here only by error, which probably means unsupported DOS = version. */ *************** *** 816,827 **** if (_djstat_flags & _STAT_ACCESS) _djstat_fail_bits |=3D _STFAIL_WRITEBIT; =20 ! /* If we run on Windows 9X, and LFN is enabled, try = harder. ! Note that we deliberately do NOT use this call when = LFN is ! disabled, even if we are on Windows 9X, because then = we ! open the file with function 3Ch, and such handles = aren't ! supported by 71A6h call we use here. */ ! if (dos_major >=3D 7 && _USE_LFN) { __dpmi_regs r; =20 --- 811,822 ---- if (_djstat_flags & _STAT_ACCESS) _djstat_fail_bits |=3D _STFAIL_WRITEBIT; =20 ! /* If we are runing on Windows 9X, NT 4.0 with LFN or 2000 or = XP ! with LFN is enabled, try harder. Note that we deliberately do=20 ! NOT use this call when LFN is disabled, even if we are on=20 ! Windows, because then we open the file with function 3Ch,=20 ! and such handles aren't supported by 71A6h call we use here. */ ! if (_USE_LFN) { __dpmi_regs r; =20 *************** *** 831,837 **** r.x.dx =3D 0; __dpmi_int(0x21, &r); if ((r.x.flags & 1) =3D=3D 0 ! && (_farpeekl(dos_mem_base, __tb) & 0x07) =3D=3D 0) stat_buf->st_mode |=3D WRITE_ACCESS; /* no R, S or H bits set = */ } =20 --- 826,832 ---- r.x.dx =3D 0; __dpmi_int(0x21, &r); if ((r.x.flags & 1) =3D=3D 0 ! && (_farpeekl(_dos_ds, __tb) & 0x07) =3D=3D 0) stat_buf->st_mode |=3D WRITE_ACCESS; /* no R, S or H bits set */ } =20 ------=_NextPart_000_009B_01C1275D.8CED7AA0--