diff --git a/sbin/sysinstall/Makefile b/sbin/sysinstall/Makefile index e41878d00444..768cf7413766 100644 --- a/sbin/sysinstall/Makefile +++ b/sbin/sysinstall/Makefile @@ -5,7 +5,7 @@ NOMAN= yet .PATH: ${.CURDIR}/../disklabel SRCS = exec.c dkcksum.c label.c main.c mbr.c \ - stage0.c stage1.c stage2.c stage3.c stage4.c stage5.c \ + stage0.c stage1.c stage2.c stage3.c stage5.c \ termcap.c utils.c makedevs.c ourcurses.c CFLAGS += -Wall -g -static @@ -25,10 +25,13 @@ makedevs.c: dev2c.sh Makefile sh ${.CURDIR}/dev2c.sh dev > makedevs.tmp rm -rf dev uudecode < ${.CURDIR}/bteasy17.uu - file2c 'const char boot0[] = {' '};' < bteasy17 >> makedevs.tmp + file2c 'const unsigned char boot0[] = {' '};' \ + < bteasy17 >> makedevs.tmp rm -rf bteasy17 - file2c 'const char boot1[] = {' '};' < ${BOOTS}/boot1 >> makedevs.tmp - file2c 'const char boot2[] = {' '};' < ${BOOTS}/boot2 >> makedevs.tmp + file2c 'const unsigned char boot1[] = {' '};' \ + < ${BOOTS}/boot1 >> makedevs.tmp + file2c 'const unsigned char boot2[] = {' '};' \ + < ${BOOTS}/boot2 >> makedevs.tmp tset -Q -S cons25 | sed 's/^.* //' | \ file2c 'const char termcap_cons25[] = {' ',0};' \ >> makedevs.tmp diff --git a/sbin/sysinstall/bootarea.c b/sbin/sysinstall/bootarea.c index 73e5f2c376a1..917b65ec0af2 100644 --- a/sbin/sysinstall/bootarea.c +++ b/sbin/sysinstall/bootarea.c @@ -28,8 +28,6 @@ extern char *bootblocks; extern struct mbr *mbr; -extern char boot1[]; -extern char boot2[]; int write_bootblocks(int fd, struct disklabel *lbl) diff --git a/sbin/sysinstall/disk.h b/sbin/sysinstall/disk.h index 1abc904abe3b..f21645a3c551 100644 --- a/sbin/sysinstall/disk.h +++ b/sbin/sysinstall/disk.h @@ -16,9 +16,6 @@ #define MBR_MAGIC 0xAA55 #define ACTIVE 0x80 -#define BOOT1 "/stand/sdboot" -#define BOOT2 "/stand/bootsd" - /* XXX -- calculate these, this is nasty */ #define DEFFSIZE 1024 #define DEFFRAG 8 diff --git a/sbin/sysinstall/main.c b/sbin/sysinstall/main.c index 5e4b8f087de0..d1db0e1c5eab 100644 --- a/sbin/sysinstall/main.c +++ b/sbin/sysinstall/main.c @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: main.c,v 1.19 1995/01/29 02:31:35 phk Exp $ + * $Id: main.c,v 1.20 1995/01/30 03:19:52 phk Exp $ * */ @@ -14,7 +14,6 @@ #include #include #include -#include #include #include @@ -27,15 +26,6 @@ #include "sysinstall.h" -jmp_buf jmp_restart; - -/* - * XXX: utils: Mkdir must do "-p". - * XXX: stage2: do mkdir for msdos-mounts. - * XXX: label: Import dos-slice. - * XXX: mbr: edit geometry - */ - void handle_intr(int sig) { @@ -52,11 +42,22 @@ main(int argc, char **argv) signal(SIGINT, SIG_IGN); /* Are we running as init? */ + cpio_fd = -1; if (getpid() == 1) { setsid(); - close(0); open("/dev/console",O_RDWR); - close(1); dup(0); - close(2); dup(0); + if (argc > 1 && strchr(argv[1],'C')) { + /* Kernel told us that we are on a CDROM root */ + close(0); open("/bootcd/dev/console",O_RDWR); + close(1); dup(0); + close(2); dup(0); + cpio_fd = open("/floppies/cpio.flp",O_RDONLY); + on_cdrom++; + chroot("/bootcd"); + } else { + close(0); open("/dev/console",O_RDWR); + close(1); dup(0); + close(2); dup(0); + } printf("sysinstall running as init\n\r"); ioctl(0,TIOCSCTTY,(char *)NULL); setlogin("root"); @@ -93,7 +94,6 @@ main(int argc, char **argv) reboot(RB_AUTOBOOT); } else { stage3(); - stage4(); stage5(); } return 0; diff --git a/sbin/sysinstall/mbr.c b/sbin/sysinstall/mbr.c index e81993b097fe..03a85a778aa8 100644 --- a/sbin/sysinstall/mbr.c +++ b/sbin/sysinstall/mbr.c @@ -83,7 +83,6 @@ void write_bootcode(int fd) { u_char buf[512]; - extern const char boot0[]; if (lseek(fd, 0, SEEK_SET) == -1) AskAbort("Couldn't seek for master boot record read\n"); @@ -106,8 +105,6 @@ WriteBootblock(int dfd,struct disklabel *label,struct dos_partition *dospart) { off_t of = label->d_partitions[OURPART].p_offset; u_char bootblocks[BBSIZE]; - extern const char boot1[]; - extern const char boot2[]; memcpy(bootblocks, boot1, MBRSIZE); diff --git a/sbin/sysinstall/stage2.c b/sbin/sysinstall/stage2.c index 06d9c4991fd8..09ca34948cfd 100644 --- a/sbin/sysinstall/stage2.c +++ b/sbin/sysinstall/stage2.c @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: stage2.c,v 1.23 1995/02/02 05:35:36 phk Exp $ + * $Id: stage2.c,v 1.24 1995/02/02 05:49:06 jkh Exp $ * */ @@ -24,6 +24,7 @@ #include #include #include +#include #include "sysinstall.h" @@ -34,7 +35,9 @@ stage2() char pbuf[90]; char dbuf[90]; FILE *f1; - int i, j; + int i, j, k; + int ffd, pfd[2]; + int zpid, cpid; memset(Fsize, 0, sizeof Fsize); @@ -82,8 +85,9 @@ stage2() if (!strcmp(Ftype[Fsize[j]], "ufs")) { MountUfs(p, dbuf, 1, 0); continue; - } - Mkdir(dbuf, FALSE); + } else { + Mkdir(dbuf, FALSE); + } } Mkdir("/mnt/etc", TRUE); @@ -152,20 +156,13 @@ stage2() fprintf(f1,"proc\t\t/proc\tprocfs rw 0 0\n"); fclose(f1); -#if 1 -{ -#include - - int ffd, pfd[2]; - int zpid, cpid; - int i,j,k; - j = fork(); if (!j) { chroot("/mnt"); chdir("/"); + ffd = cpio_fd; retry: - while (1) { + while (ffd < 0) { dialog_msgbox(TITLE, "Insert CPIO floppy in floppy drive 0", -1, -1, 1); ffd = open("/dev/rfd0",O_RDONLY); @@ -209,6 +206,7 @@ stage2() /* bininst.sh MUST be the last file on the floppy */ if (access("/stand/OK", R_OK) == -1) { AskAbort("CPIO floppy was bad! Please check media for defects and retry."); + ffd = -1; goto retry; } unlink("/stand/OK"); @@ -217,9 +215,7 @@ stage2() } i = wait(&k); Debug("chroot'er: %d %d %d",i,j,k); -} -#endif sync(); TellEm("Unmount disks"); diff --git a/sbin/sysinstall/sysinstall.h b/sbin/sysinstall/sysinstall.h index 699934fff4e0..c0417d66aaea 100644 --- a/sbin/sysinstall/sysinstall.h +++ b/sbin/sysinstall/sysinstall.h @@ -54,6 +54,10 @@ # define EXTERN extern #endif +extern unsigned char boot0[]; +extern unsigned char boot1[]; +extern unsigned char boot2[]; + /* All this "disk" stuff */ EXTERN int Ndisk; EXTERN struct disklabel *Dlbl[MAX_NO_DISKS]; @@ -76,6 +80,10 @@ EXTERN int debug_fd; EXTERN int dialog_active; EXTERN int fixit; +EXTERN int on_serial; +EXTERN int on_cdrom; +EXTERN int cpio_fd; + extern int no_disks; extern int inst_disk; extern unsigned char *scratch; @@ -118,9 +126,6 @@ void stage2 __P((void)); /* stage3.c */ void stage3 __P((void)); -/* stage4.c */ -void stage4 __P((void)); - /* stage5.c */ void stage5 __P((void)); @@ -137,6 +142,7 @@ void ShowFile __P((char *filename, char *header)); /* mbr.c */ int build_bootblocks __P((int dfd,struct disklabel *label,struct dos_partition *dospart)); void Fdisk __P((void)); +void read_dospart __P((int, struct dos_partition *)); /* label.c */ void DiskLabel __P((void)); diff --git a/sbin/sysinstall/termcap.c b/sbin/sysinstall/termcap.c index 80f538a46706..bd1e0863d2e5 100644 --- a/sbin/sysinstall/termcap.c +++ b/sbin/sysinstall/termcap.c @@ -39,6 +39,7 @@ set_termcap() if (setenv("TERMCAP", termcap_vt100, 1) < 0) return -1; debug_fd = dup(1); + on_serial++; } else if (color_display) { if (setenv("TERM", "cons25", 1) < 0) return -1; diff --git a/sbin/sysinstall/utils.c b/sbin/sysinstall/utils.c index b92f05f34b8e..243b1912ca74 100644 --- a/sbin/sysinstall/utils.c +++ b/sbin/sysinstall/utils.c @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: utils.c,v 1.34 1994/12/27 23:26:59 jkh Exp $ + * $Id: utils.c,v 1.35 1995/01/14 10:31:29 jkh Exp $ * */ @@ -66,8 +66,10 @@ TellEm(char *fmt, ...) write(debug_fd,"Progress <",10); write(debug_fd,p,strlen(p)); write(debug_fd,">\n\r",3); - dialog_clear_norefresh(); - dialog_msgbox("Progress", p, -1, -1, 0); + if(!on_serial) { + dialog_clear_norefresh(); + dialog_msgbox("Progress", p, -1, -1, 0); + } free(p); } @@ -81,7 +83,7 @@ Fatal(char *fmt, ...) vsnprintf(p, 2048, fmt, ap); va_end(ap); strip_trailing_newlines(p); - if (dialog_active) + if (dialog_active && !on_serial) dialog_msgbox("Fatal", p, -1, -1, 1); else fprintf(stderr, "Fatal -- %s\n", p);