home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 8 / CDACTUAL8.iso / install / fips / source / hdstruct.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-11  |  3.5 KB  |  106 lines

  1. /* 
  2.     FIPS - the First nondestructive Interactive Partition Splitting program 
  3.  
  4.     Module hdstruct.cpp 
  5.  
  6.     RCS - Header: 
  7.     $Header: c:/daten/fips/source/main/RCS/hdstruct.cpp 1.1 1994/05/25 22:19:52 schaefer Exp schaefer $ 
  8.  
  9.     Copyright (C) 1993 Arno Schaefer 
  10.  
  11.     This program is free software; you can redistribute it and/or modify 
  12.     it under the terms of the GNU General Public License as published by 
  13.     the Free Software Foundation; either version 2 of the License, or 
  14.     (at your option) any later version. 
  15.  
  16.     This program is distributed in the hope that it will be useful, 
  17.     but WITHOUT ANY WARRANTY; without even the implied warranty of 
  18.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
  19.     GNU General Public License for more details. 
  20.  
  21.     You should have received a copy of the GNU General Public License 
  22.     along with this program; if not, write to the Free Software 
  23.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
  24.  
  25.  
  26.     Report problems and direct all questions to: 
  27.  
  28.     schaefer@rbg.informatik.th-darmstadt.de 
  29. */ 
  30.  
  31. #include "types.h" 
  32. #include "hdstruct.h" 
  33.  
  34. rootsector::rootsector (rootsector &rs) 
  35.     drive = rs.drive; 
  36.     for (int i=0;i<512;i++) data[i] = rs.data[i]; 
  37.  
  38. void rootsector::operator= (rootsector &rs) 
  39.     drive = rs.drive; 
  40.     for (int i=0;i<512;i++) data[i] = rs.data[i]; 
  41.  
  42. void harddrive::operator= (harddrive &hd) 
  43.     physical_drive::operator= (hd); 
  44.     *rootsector = *(hd.rootsector); 
  45.     partition_table () = hd.partition_table(); 
  46.  
  47. /* ----------------------------------------------------------------------- */ 
  48. /* Extract Partition Table from rootsector                                 */ 
  49. /* ----------------------------------------------------------------------- */ 
  50.  
  51. void partition_table::get (rootsector *rootsector) 
  52.     for (int i=0;i<4;i++) 
  53.     { 
  54.         class partition_info *p = &partition_info[i]; 
  55.         byte *pi = &(rootsector->data[0x1be+16*i]); 
  56.  
  57.         p->bootable = *pi; 
  58.         p->start_head = *(pi+1); 
  59.         p->start_cylinder = *(pi+3) | ((*(pi+2) << 2) & 0x300); 
  60.         p->start_sector = *(pi+2) & 0x3f; 
  61.         p->system = *(pi+4); 
  62.         p->end_head = *(pi+5); 
  63.         p->end_cylinder = *(pi+7) | ((*(pi+6) << 2) & 0x300); 
  64.         p->end_sector = *(pi+6) & 0x3f; 
  65.         p->start_sector_abs = (dword) *(pi+8) | ((dword) *(pi+9) << 8) | ((dword) *(pi+10) << 16) | ((dword) *(pi+11) << 24); 
  66.         p->no_of_sectors_abs = (dword) *(pi+12) | ((dword) *(pi+13) << 8) | ((dword) *(pi+14) << 16) | ((dword) *(pi+15) << 24); 
  67.     } 
  68.  
  69. /* ----------------------------------------------------------------------- */ 
  70. /* Write Partition Table back into rootsector                              */ 
  71. /* ----------------------------------------------------------------------- */ 
  72.  
  73. void partition_table::put (rootsector *rootsector) 
  74.     for (int i=0;i<4;i++) 
  75.     { 
  76.         class partition_info p = partition_info[i]; 
  77.         byte *pi = &(rootsector->data[0x1be+16*i]); 
  78.  
  79.         *pi = p.bootable; 
  80.         *(pi+1) = p.start_head; 
  81.         *(pi+2) = ((p.start_cylinder >> 2) & 0xc0) | (p.start_sector & 0x3f); 
  82.         *(pi+3) = p.start_cylinder & 0xff; 
  83.         *(pi+4) = p.system; 
  84.         *(pi+5) = p.end_head; 
  85.         *(pi+6) = ((p.end_cylinder >> 2) & 0xc0) | (p.end_sector & 0x3f); 
  86.         *(pi+7) = p.end_cylinder & 0xff; 
  87.         *(pi+8) = p.start_sector_abs & 0xff; 
  88.         *(pi+9) = (p.start_sector_abs >> 8) & 0xff; 
  89.         *(pi+10) = (p.start_sector_abs >> 16) & 0xff; 
  90.         *(pi+11) = (p.start_sector_abs >> 24) & 0xff; 
  91.         *(pi+12) = p.no_of_sectors_abs & 0xff; 
  92.         *(pi+13) = (p.no_of_sectors_abs >> 8) & 0xff; 
  93.         *(pi+14) = (p.no_of_sectors_abs >> 16) & 0xff; 
  94.         *(pi+15) = (p.no_of_sectors_abs >> 24) & 0xff; 
  95.     } 
  96.