diff --git a/sbin/sysinstall/bootarea.c b/sbin/sysinstall/bootarea.c index 87eca3e145ae..a8bab7f511cc 100644 --- a/sbin/sysinstall/bootarea.c +++ b/sbin/sysinstall/bootarea.c @@ -54,11 +54,11 @@ disable_label(int fd) int write_bootblocks(int fd, off_t offset, int bbsize) { - if (ioctl(fd, DIOCSDINFO, &avail_disklabels[inst_disk]) < 0 && - errno != ENODEV && errno != ENOTTY) { - sprintf(errmsg, "Failed to change in-core disklabel\n"); + if (ioctl(fd, DIOCWDINFO, &avail_disklabels[inst_disk]) < 0) { + Fatal("Failed to write disklabel: %s\n", strerror(errno)); return(-1); } + return(0); if (lseek(fd, (offset * avail_disklabels[inst_disk].d_secsize), SEEK_SET) < 0) { sprintf(errmsg, "Couldn't seek to start of partition\n"); @@ -69,7 +69,10 @@ write_bootblocks(int fd, off_t offset, int bbsize) return(-1); if (write(fd, bootblocks, bbsize) != bbsize) { - sprintf(errmsg, "Failed to write bootblocks\n"); + sprintf(errmsg, "Failed to write bootblocks (%p) %d %s\n", + bootblocks, + errno, strerror(errno) + ); return(-1); } diff --git a/sbin/sysinstall/exec.c b/sbin/sysinstall/exec.c index cbe9b744af31..d1ec7f515306 100644 --- a/sbin/sysinstall/exec.c +++ b/sbin/sysinstall/exec.c @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: exec.c,v 1.2 1994/10/21 05:36:42 phk Exp $ + * $Id: exec.c,v 1.4 1994/10/26 05:40:59 phk Exp $ * */ @@ -52,14 +52,17 @@ exec(int magic, char *cmd, char *args, ...) if ((pid = fork()) == 0) { switch (magic) { case 0: - close(0); open("/dev/null",O_RDONLY); - close(1); open("/dev/null",O_WRONLY); - close(2); open("/dev/null",O_WRONLY); + close(0); dup(debug_fd); + close(1); dup(debug_fd); + close(2); dup(debug_fd); + close(debug_fd); break; case 1: - close(2); open("/dev/null",O_WRONLY); + close(2); dup(debug_fd); + close(debug_fd); break; case 2: + close(debug_fd); default: break; } diff --git a/sbin/sysinstall/label.c b/sbin/sysinstall/label.c index 07ab4bbb0e86..2fb45e6eb7af 100644 --- a/sbin/sysinstall/label.c +++ b/sbin/sysinstall/label.c @@ -418,13 +418,22 @@ build_disklabel(struct disklabel *lbl) nsects = Mbtosects(atoi(label_fields[i][UPARTSIZES].field), lbl->d_secsize); nsects = rndtocylbdry(nsects, lbl->d_secpercyl); - offset = rndtocylbdry(offset, lbl->d_secpercyl); - lbl->d_partitions[i].p_size = nsects; - lbl->d_partitions[i].p_offset = offset; - offset += nsects; - total_sects += nsects; - lbl->d_partitions[i].p_fstype = - getfstype(label_fields[i][FSTYPE].field); + if(nsects) { + offset = rndtocylbdry(offset, lbl->d_secpercyl); + lbl->d_partitions[i].p_size = nsects; + lbl->d_partitions[i].p_offset = offset; + Debug("Part%d: %d sects, %d offset, %d end", + i,nsects,offset,nsects+offset); + offset += nsects; + total_sects += nsects; + lbl->d_partitions[i].p_fstype = + getfstype(label_fields[i][FSTYPE].field); + lbl->d_npartitions = i+1; + } else { + lbl->d_partitions[i].p_size = 0; + lbl->d_partitions[i].p_offset = 0; + lbl->d_partitions[i].p_fstype = 0; + } } } } diff --git a/sbin/sysinstall/main.c b/sbin/sysinstall/main.c index 20b3b940f571..046b9b3cb4d6 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.7 1994/10/24 03:30:55 paul Exp $ + * $Id: main.c,v 1.8 1994/10/26 02:53:09 phk Exp $ * */ @@ -73,11 +73,12 @@ main(int argc, char **argv) close(0); open("/dev/console",O_RDWR); close(1); dup(0); close(2); dup(0); + printf("sysinstall running as init\n\r"); i = 1; ioctl(0,TIOCSPGRP,&i); setlogin("root"); } - + debug_fd = open("/dev/ttyv1",O_WRONLY); if (set_termcap() == -1) { Fatal("Can't find terminal entry\n"); } diff --git a/sbin/sysinstall/stage0.c b/sbin/sysinstall/stage0.c index c68045d7223a..fee3dfd8f9cb 100644 --- a/sbin/sysinstall/stage0.c +++ b/sbin/sysinstall/stage0.c @@ -32,10 +32,17 @@ static char *welcome[] = { "Exit to shell.", }; -void stage0() +void +stage0() { int valid = 0; + if (!access(README_FILE, R_OK)) { + dialog_clear(); + dialog_textbox("READ ME FIRST", README_FILE, 24, 80); + } + return; + do { if (!dialog_menu("Welcome to FreeBSD!", "Please select one of the following options.\n", diff --git a/sbin/sysinstall/stage1.c b/sbin/sysinstall/stage1.c index 0e0ac97d7edb..b842a92253a6 100644 --- a/sbin/sysinstall/stage1.c +++ b/sbin/sysinstall/stage1.c @@ -305,6 +305,7 @@ stage1() dialog_msgbox(TITLE, "This is an experimental disklabel configuration\nmenu. It doesn't perform any validation of the entries\nas yet so BE SURE YOU TYPE THINGS CORRECTLY.\n\n Hit escape to quit the editor.\n\nThere may be some delay exiting because of a dialog bug", 20,70,1); dialog_clear(); edit_disklabel(&avail_disklabels[inst_disk]); + build_disklabel(&avail_disklabels[inst_disk]); if (build_bootblocks(&avail_disklabels[inst_disk]) == -1) Fatal(errmsg); diff --git a/sbin/sysinstall/stage4.c b/sbin/sysinstall/stage4.c index 1e962438c674..7d3383bf16c9 100644 --- a/sbin/sysinstall/stage4.c +++ b/sbin/sysinstall/stage4.c @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: stage3.c,v 1.4 1994/10/21 02:14:52 phk Exp $ + * $Id: stage4.c,v 1.2 1994/10/26 05:41:01 phk Exp $ * */ @@ -60,7 +60,7 @@ stage4() close(pfd[1]); close(1); open("/dev/null",O_WRONLY); chdir("/stand"); - i = exec (1,"/stand/cpio","/stand/cpio","-idum", 0); + i = exec (1,"/stand/cpio","/stand/cpio","-iduvm", 0); exit(i); } close(pfd[0]); diff --git a/sbin/sysinstall/stage5.c b/sbin/sysinstall/stage5.c index cc4e971d30e6..3166190554dc 100644 --- a/sbin/sysinstall/stage5.c +++ b/sbin/sysinstall/stage5.c @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: stage3.c,v 1.4 1994/10/21 02:14:52 phk Exp $ + * $Id: stage5.c,v 1.2 1994/10/26 05:41:02 phk Exp $ * */ @@ -29,6 +29,7 @@ stage5() { end_dialog(); dialog_active=0; + setenv("PATH","/stand",1); for(;;) exec (2,"/stand/sh","/stand/-sh", 0); } diff --git a/sbin/sysinstall/sysinstall.h b/sbin/sysinstall/sysinstall.h index f3f3f20e73ff..ebfadb659269 100644 --- a/sbin/sysinstall/sysinstall.h +++ b/sbin/sysinstall/sysinstall.h @@ -17,9 +17,6 @@ #define BOOT1 "/stand/sdboot" #define BOOT2 "/stand/bootsd" -#define BOOT1 "/stand/sdboot" -#define BOOT2 "/stand/bootsd" - #define MAXFS 25 #define MAX_NO_DISKS 10 @@ -45,6 +42,7 @@ EXTERN char *devicename[MAXFS+1]; EXTERN char *mountpoint[MAXFS+1]; EXTERN int dialog_active; EXTERN char selection[]; +EXTERN int debug_fd; extern unsigned char **avail_disknames; extern int no_disks; @@ -57,9 +55,10 @@ extern struct disklabel *avail_disklabels; extern u_short dkcksum(struct disklabel *); /* utils.c */ -void Abort __P((void)); -void ExitSysinstall __P((void)); +void Abort __P((void)); +void ExitSysinstall __P((void)); void TellEm __P((char *fmt, ...)); +void Debug __P((char *fmt, ...)); void stage0 __P((void)); void *Malloc __P((size_t size)); char *StrAlloc __P((char *str)); diff --git a/sbin/sysinstall/termcap.c b/sbin/sysinstall/termcap.c index 676639992cd2..2091d5fccfe4 100644 --- a/sbin/sysinstall/termcap.c +++ b/sbin/sysinstall/termcap.c @@ -70,7 +70,7 @@ set_termcap() if (access("/etc/termcap.small",R_OK)) { no_termcap = 1; } else if (setenv("TERMCAP", "/etc/termcap.small", 1) < 0) - return -1; + no_termcap = 1; if (ioctl(STDERR_FILENO, GIO_COLOR, &color_display) < 0) { char buf[64]; diff --git a/sbin/sysinstall/utils.c b/sbin/sysinstall/utils.c index d81dfd7bd78e..4e61f6c49787 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.11 1994/10/24 03:55:25 ache Exp $ + * $Id: utils.c,v 1.12 1994/10/26 02:53:15 phk Exp $ * */ @@ -28,6 +28,21 @@ #include "sysinstall.h" +void +Debug(char *fmt, ...) +{ + char *p; + va_list ap; + p = Malloc(2048); + va_start(ap,fmt); + vsnprintf(p, 2048, fmt, ap); + va_end(ap); + write(debug_fd,"Debug <",7); + write(debug_fd,p,strlen(p)); + write(debug_fd,">\n\r",3); + free(p); +} + void TellEm(char *fmt, ...) { @@ -37,8 +52,10 @@ TellEm(char *fmt, ...) va_start(ap,fmt); vsnprintf(p, 2048, fmt, ap); va_end(ap); + write(debug_fd,"Progress <",10); + write(debug_fd,p,strlen(p)); + write(debug_fd,">\n\r",3); dialog_msgbox("Progress", p, 3, 75, 0); - dialog_clear(); free(p); }