#include "dos.h" /* AN000 */ #include "fdisk.h" /* AN000 */ #include "subtype.h" /* AN000 */ #include "extern.h" /* AN000 */ /* */ void write_info_to_disk() BEGIN char i; unsigned char j; unsigned extended_location; char extended_index; char temp; char first_found; char changed_flag; char temp_disk; temp = c(NUL); /* AN009 */ temp_disk = cur_disk; /* See if need to update the master boot record */ for (j = uc(0); j < number_of_drives; j++) /* AC000 */ BEGIN /* Save disk number */ cur_disk = ((char)(j)); /* See if there were any errors on that drive */ if (good_disk[j]) BEGIN for (i=c(0); i < c(4); i++) /* AC000 */ BEGIN if (part_table[j][i].changed) BEGIN write_master_boot_to_disk(j); break; END END /* See if the extended partition exists - if not, don't fool with the logical*/ /* drives - there is nothing to point to thier structures. Otherwise you get into */ /* a chicken and the egg situation, where you are trying to write out 'deletes' of */ /* the logical drive based on the start of the extended partition, but there isn't one */ /* because it has already been deleted already. Bad things happen - PTM P941 */ if (find_partition_type(uc(EXTENDED))); /* AC000 */ BEGIN /* See if any extended partitions need to be updated */ changed_flag = FALSE; for (i=c(0);i > 24)); /* AC000 */ boot_record[0x1C8+(index)] = uc(((long_temp & 0x00FF0000l) >> 16)); /* AC000 */ boot_record[0x1C7+(index)] = uc(((long_temp & 0x0000FF00l) >> 8)); /* AC000 */ boot_record[0x1C6+(index)] = uc((long_temp & 0x000000FFl)); /* AC000 */ /* Number of sectors */ long_temp = part_table[disk][i].num_sec; boot_record[0x1CD+(index)] = uc(long_temp >> 24); /* AC000 */ boot_record[0x1CC+(index)] = uc((long_temp & 0x00FF0000l) >> 16); /* AC000 */ boot_record[0x1CB+(index)] = uc((long_temp & 0x0000FF00l) >> 8); /* AC000 */ boot_record[0x1CA+(index)] = uc(long_temp & 0x000000FFl); /* AC000 */ END END boot_record[510] = uc(0x55); /* AC000 */ boot_record[511] = uc(0xAA); /* AC000 */ return(write_boot_record(u(0),disk)); /* AC000 */ END /* */ char write_ext_boot_to_disk(entry,disk) char entry; unsigned char disk; BEGIN char i; unsigned j; unsigned long long_temp; unsigned index; char location; char next_drive; char pointer; char write; /* Clean out the boot_record */ for (j=u(0);j < u(BYTES_PER_SECTOR); j++) /* AC000 */ BEGIN boot_record[j] = uc(0); /* AC000 */ END /* First - setup the logical devices */ /* See if it has been deleted - if so, leave entries as zero */ /* Otherwise - go unscramble everything out of the arrays */ if (ext_table[disk][sort[entry]].sys_id != uc(0)) /* AC000 */ BEGIN /* Get boot ind */ boot_record[0x1BE] = ext_table[disk][sort[entry]].boot_ind; /* Start head */ boot_record[0x1BF] = ext_table[disk][sort[entry]].start_head; /* Start sector - scramble it to INT 13 format*/ boot_record[0x1C0] = (ext_table[disk][sort[entry]].start_sector & 0x3F) | ((ext_table[disk][sort[entry]].start_cyl/256) << 6); /* Start cyl - scramble it to INT 13 format*/ boot_record[0x1C1] = ((unsigned char)(ext_table[disk][sort[entry]].start_cyl%256)); /* System id */ boot_record[0x1C2]= ext_table[disk][sort[entry]].sys_id; /* End head */ boot_record[0x1C3] = ext_table[disk][sort[entry]].end_head; /* End sector - scramble it to INT 13 format*/ boot_record[0x1C4] = (ext_table[disk][sort[entry]].end_sector & 0x3F) | ((ext_table[disk][sort[entry]].end_cyl/256) << 6); /* End cyl - scramble it to INT 13 format*/ boot_record[0x1C5] = ((unsigned char)(ext_table[disk][sort[entry]].end_cyl%256)); /* Relative sectors */ long_temp = ext_table[disk][sort[entry]].rel_sec; boot_record[0x1C9] = uc((long_temp >> 24)); /* AC000 */ boot_record[0x1C8] = uc(((long_temp & 0x00FF0000l) >> 16)); /* AC000 */ boot_record[0x1C7] = uc(((long_temp & 0x0000FF00l) >> 8)); /* AC000 */ boot_record[0x1C6] = uc((long_temp & 0x000000FFl)); /* AC000 */ /* Number of sectors */ long_temp = ext_table[disk][sort[entry]].num_sec; boot_record[0x1CD] = uc((long_temp >> 24)); /* AC000 */ boot_record[0x1CC] = uc(((long_temp & 0x00FF0000l) >> 16)); /* AC000 */ boot_record[0x1CB] = uc(((long_temp & 0x0000FF00l) >> 8)); /* AC000 */ boot_record[0x1CA] = uc((long_temp & 0x000000FFl)); /* AC000 */ END /* set up pointer to next logical drive unless this is # 23 */ if (entry != c(22)) /* AC000 */ BEGIN /* Find the drive to be pointed to */ pointer = entry+1; /* Handle the special case of a deleted or empty first entry in partition*/ if (entry == c(23)) /* AC000 */ BEGIN pointer = c(0); /* AC000 */ END for (i = pointer; i > 24)); /* AC000 */ boot_record[0x1D8] = uc(((long_temp & 0x00FF0000l) >> 16)); /* AC000 */ boot_record[0x1D7] = uc(((long_temp & 0x0000FF00l) >> 8)); /* AC000 */ boot_record[0x1D6] = uc((long_temp & 0x000000FFl)); /* AC000 */ /* Number of sectors in the next volume*/ long_temp = ((unsigned long)(ext_table[disk][next_drive].end_cyl - ext_table[disk][next_drive].start_cyl+1)) * max_head[disk] * max_sector[disk]; boot_record[0x1DD] = uc((long_temp >> 24)); /* AC000 */ boot_record[0x1DC] = uc(((long_temp & 0x00FF0000l) >> 16)); /* AC000 */ boot_record[0x1DB] = uc(((long_temp & 0x0000FF00l) >> 8)); /* AC000 */ boot_record[0x1DA] = uc((long_temp & 0x000000FFl)); /* AC000 */ END END boot_record[510] = uc(0x55); /* AC000 */ boot_record[511] = uc(0xAA); /* AC000 */ /* Write the boot record out */ if (entry != c(23)) /* AC000 */ BEGIN write = write_boot_record(ext_table[disk][sort[entry]].start_cyl,disk); END else BEGIN /* Write the special case of the first entry only having a pointer */ write = write_boot_record(ext_table[disk][23].start_cyl,disk); END return(write); END