delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1997/02/17/04:22:01

Date: Mon, 17 Feb 1997 11:07:07 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Douglas Rupp <rupp AT gnat DOT com>
cc: djgpp-workers AT delorie DOT com, Charles Sandmann <sandmann AT clio DOT rice DOT edu>
Subject: Re: fstat returns garbage
In-Reply-To: <330734E7.4313C7C3@gnat.com>
Message-ID: <Pine.SUN.3.91.970217110616.17729B-100000@is>
MIME-Version: 1.0

> 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.


*** 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;
  
          }
  

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019