Get stage0 and stage5 working.

Try to reformat this code to be a little more human.  Weird europeans
have been writing this, and can't even seem to agree a single coding
style for more than 4 consecutive lines! :-)
This commit is contained in:
Jordan K. Hubbard 1994-11-02 06:19:53 +00:00
parent c4b01b57f6
commit 0782333682
9 changed files with 464 additions and 424 deletions

View File

@ -24,45 +24,47 @@
#include "sysinstall.h"
static char *welcome[] = {
"View 'READ ME FIRST' File.",
static unsigned char *welcome[] = {
"1. README",
"View `READ ME FIRST' File.",
"2. COPYRIGHT",
"View FreeBSD Copyright Information.",
"3. Proceed",
"Proceed with installation.",
"Repair existing installation ('fixit' mode).",
"4. Fixit",
"Repair existing installation (`fixit' mode).",
"5. Exit",
"Exit to shell.",
};
void bailout(void);
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",
10, 75, 5, 5, welcome, selection))
valid = 1;
dialog_clear();
} while (!valid);
evil_goto:
if (dialog_menu("Welcome to FreeBSD!",
"Please select one of the following options:",
15, 75, 6, 5, welcome, selection)) {
bailout();
}
switch (atoi(selection)) {
case 1: /* View readme */
if (!access(README_FILE, R_OK)) {
dialog_clear();
dialog_textbox("READ ME FIRST", README_FILE, 24, 80);
dialog_clear();
}
goto evil_goto;
break;
case 2: /* View copyrights */
if (!access(COPYRIGHT_FILE, R_OK)) {
dialog_clear();
dialog_textbox("COPYRIGHT", COPYRIGHT_FILE, 24, 80);
dialog_clear();
}
goto evil_goto;
break;
case 3: /* Proceed (do nothing special, really) */
@ -71,10 +73,19 @@ stage0()
case 4:
dialog_msgbox("Sorry!", "This feature not currently implemented.",
6, 75, 1);
goto evil_goto;
break;
case 5:
exit(0);
bailout();
break; /* hope not! :) */
}
}
void
bailout()
{
dialog_clear();
end_dialog();
exit(0);
}

View File

@ -61,73 +61,74 @@ char boot2[] = BOOT2;
int
alloc_memory()
{
int i;
int i;
scratch = (char *) calloc(SCRATCHSIZE, sizeof(char));
if (!scratch)
return(-1);
scratch = (char *) calloc(SCRATCHSIZE, sizeof(char));
if (!scratch)
return(-1);
errmsg = (char *) calloc(ERRMSGSIZE, sizeof(char));
if (!errmsg)
return(-1);
errmsg = (char *) calloc(ERRMSGSIZE, sizeof(char));
if (!errmsg)
return(-1);
avail_disklabels = (struct disklabel *)calloc(MAX_NO_DISKS,
sizeof(struct disklabel));
if (!avail_disklabels)
return(-1);
avail_disklabels = (struct disklabel *) calloc(MAX_NO_DISKS, sizeof(struct disklabel));
if (!avail_disklabels)
return(-1);
avail_fds = (int *)calloc(MAX_NO_DISKS, sizeof(int));
if (!avail_fds)
return(-1);
avail_disknames = (unsigned char **)calloc(MAX_NO_DISKS, sizeof(char *));
if (!avail_disknames)
return(-1);
for (i = 0; i < MAX_NO_DISKS; i++) {
avail_disknames[i] = (char *)calloc(15, sizeof(char));
if (!avail_disknames[i])
return(-1);
}
avail_fds = (int *) calloc(MAX_NO_DISKS, sizeof(int));
if (!avail_fds)
return(-1);
options = (unsigned char **)calloc(MAX_NO_DISKS, sizeof(char *));
if (!options)
return(-1);
for (i = 0; i < MAX_NO_DISKS; i++) {
options[i] = (char *)calloc(100, sizeof(char));
if (!options[i])
return(-1);
}
avail_disknames = (unsigned char **) calloc(MAX_NO_DISKS, sizeof(char *));
if (!avail_disknames)
return(-1);
for (i=0;i<MAX_NO_DISKS;i++) {
avail_disknames[i] = (char *) calloc(15, sizeof(char));
if (!avail_disknames[i])
return(-1);
}
mbr = (struct mbr *) malloc(sizeof(struct mbr));
if (!mbr)
return(-1);
options = (unsigned char **) calloc(MAX_NO_DISKS, sizeof(char *));
if (!options)
return(-1);
for (i=0;i<MAX_NO_DISKS;i++) {
options[i] = (char *) calloc(100, sizeof(char));
if (!options[i])
return(-1);
}
bootblocks = (char *) malloc(BBSIZE);
if (!bootblocks)
return(-1);
mbr = (struct mbr *) malloc(sizeof(struct mbr));
if (!mbr)
return(-1);
bootblocks = (char *) malloc(BBSIZE);
if (!bootblocks)
return(-1);
return(0);
return(0);
}
void
free_memory()
{
int i;
int i;
free(scratch);
free(errmsg);
free(avail_disklabels);
free(avail_fds);
free(scratch);
free(errmsg);
free(avail_disklabels);
free(avail_fds);
for (i=0;i<MAX_NO_DISKS;i++)
free(avail_disknames[i]);
free(avail_disknames);
for (i = 0; i < MAX_NO_DISKS; i++)
free(avail_disknames[i]);
free(avail_disknames);
for (i=0;i<MAX_NO_DISKS;i++)
free(options[i]);
free(options);
for (i = 0; i < MAX_NO_DISKS; i++)
free(options[i]);
free(options);
free(mbr);
free(bootblocks);
free(mbr);
free(bootblocks);
}
@ -143,7 +144,7 @@ query_disks()
struct disklabel dl;
int fd;
for(i=0;i<MAX_NO_DISKS;i++)
for(i = 0; i < MAX_NO_DISKS; i++)
if(Dname[i]) {
close(Dfd[i]); Dfd[i] = 0;
free(Dlbl[i]); Dlbl[i] = 0;
@ -152,10 +153,10 @@ query_disks()
Ndisk = 0;
for (j=0; device_list[j]; j++) {
for (i=0;i<10;i++) {
sprintf(diskname,"%s%d",device_list[j],i);
sprintf(disk,"/dev/r%sd",diskname);
for (j = 0; device_list[j]; j++) {
for (i = 0; i < 10; i++) {
sprintf(diskname, "%s%d", device_list[j], i);
sprintf(disk, "/dev/r%sd", diskname);
if (stat(disk, &st) || !(st.st_mode & S_IFCHR))
continue;
if ((fd = open(disk, O_RDWR)) == -1)
@ -163,10 +164,10 @@ query_disks()
if (ioctl(fd, DIOCGDINFO, &dl) == -1) {
close(fd);
continue;
}
}
Dlbl[Ndisk] = Malloc(sizeof dl);
memcpy(Dlbl[Ndisk], &dl, sizeof dl);
Dname[Ndisk]=StrAlloc(diskname);
Dname[Ndisk] = StrAlloc(diskname);
Dfd[Ndisk] = fd;
Ndisk++;
if(Ndisk == MAX_NO_DISKS)
@ -178,209 +179,213 @@ query_disks()
int
select_disk()
{
int i;
int valid;
int i;
int valid;
do {
valid = 1;
sprintf(scratch,"There are %d disks available for installation: ",no_disks);
do {
valid = 1;
sprintf(scratch,"There are %d disks available for installation: ",
no_disks);
for (i=0;i<no_disks;i++) {
sprintf(options[(i*2)], "%d",i+1);
sprintf(options[(i*2)+1], "%s, (%dMb) -> %s",avail_disklabels[i].d_typename,disk_size(&avail_disklabels[i]),avail_disknames[i]);
}
for (i = 0; i < no_disks; i++) {
sprintf(options[(i*2)], "%d",i+1);
sprintf(options[(i*2)+1], "%s, (%dMb) -> %s",
avail_disklabels[i].d_typename,
disk_size(&avail_disklabels[i]),
avail_disknames[i]);
}
if (dialog_menu("FreeBSD Installation", scratch, 10, 75, 5, no_disks, options, selection)) {
dialog_clear();
sprintf(scratch,"\n\n\nYou did not select a valid disk.\n\n");
AskAbort(scratch);
valid = 0;
}
dialog_clear();
} while (!valid);
return(atoi(selection) - 1);
if (dialog_menu("FreeBSD Installation", scratch, 10, 75, 5, no_disks,
options, selection)) {
dialog_clear();
sprintf(scratch,"\n\n\nYou did not select a valid disk.\n\n");
AskAbort(scratch);
valid = 0;
}
dialog_clear();
} while (!valid);
return(atoi(selection) - 1);
}
int
select_partition(int disk)
{
int valid;
int i;
int choice;
int valid;
int i;
int choice;
do {
valid = 1;
do {
valid = 1;
whole_disk = 0;
sprintf(scratch,"Select one of the following areas to install to:");
sprintf(options[0], "%d", 0);
sprintf(options[1], "%s, (%dMb)", "Install to entire disk",
disk_size(&avail_disklabels[inst_disk]));
for (i=0; i < NDOSPART; i++) {
sprintf(options[(i*2)+2], "%d",i+1);
sprintf(options[(i*2)+3], "%s, (%ldMb)",
part_type(mbr->dospart[i].dp_typ),
mbr->dospart[i].dp_size * 512 / (1024 * 1024));
}
if (dialog_menu(TITLE,
scratch, 10, 75, 5, 5, options, selection)) {
sprintf(scratch,"You did not select a valid partition");
dialog_clear();
AskAbort(scratch);
valid = 0;
}
dialog_clear();
choice = atoi(selection) - 1;
if (choice == -1) {
whole_disk = 1;
choice = 0;
if (dialog_yesno(TITLE, "\n\nInstalling to the whole disk will erase all its current data.\n\nAre you sure you want to do this?", 10, 75)) {
valid = 0;
whole_disk = 0;
sprintf(scratch,"Select one of the following areas to install to:");
sprintf(options[0], "%d", 0);
sprintf(options[1], "%s, (%dMb)", "Install to entire disk",
disk_size(&avail_disklabels[inst_disk]));
for (i=0; i < NDOSPART; i++) {
sprintf(options[(i*2)+2], "%d",i+1);
sprintf(options[(i*2)+3], "%s, (%ldMb)",
part_type(mbr->dospart[i].dp_typ),
mbr->dospart[i].dp_size * 512 / (1024 * 1024));
}
if (dialog_menu(TITLE,
scratch, 10, 75, 5, 5, options, selection)) {
sprintf(scratch,"You did not select a valid partition");
dialog_clear();
AskAbort(scratch);
valid = 0;
}
dialog_clear();
choice = atoi(selection) - 1;
if (choice == -1) {
whole_disk = 1;
choice = 0;
if (dialog_yesno(TITLE, "\n\nInstalling to the whole disk will erase all its current data.\n\nAre you sure you want to do this?", 10, 75)) {
valid = 0;
whole_disk = 0;
}
}
dialog_clear();
} while (!valid);
return(choice);
}
}
dialog_clear();
} while (!valid);
return(choice);
}
void
stage1()
{
int i,j;
int ok = 0;
int ready = 0;
int i,j;
int ok = 0;
int ready = 0;
query_disks();
while (!ready) {
clear(); standend();
j = 0;
mvprintw(j++,0,"%s -- Diskspace editor",TITLE);
j++;
mvprintw(j++,0,"Disks Total FreeBSD ");
j++;
for(i=0;i<MAX_NO_DISKS;i++) {
if(!Dname[i])
continue;
mvprintw(j++,0,"%2d: %-6s %5lu MB %5lu MB",
i,
Dname[i],
PartMb(Dlbl[i],RAWPART),
PartMb(Dlbl[i],OURPART) );
}
j++;
mvprintw(j++,0,"Filesystems Type Size Mountpoint");
j++;
for(i=0;i<MAX_NO_FS;i++) {
if(!Fname[i])
continue;
mvprintw(j++,0,"%2d: %-5s %-5s %5lu MB %-s",
i,Fname[i],Ftype[i],Fsize[i],Fmount[i]);
}
mvprintw(21,0,"Commands available:");
mvprintw(22,0,"(F)disk (D)isklabel (Q)uit");
mvprintw(23,0,"Enter Command> ");
i = getch();
switch(i) {
case 'q': case 'Q':
return;
case 'f': case 'F':
Fdisk();
query_disks();
break;
case 'd': case 'D':
DiskLabel();
break;
default:
beep();
}
query_disks();
while (!ready) {
clear(); standend();
j = 0;
mvprintw(j++, 0, "%s -- Diskspace editor", TITLE);
j++;
mvprintw(j++, 0, "Disks Total FreeBSD ");
j++;
for(i = 0; i < MAX_NO_DISKS; i++) {
if(!Dname[i])
continue;
mvprintw(j++, 0, "%2d: %-6s %5lu MB %5lu MB",
i,
Dname[i],
PartMb(Dlbl[i],RAWPART),
PartMb(Dlbl[i],OURPART));
}
j++;
mvprintw(j++, 0, "Filesystems Type Size Mountpoint");
j++;
for(i = 0; i < MAX_NO_FS; i++) {
if(!Fname[i])
continue;
mvprintw(j++, 0, "%2d: %-5s %-5s %5lu MB %-s",
i, Fname[i], Ftype[i], Fsize[i], Fmount[i]);
}
for (i=0; Dname[i]; i++)
close(Dfd[i]);
return;
mvprintw(21, 0, "Commands available:");
mvprintw(22, 0, "(F)disk (D)isklabel (Q)uit");
mvprintw(23, 0, "Enter Command> ");
i = getch();
switch(i) {
case 'q': case 'Q':
return;
case 'f': case 'F':
Fdisk();
query_disks();
break;
case 'd': case 'D':
DiskLabel();
break;
default:
beep();
}
}
for (i = 0; Dname[i]; i++)
close(Dfd[i]);
return;
}
#if 0
while (!ready) {
ready = 1;
ready = 1;
inst_disk = select_disk();
if (read_mbr(avail_fds[inst_disk], mbr) == -1) {
sprintf(scratch, "The following error occured while trying\nto read the master boot record:\n\n%s\nIn order to install FreeBSD a new master boot record\nwill have to be written which will mean all current\ndata on the hard disk will be lost.", errmsg);
ok = 0;
while (!ok) {
AskAbort(scratch);
if (!dialog_yesno(TITLE, "Are you sure you wish to proceed?",
10, 75)) {
dialog_clear();
if (clear_mbr(mbr, boot1) == -1) {
sprintf(scratch, "\n\nCouldn't create new master boot record.\n\n%s", errmsg);
Fatal(scratch);;
}
ok = 1;
}
dialog_clear();
}
}
if (custom_install)
if (!dialog_yesno(TITLE, "Do you wish to edit the DOS partition table?",
10, 75)) {
dialog_clear();
edit_mbr(mbr, &avail_disklabels[inst_disk]);
}
dialog_clear();
inst_part = select_partition(inst_disk);
inst_disk = select_disk();
if (read_mbr(avail_fds[inst_disk], mbr) == -1) {
sprintf(scratch, "The following error occured while trying\nto read the master boot record:\n\n%s\nIn order to install FreeBSD a new master boot record\nwill have to be written which will mean all current\ndata on the hard disk will be lost.", errmsg);
ok = 0;
while (!ok) {
if (build_mbr(mbr, boot1, &avail_disklabels[inst_disk]) != -1) {
ready = 1;
ok = 1;
} else {
sprintf(scratch, "The DOS partition table is inconsistent.\n\n%s\nDo you wish to edit it by hand?", errmsg);
if (!dialog_yesno(TITLE, scratch, 10, 75)) {
dialog_clear();
edit_mbr(mbr, &avail_disklabels[inst_disk]);
} else {
dialog_clear();
AskAbort("Installation cannot proceed without\na valid master boot record\n");
ok = 1;
ready = 0;
}
while (!ok) {
AskAbort(scratch);
if (!dialog_yesno(TITLE,
"Are you sure you wish to proceed?",
10, 75)) {
dialog_clear();
if (clear_mbr(mbr, boot1) == -1) {
sprintf(scratch, "\n\nCouldn't create new master boot record.\n\n%s", errmsg);
Fatal(scratch);;
}
dialog_clear();
ok = 1;
}
dialog_clear();
}
}
if (custom_install)
if (!dialog_yesno(TITLE, "Do you wish to edit the DOS partition table?",
10, 75)) {
dialog_clear();
edit_mbr(mbr, &avail_disklabels[inst_disk]);
}
if (ready) {
default_disklabel(&avail_disklabels[inst_disk],
mbr->dospart[inst_part].dp_size,
mbr->dospart[inst_part].dp_start);
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]);
dialog_clear();
inst_part = select_partition(inst_disk);
build_disklabel(&avail_disklabels[inst_disk]);
if (build_bootblocks(&avail_disklabels[inst_disk]) == -1)
Fatal(errmsg);
}
/* ready could have been reset above */
if (ready) {
if (dialog_yesno(TITLE, "We are now ready to format the hard disk for FreeBSD.\n\nSome or all of the disk will be overwritten during this process.\n\nAre you sure you wish to proceed ?", 10, 75)) {
dialog_clear();
AskAbort("Do you want to quit?");
ready = 0;
}
ok = 0;
while (!ok) {
if (build_mbr(mbr, boot1, &avail_disklabels[inst_disk]) != -1) {
ready = 1;
ok = 1;
} else {
sprintf(scratch, "The DOS partition table is inconsistent.\n\n%s\nDo you wish to edit it by hand?", errmsg);
if (!dialog_yesno(TITLE, scratch, 10, 75)) {
dialog_clear();
edit_mbr(mbr, &avail_disklabels[inst_disk]);
} else {
dialog_clear();
AskAbort("Installation cannot proceed without\na valid master boot record\n");
ok = 1;
ready = 0;
}
}
dialog_clear();
}
if (ready) {
default_disklabel(&avail_disklabels[inst_disk],
mbr->dospart[inst_part].dp_size,
mbr->dospart[inst_part].dp_start);
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);
}
/* ready could have been reset above */
if (ready) {
if (dialog_yesno(TITLE, "We are now ready to format the hard disk for FreeBSD.\n\nSome or all of the disk will be overwritten during this process.\n\nAre you sure you wish to proceed ?", 10, 75)) {
dialog_clear();
AskAbort("Do you want to quit?");
ready = 0;
}
dialog_clear();
}
}
if(getenv("STAGE0")) {
Fatal("We stop here");
if (getenv("STAGE0")) {
Fatal("We stop here");
}
/* Write master boot record and bootblocks */
if (write_mbr(avail_fds[inst_disk], mbr) == -1)
@ -399,3 +404,4 @@ stage1()
}
}
#endif

View File

@ -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.8 1994/10/26 10:33:36 jkh Exp $
* $Id: stage2.c,v 1.9 1994/11/01 10:10:39 phk Exp $
*
*/
@ -30,29 +30,29 @@
void
stage2()
{
char *p,*q;
char *p, *q;
char pbuf[90];
char dbuf[90];
FILE *f1;
int i,j;
int i, j;
/* Sort in mountpoint order */
memset(Fsize,0,sizeof Fsize);
memset(Fsize, 0, sizeof Fsize);
for(i=1; Fname[i]; i++)
for (i = 1; Fname[i]; i++)
Fsize[i] = i;
for(j=1;j;)
for(j=0,i=1;Fsize[i+1];i++) {
if(strcmp(Fmount[Fsize[i]],Fmount[Fsize[i+1]]) > 0) {
for (j = 1; j;)
for (j = 0, i = 1; Fsize[i+1]; i++) {
if (strcmp(Fmount[Fsize[i]], Fmount[Fsize[i+1]]) > 0) {
j = Fsize[i];
Fsize[i] = Fsize[i+1];
Fsize[i+1] = j;
Fsize[i + 1] = j;
}
}
for(j=1;Fsize[j];j++) {
if(strcmp(Ftype[Fsize[j]],"ufs"))
for (j = 1; Fsize[j]; j++) {
if (strcmp(Ftype[Fsize[j]], "ufs"))
continue;
p = Fname[Fsize[j]];
TellEm("newfs /dev/r%s",p);
@ -63,14 +63,14 @@ stage2()
Fatal("Exec(/stand/newfs) failed, code=%d.",i);
}
for(j=1;Fsize[j];j++) {
if(strcmp(Ftype[Fsize[j]],"ufs"))
for (j = 1; Fsize[j]; j++) {
if (strcmp(Ftype[Fsize[j]], "ufs"))
continue;
strcpy(dbuf,"/mnt");
strcpy(dbuf, "/mnt");
p = Fname[Fsize[j]];
q = Fmount[Fsize[j]];
if(strcmp(q,"/"))
strcat(dbuf,q);
if (strcmp(q, "/"))
strcat(dbuf, q);
MountUfs(p, dbuf, 1, 0);
}
@ -80,13 +80,14 @@ stage2()
Mkdir("/mnt/stand");
CopyFile("/stand/sysinstall","/mnt/stand/sysinstall");
link("/mnt/stand/sysinstall","/mnt/stand/cpio");
link("/mnt/stand/sysinstall","/mnt/stand/gunzip");
link("/mnt/stand/sysinstall","/mnt/stand/gzip");
link("/mnt/stand/sysinstall","/mnt/stand/zcat");
link("/mnt/stand/sysinstall","/mnt/stand/newfs");
link("/mnt/stand/sysinstall","/mnt/stand/fsck");
link("/mnt/stand/sysinstall","/mnt/stand/dialog");
Link("/mnt/stand/sysinstall","/mnt/stand/cpio");
Link("/mnt/stand/sysinstall","/mnt/stand/gunzip");
Link("/mnt/stand/sysinstall","/mnt/stand/gzip");
Link("/mnt/stand/sysinstall","/mnt/stand/zcat");
Link("/mnt/stand/sysinstall","/mnt/stand/newfs");
Link("/mnt/stand/sysinstall","/mnt/stand/fsck");
Link("/mnt/stand/sysinstall","/mnt/stand/dialog");
CopyFile("/kernel","/mnt/kernel");
TellEm("make /dev entries");
chdir("/mnt/dev");
@ -95,16 +96,16 @@ stage2()
TellEm("Making /mnt/etc/fstab");
f1 = fopen("/mnt/etc/fstab","w");
if(!f1)
if (!f1)
Fatal("Couldn't open /mnt/etc/fstab for writing.");
TellEm("Writing filesystems");
for(j=1;Fsize[j];j++) {
if(!strcmp(Ftype[Fsize[j]],"swap"))
fprintf(f1,"/dev/%s\t\tnone\tswap sw 0 0\n",Fname[Fsize[j]]);
for (j = 1; Fsize[j]; j++) {
if (!strcmp(Ftype[Fsize[j]],"swap"))
fprintf(f1, "/dev/%s\t\tnone\tswap sw 0 0\n", Fname[Fsize[j]]);
else
fprintf(f1,"/dev/%s\t\t%s\t%s rw 1 1\n",
Fname[Fsize[j]], Fmount[Fsize[j]], Ftype[Fsize[j]]);
fprintf(f1, "/dev/%s\t\t%s\t%s rw 1 1\n",
Fname[Fsize[j]], Fmount[Fsize[j]], Ftype[Fsize[j]]);
}
TellEm("Writing procfs");
fprintf(f1,"proc\t\t/proc\tprocfs rw 0 0\n");
@ -116,18 +117,18 @@ stage2()
close(i);
TellEm("Unmount disks");
for(j=1;Fsize[j];j++)
for (j = 1; Fsize[j]; j++)
continue;
for(j--;j > 0;j--) {
if(!strcmp(Ftype[Fsize[j]],"swap"))
for (j--; j > 0; j--) {
if (!strcmp(Ftype[Fsize[j]],"swap"))
continue;
strcpy(dbuf,"/mnt");
if(strcmp(Fmount[Fsize[j]],"/"))
strcat(dbuf,Fmount[Fsize[j]]);
TellEm("unmount %s",dbuf);
if (strcmp(Fmount[Fsize[j]],"/"))
strcat(dbuf, Fmount[Fsize[j]]);
TellEm("unmount %s", dbuf);
/* Don't do error-check, we reboot anyway... */
unmount(dbuf, 0);
}
dialog_msgbox(TITLE,"Remove the floppy from the drive, and hit return to reboot from the hard disk",6, 75, 1);
dialog_msgbox(TITLE,"Remove the floppy from the drive and hit return to reboot from the hard disk",6, 75, 1);
}

View File

@ -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: stage3.c,v 1.6 1994/10/26 05:41:01 phk Exp $
*
*/
@ -28,45 +28,45 @@
void
stage3()
{
char pbuf[90],*p;
int mountflags;
struct fstab *fs;
char pbuf[90],*p;
int mountflags;
struct fstab *fs;
/*
* Mount things in /etc/fstab we like.
*/
/*
* Mount things in /etc/fstab we like.
*/
mountflags = MNT_UPDATE;
while((fs = getfsent()) != NULL) {
p = fs->fs_spec;
if (*p++ != '/') continue;
if (*p++ != 'd') continue;
if (*p++ != 'e') continue;
if (*p++ != 'v') continue;
if (*p++ != '/') continue;
mountflags = MNT_UPDATE;
while((fs = getfsent()) != NULL) {
p = fs->fs_spec;
if (*p++ != '/') continue;
if (*p++ != 'd') continue;
if (*p++ != 'e') continue;
if (*p++ != 'v') continue;
if (*p++ != '/') continue;
if (!strcmp(fs->fs_type,"sw")) {
swapon(fs->fs_file);
continue;
}
if (strcmp(fs->fs_vfstype,"ufs")) continue;
if (!strcmp(fs->fs_type,"ro"))
mountflags |= MNT_RDONLY;
else if (!strcmp(fs->fs_type,"rw"))
;
else
continue;
strcpy(pbuf,"/dev/r");
strcat(pbuf,p);
TellEm("fsck -y %s",pbuf);
if (exec(0, "/stand/fsck",
"/stand/fsck", "-y", pbuf, 0) == -1)
Fatal(errmsg);
MountUfs(p,fs->fs_file,0,mountflags);
mountflags = 0;
if (!strcmp(fs->fs_type, "sw")) {
swapon(fs->fs_file);
continue;
}
endfsent();
if (strcmp(fs->fs_vfstype, "ufs")) continue;
if (!strcmp(fs->fs_type, "ro"))
mountflags |= MNT_RDONLY;
else if (!strcmp(fs->fs_type, "rw"))
;
else
continue;
strcpy(pbuf, "/dev/r");
strcat(pbuf,p);
TellEm("fsck -y %s",pbuf);
if (exec(0, "/stand/fsck",
"/stand/fsck", "-y", pbuf, 0) == -1)
Fatal(errmsg);
MountUfs(p, fs->fs_file, 0, mountflags);
mountflags = 0;
}
endfsent();
}

View File

@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
* $Id: stage4.c,v 1.2 1994/10/26 05:41:01 phk Exp $
* $Id: stage4.c,v 1.3 1994/10/29 10:01:37 phk Exp $
*
*/
@ -29,52 +29,52 @@
void
stage4()
{
int ffd,pfd[2];
int zpid,cpid;
int i,j;
int ffd, pfd[2];
int zpid, cpid;
int i,j;
if (access("/stand/need_cpio_floppy",R_OK))
return;
if (access("/stand/need_cpio_floppy",R_OK))
return;
while (1) {
dialog_msgbox(TITLE,
"Insert CPIO floppy in floppy drive 0", 6, 75, 1);
ffd = open("/dev/fd0a",O_RDONLY);
if(ffd > 0)
break;
}
TellEm("cd /stand ; gunzip < /dev/fd0 | cpio -idum");
pipe(pfd);
zpid = fork();
if(!zpid) {
close(0); dup(ffd); close(ffd);
close(1); dup(pfd[1]); close(pfd[1]);
close(pfd[0]);
i = exec (1,"/stand/gunzip","/stand/gunzip", 0);
exit(i);
}
cpid = fork();
if(!cpid) {
close(0); dup(pfd[0]); close(pfd[0]);
close(ffd);
close(pfd[1]);
close(1); open("/dev/null",O_WRONLY);
chdir("/stand");
i = exec (1,"/stand/cpio","/stand/cpio","-iduvm", 0);
exit(i);
}
while (1) {
dialog_msgbox(TITLE,
"Insert CPIO floppy in floppy drive 0", 6, 75, 1);
ffd = open("/dev/fd0a",O_RDONLY);
if (ffd > 0)
break;
}
TellEm("cd /stand ; gunzip < /dev/fd0 | cpio -idum");
pipe(pfd);
zpid = fork();
if (!zpid) {
close(0); dup(ffd); close(ffd);
close(1); dup(pfd[1]); close(pfd[1]);
close(pfd[0]);
close(pfd[1]);
i = exec (1,"/stand/gunzip","/stand/gunzip", 0);
exit(i);
}
cpid = fork();
if (!cpid) {
close(0); dup(pfd[0]); close(pfd[0]);
close(ffd);
i = wait(&j);
if(i < 0 || j)
Fatal("Pid %d, status %d, cpio=%d, gunzip=%d.\nerror:%s",
i,j,cpid,zpid,strerror(errno));
i = wait(&j);
if(i < 0 || j)
Fatal("Pid %d, status %d, cpio=%d, gunzip=%d.\nerror:%s",
i,j,cpid,zpid,strerror(errno));
TellEm("unlink /stand/need_cpio_floppy");
unlink("/stand/need_cpio_floppy");
close(pfd[1]);
close(1); open("/dev/null",O_WRONLY);
chdir("/stand");
i = exec (1,"/stand/cpio","/stand/cpio","-iduvm", 0);
exit(i);
}
close(pfd[0]);
close(pfd[1]);
close(ffd);
i = wait(&j);
if (i < 0 || j)
Fatal("Pid %d, status %d, cpio=%d, gunzip=%d.\nerror:%s",
i, j, cpid, zpid, strerror(errno));
i = wait(&j);
if (i < 0 || j)
Fatal("Pid %d, status %d, cpio=%d, gunzip=%d.\nerror:%s",
i, j, cpid, zpid, strerror(errno));
TellEm("unlink /stand/need_cpio_floppy");
unlink("/stand/need_cpio_floppy");
}

View File

@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
* $Id: stage5.c,v 1.2 1994/10/26 05:41:02 phk Exp $
* $Id: stage5.c,v 1.3 1994/10/29 10:01:37 phk Exp $
*
*/
@ -24,9 +24,19 @@
#include "sysinstall.h"
static unsigned char msg[] = "
You are now done with the first phase of the installation. We will,
for now, dump you rather unceremoniously into a shell where you can
then ftp, SLIP, DOS floppy or carrier pigeon the bindist over. This
will NOT be so unfriendly in the BETA installation, and will lead
instead to a menu offering you various helpful ways of getting the
bindist. This is all we had time for in the ALPHA, however. Sorry!
Thank you for your patience!";
void
stage5()
{
dialog_msgbox(TITLE, msg, 7, 75, 1);
end_dialog();
dialog_active=0;
setenv("PATH","/stand",1);

View File

@ -762,66 +762,69 @@ stage2()
void
main(int argc, char **argv)
{
int i;
int i;
/* phk's main */
if (argc > 1 && !strcmp(argv[1],"phk")) {
return Xmain(argc,argv);
}
/* phk's main */
if (argc > 1 && !strcmp(argv[1],"phk")) {
return Xmain(argc,argv);
}
/* paul's main */
/* Are we running as init? */
if (getpid() == 1) {
close(0); open("/dev/console",O_RDWR);
close(1); dup(0);
close(2); dup(0);
i = 1;
ioctl(0,TIOCSPGRP,&i);
setlogin("root");
}
/* paul's main */
/* Are we running as init? */
if (getpid() == 1) {
close(0); open("/dev/console", O_RDWR);
close(1); dup(0);
close(2); dup(0);
i = 1;
ioctl(0,TIOCSPGRP,&i);
setlogin("root");
}
if (set_termcap() == -1)
fatal("Can't find terminal entry\n");
if (set_termcap() == -1)
fatal("Can't find terminal entry\n");
if (alloc_memory() == -1)
fatal("Couldn't allocate memory\n");
if (alloc_memory() == -1)
fatal("Couldn't allocate memory\n");
if (uname(&utsname) == -1) {
/* Fake uname entry */
bcopy("FreeBSD", utsname.sysname, strlen("FreeBSD"));
}
if (uname(&utsname) == -1) {
/* Fake uname entry */
bcopy("FreeBSD", utsname.sysname, strlen("FreeBSD"));
}
/* XXX - libdialog has particularly bad return value checking */
init_dialog();
/* If we haven't crashed I guess dialog is running ! */
dialog_active = 1;
/* XXX - libdialog has particularly bad return value checking */
init_dialog();
/* If we haven't crashed I guess dialog is running ! */
dialog_active = 1;
strcpy(scratch, "/etc/");
strcat(scratch, STATUSFILE);
if (read_status(scratch, sysinstall) == -1) {
fatal(errmsg);
}
strcpy(scratch, "/etc/");
strcat(scratch, STATUSFILE);
if (read_status(scratch, sysinstall) == -1) {
fatal(errmsg);
}
switch(sysinstall->status) {
case NOT_INSTALLED:
stage1();
dialog_msgbox("Stage 1 complete",
"Remove all floppy disks from the drives and hit return to reboot from the hard disk",
10, 75, 1);
if (reboot(RB_AUTOBOOT) == -1)
fatal("Reboot failed");
break;
case DISK_READY:
dialog_msgbox("Stage 2 install", "Hi!", 10, 75, 1);
stage2();
dialog_msgbox("Stage 2 complete",
"Well, this is as far as it goes so far :-)\n",
10, 75, 1);
break;
case INSTALLED_BASE:
break;
default:
fatal("Unknown installation status");
}
exit_sysinstall();
switch(sysinstall->status) {
case NOT_INSTALLED:
stage1();
dialog_msgbox("Stage 1 complete",
"Remove all floppy disks from the drives and hit return to reboot from the hard disk",
10, 75, 1);
if (reboot(RB_AUTOBOOT) == -1)
fatal("Reboot failed");
break;
case DISK_READY:
dialog_msgbox("Stage 2 install", "Hi!", 10, 75, 1);
stage2();
dialog_msgbox("Stage 2 complete",
"Well, this is as far as it goes so far :-)\n",
10, 75, 1);
break;
case INSTALLED_BASE:
break;
default:
fatal("Unknown installation status");
}
exit_sysinstall();
}

View File

@ -95,6 +95,7 @@ void Fatal __P((char *fmt, ...));
void AskAbort __P((char *fmt, ...));
void MountUfs __P((char *device, char *mountpoint, int do_mkdir,int flags));
void Mkdir __P((char *path));
void Link __P((char *from, char *to));
void CopyFile __P((char *p1, char *p2));
u_long PartMb(struct disklabel *lbl,int part);

View File

@ -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.13 1994/10/29 10:01:40 phk Exp $
* $Id: utils.c,v 1.15 1994/11/01 10:10:43 phk Exp $
*
*/
@ -186,6 +186,14 @@ Mkdir(char *path)
}
}
void
Link(char *from, char *to)
{
TellEm("ln %s %s", from, to);
if (link(from, to) == -1)
Fatal("Couldn't create link: %s -> %s\n", from, to);
}
void
CopyFile(char *p1, char *p2)
{