home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / be.zip / mbr.ini < prev   
Text File  |  1999-12-20  |  4KB  |  117 lines

  1. //
  2. // mbr.ini - BE initialisation file for decoding master boot records
  3. //
  4. // Under Linux, root can obtain the MBR via a command much like :-
  5. //
  6. //   # dd if=/dev/sda of=mbr.dat bs=512 count=1
  7. //
  8. // Then you'd invoke BE via :-
  9. //
  10. //   % be -i mbr.ini mbr.dat
  11. //
  12. // The file assumes the drive from which the MBR was obtained has
  13. // 63 sectors per track and 255 heads. These assumptions are used in
  14. // computations of LBAs given CHS information. If the disk geometry is
  15. // actually different (as is likely for <8GB disks), you can override
  16. // the assumptions via a command line much like :-
  17. //
  18. //   % be -Ssectors_per_track=32 -Sheads=127 -i mbr.ini mbr.dat
  19. //
  20. // Information obtained mainly from STORAGE.INF.
  21. //
  22.  
  23. set nspt `sectors_per_track 63`
  24. set nh   `heads 255`
  25.  
  26. map BOOTINDIC
  27.     {
  28.     "Not Active" 0x80 : 0x80
  29.     "Active"     0x00 : 0x80
  30.     }
  31.  
  32. map PARTOWNER
  33.     {
  34.     "Unused"                                           0x00
  35.     "DOS, 12-bit FAT"                                  0x01
  36.     "XENIX System"                                     0x02
  37.     "XENIX User"                                       0x03
  38.     "DOS, 16-bit FAT"                                  0x04
  39.     "Extended"                                         0x05
  40.     "DOS, >32MB support, <=64KB Allocation unit"       0x06
  41.     "OS/2, >32MB partition support"                    0x07
  42.     "AIX, OS/2 (<= 1.3 only), DELL array, or C= DOS"   0x08
  43.     "AIX"                                              0x09
  44.     "OS/2 Boot Manager Partition"                      0x0A
  45.     "OS/2 Boot Manager: DOS - Inactive type 1"         0x11
  46.     "OS/2 Boot Manager: DOS - Inactive type 4"         0x14
  47.     "OS/2 Boot Manager: DOS - Inactive type 6"         0x16
  48.     "OS/2 Boot Manager: DOS - Inactive type 7"         0x17
  49.     "Series/1 Disk"                                    0x40
  50.     "Personal RISC Boot Partition"                     0x41
  51.     "OnTrack Disk Manager 0x50"                        0x50
  52.     "OnTrack Disk Manager 0x51"                        0x51
  53.     "SCO UNIX"                                         0x63
  54.     "Novell/Speedstore"                                0x64
  55.     "Novell 286 NetWare"                               0x65
  56.     "Novell 386 NetWare"                               0x66
  57.     "Novell future use 0x67"                           0x67
  58.     "Novell future use 0x68"                           0x68
  59.     "Novell future use 0x69"                           0x69
  60.     "PC/IX"                                            0x75
  61.     "Linux swap"                                       0x82
  62.     "Linux native"                                     0x83
  63.     "System Hibernation for APM 1.1"                   0x84
  64.     "HPFS FT mirrored partition"                       0x87
  65.     "HPFS FT disabled mirrored partition"              0xC7
  66.     "CP/M 86"                                          0xD8
  67.     "Speedstore 0xE1"                                  0xE1
  68.     "Storage Dimensions 0xE3"                          0xE3
  69.     "Speedstore 0xE4"                                  0xE4
  70.     "Storage Dimensions 0xF1"                          0xF1
  71.     "Storage Dimensions 0xF4"                          0xF4
  72.     "IBM PS/2 IML"                                     0xFE
  73.     "Bad Block Tables - Must be on cylinder 0"         0xFF
  74.     }
  75.  
  76. def PARTCHS
  77.     {
  78.     at 1 n8 bits 7:6 hex width 3            suppress "CylinderHigh"
  79.     at 2 n8 hex width 4                     suppress "CylinderLow"
  80.     expr "(CylinderHigh<<8)+CylinderLow" dec width 4 "Cylinder"
  81.     at 0 n8 dec width 3                              "Head"
  82.     at 1 n8 bits 5:0 dec width 2                     "Sector"
  83.  
  84.     expr "(Cylinder*nh+Head)*nspt+Sector-1" width 8 dec
  85.                                             suppress "lba"
  86.     }
  87.  
  88. def PART
  89.     {
  90.     n8 map BOOTINDIC          "BootIndicator"
  91.     PARTCHS open              "PartitionStart"
  92.     n8 map PARTOWNER          "SystemIndicator"
  93.     PARTCHS open              "PartitionEnd"
  94.     n32 dec width 8           "OffsetFromStartOfDiskInSectors"
  95.     n32 dec width 8           "PartitionLengthInSectors"
  96.  
  97.     // By adding these two, you can work out the LBA
  98.     // immediately following the partition
  99.     expr "OffsetFromStartOfDiskInSectors+PartitionLengthInSectors"
  100.          dec width 8 suppress "next_lba"
  101.  
  102.     expr "OffsetFromStartOfDiskInSectors*512" hex ptr MBR
  103.          valid "SystemIndicator==Extended" suppress "extended" 
  104.     }
  105.  
  106. def MBR
  107.     {
  108.     buf 446 hex                          "MasterBootRecordProgram"
  109.     4 PART                               "PartitionTable"
  110.     n16 be hex valid "Signature==0x55aa" "Signature"
  111.     }
  112.  
  113. def main
  114.     {
  115.     MBR "mbr"
  116.     }
  117.