⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lilo.c

📁 linux 的引导程序源码The Microsoft&reg Windows&reg Software Development Kit (SDK) provides the documentation
💻 C
📖 第 1 页 / 共 3 页
字号:
static char *bitmap_file;    int query,more,version,uninstall,validate,activate,instmbr,geom;    struct stat st;    int fd;    long raid_offset;    errstd = stderr;    config_file = DFL_CONFIG;    act1 = act2 = tell_param = 	    reboot_arg = identify = ident_opt = new_root = uninst_dev = NULL;    lowest = do_md_install = zflag =	    query = version = uninstall = validate = activate = instmbr = 0;    verbose = -1;    name = *argv;    argc--;    cfg_init(cf_options);    while (argc && **++argv == '-') {	argc--;      /* first those options with a mandatory parameter */      /* Notably absent are "RuUv" */	if (strchr("AbBCdDEfiImMPrsSTx", ch=(*argv)[1])) {	    if ((*argv)[2]) param = (*argv)+2;	    else {		param = *++argv;		if(argc-- <= 0) usage(name);	    }	} else { 	    param = NULL;	}#if 0fprintf(errstd,"argc=%d, *argv=%s, ch=%c param=%s\n", argc, *argv, ch, param);#endif	switch (ch) {	    case 'A':		activate = 1;		act1 = param;		if (argc && argv[1][0] != '-') {		    act2 = *++argv;		    argc--;		}		break;	    case 'b':		cfg_set(cf_options,"boot",param,NULL);		break;	    case 'B':		cfg_set(cf_options,"bitmap",param,NULL);		break;	    case 'c':		cfg_set(cf_options,"compact",NULL,NULL);		compact = 1;		break;	    case 'C':		config_file = param;		break;	    case 'd':		cfg_set(cf_options,"delay",param,NULL);		break;	    case 'D':		cfg_set(cf_options,"default",param,NULL);		break;	    case 'E':	        eflag=1;	        bitmap_file = param;	        break;	    case 'f':		cfg_set(cf_options,"disktab",param,NULL);		break;	    case 'F':		force_fs=1;		break;	    case 'g':		geometric |= 1;		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 |= 2;		break;	    case 'L':		geometric |= 4;		break;	    case 'm':		cfg_set(cf_options,"map",param,NULL);		break;	    case 'M':		instmbr = 1;		act1 = param;#ifndef LCF_BUILTIN		if (argc && argv[1][0] != '-') {		    act2 = *++argv;		    argc--;		}#endif		break;	    case 'p':		passw = 1;	/* force re-gen of password file */		break;	    case 'P':		if (!strcmp(param,"fix"))		    cfg_set(cf_options,"fix-table",NULL,NULL);		else if (!strcmp(param,"ignore"))		    cfg_set(cf_options,"ignore-table",NULL,NULL);		else usage(name);		break;	    case 'q':		query = 1;		break;	    case 'r':		new_root = param;		break;	    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;	    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;	    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;	    case 'w':		cfg_set(cf_options,"nowarn",NULL,NULL);		nowarn = 1;		break;	    case 'x':		if (!strcmp(param,"none"))		    cfg_set(cf_options,RAID_EXTRA_BOOT,param,NULL);		else if (!strcmp(param,"auto"))		    cfg_set(cf_options,RAID_EXTRA_BOOT,param,NULL);		else if (!strcmp(param,"mbr-only"))		    cfg_set(cf_options,RAID_EXTRA_BOOT,param,NULL);		else		    cfg_set(cf_options,RAID_EXTRA_BOOT,param,NULL);		break;	    case 'X':#ifndef PAR1_PARAMS		printf(		"-DCODE_START_1=%d -DCODE_START_2=%d "		  "\n"		  ,		  sizeof(BOOT_PARAMS_1),		  sizeof(BOOT_PARAMS_2)		     );#if 1{#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",	sizeof(BITMAPFILEHEADER),	sizeof(BITMAPHEADER),	sizeof(BITMAPHEADER2),	sizeof(RGB),	sizeof(pal),	sizeof(RGB2),	sizeof(pal2),	sizeof(BITMAPLILOHEADER) );	printf("\nBPB=%d BP_DOS=%d\n",		sizeof(BIOS_PARAMETER_BLOCK),		sizeof(BOOT_PARAMS_DOS)		  );}#endif#endif		printf("\nCFLAGS = " CFLAGS "\n");		printf("\nMAX_IMAGES = %d\n", MAX_IMAGES);		exit(0);	    case 'z':		zflag++;	/* force zero of MBR 8-byte area */		break;	    default:		usage(name);	}    }    if (argc) usage(name);    if (!new_root) new_root = getenv("ROOT");    if (new_root && *new_root) {	if (chroot(new_root) < 0) die("chroot %s: %s",new_root,strerror(errno));	if (chdir("/dev") < 0 && !nowarn)	    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);    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-2002 John Coffman\n"	       );        if (verbose>0) printf("Released %s and compiled at %s on %s.\n",	        VERSION_DATE, __TIME__, __DATE__);#if 0 && defined(LCF_DSECS)	printf("MAX_IMAGES = %d\n", MAX_IMAGES);#endif        printf("\n");        if (version) return 0;    }    preload_types();    if (geometric & (geometric-1))	die ("Only one of '-g', '-l', or '-L' may be specified");    if (verbose > 0) errstd = stdout;    if (eflag) do_bitmap_edit(bitmap_file);    fd = cfg_open(config_file);    more = cfg_parse(cf_options);    if (verbose>=6) printf("main: cfg_parse returns %d\n", more);    if (tell_param) probe_tell(tell_param);    if (instmbr) do_install_mbr(act1, act2);        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);#if 0		else {		    char *p = cfg_get_strg(cf_all,"password");		    char *pp = cfg_get_strg(cf_options,"password");		    		    if ( ((p && *p) || (pp && *pp))  &&			     (st.st_mode & (S_IRGRP | S_IROTH)) )			fprintf(errstd,"Warning: %s should be readable only "			  "for root if using PASSWORD\n",config_file);		}#else	    config_read = !!(st.st_mode & (S_IRGRP | S_IROTH));#endif	}    }    preload_dev_cache();        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");    nowarn = cfg_get_flag(cf_options,"nowarn");    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==4) lba32 = 1;	else if (geometric==2) linear = 1;	else if (geometric==1) geom = 1;    }    #ifdef LCF_LBA32    if (geom+linear+lba32 == 0) {	if (!nowarn) fprintf(errstd,"Warning: LBA32 addressing assumed\n");	lba32 = 1;    }#endif    if (linear && !nowarn) fprintf(errstd,    	"Warning:  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");    if (verbose<0 && cfg_get_strg(cf_options,"verbose"))	verbose = to_number(cfg_get_strg(cf_options,"verbose"));    if (verbose<0) verbose = 0;        if (identify) identify_image(identify,ident_opt);/* test for a RAID installation */    raid_offset = raid_setup();    if (verbose >= 2)        printf("raid_setup returns offset = %08lX  ndisk = %d\n", raid_offset, ndisk);	    	if (uninstall)	    bsect_uninstall(uninst_dev ? uninst_dev : cfg_get_strg(cf_options,	      "boot"),cfg_get_strg(cf_options,"backup"),validate);	if (!nowarn && compact && (linear || lba32))	    fprintf(errstd,"Warning: COMPACT may conflict with %s on some "		"systems\n", lba32 ? "LBA32" : "LINEAR");	if (reboot_arg) {	    map_patch_first(cfg_get_strg(cf_options,"map") ? cfg_get_strg(	      cf_options,"map") : MAP_FILE, reboot_arg);	    sync();	    exit(0);	}	if (argc) usage(name);	geo_init(cfg_get_strg(cf_options,"disktab"));	if (query)	    show_images(!cfg_get_strg(cf_options,"map") ? MAP_FILE :	      cfg_get_strg(cf_options,"map"));	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") ?			to_number(cfg_get_strg(cf_options,"delay")) : 0,		cfg_get_strg(cf_options,"timeout") ?			to_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");	}	if (!bsect_number())	    die("No images have been defined or default image doesn't exist.");	check_fallback();		if (do_md_install) raid_final();	else if (!test)	    if (cfg_get_strg(cf_options,"force-backup"))		bsect_update(cfg_get_strg(cf_options,"force-backup"),1,0);	    else bsect_update(cfg_get_strg(cf_options,"backup"),0,0);	else {	    bsect_cancel();	    if (passw)	        fprintf(errstd,"The password crc file has *NOT* been updated.\n");	    fprintf(errstd,"The boot sector and the map file have *NOT* been "	      "altered.\n");	}	    return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -