Getting drive sizes larger than 2 gigs... 
Author Message
 Getting drive sizes larger than 2 gigs...

Is there any way in TP 7.0 to get the disk size and free space for drives
greater than 2 gigs?

Or is this a DOS limitation?  Also, if it IS a DOS limitation, would it
possible to get this information directly from the BIOS?

Thanks for any help!



Wed, 18 Jun 1902 08:00:00 GMT  
 Getting drive sizes larger than 2 gigs...

Quote:

> Is there any way in TP 7.0 to get the disk size and free space for drives
> greater than 2 gigs? Or is this a DOS limitation?

DOS supports 4GB disks, but TP doesn't have DWORD type.
DOS usually groups data in n*512 bytes, so you can try shifting the
values to divide by 512.

Andras



Wed, 18 Jun 1902 08:00:00 GMT  
 Getting drive sizes larger than 2 gigs...

noname heeft geschreven in bericht ...

Quote:
>Is there any way in TP 7.0 to get the disk size and free space for drives
>greater than 2 gigs?

Fat16 only supports drives smaller than 2 GB.
Fat32 supports larger drives.

You could use the Win95 calls for the disk space to see the real amount.

Quote:

>Or is this a DOS limitation?  Also, if it IS a DOS limitation, would it
>possible to get this information directly from the BIOS?

>Thanks for any help!



Wed, 18 Jun 1902 08:00:00 GMT  
 Getting drive sizes larger than 2 gigs...

: Is there any way in TP 7.0 to get the disk size and free space for drives
: greater than 2 gigs?

: Or is this a DOS limitation?  Also, if it IS a DOS limitation, would it
: possible to get this information directly from the BIOS?

: Thanks for any help!

FAT-16 is limited to 1.6 (something or other) Gigs. Fat-32 supports >2Gb
hard drives as do most sophisticated file systems. The big problem is
that in BP/TP 7.0 and prior, the maximum longint is a signed 32-bit
integer (roughly -2,000,000,000 to 2,000,000,000) which shows an obvious
limitation of retriving sizes up to 2,000,000,000 and down to
-2,000,000,000. I believe that (and please correct me if I am wrong) that
once you get up to the upper bound of the longint (the 2bil mark) because
the MCB would then be set, it would "roll over" to -2bil. So, we can test
if hdsize is less than 0 then you add 2,147,483,648 to get the actual HD
size. Whoops, can't do that! TP doesn't have a type to handle that.

--- begin SWAG snippet.

function drivesize(d:byte):longint; {-1 not found, 1=>1 gig}
var r : registers;
begin
  with r do begin
    ah := $36;
    dl := d;
    intr($21,r);
    if AX=$FFFF then drivesize := -1 {drive not found}
    else if (DX=$FFFF) or (longint(ax)*cx*dx=1073725440) then drivesize:=1
    else drivesize := longint(ax)*cx*dx;
  end;
end;

function drivefree(d:byte):longint; {-1 not found, 1=>1Gig}
var r : registers;
begin
  with r do begin
    ah := $36;
    dl := d;
    intr($21,r);
    if AX=$FFFF then drivefree:=-1 { not found }
    else if (BX=$FFFF) or (longint(ax)*bx*cx=1073725440) then drivefree:=1
    else drivefree := longint(ax)*bx*cx;
  end;
end;

--- end snippet

Hope that helps.
--
  Peter Mac Millan    | Get the new, improved, wounderfully enhanced, and



Wed, 18 Jun 1902 08:00:00 GMT  
 Getting drive sizes larger than 2 gigs...

Quote:
> Is there any way in TP 7.0 to get the disk size and free space for drives
> greater than 2 gigs?

> Or is this a DOS limitation?  Also, if it IS a DOS limitation, would it
> possible to get this information directly from the BIOS?

Hi!

Here is a workaround for your problem. I had the same question
some months ago and got this code snippet from a guy called
Jason Burgon, thanks again Jason! Its a function to get the
free space in KB, *not* Bytes, to avoid the longint overflows...

type
  { GetDiskInfo record }
  TDiskInfo = record
     SectsPerCluster: Word;
     BytesPerSector : Word;
     ClustersFree   : Word;
     ClustersTotal  : Word;
  end;

function LongMul(X, Y: Integer): Longint;
inline($5A/$58/$F7/$EA);

function GetDiskInfo(Drive: Byte;
                     var DiskInfo: TDiskInfo): Boolean; assembler;
asm
            mov   dl,[Drive]
            mov   ah,$36
            int   $21
            les   di,[DiskInfo]
            cmp   ax,-1
            mov   [es:di+TDiskInfo.SectsPerCluster],ax
            mov   al,0

            mov   [es:di+TDiskInfo.BytesPerSector],cx
            mov   [es:di+TDiskInfo.ClustersFree],bx
            mov   [es:di+TDiskInfo.ClustersTotal],dx
            mov   al,1

end;

function GetKbFree(Drive: Byte): Longint;
var DiskInfo: TDiskInfo;
begin
   GetKbFree := 0;
   if GetDiskInfo(Drive), DiskInfo)then
      with DiskInfo do
         GetKbFree:=LongMul(LongMul(SectsPerCluster,BytesPerSector) shr 5,
                         ClustersFree) shr 5;
end;

In both functions Drive is 0 for default drive, 1 = A: 2 = B: etc.

bye
   Martin
--         base your joy not upon the deeds of others        --
--           for what is given can be taken away...          --

-- Coder's Guild member: http://www.paracatz.com/codersguild --



Wed, 18 Jun 1902 08:00:00 GMT  
 Getting drive sizes larger than 2 gigs...



Quote:

>: Is there any way in TP 7.0 to get the disk size and free space for drives
>: greater than 2 gigs?

>: Or is this a DOS limitation?  Also, if it IS a DOS limitation, would it
>: possible to get this information directly from the BIOS?

>: Thanks for any help!

>FAT-16 is limited to 1.6 (something or other) Gigs.

It will certainly do 2Gb and, as DOS uses dwords, you can, AIUI, get
*almost* 4Gb

Quote:
>The big problem is
>that in BP/TP 7.0 and prior, the maximum longint is a signed 32-bit
>integer (roughly -2,000,000,000 to 2,000,000,000)

This is the problem. I 've seen posted a solution to this but can't find
it at the moment.

Quote:
> I believe that (and please correct me if I am wrong) that
>once you get up to the upper bound of the longint (the 2bil mark) because
>the MCB would then be set, it would "roll over" to -2bil.

The MCB is a memory Control Block, I think you may mean the MBR - Master
Boot Record. As a dword, 4Gb is the maximum unless you are using FAT-32.

Quote:
>So, we can test
>if hdsize is less than 0 then you add 2,147,483,648 to get the actual HD
>size. Whoops, can't do that! TP doesn't have a type to handle that.

True. The best solution to using more than MaxInt is to use strings to
represent answers to calculations if you want byte accuracy.

--

Never curse the Crocodile's mother before crossing the river



Wed, 18 Jun 1902 08:00:00 GMT  
 Getting drive sizes larger than 2 gigs...


Quote:

>> Is there any way in TP 7.0 to get the disk size and free space for drives
>> greater than 2 gigs? Or is this a DOS limitation?

DOS only supports 2 GB.
Quote:
>DOS supports 4GB disks, but TP doesn't have DWORD type.
>DOS usually groups data in n*512 bytes, so you can try shifting the
>values to divide by 512.

>Andras



Wed, 18 Jun 1902 08:00:00 GMT  
 Getting drive sizes larger than 2 gigs...


Quote:
> DOS only supports 2 GB.

Really? But my friend has a 4GB drive, and it works...
(DOS 6.22 and 64K cluster size)

Andras



Wed, 18 Jun 1902 08:00:00 GMT  
 Getting drive sizes larger than 2 gigs...


writes

Quote:

>> DOS only supports 2 GB.

>Really? But my friend has a 4GB drive, and it works...
>(DOS 6.22 and 64K cluster size)

That's right.  4GB is the limit of a dword in DOS. Turbo Pascal uses
longint as a signed dword which means it can only go to 2Gb.

Mind you, and off-topic, you *should* partition large disks into a set
of smaller drives as you save _alot_ of space. My 4Gb drive is down to
4K clusters - far better than 64K :-)

--

Never curse the Crocodile's mother before crossing the river



Wed, 18 Jun 1902 08:00:00 GMT  
 Getting drive sizes larger than 2 gigs...

Quote:

> Mind you, and off-topic, you *should* partition large disks into a set
> of smaller drives as you save _alot_ of space. My 4Gb drive is down to
> 4K clusters - far better than 64K :-)

Yes, but it isn't my problem.
I put all small files into compressed Jam drives. ;-)

Andras



Wed, 18 Jun 1902 08:00:00 GMT  
 Getting drive sizes larger than 2 gigs...

Peter Mac Millan heeft geschreven in bericht ...

Quote:

>: Is there any way in TP 7.0 to get the disk size and free space for drives
>: greater than 2 gigs?

>: Or is this a DOS limitation?  Also, if it IS a DOS limitation, would it
>: possible to get this information directly from the BIOS?

>: Thanks for any help!

>FAT-16 is limited to 1.6 (something or other) Gigs.

I've got a 2 GB fat 16 drive.

Fat-32 supports >2Gb
Yes, but the standard routines still report 2 GB when the actual value is
larger.



Wed, 18 Jun 1902 08:00:00 GMT  
 Getting drive sizes larger than 2 gigs...

Pedt Scragg heeft geschreven in bericht ...

Quote:



>>: Is there any way in TP 7.0 to get the disk size and free space for
drives
>>: greater than 2 gigs?

>>: Or is this a DOS limitation?  Also, if it IS a DOS limitation, would it
>>: possible to get this information directly from the BIOS?

>>: Thanks for any help!

>>FAT-16 is limited to 1.6 (something or other) Gigs.

>It will certainly do 2Gb and, as DOS uses dwords, you can, AIUI, get
>*almost* 4Gb

>>The big problem is
>>that in BP/TP 7.0 and prior, the maximum longint is a signed 32-bit
>>integer (roughly -2,000,000,000 to 2,000,000,000)

>This is the problem. I 've seen posted a solution to this but can't find
>it at the moment.

>> I believe that (and please correct me if I am wrong) that
>>once you get up to the upper bound of the longint (the 2bil mark) because
>>the MCB would then be set, it would "roll over" to -2bil.

>The MCB is a memory Control Block, I think you may mean the MBR - Master
>Boot Record. As a dword, 4Gb is the maximum unless you are using FAT-32.

>>So, we can test
>>if hdsize is less than 0 then you add 2,147,483,648 to get the actual HD
>>size. Whoops, can't do that! TP doesn't have a type to handle that.

You can just divide the longint in assembler by 1024 to get the amount of KB
or use an alternative value to string conversion routine.
What about the Comp type?

- Show quoted text -

Quote:

>--

>Never curse the Crocodile's mother before crossing the river



Wed, 18 Jun 1902 08:00:00 GMT  
 Getting drive sizes larger than 2 gigs...

Martin Kruk heeft geschreven in bericht

Quote:
>> Is there any way in TP 7.0 to get the disk size and free space for drives
>> greater than 2 gigs?

>> Or is this a DOS limitation?  Also, if it IS a DOS limitation, would it
>> possible to get this information directly from the BIOS?

>Hi!

This is from the Ralph Brown interrupt list I have.
It says at function $36 from  int $21:
 (FAT32 drive) the reported total and free space are limited to
                                                         2G-32K
Quote:

>type
>  { GetDiskInfo record }
>  TDiskInfo = record
>     SectsPerCluster: Word;
>     BytesPerSector : Word;
>     ClustersFree   : Word;
>     ClustersTotal  : Word;
>  end;

>function LongMul(X, Y: Integer): Longint;
>inline($5A/$58/$F7/$EA);

>function GetDiskInfo(Drive: Byte;
>                     var DiskInfo: TDiskInfo): Boolean; assembler;
>asm
>            mov   dl,[Drive]
>            mov   ah,$36
>            int   $21
>            les   di,[DiskInfo]
>            cmp   ax,-1
>            mov   [es:di+TDiskInfo.SectsPerCluster],ax
>            mov   al,0

>            mov   [es:di+TDiskInfo.BytesPerSector],cx
>            mov   [es:di+TDiskInfo.ClustersFree],bx
>            mov   [es:di+TDiskInfo.ClustersTotal],dx
>            mov   al,1

>end;

>function GetKbFree(Drive: Byte): Longint;
>var DiskInfo: TDiskInfo;
>begin
>   GetKbFree := 0;
>   if GetDiskInfo(Drive), DiskInfo)then
>      with DiskInfo do
>         GetKbFree:=LongMul(LongMul(SectsPerCluster,BytesPerSector) shr 5,
>                         ClustersFree) shr 5;
>end;

>In both functions Drive is 0 for default drive, 1 = A: 2 = B: etc.

>bye
>   Martin
>--         base your joy not upon the deeds of others        --
>--           for what is given can be taken away...          --

>-- Coder's Guild member: http://www.paracatz.com/codersguild --



Wed, 18 Jun 1902 08:00:00 GMT  
 Getting drive sizes larger than 2 gigs...

[...]

Hi Olaf!

So you made a hell of alot of comments in this thread, but do you
have a solution for this problem as well? I mean, better than

Quote:
> You could use the Win95 calls for the disk space to see the real amount.

regards
   Martin
--         base your joy not upon the deeds of others        --
--           for what is given can be taken away...          --

-- Coder's Guild member: http://www.paracatz.com/codersguild --


Wed, 18 Jun 1902 08:00:00 GMT  
 Getting drive sizes larger than 2 gigs...


Quote:

>> DOS only supports 2 GB.

>Really? But my friend has a 4GB drive, and it works...
>(DOS 6.22 and 64K cluster size)

Very strange?
Did he put the entire 4 GB in one partition?
Do all programs work with this?
Quote:
>Andras



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 25 post ]  Go to page: [1] [2]

 Relevant Pages 

1. Problem with DISKFREE on 2+ GIG drives?

2. Turbo Pascal 5.5 Large Drive Function/Procedure

3. Diskspace on large drive and BP7

4. DiskFree and DiskSize on large/NonDos drives

5. Find Cluster size inn hard drive via Pascal

6. Display Free Hard Disk Size Of SCSI Hard Drive

7. Drive Size Detection Help

8. BDE.dbiCreateInMemTable - Record Size Too Large for Table Error

9. Static data size/data segment to large

10. How Large is your database size?

11. Large disk size

12. Large Array sizes

 

 
Powered by phpBB® Forum Software