1994-10-20 05:00:00 +00:00
|
|
|
/*
|
|
|
|
* ----------------------------------------------------------------------------
|
|
|
|
* "THE BEER-WARE LICENSE" (Revision 42):
|
|
|
|
* <phk@login.dkuug.dk> wrote this file. As long as you retain this notice you
|
|
|
|
* can do whatever you want with this stuff. If we meet some day, and you think
|
|
|
|
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
|
|
|
|
* ----------------------------------------------------------------------------
|
|
|
|
*
|
1994-10-26 10:33:36 +00:00
|
|
|
* $Id: stage2.c,v 1.7 1994/10/26 05:41:00 phk Exp $
|
1994-10-20 05:00:00 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <dialog.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
#include <sys/stat.h>
|
1994-10-20 06:48:40 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/mount.h>
|
1994-10-20 05:00:00 +00:00
|
|
|
|
|
|
|
#include "sysinstall.h"
|
|
|
|
|
|
|
|
void
|
|
|
|
stage2()
|
|
|
|
{
|
|
|
|
char **p,**q;
|
1994-10-20 06:48:40 +00:00
|
|
|
char pbuf[90];
|
|
|
|
char dbuf[90];
|
1994-10-26 02:53:15 +00:00
|
|
|
FILE *f1;
|
1994-10-21 02:14:54 +00:00
|
|
|
int i;
|
1994-10-20 05:00:00 +00:00
|
|
|
|
1994-10-20 06:48:40 +00:00
|
|
|
for(q=mountpoint,p = devicename; *p; p++,q++) {
|
|
|
|
if(!strcmp(*q,"swap"))
|
|
|
|
continue;
|
1994-10-20 05:00:00 +00:00
|
|
|
TellEm("newfs /dev/r%s",*p);
|
1994-10-20 06:48:40 +00:00
|
|
|
strcpy(pbuf, "/dev/r");
|
|
|
|
strcat(pbuf, *p);
|
1994-10-26 02:53:15 +00:00
|
|
|
i = exec(0, "/stand/newfs", "/stand/newfs", pbuf, 0);
|
1994-10-21 02:14:54 +00:00
|
|
|
if (i)
|
1994-10-26 02:53:15 +00:00
|
|
|
Fatal("Exec(/stand/newfs) failed, code=%d.",i);
|
1994-10-20 05:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for(q=mountpoint,p = devicename; *p; p++,q++) {
|
1994-10-21 02:14:54 +00:00
|
|
|
if(!strcmp(*q,"swap"))
|
|
|
|
continue;
|
1994-10-26 02:53:15 +00:00
|
|
|
strcpy(dbuf,"/mnt");
|
|
|
|
if(strcmp(*q,"/"))
|
|
|
|
strcat(dbuf,*q);
|
|
|
|
MountUfs(*p, dbuf, 1, 0);
|
1994-10-20 05:00:00 +00:00
|
|
|
}
|
|
|
|
|
1994-10-26 02:53:15 +00:00
|
|
|
Mkdir("/mnt/etc");
|
|
|
|
Mkdir("/mnt/dev");
|
|
|
|
Mkdir("/mnt/mnt");
|
|
|
|
Mkdir("/mnt/stand");
|
|
|
|
|
|
|
|
CopyFile("/stand/sysinstall","/mnt/stand/sysinstall");
|
|
|
|
link("/mnt/stand/sysinstall","/mnt/stand/cpio");
|
|
|
|
link("/mnt/stand/sysinstall","/mnt/stand/gunzip");
|
1994-10-26 05:41:02 +00:00
|
|
|
link("/mnt/stand/sysinstall","/mnt/stand/gzip");
|
|
|
|
link("/mnt/stand/sysinstall","/mnt/stand/zcat");
|
1994-10-26 02:53:15 +00:00
|
|
|
link("/mnt/stand/sysinstall","/mnt/stand/newfs");
|
|
|
|
link("/mnt/stand/sysinstall","/mnt/stand/fsck");
|
1994-10-26 05:41:02 +00:00
|
|
|
link("/mnt/stand/sysinstall","/mnt/stand/dialog");
|
1994-10-26 02:53:15 +00:00
|
|
|
CopyFile("/kernel","/mnt/kernel");
|
|
|
|
TellEm("make /dev entries");
|
|
|
|
chdir("/mnt/dev");
|
|
|
|
makedevs();
|
|
|
|
chdir("/");
|
1994-10-20 05:00:00 +00:00
|
|
|
|
1994-10-21 02:14:54 +00:00
|
|
|
TellEm("Making /mnt/etc/fstab");
|
|
|
|
f1 = fopen("/mnt/etc/fstab","w");
|
|
|
|
if(!f1)
|
|
|
|
Fatal("Couldn't open /mnt/etc/fstab for writing.");
|
1994-10-20 05:00:00 +00:00
|
|
|
|
1994-10-21 02:14:54 +00:00
|
|
|
TellEm("Writing filesystems");
|
1994-10-20 06:48:40 +00:00
|
|
|
for(q=mountpoint,p = devicename; *p; p++,q++) {
|
|
|
|
if(!strcmp(*q,"swap"))
|
|
|
|
continue;
|
1994-10-21 02:14:54 +00:00
|
|
|
fprintf(f1,"/dev/%s\t\t%s\tufs rw 1 1\n",*p,*q);
|
1994-10-20 06:48:40 +00:00
|
|
|
}
|
1994-10-21 02:14:54 +00:00
|
|
|
TellEm("Writing swap-devs");
|
1994-10-20 06:48:40 +00:00
|
|
|
for(q=mountpoint,p = devicename; *p; p++,q++) {
|
|
|
|
if(strcmp(*q,"swap"))
|
|
|
|
continue;
|
1994-10-21 02:14:54 +00:00
|
|
|
fprintf(f1,"/dev/%s\t\tnone\tswap sw 0 0\n",*p);
|
1994-10-20 06:48:40 +00:00
|
|
|
}
|
1994-10-21 02:14:54 +00:00
|
|
|
TellEm("Writing procfs");
|
|
|
|
fprintf(f1,"proc\t\t/proc\tprocfs rw 0 0\n");
|
|
|
|
fclose(f1);
|
1994-10-20 05:00:00 +00:00
|
|
|
|
1994-10-26 02:53:15 +00:00
|
|
|
sync();
|
|
|
|
TellEm("Make marker-file");
|
|
|
|
i = open("/mnt/stand/need_cpio_floppy",O_CREAT|O_WRONLY|O_TRUNC);
|
|
|
|
close(i);
|
|
|
|
|
1994-10-20 06:48:40 +00:00
|
|
|
/* we have to unmount in reverse order */
|
|
|
|
for(p = mountpoint; *p; p++)
|
|
|
|
continue;
|
1994-10-26 02:53:15 +00:00
|
|
|
|
1994-10-21 02:14:54 +00:00
|
|
|
TellEm("Unmount disks");
|
1994-10-20 06:48:40 +00:00
|
|
|
for(p--;p >= mountpoint;p--) {
|
1994-10-21 02:14:54 +00:00
|
|
|
if(!strcmp(*p,"swap"))
|
1994-10-20 06:48:40 +00:00
|
|
|
continue;
|
|
|
|
strcpy(dbuf,"/mnt");
|
1994-10-26 02:53:15 +00:00
|
|
|
if(strcmp(*p,"/"))
|
|
|
|
strcat(dbuf,*p);
|
1994-10-20 06:48:40 +00:00
|
|
|
TellEm("unmount %s",dbuf);
|
1994-10-26 02:53:15 +00:00
|
|
|
/* Don't do error-check, we reboot anyway... */
|
|
|
|
unmount(dbuf, 0);
|
1994-10-20 05:00:00 +00:00
|
|
|
}
|
1994-10-26 10:33:36 +00:00
|
|
|
dialog_msgbox(TITLE,"Remove the floppy from the drive, and hit return to reboot from the hard disk",6, 75, 1);
|
1994-10-20 05:00:00 +00:00
|
|
|
}
|