×
Menu
Index

GETHDINFO Subroutine

 
Usage:
h = GETHDINFO(num [,1|-1])
 
Description:
Obtains information about a hard drive and its partitions for the given hard drive number (zero-based).  The return value of 1 or 0 indicates success or failure respectively.  In addition, the return value contains several members that provide information about the drive and partitions.  Version 1.32 added the optional second parameter; when the second parameter is non-zero, extended information is also returned.  Version 1.66 supports the second parameter being less than zero to include unpartitioned space.  Version 1.51 adds a zero index to the Partition[] array member if the drive is not partitioned.
 
The member names are:
 
NUM
Hard Drive Number as provided on input (num)
BIOSHDNUM
BIOS Hard Drive Number (starting at 0x80)
SIG
Disk NT Signature
GUID
Disk GUID if GPT
SECSIZE
Sector Size
SIZE
Size of Drive in Sectors
C
Last BIOS Cylinder (Total Cylinders – 1)
H
Last BIOS Head (Total Heads – 1)
S
Number BIOS Sectors Per Track
EMBR
Indicator if EMBR exists (1) or not (0)
OutOfSync
Indicator if EMBR exists but MBR partitions are different (1) 
GPT
Indicator if GPT exists (1) or not (0)
MaxEntries
Maximum number of primary partitions allowed (added in 1.76)
BUS
Bus type: SCSI, PATA, USB, ASPI, 1394, SPTI, SG,
SATA, VIRT, SAA, Fibre, RAID, ISCSI, SAS, SD
NAME
Name of Device
PARTITION[]
Array (1 based) of partition entries or Partition[0] if drive is not partitioned
PARTITION[].VOLUME[]
Array (1 based) of volume entries for a given Extended Partition
 
For each PARTITION or VOLUME member the following member names exist:
 
NAME
Name or Volume Label
STARTLBA
Starting LBA
ENDLBA
Ending LBA
ID
ID of partition as used by TeraByte products
GUID
GPT entry GUID
TYPE
Type of GPT entry
SIZE
Total Sectors
FSID
File System ID
FSNAME
Friendly name of File System ID
MBRFLAG
MBR Bootable Flag
MBRENTRY
Entry in MBR (or EBR) Partition Table (0-3 or 255 if not in MBR)
PEFLAG
Partition Flag (EMBR/GPT and Partition Only)
DRVLTR
Drive letter assigned to partition (Windows Version Only)
 
For each PARTITION or VOLUME member, extended information is returned under a member named EX. The following extended members are available:
 
USEDSECTORS
Number of used sectors in the file system
FREESECTORS
Number of free sectors in the file system
LASTUSEDSECTOR
Last used sector (starting at zero) in the file system
AACOUNT
Number of allocated areas found in the file system
 
Note that USEDSECTORS+FREESECTORS may not equal the size of the partition when the file system area does not match the partition boundaries.  The LASTUSEDSECTOR value is the last sector within the file system that is in use (the required number of sectors for restoring as reported in the TeraByte imaging utilities is LASTUSEDSECTOR+1).  The AACOUNT represent the number areas within the file system that consist of some number of consecutive in-use sectors. 
 
Example:
sub main()
 
 getdrvltrinfo()
 n=0
 h=gethdinfo(n)
 
 while h
   printl("HDNum:", h.num)
   printl("DiskID:0x", hex(h.sig))
   printl("secsize:", h.secsize)
   printl("size:", h.size)
   printl("embr:", h.embr)
   printl("gpt:", h.gpt)
   printl("guid:", h.guid)
   printl("bus:", h.bus)
   printl("c:", h.c)
   printl("h:", h.h)
   printl("s:", h.s)
   
   pn=1
   while h.partition[pn]
     printl("start lba:", h.partition[pn].startlba)
     printl("end lba:", h.partition[pn].endlba)
     printl("fs:", h.partition[pn].fsid)
     printl("name:", h.partition[pn].name)
     printl("fsname:", h.partition[pn].fsname)
     printl("size:", h.partition[pn].size)
     printl("id:", hex(h.partition[pn].id))
     printl("mbrflag:", hex(h.partition[pn].mbrflag))
     printl("mbrentry:", h.partition[pn].mbrentry)
     printl("drvltr:", h.partition[pn].drvltr)
     vn=1
     while h.partition[pn].volume[vn]
       printl("  start lba:", h.partition[pn].volume[vn].startlba)
       printl("  end lba:", h.partition[pn].volume[vn].endlba)
       printl("  fs:", h.partition[pn].volume[vn].fsid)
       printl("  name:", h.partition[pn].volume[vn].name)
       printl("  fsname:", h.partition[pn].volume[vn].fsname)
       printl("  size:", h.partition[pn].volume[vn].size)
       printl("  id:", hex(h.partition[pn].volume[vn].id))
       printl("  drvltr:", h.partition[pn].volume[vn].drvltr)
       vn=vn+1
     wend
     pn=pn+1
   wend
 
   printl("")
   n=n+1
   h=gethdinfo(n)
 wend
 getdrvltrinfo(0)
 
end sub