delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/05/26/03:26:11

To: Eric Backus <ericb AT lsid DOT hp DOT com>
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Re: Library problems
Date: Thu, 26 May 94 09:49:41 +0300
From: eliz AT is DOT elta DOT co DOT il

I wrote:
>> 4) stat() and fstat() return inconsistent results for the same file.
>>     The st_blksize field is reported as 4096 (correct) by fstat(),
>>     but stat() returns 512 (incorrect) in it.  stat() returns a
>>     unique value for each file in the st_ino field, whereas fstat()
>>     always returns 0 there.

You wrote:

> One way to make fstat() and stat() consistant would be to have fstat()
> call stat().

This is not necessary in the case in point.  The blocksize returned by
stat() is just incorrectly assigned (in exphdlr.c) a value of 512.  The
st_ino value does require the pathname of the file, though, because it returns
its hash value in the st_ino field, but that is a design decision.  You could
return e.g. the number of the file's first cluster instead.  If you do want to
stay with the current design, you need the filename, which brings us to:

> There must be some way to ask DOS for the pathname
> associated with the file pointer that fstat() gets, but I'm not a DOS
> expert so I don't know how to do that.

There is no *documented* way to do this, as far as I know.  ``Undocumented DOS''
book describes at least one *undocumented* way, using the file table in the
PSP (program segment prefix) of the program.

	Eli Zaretskii

- Raw text -


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