1 /* lilo.c - LILO command-line parameter processing
3 * Copyright 1992-1998 Werner Almesberger
4 * Copyright 1999-2007 John Coffman
5 * Copyright 2009-2014 Joachim Wiedorn
8 * Licensed under the terms contained in the file 'COPYING'
9 * in the source directory.
23 /*#include <asm/page.h>*/
36 #endif /* !__MSDOS__ */
41 #include "partition.h"
47 #endif /* !__MSDOS__ */
50 char *config_file; /* actual name of the config file */
51 int config_read; /* readable by other than root */
54 static void configuration(void)
56 #if VERSION_MINOR>=50 && !__MSDOS__
59 "-DBOOT_PARAMS_1=%d -DBOOT_PARAMS_2=%d PATH_MAX=%d"
62 (int)sizeof(BOOT_PARAMS_1),
63 (int)sizeof(BOOT_PARAMS_2),
72 printf("\nBMFH=%d BMH=%d BMH2=%d RGB=%d(%d) RGB2=%d(%d) LH=%d\n",
73 (int)sizeof(BITMAPFILEHEADER),
74 (int)sizeof(BITMAPHEADER),
75 (int)sizeof(BITMAPHEADER2),
80 (int)sizeof(BITMAPLILOHEADER) );
81 printf("\nBPB=%d BP_DOS=%d\n",
82 (int)sizeof(BIOS_PARAMETER_BLOCK),
83 (int)sizeof(BOOT_PARAMS_DOS)
87 printf("\nSECTOR_ADDR6=%d\n", (int)sizeof(SECTOR_ADDR6));
90 #endif /* VERSION_MINOR>=50 && !__MSDOS__ */
96 if (crc(First.data,First.size)) {
97 j = crc(First.data,First.size-4);
99 printf("1=0x%x\n", j);
101 if (crc(Second.data,Second.size)) {
102 j = crc(Second.data,Second.size-4);
104 printf("2=0x%x\n", j);
106 if (crc(Third.data,Third.size)) {
107 j = crc(Third.data,Third.size-4);
109 printf("3=0x%x\n", j);
111 if (crc(Bitmap.data,Bitmap.size)) {
112 j = crc(Bitmap.data,Bitmap.size-4);
114 printf("B=0x%x\n", j);
116 if (crc(Chain.data,Chain.size)) {
117 j = crc(Chain.data,Chain.size-4);
119 printf("C=0x%x\n", j);
121 if (crc(Mbr.data,Mbr.size)) {
122 j = crc(Mbr.data,Mbr.size-4);
124 printf("M=0x%x\n", j);
126 if (crc(Mbr2.data,Mbr2.size)) {
127 j = crc(Mbr2.data,Mbr2.size-4);
129 printf("N=0x%x\n\n", j);
137 extern int has_partitions_beta(dev_t dev); /* defined in geometry.c */
141 for (i=0; i<256; i++) {
142 if ( has_partitions_beta(MKDEV(i,0)) != has_partitions(MKDEV(i,0)) ) {
143 printf("Major device = %d is not configured.\n", i);
147 printf("%sk = %d (should be 0)\n\n", k?"ERROR: ":"", k);
148 for (i=0, j=0; i<40960; i+=17) {
151 for (k=0; k<81920; k+=19) {
155 if (major != i || minor != k) {
156 printf("ERROR: (%d,%d) -> (%d,%d)\n",
162 if (j==0) printf("MKDEV check passed\n");
166 #if VERSION_MINOR>=50
173 printf("dev_t is %ssigned size=%d i=%08X\n", i==0xFFF0 ? "un" : "", (int)sizeof(dev_t), i);
174 printf("size of BOOT_VOLID = %d BOOT_SECTOR = %d\n", (int)sizeof(x), (int)sizeof(b));
175 printf("Size of MENUTABLE = %d\n", (int)sizeof(MENUTABLE));
178 printf("\nCFLAGS = " CFLAGS "\n");
179 #if defined(LCF_DEVMAPPER) && defined(HAS_LIBDEVMAPPER_H)
184 printf(" device-mapper\n");
185 printf("\nglibc version %d.%d\n", __GLIBC__, __GLIBC_MINOR__);
186 printf("Kernel Headers included from %d.%d.%d\n",
187 LINUX_VERSION_CODE>>16,
188 LINUX_VERSION_CODE>>8 & 255,
189 LINUX_VERSION_CODE & 255);
190 printf("Maximum Major Device = %d\n", MAJOR(~0UL));
191 #endif /* !__MSDOS__ */
192 printf("MAX_IMAGES = %d\t\tc=%d, s=%d, i=%d, "
193 "l=%d, ll=%d, f=%d, d=%d, ld=%d\n",
194 MAX_IMAGES, (int)sizeof(char),
195 (int)sizeof(short), (int)sizeof(int),
196 (int)sizeof(long), (int)sizeof(
199 #endif /* !__MSDOS__ */
201 (int)sizeof(float), (int)sizeof(double),
202 (int)sizeof(long double)
204 printf("IMAGE_DESCR = %d DESCR_SECTORS = %d\n\n",
205 (int)sizeof(IMAGE_DESCR), (int)sizeof(DESCR_SECTORS));
210 static void show_other(int fd)
212 BOOT_SECTOR buf[SETUPSECS-1];
213 const unsigned char *drvmap;
214 const unsigned char *prtmap;
216 if (read(fd,buf,sizeof(buf)) != sizeof(buf))
217 die("Read on map file failed (access conflict ?) 1");
218 if (!strncmp(buf[0].par_c.signature-4,"LILO",4)) {
219 printf(" Pre-21 signature (0x%02x,0x%02x,0x%02x,0x%02x)\n",
220 buf[0].par_c.signature[0],buf[0].par_c.signature[1],
221 buf[0].par_c.signature[2],buf[0].par_c.signature[3]);
224 if (strncmp(buf[0].par_c.signature,"LILO",4)) {
225 printf(" Bad signature (0x%02x,0x%02x,0x%02x,0x%02x)\n",
226 buf[0].par_c.signature[0],buf[0].par_c.signature[1],
227 buf[0].par_c.signature[2],buf[0].par_c.signature[3]);
230 drvmap = ((unsigned char *) buf+buf[0].par_c.drvmap);
231 prtmap = drvmap+2*(DRVMAP_SIZE+1);
232 while (drvmap[0] && drvmap[1]) {
233 if (drvmap[0]==0xFF && drvmap[1]==0xFF) {
234 if (drvmap[3]==0xFF) printf(" Master-Boot: This BIOS drive will always appear as 0x80 (or 0x00)\n");
235 else printf(" Boot-As: This BIOS drive will always appear as 0x%02X\n", drvmap[3]);
238 printf(" BIOS drive 0x%02X is mapped to 0x%02X\n",drvmap[0],
243 /* fix VERY old bug -- offset of 0 in PT is okay */
244 while (prtmap[0] /*** && prtmap[1] ***/ ) {
245 printf(" BIOS drive 0x%02x, offset 0x%x: 0x%02x -> 0x%02x\n",
246 prtmap[0],prtmap[1]+PART_TABLE_OFFSET,prtmap[2],prtmap[3]);
250 #endif /* !__MSDOS__ */
252 static void show_images(char *map_file)
255 DESCR_SECTORS descrs;
258 BOOT_PARAMS_2 param2;
261 char buffer[SECTOR_SIZE];
263 static DESCR_SECTORS descrs;
264 static char buffer[SECTOR_SIZE];
265 #endif /*__MSDOS__ */
270 unsigned short flags;
274 fd = geo_open(&geo,map_file,O_RDONLY);
275 #else /* __MSDOS__ */
276 if ((fd = open(map_file,O_RDONLY))<=0)
277 die("Cannot open map file: %s", map_file);
278 #endif /* __MSDOS__ */
279 if (read(fd,buffer,SECTOR_SIZE) != SECTOR_SIZE)
280 die("read cmdline %s: %s",map_file,strerror(errno));
281 if (read(fd,(char*)&descrs,sizeof(descrs)) != sizeof(descrs))
282 die("read descrs %s: %s",map_file,strerror(errno));
284 if (lseek(fd, SECTOR_SIZE, SEEK_CUR) <= 0) /* skip zero sector */
285 die("lseek over zero sector %s: %s",map_file,strerror(errno));
286 if (read(fd,(char*)¶m2,sizeof(param2)) != sizeof(param2))
287 die("read second params %s: %s",map_file,strerror(errno));
288 if (lseek(fd, - sizeof(menu), SEEK_END) <= 0)
289 die("lseek keytable %s: %s",map_file,strerror(errno));
290 if (read(fd,(char*)&menu,sizeof(menu)) != sizeof(menu))
291 die("read keytable %s: %s",map_file,strerror(errno));
292 tlba32 = (descrs.d.descr[0].start.device & LBA32_FLAG) != 0;
293 tlinear = !tlba32 && (descrs.d.descr[0].start.device & LINEAR_FLAG);
294 if (tlinear != linear || tlba32 != lba32) {
295 printf("Warning: mapfile created with %s option\n",
296 tlinear?"linear":tlba32?"lba32":"no linear/lba32");
297 linear = tlinear; lba32 = tlba32;
300 bsect_read(cfg_get_strg(cf_options,"boot"),&boot);
302 if (boot.par_1.cli != 0xFA) { /* relocation happened */
304 if (boot.sector[0] == 0xEB) /* jmp short */
305 offset = boot.sector[1]+2;
306 else if (boot.sector[0] == 0xE9) /* jmp near */
307 offset = *(short*)&boot.sector[1] + 3;
308 else die("Cannot undo boot sector relocation.");
309 len = SECTOR_SIZE - offset;
310 memmove(&boot, &boot.sector[offset], len);
311 if (boot.par_1.cli != 0xFA)
312 die("Cannot recognize boot sector.");
316 Time = boot.par_1.map_stamp;
317 printf("Installed: %s\n", ctime(&Time));
319 printf("Installed: %s\n", ctime((time_t*)&boot.par_1.map_stamp));
321 printf("Global settings:\n");
322 tsecs = (param2.delay*2197+3999)/4000;
323 printf(" Delay before booting: %d.%d seconds\n",tsecs/10,tsecs % 10);
324 if (param2.timeout == 0xffff) printf(" No command-line timeout\n");
326 tsecs = (param2.timeout*2197+3999)/4000;
327 printf(" Command-line timeout: %d.%d seconds\n",tsecs/10,
330 printf(" %snattended booting\n", param2.flag2&FLAG2_UNATTENDED ? "U" : "No u");
331 printf(" %sPC/AT keyboard hardware prescence check\n", param2.flag2&FLAG2_NOKBD ? "" : "No ");
332 if (boot.par_1.prompt & FLAG_PROMPT) printf(" Always enter boot prompt\n");
333 else printf(" Enter boot prompt only on demand\n");
334 printf(" Boot-time BIOS data%s saved\n",
335 boot.par_1.prompt & FLAG_NOBD ? " NOT" : "");
336 printf(" Boot-time BIOS data auto-suppress write%s bypassed\n",
337 boot.par_1.prompt & FLAG_BD_OKAY ? "" : " NOT");
338 printf(" Large memory (>15M) is%s used to load initial ramdisk\n",
339 boot.par_1.prompt & FLAG_LARGEMEM ? "" : " NOT");
340 printf(" %sRAID installation\n",
341 boot.par_1.prompt & FLAG_RAID ? "" : "Non-");
342 printf(" Boot device %s be used for the Map file\n",
343 boot.par_1.prompt & FLAG_MAP_ON_BOOT ? "WILL" : "will not");
344 if (!param2.port) printf(" Serial line access is disabled\n");
345 else printf(" Boot prompt can be accessed from COM%d\n",
347 if (!param2.msg_len) printf(" No message for boot prompt\n");
348 else if (!cfg_get_strg(cf_options,"bitmap"))
349 printf(" Boot prompt message is %d bytes\n",param2.msg_len);
350 else printf(" Bitmap file is %d paragraphs (%d bytes)\n",
351 param2.msg_len, 16*param2.msg_len);
353 if (*(unsigned short *) buffer != DC_MAGIC /* || !buffer[2] */)
355 printf(" No default boot command line\n");
356 else printf(" Default boot command line: \"%s\"\n",buffer+2);
358 printf("Serial numbers %08X\n", menu.serial_no[0]);
363 else /* verbose==0 */
364 #endif /* !__MSDOS__ */
366 if (*(unsigned short *) buffer == DC_MAGIC)
367 printf("Default boot command line: \"%s\"\n",buffer+2);
370 for (image = 0; image < MAX_IMAGES; image++) {
371 if (*(name = descrs.d.descr[image].name)) {
374 #else /* !__MSDOS__ */
375 printf("%s%-" SA(MAX_IMAGE_NAME) "s %s%s%s",verbose > 0 ? " " : "",name,
378 descrs.d.descr[image].flags & FLAG_VMDEFAULT ? "@" :
381 #ifdef LCF_NOKEYBOARD
382 descrs.d.descr[image].flags & FLAG_NOKBDEFAULT ? "&" :
385 #endif /* !__MSDOS__ */
389 if (descrs.d.descr[image].start.device & (LINEAR_FLAG|LBA32_FLAG)) {
391 sector = (descrs.d.descr[image].start.device & LBA32_FLAG)
392 && (descrs.d.descr[image].start.device & LBA32_NOCOUNT)
393 ? descrs.d.descr[image].start.num_sect : 0;
394 sector = (sector<<8)+descrs.d.descr[image].start.head;
395 sector = (sector<<8)+descrs.d.descr[image].start.track;
396 sector = (sector<<8)+descrs.d.descr[image].start.sector;
397 printf(" <dev=0x%02x,%s=%d>",
398 descrs.d.descr[image].start.device&DEV_MASK,
399 descrs.d.descr[image].start.device&LBA32_FLAG ? "lba32" : "linear",
402 else { /* CHS addressing */
403 printf(" <dev=0x%02x,hd=%d,cyl=%d,sct=%d>",
404 descrs.d.descr[image].start.device,
405 descrs.d.descr[image].start.head,
406 descrs.d.descr[image].start.track,
407 descrs.d.descr[image].start.sector);
412 flags = descrs.d.descr[image].flags;
414 if (flags & FLAG_VMDISABLE)
415 printf(" Virtual Boot is disabled\n");
416 if (flags & FLAG_VMWARN)
417 printf(" Warn on Virtual boot\n");
419 #ifdef LCF_NOKEYBOARD
420 if (flags & FLAG_NOKBDISABLE)
421 printf(" NoKeyboard Boot is disabled\n");
423 if ( !(flags & FLAG_PASSWORD) )
424 printf(" No password\n");
425 else printf(" Password is required for %s\n",flags &
426 FLAG_RESTR ? "specifying options" : "booting this image");
427 printf(" Boot command-line %s be locked\n",flags &
428 FLAG_LOCK ? "WILL" : "won't");
429 printf(" %single-key activation\n",flags & FLAG_SINGLE ?
431 if (flags & FLAG_KERNEL) {
433 if (!(flags & FLAG_VGA))
434 printf(" VGA mode is taken from boot image\n");
436 printf(" VGA mode: ");
437 switch (descrs.d.descr[image].vga_mode) {
442 printf("EXTENDED\n");
448 printf("%d (0x%04x)\n",
449 descrs.d.descr[image].vga_mode,
450 descrs.d.descr[image].vga_mode);
454 if (!(flags & FLAG_LOADHI))
455 printf(" Kernel is loaded \"low\"\n");
456 else printf(" Kernel is loaded \"high\"\n");
457 if (!*(unsigned int *) descrs.d.descr[image].rd_size)
458 printf(" No initial RAM disk\n");
459 else printf(" Initial RAM disk is %d bytes\n",
460 *(unsigned int *) descrs.d.descr[image].rd_size);
461 if (flags & FLAG_TOOBIG)
462 printf(" and is too big to fit between 4M-15M\n");
464 if (!geo_find(&geo,descrs.d.descr[image].start)) {
465 printf(" Map sector not found\n");
468 if (read(fd,addr,4*sizeof(SECTOR_ADDR)) !=
469 4*sizeof(SECTOR_ADDR))
470 die("Read on map file failed (access conflict ?) 2");
471 if (!geo_find(&geo,addr[0]))
472 printf(" Fallback sector not found\n");
474 if (read(fd,buffer,SECTOR_SIZE) != SECTOR_SIZE)
475 die("Read on map file failed (access conflict ?) 3");
476 if (*(unsigned short *) buffer != DC_MAGIC)
477 printf(" No fallback\n");
478 else printf(" Fallback: \"%s\"\n",buffer+2);
482 if (flags & FLAG_KERNEL)
484 if (!geo_find(&geo,addr[1]))
485 printf(" Options sector not found\n");
487 if (read(fd,buffer,SECTOR_SIZE) != SECTOR_SIZE)
488 die("Read on map file failed (access conflict ?) 4");
489 if (*buffer) printf(" Options: \"%s\"\n",buffer);
490 else printf(" No options\n");
495 if (!(flags & FLAG_KERNEL)) {
497 if (geo_find(&geo,addr[3])) show_other(fd);
498 else printf(" Image data not found\n");
501 #endif /* !__MSDOS__ */
507 if (descrs.l.checksum ==
508 crc32(descrs.sector, sizeof(descrs.l.sector), CRC_POLY1) )
509 #endif /* !__MSDOS__ */
513 fprintf(errstd,"Checksum error\n");
515 #endif /* !__MSDOS__ */
519 static void usage(char *name)
524 here = strrchr(name,'/');
525 #else /* __MSDOS__ */
526 here = strrchr(name,'\\');
527 #endif /* __MSDOS__ */
528 if (here) name = here+1;
529 fprintf(errstd,"usage: %s [ -C config_file ] -q [ -m map_file ] "
530 "[ -v N | -v ... ]\n",name);
532 fprintf(errstd,"%7s%s [ -C config_file ] [ -b boot_device ] [ -c ] "
533 "[ -g | -l | -L ]\n","",name);
534 fprintf(errstd,"%12s[ -F ] [ -i boot_loader ] [ -m map_file ] [ -d delay ]\n","");
535 fprintf(errstd,"%12s[ -v N | -v ... ] [ -t ] [ -s save_file | -S save_file ]\n",
537 fprintf(errstd,"%12s[ -p ][ -P fix | -P ignore ] [ -r root_dir ] [ -w | -w+ ]\n","");
538 #endif /* !__MSDOS__ */
539 fprintf(errstd,"%7s%s [ -C config_file ] [ -m map_file ] "
540 "-R [ word ... ]\n","",name);
542 fprintf(errstd,"%7s%s [ -C config_file ] -I name [ options ]\n","",name);
543 fprintf(errstd,"%7s%s [ -C config_file ] [ -s save_file ] "
544 "-u | -U [ boot_device ]\n","",name);
545 fprintf(errstd,"%7s%s -H\t\t\t\tinstall only to active discs (RAID-1)\n", "", name);
546 fprintf(errstd,"%7s%s -A /dev/XXX [ N ]\t\tinquire/activate a partition\n","",name);
547 fprintf(errstd,"%7s%s -M /dev/XXX [ mbr | ext ]\tinstall master boot record\n","",name);
548 fprintf(errstd,"%7s%s -T help \t\t\tlist additional options\n", "", name);
549 fprintf(errstd,"%7s%s -X\t\t\t\tinternal compile-time options\n", "", name);
550 #endif /* !__MSDOS__ */
551 fprintf(errstd,"%7s%s -V [ -v ]\t\t\tversion information\n\n","",name);
556 int main(int argc,char **argv)
558 char *name,*reboot_arg,*ident_opt,*new_root;
559 char *tell_param, *uninst_dev, *param, *act1, *act2, ch;
560 static char *bitmap_file;
561 int more,version,uninstall,validate,activate,instmbr,geom;
562 int fd, temp=0, tell_early=0;
566 #endif /* !__MSDOS__ */
569 #if VERSION_MINOR>=50
570 if (sizeof(MENUTABLE)!=256) die("MENUTABLE is not 256 bytes (common.h)");
573 #endif /* !__MSDOS__ */
575 config_file = DFL_CONFIG;
576 act1 = act2 = tell_param =
577 reboot_arg = identify = ident_opt = new_root = uninst_dev = NULL;
578 do_md_install = zflag =
579 version = uninstall = validate = activate = instmbr = 0;
583 #else /* __MSDOS__ */
585 #endif /* __MSDOS__ */
589 if (atexit( (void(*)(void)) sync)) die("atexit(sync)");
590 if (atexit( (void(*)(void)) purge)) die("atexit(purge)");
591 #endif /* !__MSDOS__ */
593 cfg_init(cf_options);
594 while (argc && **++argv == '-') {
596 /* first those options with a mandatory parameter */
597 /* Notably absent are "RuUvw" */
598 if (strchr("AbBCdDEfiImMPrsSTxZ", ch=(*argv)[1])) {
599 if ((*argv)[2]) param = (*argv)+2;
602 if(argc-- <= 0) usage(name);
606 if (strchr("cFglLpqtVXz", ch) /* those with no args */
607 && (*argv)[2]) usage(name);
610 fprintf(errstd,"argc=%d, *argv=%s, ch=%c param=%s\n", argc, *argv, ch, param);
617 if (argc && argv[1][0] != '-') {
623 cfg_set(cf_options,"boot",param,NULL);
626 cfg_set(cf_options,"bitmap",param,NULL);
629 cfg_set(cf_options,"compact",NULL,NULL);
632 #endif /* !__MSDOS */
638 cfg_set(cf_options,"delay",param,NULL);
641 cfg_set(cf_options,"default",param,NULL);
648 cfg_set(cf_options,"disktab",param,NULL);
654 geometric |= AD_GEOMETRIC;
660 cfg_set(cf_options,"install",param,NULL);
664 if (argc && *argv[1] != '-') {
672 geometric |= AD_LINEAR;
675 geometric |= AD_LBA32;
677 #endif /* !__MSDOS__ */
679 cfg_set(cf_options,"map",param,NULL);
685 #if !defined LCF_BUILTIN || 1
686 if (argc && argv[1][0] != '-') {
693 passw = 1; /* force re-gen of password file */
696 if ((act1=strchr(param,'='))) {
697 *act1++ = 0; /* null terminate */
698 cfg_set(cf_options,param,act1,NULL);
700 else if (!strcasecmp(param,"fix"))
701 cfg_set(cf_options,"fix-table",NULL,NULL);
702 else if (!strcasecmp(param,"ignore"))
703 cfg_set(cf_options,"ignore-table",NULL,NULL);
704 else if (!strcasecmp(param,"x"))
707 cfg_set(cf_options,param,NULL,NULL);
709 #endif /* !__MSDOS__ */
717 #endif /* !__MSDOS__ */
719 if (*(param = (*argv)+2)) argc++;
720 else if (argc) param = *++argv;
721 else reboot_arg = "";
725 *(reboot_arg = alloc(strlen(param)+1)) = 0;
728 strcat(reboot_arg = ralloc(reboot_arg,
729 strlen(reboot_arg)+strlen(param)+2)," ");
731 strcat(reboot_arg, param);
735 fprintf(errstd,"REBOOT=\"%s\"\n", reboot_arg);
740 cfg_set(cf_options,"backup",param,NULL);
743 cfg_set(cf_options,"force-backup",param,NULL);
754 case 'U': /* argument to -u or -U is optional */
756 if ((*argv)[2]) param = (*argv)+2;
757 else if (argc && argv[1][0] != '-') {
763 #endif /* !__MSDOS__ */
765 if ((*argv)[2]) param = (*argv)+2;
766 else if (argc && argv[1][0]>='0' && argv[1][0]<='9') {
771 verbose = to_number(param);
773 if (verbose<0) verbose = 1;
775 if (verbose) errstd = stdout;
782 cfg_set(cf_options,"nowarn",NULL,NULL);
784 if ( (*argv)[2] == '+' ) nowarn = -1;
787 cfg_set(cf_options,RAID_EXTRA_BOOT,param,NULL);
789 #endif /* !__MSDOS__ */
795 zflag++; /* force zero of MBR 8-byte area */
798 cfg_set(cf_options,"bios-passes-dl",param,NULL);
800 #endif /* !__MSDOS__ */
805 if (argc) usage(name);
807 if (!new_root) new_root = getenv("ROOT");
808 if (new_root && *new_root) {
809 pp_fd = fopen(PARTITIONS, "r");
810 if (chroot(new_root) < 0) die("chroot %s: %s",new_root,strerror(errno));
811 if (chdir("/dev") < 0)
812 warn("root at %s has no /dev directory", new_root);
813 if (chdir("/") < 0) die("chdir /: %s",strerror(errno));
815 if (atexit(temp_remove)) die("atexit() failed");
816 if (version+activate+instmbr+(tell_param!=NULL) > 1) usage(name);
817 if (activate) do_activate(act1, act2);
818 #endif /* !__MSDOS__ */
820 if (verbose > 0 || version) {
821 printf("LILO version %d.%d%s", VERSION_MAJOR, VERSION_MINOR, VERSION_EDIT);
823 printf(" (test mode)\n");
825 printf(" (released %s)\n", VERSION_DATE);
826 if (version && verbose<=0) {
827 /* exit if user asks for version and no verbose */
830 printf(" * Copyright (C) 1992-1998 Werner Almesberger (until v20)\n"
831 " * Copyright (C) 1999-2007 John Coffman (until v22)\n"
832 " * Copyright (C) 2009-2014 Joachim Wiedorn (since v23)\n"
833 "This program comes with ABSOLUTELY NO WARRANTY. This is free software \n"
834 "distributed under the BSD License (3-clause). Details can be found in \n"
835 "the file COPYING, which is distributed with this software.\n"
839 #include <sys/utsname.h>
842 printf("Compiled at %s on %s%s\n", __TIME__, __DATE__, semi);
844 if (verbose>=2 && uname(&buf)==0) {
845 printf("Running %s kernel %s on %s\n",
846 buf.sysname, buf.release, buf.machine);
852 if (verbose>=2) configuration();
857 if (verbose > 0) errstd = stdout;
860 if (geometric & (geometric-1))
861 die ("Only one of '-g', '-l', or '-L' may be specified");
863 if (tell_param) tell_early = strcasecmp(tell_param, "chrul")
864 && strcasecmp(tell_param, "ebda");
865 if (eflag) do_bitmap_edit(bitmap_file);
866 if (tell_param && tell_early) probe_tell(tell_param);
867 if (instmbr) do_install_mbr(act1, act2);
868 #endif /* !__MSDOS__ */
870 fd = cfg_open(config_file);
871 more = fd<0 ? 0 : cfg_parse(cf_options);
874 temp = cfg_get_flag(cf_options,"nowarn");
875 if (nowarn < 0) nowarn = 0;
877 /* All warnings appear if very verbose modes used */
878 if (verbose>=3) nowarn = 0;
879 #endif /* !__MSDOS__ */
881 if (verbose>=6) printf("main: cfg_parse returns %d\n", more);
884 if (tell_param && !tell_early) probe_tell(tell_param);
886 if (fstat(fd,&st) < 0)
887 die("fstat %s: %s", config_file, strerror(errno) );
889 if (S_ISREG(st.st_mode)) {
891 warn("%s should be owned by root", config_file);
892 else if (st.st_mode & (S_IWGRP | S_IWOTH))
893 warn("%s should be writable only for root", config_file);
894 config_read = !!(st.st_mode & (S_IRGRP | S_IROTH));
897 if (!cfg_get_flag(cf_options,"nodevcache")) preload_dev_cache();
899 if (verbose<0 && cfg_get_strg(cf_options,"verbose"))
900 verbose = to_number(cfg_get_strg(cf_options,"verbose"));
901 if (verbose<0) verbose = 0;
902 if (verbose) errstd = stdout;
904 compact = cfg_get_flag(cf_options,"compact");
905 geom = cfg_get_flag(cf_options,"geometric");
906 linear = cfg_get_flag(cf_options,"linear");
907 lba32 = cfg_get_flag(cf_options,"lba32");
909 if (geom+linear+lba32 > 1)
910 die("May specify only one of GEOMETRIC, LINEAR or LBA32");
912 if (geom+linear+lba32 > 0)
913 warn("Ignoring entry '%s'", geom ? "geometric" :
914 linear ? "linear" : "lba32");
915 geom = linear = lba32 = 0;
916 if (geometric==AD_LBA32) lba32 = 1;
917 else if (geometric==AD_LINEAR) linear = 1;
918 else if (geometric==AD_GEOMETRIC) geom = 1;
920 if (geom+linear+lba32 == 0) {
921 warn("LBA32 addressing assumed");
925 "LINEAR is deprecated in favor of LBA32: LINEAR specifies 24-bit\n"
926 " disk addresses below the 1024 cylinder limit; LBA32 specifies 32-bit disk\n"
927 " addresses not subject to cylinder limits on systems with EDD-BIOS extensions;\n"
928 " use LINEAR only if you are aware of its limitations.");
930 if (identify) identify_image(identify,ident_opt);
933 bsect_uninstall(uninst_dev ? uninst_dev : cfg_get_strg(cf_options,
934 "boot"),cfg_get_strg(cf_options,"backup"),validate);
935 #endif /* !__MSDOS__ */
938 map_patch_first(cfg_get_strg(cf_options,"map") ? cfg_get_strg(
939 cf_options,"map") : MAP_FILE, reboot_arg);
944 if ( (param = cfg_get_strg(cf_options,"bios-passes-dl")) ) {
945 if (strchr("YyTt1", *param)) bios_passes_dl = DL_GOOD;
946 if (strchr("NnFf0", *param)) bios_passes_dl = DL_BAD;
948 if (bios_passes_dl == DL_NOT_SET) check_bios(); /* in probe.c */
950 if (compact && (linear || lba32) && verbose>=4)
951 warn("COMPACT may conflict with %s on some "
952 "systems", lba32 ? "LBA32" : "LINEAR");
954 geo_init(cfg_get_strg(cf_options,"disktab"));
955 #endif /* !__MSDOS__ */
957 show_images(!cfg_get_strg(cf_options,"map") ? MAP_FILE :
958 cfg_get_strg(cf_options,"map"));
961 /*************************************************/
962 /* Doing a real install (may be test mode) */
963 /*************************************************/
965 /* test for a RAID installation */
966 raid_offset = raid_setup();
968 printf("raid_setup returns offset = %08X ndisk = %d\n", raid_offset, ndisk);
972 if (verbose >=2 && do_md_install)
973 printf("raid flags: at bsect_open 0x%02X\n", raid_flags);
976 cfg_get_strg(cf_options,"boot"),
977 cfg_get_strg(cf_options,"map") ?
978 cfg_get_strg(cf_options,"map") : MAP_FILE,
979 cfg_get_strg(cf_options,"install"),
980 cfg_get_strg(cf_options,"delay") ?
981 timer_number(cfg_get_strg(cf_options,"delay")) : 0,
982 cfg_get_strg(cf_options,"timeout") ?
983 timer_number(cfg_get_strg(cf_options,"timeout")) : -1,
987 if (cfg_parse(cf_top)) cfg_error("Syntax error");
990 temp = bsect_number();
991 if (temp==0) die("No images have been defined.");
992 else if (temp<0) die("Default image doesn't exist.");
997 #ifdef LCF_NOKEYBOARD
1003 if (verbose>=2) dump_serial_nos();
1004 if (do_md_install) raid_final();
1008 if (verbose) printf("Writing boot sector.\n");
1010 cp = cfg_get_strg(cf_options,"force-backup");
1011 if (cp) bsect_update(cp,1,0);
1012 else bsect_update(cfg_get_strg(cf_options,"backup"),0,0);
1018 printf("The password crc file has *NOT* been updated.\n");
1020 printf("The boot sector and the map file have *NOT* been "
1023 if (verbose>=4) dump_serial_nos();
1026 printf("%d warnings were ", warnings);
1027 else printf("One warning was ");
1028 printf("%sed.\n", nowarn ? "suppress" : "issu");
1030 #else /* __MSDOS__ */
1031 die("No option switches specified: -q, -R, or -V");
1032 #endif /* __MSDOS__ */