📄 raid.c
字号:
autocount = 0; /* check that all devices have an accessible block for writeback info */ for (pass=0; pass < ndisk; pass++) { if (extra == X_MBR_ONLY || extra == X_MBR) raid_bios[pass] |= TO_BE_COVERED; if (extra == X_AUTO /*&& raid_bios[pass] != 0x80*/) { if (do_md_install == MD_SKEWED) { raid_bios[pass] |= TO_BE_COVERED; autocount++; } if (do_md_install == MD_MIXED) { if (is_primary(raid_device[pass])) raid_bios[pass] |= IS_COVERED; else { raid_bios[pass] |= TO_BE_COVERED; autocount++; } } } if (extra != X_MBR) if ((do_md_install == MD_PARALLEL && is_accessible(raid_device[pass])) || (do_md_install == MD_MIXED && pri_offset == raid_offset[pass] && is_primary(raid_device[pass])) ) raid_bios[pass] |= IS_COVERED; } nlist = 0; if (extra==X_SPEC) { char *next, *scan; scan = next = extrap; while (next && *next) { scan = next; while (isspace(*scan)) scan++; /* deblank the line */ next = strchr(scan, ','); /* find the separator */ if (next) *next++ = 0; /* NUL terminate scan */ if ((md_fd=open(scan,O_NOACCESS)) < 0) die("Unable to open %s", scan); if (fstat(md_fd,&st) < 0) die("Unable to stat %s",scan); if (!S_ISBLK(st.st_mode)) die("%s (%04X) not a block device", scan, (int)st.st_rdev); if (verbose>=4) printf("RAID list: %s is device 0x%04X\n", scan, (int)st.st_rdev); close(md_fd); list_index[nlist] = ndisk; /* raid_bios==0 here */ for (pass=0; pass < ndisk; pass++) { if (master(st.st_rdev) == master(raid_device[pass])) { list_index[nlist] = pass; if (st.st_rdev == raid_device[pass]) die("Cannot write to a partition within a RAID set: %s", scan); else if (is_accessible(st.st_rdev)) raid_bios[pass] |= IS_COVERED; break; } } if (list_index[nlist] == ndisk) {#ifdef FLAG_RAID_NOWRITE raid_flags |= FLAG_RAID_NOWRITE; /* disk is outside RAID set */#endif if (!nowarn) printf("Warning: device outside of RAID set %s 0x%04X\n", scan, (int)st.st_rdev); } raid_list[nlist++] = stralloc(scan); } } /* if the install is to MBRs, then change the boot= name */ if (extra == X_MBR_ONLY) {#if 0 if (cfg_get_strg(cf_options,"boot")) cfg_unset(cf_options,"boot"); cfg_set(cf_options, "boot", (boot=raid_mbr[0]), NULL);#endif } else { /* if skewed install, disable mdX boot records as source of writeback info */ if (do_md_install == MD_SKEWED) raid_flags |= FLAG_RAID_DEFEAT#ifdef FLAG_RAID_NOWRITE | (extra == X_NONE ? FLAG_RAID_NOWRITE : 0)#endif ; } mask = 1; for (pass=0; pass < ndisk; pass++) { mask &= !!(raid_bios[pass] & COVERED); }#ifdef FLAG_RAID_NOWRITE if (!mask) { raid_flags |= FLAG_RAID_NOWRITE; } if (raid_flags & FLAG_RAID_NOWRITE) { if (!nowarn) { fprintf(errstd, "\nWarning: FLAG_RAID_NOWRITE has been set.\n");#if 0 if (verbose >= 1) fprintf(errstd, " The boot loader will be unable to update the stored command line;\n" " 'lock' and 'fallback' are not operable; the 'lilo -R' boot command\n" " line will be locked.\n\n");#endif } }#endif /* if the disk= bios= did not specify the bios, then this is the default */ if (md_disk->bios < 0) { md_disk->bios = md_bios; } md_bios = md_disk->bios; if (md_disk->bios < 0x80 || md_disk->bios > DEV_MASK) die("Unusual RAID bios device code: 0x%02X", md_disk->bios);#if 0/* Assigning all disks the same bios code is OBSOLETE in 22.5.6 */ disk = disktab; for (pass=0; pass < ndisk; pass++) { disk->bios = md_disk->bios; /* all disks in the array are */ disk = disk->next; /* assigned the same bios code */ }#endif if (verbose) { printf( "Using BIOS device code 0x%02X for RAID boot blocks\n", md_disk->bios); }#if 0 if ( mask && ( extra == X_NONE || (extra == X_AUTO && autocount == 0) ) ) { if (bios_passes_dl > DL_BAD) bios_passes_dl = DL_GOOD; }#endif if (!nowarn && bios_passes_dl==DL_GOOD && !(extra == X_MBR_ONLY || extra == X_MBR)) fprintf(errstd, "Warning: Boot sector on %s will depend upon the BIOS device code\n" " passed in the DL register being accurate. Install Master Boot Records\n" " with the 'lilo -M' command, and activate the RAID1 partitions with the\n" " 'lilo -A' command.\n", boot ); return raid_offset[pri_index]; } /* IF (test for a raid installation */} /* int raid_setup(void) */void raid_final(void){ int pass, force = 0; char *cp = NULL; int mask = FLAG_SAVE; if (bios_passes_dl < DL_GOOD) mask &= ~FLAG_MAP_ON_BOOT; if (test) /* do nothing */; else if ((cp=cfg_get_strg(cf_options,"force-backup"))) force=1; else cp=cfg_get_strg(cf_options,"backup"); if (verbose>=2) { printf("do_md_install: %s\n", do_md_install == MD_PARALLEL ? "MD_PARALLEL" : do_md_install == MD_MIXED ? "MD_MIXED" : do_md_install == MD_SKEWED ? "MD_SKEWED" : "unknown"); for (pass=0; pass<ndisk; pass++) printf(" offset %08X %s\n", raid_offset[pass], raid_mbr[pass]); } if (extra == X_MBR_ONLY) { pass = 0; while (pass < ndisk) {#ifndef LCF_UNIFY# error "Bios Translation algorithms require '-DUNIFY' in Makefile"#endif if (pass==0 && test) { bsect_cancel(); if (passw) printf("The password crc file has *NOT* been updated.\n"); printf("The map file has *NOT* been altered.\n"); } if (!test) { bsect_raid_update(raid_mbr[pass], raid_offset[pass], cp, force, pass ? pass : -1, mask ); } printf("The Master boot " "record of %s has%s been updated.\n", raid_mbr[pass], test ? " *NOT*" : "" ); pass++; } } else { /* extra != X_MBR_ONLY */ #ifdef FLAG_RAID_DEFEAT raid_flags &= ~FLAG_RAID_DEFEAT; /* change won't affect /dev/mdX */#endif { if (test) { bsect_cancel(); if (passw) fprintf(errstd,"The password crc file has *NOT* been updated.\n"); printf("The map file has *NOT* been updated.\n"); } else { /* write out the /dev/mdX boot records */ bsect_raid_update(boot, 0L, cp, force, 0, FLAG_SAVE); } printf("The boot record of %s has%s been updated.\n", boot, test ? " *NOT*" : ""); } if (extra == X_NONE || (extra == X_AUTO && autocount == 0) ) return; if (extra == X_SPEC) for (pass = 0; pass < nlist; pass++) { int index; if (raid_bios[list_index[pass]] & 0xFF) { index = list_index[pass]; /* within RAID set */ } else { /* not in the RAID set */#ifdef FLAG_RAID_DEFEAT raid_flags |= FLAG_RAID_DEFEAT; /* make outsider invisible */#endif index = lowest; } if (verbose>=3) printf("Specifed partition: %s raid offset = %08X\n", raid_list[pass], raid_offset[index]); if (!test) bsect_raid_update(raid_list[pass], raid_offset[index], cp, force, 1, mask); printf("The boot record of %s has%s been updated.\n", raid_list[pass], (test ? " *NOT*" : ""));#ifdef FLAG_RAID_DEFEAT raid_flags &= ~FLAG_RAID_DEFEAT; /* restore DEFEAT flag to 0 */#endif } else { /* extra = X_AUTO or X_MBR*/ for (pass = 0; pass < ndisk; pass++) { if (!(raid_bios[pass] & IS_COVERED)) { if ((raid_bios[pass] & 0xFF) != 0x80 || extra == X_MBR) { if (!test) bsect_raid_update(raid_mbr[pass], raid_offset[pass], cp, force, 1, mask); printf("The Master boot record of %s has%s been updated.\n", raid_mbr[pass], (test ? " *NOT*" : "")); } else if (!nowarn) { fprintf(errstd, "Warning: %splicit AUTO does not allow updating the Master Boot Record\n" " of '%s' on BIOS device code 0x80, the System Master Boot Record.\n" " You must explicitly specify updating of this boot sector with\n" " '-x %s' or 'raid-extra-boot = %s' in the\n" " configuration file.\n", cfg_get_strg(cf_options, RAID_EXTRA_BOOT) ? "Ex" : "Im", raid_mbr[pass], raid_mbr[pass], raid_mbr[pass] ); } } } } }#ifdef FLAG_RAID_NOWRITE if (raid_flags & FLAG_RAID_NOWRITE) { if (!nowarn) { fprintf(errstd, "Warning: FLAG_RAID_NOWRITE has been set.\n"); if (verbose >= 1) fprintf(errstd, " The boot loader will be unable to update the stored command line;\n" " 'lock' and 'fallback' are not operable; the 'lilo -R' boot command\n" " line will be locked.\n\n"); } }#endif}/* form the mask of the raid bios codes and the list of offsets *//* this information goes into the MENUTABLE passed to the loader */int raid_mask(int *offsets){ int mask = 0; int i, j; int offset[MAX_BIOS_DEVICES]; if (ndisk > MAX_RAID_DEVICES) die("More than %d active RAID1 disks", MAX_RAID_DEVICES); memset(offset, 0, sizeof(offset)); for (i=0; i<ndisk; i++) { offset[j = raid_bios[i] & (DEV_MASK & 0x7F) ] = raid_offset[i]; mask |= 1<<j; } for (i=0; i<nelem(offset); i++) { if ( (mask>>i) & 1 ) *offsets++ = offset[i]; if (do_md_install && verbose>=3) printf("RAID offset entry %d 0x%08X\n", offset[i], offset[i]); } if (verbose>=2) printf("RAID device mask 0x%04X\n", mask); return mask;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -