📄 lilo.c
字号:
break; case 'i': cfg_set(cf_options,"install",param,NULL); break; case 'I': identify = param; if (argc && *argv[1] != '-') { ident_opt = *++argv; argc--; } else { ident_opt = "i"; } break; case 'l': geometric |= AD_LINEAR; break; case 'L': geometric |= AD_LBA32; break;#endif /* !__MSDOS__ */ case 'm': cfg_set(cf_options,"map",param,NULL); break;#if !__MSDOS__ case 'M': instmbr = 1; act1 = param;#if !defined LCF_BUILTIN || 1 if (argc && argv[1][0] != '-') { act2 = *++argv; argc--; }#endif break; case 'p': passw = 1; /* force re-gen of password file */ break; case 'P': if ((act1=strchr(param,'='))) { *act1++ = 0; /* null terminate */ cfg_set(cf_options,param,act1,NULL); } else if (!strcasecmp(param,"fix")) cfg_set(cf_options,"fix-table",NULL,NULL); else if (!strcasecmp(param,"ignore")) cfg_set(cf_options,"ignore-table",NULL,NULL); else if (!strcasecmp(param,"x")) extended_pt = 1; else cfg_set(cf_options,param,NULL,NULL); break;#endif /* !__MSDOS__ */ case 'q': query = 1; break;#if !__MSDOS__ case 'r': new_root = param; break;#endif /* !__MSDOS__ */ case 'R': if (*(param = (*argv)+2)) argc++; else if (argc) param = *++argv; else reboot_arg = ""; while (argc) { if (!reboot_arg) *(reboot_arg = alloc(strlen(param)+1)) = 0; else { param = *++argv; strcat(reboot_arg = ralloc(reboot_arg, strlen(reboot_arg)+strlen(param)+2)," "); } strcat(reboot_arg, param); argc--; }#if 0fprintf(errstd,"REBOOT=\"%s\"\n", reboot_arg); #endif break;#if !__MSDOS__ case 's': cfg_set(cf_options,"backup",param,NULL); break; case 'S': cfg_set(cf_options,"force-backup",param,NULL); break; case 't': test = 1; break; case 'T': tell_param = param; break; case 'u': validate = 1; /* fall through */ case 'U': /* argument to -u or -U is optional */ uninstall = 1; if ((*argv)[2]) param = (*argv)+2; else if (argc && argv[1][0] != '-') { param = *++argv; argc--; } uninst_dev = param; break;#endif /* !__MSDOS__ */ case 'v': if ((*argv)[2]) param = (*argv)+2; else if (argc && argv[1][0]>='0' && argv[1][0]<='9') { param = *++argv; argc--; } if (param) verbose = to_number(param); else if (verbose<0) verbose = 1; else verbose++; if (verbose) errstd = stdout; break; case 'V': version = 1; break;#if !__MSDOS__ case 'w': cfg_set(cf_options,"nowarn",NULL,NULL); nowarn = 1; if ( (*argv)[2] == '+' ) nowarn = -1; break; case 'x': cfg_set(cf_options,RAID_EXTRA_BOOT,param,NULL); break;#endif /* !__MSDOS__ */ case 'X':#if VERSION_MINOR>=50 && !__MSDOS__{ printf( "-DBOOT_PARAMS_1=%d -DBOOT_PARAMS_2=%d PATH_MAX=%d" "\n" , (int)sizeof(BOOT_PARAMS_1), (int)sizeof(BOOT_PARAMS_2), PATH_MAX );}{#include "bitmap.h" RGB pal[16]; RGB2 pal2[16]; printf("\nBMFH=%d BMH=%d BMH2=%d RGB=%d(%d) RGB2=%d(%d) LH=%d\n", (int)sizeof(BITMAPFILEHEADER), (int)sizeof(BITMAPHEADER), (int)sizeof(BITMAPHEADER2), (int)sizeof(RGB), (int)sizeof(pal), (int)sizeof(RGB2), (int)sizeof(pal2), (int)sizeof(BITMAPLILOHEADER) ); printf("\nBPB=%d BP_DOS=%d\n", (int)sizeof(BIOS_PARAMETER_BLOCK), (int)sizeof(BOOT_PARAMS_DOS) );}#ifdef LCF_FIRST6 printf("\nSECTOR_ADDR6=%d\n", (int)sizeof(SECTOR_ADDR6));#endif#endif /* VERSION_MINOR>=50 && !__MSDOS__ */#if !__MSDOS__{ unsigned int j; if (verbose>=5) { if (crc(First.data,First.size)) { j = crc(First.data,First.size-4); brev(j); printf("1=0x%x\n", j); } if (crc(Second.data,Second.size)) { j = crc(Second.data,Second.size-4); brev(j); printf("2=0x%x\n", j); } if (crc(Third.data,Third.size)) { j = crc(Third.data,Third.size-4); brev(j); printf("3=0x%x\n", j); } if (crc(Bitmap.data,Bitmap.size)) { j = crc(Bitmap.data,Bitmap.size-4); brev(j); printf("B=0x%x\n", j); } if (crc(Chain.data,Chain.size)) { j = crc(Chain.data,Chain.size-4); brev(j); printf("C=0x%x\n", j); } if (crc(Mbr.data,Mbr.size)) { j = crc(Mbr.data,Mbr.size-4); brev(j); printf("M=0x%x\n", j); } if (crc(Mbr2.data,Mbr2.size)) { j = crc(Mbr2.data,Mbr2.size-4); brev(j); printf("N=0x%x\n\n", j); } }}#if BETA_TEST{ int i, k=0;extern int has_partitions_beta(dev_t dev); /* defined in geometry.c */ printf("\n"); for (i=0; i<256; i++) { if ( has_partitions_beta(MKDEV(i,0)) != has_partitions(MKDEV(i,0)) ) { printf("Major device = %d is not configured.\n", i); k ++; } } printf("k = %d (should be 0)\n\n", k);}#endif#if VERSION_MINOR>=50{ dev_t dev; int i; BOOT_VOLID x; BOOT_SECTOR b; dev = 0xFFF0; i = dev; printf("dev_t is %ssigned size=%d i=%08X\n", i==0xFFF0 ? "un" : "", (int)sizeof(dev_t), i); printf("size of BOOT_VOLID = %d BOOT_SECTOR = %d\n", (int)sizeof(x), (int)sizeof(b)); printf("Size of MENUTABLE = %d\n", (int)sizeof(MENUTABLE));}#endif printf("\nCFLAGS = " CFLAGS "\n"); printf("\nglibc version %d.%d\n", __GLIBC__, __GLIBC_MINOR__); printf("Kernel Headers included from %d.%d.%d\n", LINUX_VERSION_CODE>>16, LINUX_VERSION_CODE>>8 & 255, LINUX_VERSION_CODE & 255);#endif /* !__MSDOS__ */ printf("\nMAX_IMAGES = %d\t\tc=%d, s=%d, i=%d, " "l=%d, ll=%d, f=%d, d=%d, ld=%d\n\n", MAX_IMAGES, (int)sizeof(char), (int)sizeof(short), (int)sizeof(int), (int)sizeof(long), (int)sizeof(#if !__MSDOS__ long#endif /* !__MSDOS__ */ long), (int)sizeof(float), (int)sizeof(double), (int)sizeof(long double) );#if __MSDOS__ || 1 printf("\nIMAGE_DESCR = %d DESCR_SECTORS = %d\n", (int)sizeof(IMAGE_DESCR), (int)sizeof(DESCR_SECTORS));#endif /* __MSDOS__ */ exit(0);#if !__MSDOS__ case 'z': zflag++; /* force zero of MBR 8-byte area */ break; case 'Z': cfg_set(cf_options,"bios-passes-dl",param,NULL); break;#endif /* !__MSDOS__ */ default: usage(name); } } if (argc) usage(name);#if !__MSDOS__ if (!new_root) new_root = getenv("ROOT"); if (new_root && *new_root) { pp_fd = fopen(PARTITIONS, "r"); if (chroot(new_root) < 0) die("chroot %s: %s",new_root,strerror(errno)); if (chdir("/dev") < 0 && nowarn < 1 ) fprintf(errstd, "Warning: root at %s has no /dev directory\n", new_root); if (chdir("/") < 0) die("chdir /: %s",strerror(errno)); } if (atexit(temp_remove)) die("atexit() failed"); if (version+activate+instmbr+(tell_param!=NULL) > 1) usage(name); if (activate) do_activate(act1, act2);#endif /* !__MSDOS__ */ if (verbose > 0 || version) { printf("LILO version %d.%d%s%s", VERSION_MAJOR, VERSION_MINOR, VERSION_EDIT, test ? " (test mode)" : ""); if (version && verbose<=0) { printf("\n"); return 0; } printf(", Copyright (C) 1992-1998 Werner Almesberger\n" "Development beyond version 21 Copyright (C) 1999-2005 John Coffman\n" ); if (verbose>0) {#if VERSION_MINOR>=50 && !__MSDOS__#include <sys/utsname.h> struct utsname buf;#endif printf("Released %s%s and compiled at %s on %s%s\n", VERSION_DATE, comma ? "," : "", __TIME__, __DATE__, semi);#if VERSION_MINOR>=50 && !__MSDOS__ if (uname(&buf)==0) { printf("Running %s kernel %s\n", buf.sysname, buf.release); }#endif } printf("\n"); if (version) return 0; } if (verbose > 0) errstd = stdout;#if !__MSDOS__ preload_types(); if (geometric & (geometric-1)) die ("Only one of '-g', '-l', or '-L' may be specified"); if (tell_param) tell_early = strcasecmp(tell_param, "chrul") && strcasecmp(tell_param, "ebda"); if (eflag) do_bitmap_edit(bitmap_file); if (tell_param && tell_early) probe_tell(tell_param); if (instmbr) do_install_mbr(act1, act2);#endif /* !__MSDOS__ */ fd = cfg_open(config_file); more = fd<0 ? 0 : cfg_parse(cf_options); #if !__MSDOS__ temp = cfg_get_flag(cf_options,"nowarn");#endif /* !__MSDOS__ */ if (nowarn < 0) nowarn = 0; else nowarn = temp; if (verbose>=6) printf("main: cfg_parse returns %d\n", more);#if !__MSDOS__ if (tell_param && !tell_early) probe_tell(tell_param); if (!nowarn) { if (fstat(fd,&st) < 0) { fprintf(errstd,"fstat %s: %s\n",config_file,strerror(errno)); exit(1); } if (S_ISREG(st.st_mode)) { if (st.st_uid) fprintf(errstd,"Warning: %s should be owned by root\n", config_file); else if (st.st_mode & (S_IWGRP | S_IWOTH)) fprintf(errstd,"Warning: %s should be writable only for " "root\n",config_file); config_read = !!(st.st_mode & (S_IRGRP | S_IROTH)); } } preload_dev_cache(); if (verbose<0 && cfg_get_strg(cf_options,"verbose")) verbose = to_number(cfg_get_strg(cf_options,"verbose")); if (verbose<0) verbose = 0; if (verbose) errstd = stdout; compact = cfg_get_flag(cf_options,"compact"); geom = cfg_get_flag(cf_options,"geometric"); linear = cfg_get_flag(cf_options,"linear"); lba32 = cfg_get_flag(cf_options,"lba32"); if (geom+linear+lba32 > 1) die("May specify only one of GEOMETRIC, LINEAR or LBA32"); if (geometric) { if (!nowarn && (geom+linear+lba32 > 0)) fprintf(errstd,"Ignoring entry '%s'\n", geom ? "geometric" : linear ? "linear" : "lba32"); geom = linear = lba32 = 0; if (geometric==AD_LBA32) lba32 = 1; else if (geometric==AD_LINEAR) linear = 1; else if (geometric==AD_GEOMETRIC) geom = 1; } if (geom+linear+lba32 == 0) { if (!nowarn && verbose) fprintf(errstd,"Warning: LBA32 addressing assumed\n"); lba32 = 1; } if (linear && !nowarn) fprintf(errstd, "\nWarning: LINEAR is deprecated in favor of LBA32: LINEAR specifies 24-bit\n" " disk addresses below the 1024 cylinder limit; LBA32 specifies 32-bit disk\n" " addresses not subject to cylinder limits on systems with EDD bios extensions;\n" " use LINEAR only if you are aware of its limitations.\n\n"); if (identify) identify_image(identify,ident_opt); if (uninstall) bsect_uninstall(uninst_dev ? uninst_dev : cfg_get_strg(cf_options, "boot"),cfg_get_strg(cf_options,"backup"),validate);#endif /* !__MSDOS__ */ if (reboot_arg) { map_patch_first(cfg_get_strg(cf_options,"map") ? cfg_get_strg( cf_options,"map") : MAP_FILE, reboot_arg); exit(0); }#if !__MSDOS__ if ( (param = cfg_get_strg(cf_options,"bios-passes-dl")) ) { if (strchr("YyTt1", *param)) bios_passes_dl = DL_GOOD; if (strchr("NnFf0", *param)) bios_passes_dl = DL_BAD; } if (bios_passes_dl == DL_NOT_SET) check_bios(); /* in probe.c */ if (!nowarn && compact && (linear || lba32) && verbose>=2) fprintf(errstd,"Warning: COMPACT may conflict with %s on some " "systems\n", lba32 ? "LBA32" : "LINEAR"); geo_init(cfg_get_strg(cf_options,"disktab"));#endif /* !__MSDOS__ */ if (query) show_images(!cfg_get_strg(cf_options,"map") ? MAP_FILE : cfg_get_strg(cf_options,"map"));#if !__MSDOS__/*************************************************//* Doing a real install (may be test mode) *//*************************************************//* test for a RAID installation */ raid_offset = raid_setup(); if (verbose >= 2) { printf("raid_setup returns offset = %08X ndisk = %d\n", raid_offset, ndisk); dump_serial_nos(); } if (verbose >=2 && do_md_install) printf("raid flags: at bsect_open 0x%02X\n", raid_flags); bsect_open( cfg_get_strg(cf_options,"boot"), cfg_get_strg(cf_options,"map") ? cfg_get_strg(cf_options,"map") : MAP_FILE, cfg_get_strg(cf_options,"install"), cfg_get_strg(cf_options,"delay") ? timer_number(cfg_get_strg(cf_options,"delay")) : 0, cfg_get_strg(cf_options,"timeout") ? timer_number(cfg_get_strg(cf_options,"timeout")) : -1, raid_offset ); if (more) { cfg_init(cf_top); if (cfg_parse(cf_top)) cfg_error("Syntax error"); } temp = bsect_number(); if (temp==0) die("No images have been defined."); else if (temp<0) die("Default image doesn't exist."); check_fallback(); check_unattended(); if (verbose>=2) dump_serial_nos(); if (do_md_install) raid_final(); else if (!test) { char *cp; if (verbose) printf("Writing boot sector.\n"); cp = cfg_get_strg(cf_options,"force-backup"); if (cp) bsect_update(cp,1,0); else bsect_update(cfg_get_strg(cf_options,"backup"),0,0); } else { bsect_cancel(); if (passw) printf("The password crc file has *NOT* been updated.\n"); printf("The boot sector and the map file have *NOT* been " "altered.\n"); } if (verbose>=4) dump_serial_nos();#else /* __MSDOS__ */ die("No option switches specified: -q, -R, or -V");#endif /* __MSDOS__ */ return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -