*** lilo-org/bsect.c Tue May 21 00:14:50 1996 --- lilo/bsect.c Sun Mar 23 20:47:00 1997 *************** *** 418,423 **** --- 418,468 ---- } } + #define BENICEWITHNT + + /* ugly patch from Cyrille Chepelov + + no guarantee at all ! it does, however, solve the problem of preserving + NT disks IDs (and thus stripe set ownership) on *my* machine. There is + no guarantee of its correct behavior on other ones. You have been warned. + + comments welcome, send flames and lawyers to /dev/null. + */ + + void BeNiceWithNT(void) + { + /* Windows NT's disk ID seems to be at offset 0x1b8 of the MBR + (it may be somewhere else in the case of extended partitions, + but I would really doubt it) + + To prevent LILO from splitting up FT disk sets, and to prevent + Disk Administrator from complaining about lost disk IDs in + general, we will brutally copy the 4 bytes at offset 0x1b8 from + the original boot sector to the new one. + + Of course, this is really needed only for MBRs. + */ + #ifdef BENICEWITHNT + #define DISKID_OFS (0x1b8) + char *diskID_orig = (char *)&bsect_orig + DISKID_OFS; + char *diskID_dest = (char *)&bsect + DISKID_OFS; + unsigned long int diskID = 0; + diskID = *((unsigned long int *)diskID_orig); + + if (*((unsigned long int *)diskID_dest)) + { + printf("lilo warning : NT diskID field is already filled.\n"); + printf(" resulting boot sector may be corrupt ! \n"); + } + + *((unsigned long int*)diskID_dest) = + *((unsigned long int*)diskID_orig); + + #endif BENICEWITHNT + } + + + /* end of C.Chepelov's ugly patch */ void bsect_update(char *backup_file,int force_backup) { *************** *** 443,448 **** --- 488,494 ---- die("creat %s: %s",backup_file,strerror(errno)); if (write(bck_file,(char *) &bsect_orig,SECTOR_SIZE) != SECTOR_SIZE) die("write %s: %s",backup_file,strerror(errno)); + if (verbose > 0) printf("Backup copy of boot sector in %s\n",backup_file); if (fstat(bck_file,&st) < 0) *************** *** 455,460 **** --- 501,509 ---- die("lseek %s: %s",boot_devnam ? boot_devnam : dev.name, strerror(errno)); if (verbose > 0) printf("Writing boot sector.\n"); + + BeNiceWithNT(); + if (write(fd,(char *) &bsect,SECTOR_SIZE) != SECTOR_SIZE) die("write %s: %s",boot_devnam ? boot_devnam : dev.name, strerror(errno)); *************** *** 572,574 **** --- 621,624 ---- } exit(0); } +