home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / BOOTANY1.ZIP / PREINST.C < prev    next >
Text File  |  1990-10-29  |  2KB  |  88 lines

  1. #include <stdio.h>
  2. #include "bootany.h"
  3.  
  4. #define DISK_READ 2
  5. #define DISK_WRITE 3
  6.  
  7. extern int bootio(int, char *);
  8.  
  9. #define EMPTY  0
  10. #define FAT_12 1
  11. #define XENIX  2
  12. #define FAT_16 4
  13. #define EXTEND 5
  14. #define BIGDOS 6
  15. #define HPFS   7
  16. #define NOVELL 0x64
  17. #define PCIX   0x75
  18. #define CP_M   0xDB
  19. #define BBT    0xFF
  20.  
  21. #define StandardTable 0
  22. #define BootAnyTable 1
  23.  
  24. main()
  25. {
  26.   static char msg[] =
  27.      "All bootable partitions have been re-validated\n";
  28.   static char msg1[] =
  29.      "All bootable partitions have been validated\n";
  30.   char bootRecord[512];
  31.   int  rc;
  32.   int tableType = StandardTable;
  33.  
  34.    if ((rc = BOOTIO(DISK_READ, bootRecord)) == 0)
  35.      {
  36.        register BootData *bootInfo =
  37.                 (BootData *)(bootRecord + DataAddr);
  38.        register PartitionEntry *part = bootInfo->partEntry;
  39.        int i;
  40.  
  41.        for (i = 0; i < 4; ++i)
  42.          {
  43.            char type;
  44.            char boot;
  45.  
  46.            if (part->bootIndicator == 0 ||
  47.                part->bootIndicator == (char)(0x80))
  48.              {
  49.                type = part->systemId;
  50.                boot = part->bootIndicator;
  51.              }
  52.             else
  53.              {
  54.                tableType = BootAnyTable;
  55.                type = part->bootIndicator;
  56.                boot = part->systemId;
  57.              }
  58.  
  59.            if (boot == (char)(0x80))
  60.             {
  61.               part->bootIndicator = boot;
  62.               part->systemId = type;
  63.             }
  64.            ++part;
  65.          }
  66.  
  67.        if (tableType == BootAnyTable)
  68.          {
  69.            if ((rc = BOOTIO(DISK_WRITE, bootRecord)) == 0)
  70.              {
  71.                printf(msg);
  72.              }
  73.             else
  74.              {
  75.                printf("Error updating boot record - rc = %d\n",rc);
  76.              }
  77.          }
  78.         else
  79.          {
  80.            printf(msg1);
  81.          }
  82.      }
  83.     else
  84.      {
  85.        printf("Error reading boot record - rc = %d\n",rc);
  86.      }
  87. }
  88.