Sender: RUPP AT gnat DOT com Message-ID: <3308340A.24EA98BE@gnat.com> Date: Mon, 17 Feb 1997 10:33:46 +0000 From: Douglas Rupp Organization: Ada Core Technologies MIME-Version: 1.0 To: Eli Zaretskii CC: djgpp-workers AT delorie DOT com, Charles Sandmann Subject: Re: fstat returns garbage References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Eli Zaretskii wrote: > > > Filelength is returning the right size, but since the "is device" flag > > bit is set, it never makes it into the st_size field. Just putting the > > size into the st_size field won't fix it though, because my code checks > > to see if it's a regular file before returning the size. > > > > I'm guessing that the field from which fstat determines if the handle is > > a device or not has been changed on NT. > > NT doesn't support the internal DOS structure (the System File Table, > or SFT) at all, but the code in `fstat' that checks for this has a bug > in case the device bit seems to be set (which is probably random, > since `fstat' is looking at a portion of memory without any meaningful > content). > > Please try the following simple patch to `fstat' (later I will correct > this in a more thorough way). Thanks for debugging this. I recommend that we also set drv_no and is_remote to zero on NT, since they come from the same words of memory. I tested this and it fixes the problem. > > *** src/libc/posix/sys/stat/fstat.c~ Mon Feb 17 09:50:10 1997 > --- src/libc/posix/sys/stat/fstat.c Mon Feb 17 09:58:06 1997 > *************** > *** 455,461 **** > default: /* DOS 4 and up */ > fattr_ofs = 4; > drv_no = sft_buf[5] & 0x3f; > - is_dev = sft_buf[5] & 0x80; > is_remote = sft_buf[6] & 0x80; > clust_ofs = 0x0b; > ftime_ofs = 0x0d; > --- 455,460 ---- > *************** > *** 463,468 **** > --- 462,471 ---- > fsize_ofs = 0x11; > name_ofs = 0x20; > ext_ofs = 0x28; > + if (dos_major == 5 && dos_minor == 50) /* NT */ > + is_dev = 0; > + else > + is_dev = sft_buf[5] & 0x80; > > } >