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

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