[comp.lang.pascal] Reading out my FAT part II, please help me!!!

erwvegm@cs.vu.nl (Erwin van Egmond) (05/07/91)

Hi,
  A while ago I asked something about reading out my FAT.
  Well, I got a lot of response but nothing that could really
  help me.
  What I want is this :
			I have a file (Any file) and I want to know
			at which sector/cluster this file is placed.
			I want to find this out with TP5.5
			This means that I'm looking for a program
			that finds the beginning of my FAT, searches 
			this FAT and returns the sector/cluster number
			of the file.

			Please , if someone can provide me with such
			a program than I would be very happy and
   			grateful!

Thankx in advance,
			Erwin van Egmond <erwvegm@cs.vu.nl>

--
++ Erwin van Egmond UUCP: ...!mcsun!cs.vu.nl!erwvegm            ++
++								++
++  With a rubber duck, one's never alone		   	++
++	-- "The Hitchhiker's Guide to the Galaxy"		++

CDCKAB%EMUVM1.BITNET@cunyvm.cuny.edu ( Karl Brendel) (05/14/91)

In article <9857@star.cs.vu.nl> erwvegm@cs.vu.nl (Erwin van Egmond)
  wrote:

>  A while ago I asked something about reading out my FAT.
>  Well, I got a lot of response but nothing that could really
>  help me.
>  What I want is this :
>                        I have a file (Any file) and I want to know
>                        at which sector/cluster this file is placed.
>                        I want to find this out with TP5.5
>                        This means that I'm looking for a program
>                        that finds the beginning of my FAT, searches
>                        this FAT and returns the sector/cluster number
>                        of the file.

I don't think you need to touch the FAT directly at all. The
directory entry for the file includes the starting cluster (two
bytes (a word) at offset $1A into the entry). Only if you then want
to trace the file's chain of clusters do you need to access the FAT
itself.

To actually get at the directory entry, you're largely on your own.
DOS functions $11 and $12 return a copy of the entire entry,
including the starting cluster. However, they use FCBs and don't
take paths, so I think you're forced into changing into the
target file's subdirectory to use them. (Functions $4E and $4F don't
use FCBs, but for some reason they don't return the starting
cluster.)

If you're wanting code, maybe this will help you create some. (I
don't have any or maybe I'd post it. :) ) If OTOH you truly want "a
program" which you can run to do this (and more FAT reporting), look
for Chris Dunford's FAT. (Try checking SIMTEL for FAT*.*.)

+====================================================================+
| Karl Brendel                           Centers for Disease Control |
| Internet: CDCKAB@EMUVM1.BITNET         Epidemiology Program Office |
| Bitnet: CDCKAB@EMUVM1                  Atlanta GA  30093       USA |
|                        Home of Epi Info 5.0                        |
+====================================================================+

campbell@cutmcvax.cs.curtin.edu.au (Trevor George Campbell CC361) (05/22/91)

CDCKAB%EMUVM1.BITNET@cunyvm.cuny.edu ( Karl Brendel) writes:

>In article <9857@star.cs.vu.nl> erwvegm@cs.vu.nl (Erwin van Egmond)
>  wrote:

>>  A while ago I asked something about reading out my FAT.
>>  Well, I got a lot of response but nothing that could really
>>  help me.
>>  What I want is this :
>>                        I have a file (Any file) and I want to know
>>                        at which sector/cluster this file is placed.
>>                        I want to find this out with TP5.5
>>                        This means that I'm looking for a program
>>                        that finds the beginning of my FAT, searches
>>                        this FAT and returns the sector/cluster number
>>                        of the file.

>I don't think you need to touch the FAT directly at all. The
>directory entry for the file includes the starting cluster (two
>bytes (a word) at offset $1A into the entry). Only if you then want
>to trace the file's chain of clusters do you need to access the FAT
>itself.

You do need to read the FAT as that is the only place that you can get the
number of the next cluster. DOS uses the FAT to store the chain of the Files
blocks. The clustor that a file occupies includes ONLY the data from the file,
and NO pointers to the next cluster that a file uses. The cluster number is
uses as an offset into the FAT to determine the next cluster number. Once you
have the cluster number of the first cluster then you don't need any more
information that the FAT for the disk.
--
Trevor          alias  <**<TOMCAT>**>

CDCKAB%EMUVM1.BITNET@cunyvm.cuny.edu ( Karl Brendel) (05/23/91)

Responding to article campbell.674915054@cutmcvax from
  campbell@cutmcvax.cs.curtin.edu.au (Trevor George Campbell CC361):

>CDCKAB%EMUVM1.BITNET@cunyvm.cuny.edu ( Karl Brendel) writes:

>>In article <9857@star.cs.vu.nl> erwvegm@cs.vu.nl (Erwin van Egmond)
>>  wrote:

[... deleted ... now Trevor writes: ]

>You do need to read the FAT as that is the only place that you can
>get the number of the next cluster. DOS uses the FAT to store the
>chain of the Files blocks. The clustor that a file occupies includes
>ONLY the data from the file, and NO pointers to the next cluster
>that a file uses. The cluster number is uses as an offset into the
>FAT to determine the next cluster number. Once you have the cluster
>number of the first cluster then you don't need any more information
>that the FAT for the disk.

Yes, Trevor, that is why I wrote:

>>Only if you then want to trace the file's chain of clusters do you
>>need to access the FAT itself.

The original poster, however, wrote:

>>>  What I want is this :
>>>                        I have a file (Any file) and I want to know
>>>                        at which sector/cluster this file is placed.
>>>                        I want to find this out with TP5.5
>>>                        This means that I'm looking for a program
>>>                        that finds the beginning of my FAT, searches
>>>                        this FAT and returns the sector/cluster number
>>>                        of the file.

He says nothing about actually tracing the chain of allocated
clusters, only about finding the starting cluster. So I wrote:

>>The directory entry for the file includes the starting cluster (two
>>bytes (a word) at offset $1A into the entry).

If he wants to trace the chain, he should say so. Don't you agree?
;)

Cheers--                        --Karl

+====================================================================+
| Karl Brendel                           Centers for Disease Control |
| Internet: CDCKAB@EMUVM1.BITNET         Epidemiology Program Office |
| Bitnet: CDCKAB@EMUVM1                  Atlanta GA  30093       USA |
|                        Home of Epi Info 5.0                        |
+====================================================================+