cluster size? 
Author Message
 cluster size?

Hello!
I have a little problem. I can't find any solution for it. So I hope I get an answer here in the net.

My question:
    How I can find out the cluster size of different hard discs?
    Which function/procedure I need?
I use Turbo-Pascal 7.0.

Thank you!

PS: I hope that everyone understand my English. It's possible to answer in
    German.



Fri, 27 Nov 1998 03:00:00 GMT  
 cluster size?

Quote:
>Hello!
>I have a little problem. I can't find any solution for it. So I hope I get an
> answer here in the net.

>My question:
>    How I can find out the cluster size of different hard discs?
>    Which function/procedure I need?
>I use Turbo-Pascal 7.0.

>Thank you!

>PS: I hope that everyone understand my English. It's possible to answer in
>    German.

You can use the following code:

TYPE
  PDiskInfo = ^TDiskInfo;
  TDiskInfo = RECORD
    SectorsPerCluster: BYTE;
    BytesPerSector,
    ClustersPerDisk: WORD;
    MediaDescriptor: BYTE;
  END;

PROCEDURE DiskInfo(Drive: Char; Data: PDiskInfo);
{ Returns cluster/sector and media descriptor information of specified drive }
ASM PUSH  DS         { Function alters DS register }
    MOV   AH,$1C     { Get File Allocation Table Info }
    MOV   DL,Drive   { get drive letter }
    OR    DL,$20     { Convert Drive letter to lower case }
    SUB   DL,$60     { Convert drive letter to drive number }
{$IFDEF MSDOS}
    INT   $21
{$ENDIF}
{$IFDEF WINDOWS}
    CALL DOS3Call
{$ENDIF}
    LES   DI,Data    { Load pointer to TDiskInfo structure }
    STOSb            { save Sectors/cluster }
    MOV   AX,CX
    STOSw            { save bytes/sector }
    MOV   AX,DX
    STOSw            { save number of clusters }
    MOV   SI,BX      { load media descriptor offset }
    LODSb            { load media descriptor }
    STOSb            { save media descriptor }
    POP   DS
END; { DiskInfo }

--------------------------------------------------------
 Robert Vandervelde  + ...that what we have learned and

 Enterprise, AL      +  ourselves.                      
 The Wiregrass       +      - Richard C. Dorf          
--------------------------------------------------------



Mon, 30 Nov 1998 03:00:00 GMT  
 cluster size?

Quote:

>Hello!
>    How I can find out the cluster size of different hard discs?
>    Which function/procedure I need?
>I use Turbo-Pascal 7.0.

Hi!

I do not know appropriate functions of standard TP7, but have my own
unit for disk examination. Well, it may be an overshoot for you, but it
definitely works. I hope, comments are sufficient. If necessary, contact
to me in English. Despite I work currently in Frankfurt, my German, alas
:-( is very poor.

Follows text of the unit:

{Author : V.Nesterov}

unit DiskInfo;
{Warning! the UNDOCUMENTED DOS function 32 is used. May be changed in
future versions. Tested in Windows 95. Works both in MS-DOS and Windows
modes.}

interface

type
  PDiskParams = ^DiskParamsRec;
  {Disk Drive Parameters Table Structure}
  DiskParamsRec = record
    DrvNum         : byte;   {0=a,1=b,...}
    SubUnit        : byte;   {?}
    SectorSize     : word;
    MaxSectorClust : byte;    {Sectors per Cluster - 1}
    Cl2Sectshift   : byte;
    BootSize       : word;
    FatNumber      : byte;    {number of FAT}
    DirEntries     : word;    {Max number of Dir entries in root}
    DataSector     : word;    {Sector number of first data cluster}
    HighestCluster : word;    {total clusters + 2}
    FatSize        : byte;    {sectors per FAT}
    RootStart      : word;    {Sector number of root beginning}
    DeviceHeader   : Pointer; {Addr of device header}
    MediaDescriptor: byte;
    AccessFlag     : byte;    {0 if accessed}
    NextDPB        : Pointer; {0FFFF if last}
  end;

function ObtainDiskDataTable(Disk:byte):PDiskParams;
  {Returns pointer to Disk Drive Parameter Table}
  {Disk - drive number. 0 - default, 1 - a:, 2 - b:, ...
  {Different from one in the structure above, where 0 - a:, 1 - b:, ...}

implementation

function ObtainDiskDataTable(Disk:byte):PDiskParams;assembler;
asm
  push  DS
  mov   DL,Disk
  mov   AX,3200h
  int   21h
  cmp   AL,0ffh

  push  DS
  pop   DX    
  mov   AX,BX

  mov   AX,00

  pop   DS
end;

end.

Wonderful Pascal, is not it? ;-)
Best regards,

Viatcheslav      {Knowledge is power. R.Bacon}



Mon, 30 Nov 1998 03:00:00 GMT  
 cluster size?

Sorry, forgot to say: in case of invalid Disk Drive Number (Disk
parameter) the ObtainDiskDataTable function returns nil.

Viatcheslav



Mon, 30 Nov 1998 03:00:00 GMT  
 cluster size?

Quote:

>>    How I can find out the cluster size of different hard discs?
>>    Which function/procedure I need?
>>I use Turbo-Pascal 7.0.

>You can use the following code:

How about start sector/cluster no. of a file on HD?

Toh Hoon Ling



Thu, 03 Dec 1998 03:00:00 GMT  
 cluster size?

Quote:

>>>    How I can find out the cluster size of different hard discs?
>>>    Which function/procedure I need?
>>>I use Turbo-Pascal 7.0.

>>You can use the following code:

>>TYPE
>>  PDiskInfo = ^TDiskInfo;
>>  TDiskInfo = RECORD
>>    SectorsPerCluster: BYTE;
>>    BytesPerSector,
>>    ClustersPerDisk: WORD;
>>    MediaDescriptor: BYTE;
>>  END;

>>PROCEDURE DiskInfo(Drive: Char; Data: PDiskInfo);
>>{ Returns cluster/sector and media descriptor information of specified drive
> }
>>ASM PUSH  DS         { Function alters DS register }
>>    MOV   AH,$1C     { Get File Allocation Table Info }
>>    MOV   DL,Drive   { get drive letter }
>>    OR    DL,$20     { Convert Drive letter to lower case }
>>    SUB   DL,$60     { Convert drive letter to drive number }
>>{$IFDEF MSDOS}
>>    INT   $21
>>{$ENDIF}
>>{$IFDEF WINDOWS}
>>    CALL DOS3Call
>>{$ENDIF}
>>    LES   DI,Data    { Load pointer to TDiskInfo structure }
>>    STOSb            { save Sectors/cluster }
>>    MOV   AX,CX
>>    STOSw            { save bytes/sector }
>>    MOV   AX,DX
>>    STOSw            { save number of clusters }
>>    MOV   SI,BX      { load media descriptor offset }
>>    LODSb            { load media descriptor }
>>    STOSb            { save media descriptor }
>>    POP   DS
>>END; { DiskInfo }

>How about start sector/cluster no. of a file on HD?

>Toh Hoon Ling


To find the start sector/clustor no. of a file, you need to find the filename
in the directory. The directory entry is formatted as:

    offset   description    size  format
     0         filename      8    ascii
     8         extension     3    ascii
    11         attribute     1    bit coded
    12         reserved     10    unused; zeros
    22         time          2    word, coded
    24         date          2    word, coded
    26         start cluster 2    word
    28         size          4    integer

But, of course, you need to load the directory using BIOS functions $13. While
finding the start cluster number for a file is too complicated to cover in this
message, I shall point you to a very good reference book that covers the basics
of the structure of the disk: The Peter Norton Programmers Guide to the IBM PC.
This book covers how DOS formats the disk into logical sectors/clusters, etc.
and gives you the knowledge you need to do what you ask. Another good book
looking into is Undocumented DOS by Andrew Schulman

--------------------------------------------------------
 Robert Vandervelde  + ...that what we have learned and

 Enterprise, AL      +  ourselves.                      
 The Wiregrass       +      - Richard C. Dorf          
--------------------------------------------------------



Sat, 05 Dec 1998 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Help with getting Cluster Size

2. Cluster Size

3. Cluster Size of Disk?

4. cluster size?

5. TP7 DiskFree() returns 0 when cluster size = 64K

6. Find Cluster size inn hard drive via Pascal

7. WANT to read a sector/cluster from FAT32 HD

8. WANT to read a sector/cluster from FAT32 HD

9. HELP: Start cluster of a file

10. Lost clusters & disk reads/writes

11. Compiler without code size restriction

12. DBase header info (file size, last change date)

 

 
Powered by phpBB® Forum Software