www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/06/01/11:24:17

To: dj AT ctron DOT com (DJ Delorie)
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Re: Better stat(); was: Library problems
Date: Wed, 01 Jun 94 18:08:05 +0300
From: eliz AT is DOT elta DOT co DOT il

>> Nope.  Getting this is a non-trivial exercise in undocumented DOS.  It
>> involves:
>> 	1) Accessing the file table in the program's PSP at the entry
>> which corresponds to the file's handle.  The number stored there is an
>> index into the DOS System File Table (SFT).
>> 	2) Getting the address of the SFT via the infamous DOS List-of-Lists
>> structure, and reading the entry at the above index.  One of the fields there
>> is a starting cluster of the file.

> Will this work for network drives?

Probably, but can't tell without testing first.  Anyhow, this method has a
serious drawback: it doesn't work for directories (you can't open() a directory,
not under DOS that is).  I've found much better way which works for ANY file or
directory, and am currently testing it.  It proved to work reliably for DOS
versions 3.3, 4.01, 5.0 and 6.2.  The only 2 cases where it needs help are: root
directories (these MUST be treated separately anyway, and as no file occupies
cluster no. 1 -- the FAT is there -- we can agree to assign that one to root
directory); and zero-length files -- these have their cluster number zeroed,
because they don't occupy disk space.  Reporting 0 as st_ino for an empty file
doesn't seem a big lossage to me.
This method also uses undocumented DOS structures, and probably won't work under
DR-DOS and OS/2 DOS-box.  For these, we will still have the current fallback.
I plan to test if the method works in a networked environment these days.

Given the above lossages, do you think the patch is worthwhile?  If so, I'll
post it when my testing is over.

	Eli Zaretskii

- Raw text -


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