Now stage 2 should do it's job I hope. Havn't tested yet.
This commit is contained in:
parent
3a06e4e7bf
commit
277a25ffe0
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=3738
@ -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.2 1994/10/20 04:59:56 phk Exp $
|
||||
* $Id: main.c,v 1.3 1994/10/20 06:14:29 phk Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -91,17 +91,28 @@ main(int argc, char **argv)
|
||||
if (getenv("STAGE0") || !access("/this_is_boot_flp",R_OK)) {
|
||||
stage0();
|
||||
stage1();
|
||||
/* XXX This is how stage one should output: */
|
||||
|
||||
/*
|
||||
* XXX This is how stage one should output:
|
||||
*/
|
||||
devicename[0] = StrAlloc("wd0a");
|
||||
mountpoint[0] = StrAlloc("/");
|
||||
|
||||
devicename[1] = StrAlloc("wd0e");
|
||||
mountpoint[1] = StrAlloc("/usr");
|
||||
|
||||
devicename[2] = StrAlloc("wd0b");
|
||||
mountpoint[2] = StrAlloc("swap");
|
||||
/*
|
||||
* XXX sort it by mountpoint, so that safe seq of mounting
|
||||
* is guaranteed
|
||||
*/
|
||||
|
||||
stage2();
|
||||
} else if (getenv("STAGE3)) {
|
||||
} else if (getenv("STAGE3")) {
|
||||
stage3();
|
||||
} else {
|
||||
fprintf(stderr,"Must setenv STAGE0 or STAGE3");
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
|
||||
* ----------------------------------------------------------------------------
|
||||
*
|
||||
* $Id$
|
||||
* $Id: stage2.c,v 1.1 1994/10/20 04:59:58 phk Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -23,6 +23,8 @@
|
||||
#include <errno.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/mount.h>
|
||||
|
||||
#include "sysinstall.h"
|
||||
|
||||
@ -30,15 +32,17 @@ void
|
||||
stage2()
|
||||
{
|
||||
char **p,**q;
|
||||
char buf[90];
|
||||
char *diskname = "sd0";
|
||||
int i;
|
||||
char pbuf[90];
|
||||
char dbuf[90];
|
||||
int i,j;
|
||||
|
||||
for(p = devicename; *p; p++) {
|
||||
for(q=mountpoint,p = devicename; *p; p++,q++) {
|
||||
if(!strcmp(*q,"swap"))
|
||||
continue;
|
||||
TellEm("newfs /dev/r%s",*p);
|
||||
strcpy(scratch, "/dev/r");
|
||||
strcat(scratch, *p);
|
||||
if (exec("/bin/newfs","/bin/newfs", scratch, 0) == -1)
|
||||
strcpy(pbuf, "/dev/r");
|
||||
strcat(pbuf, *p);
|
||||
if (exec("/bin/newfs","/bin/newfs", pbuf, 0) == -1)
|
||||
Fatal(errmsg);
|
||||
}
|
||||
|
||||
@ -56,25 +60,42 @@ stage2()
|
||||
Fatal("Couldn't open /mnt/etc/fstab for writing");
|
||||
}
|
||||
|
||||
sprintf(scratch,"/dev/%sa / ufs rw 1 1\n",diskname);
|
||||
write(i,scratch,strlen(scratch));
|
||||
sprintf(scratch,"/dev/%sb none swap sw 0 0\n",diskname);
|
||||
write(i,scratch,strlen(scratch));
|
||||
sprintf(scratch,"proc /proc procfs rw 0 0\n");
|
||||
write(i,scratch,strlen(scratch));
|
||||
sprintf(scratch,"/dev/%se /usr ufs rw 1 2\n",diskname);
|
||||
write(i,scratch,strlen(scratch));
|
||||
/* This file is our own. It serves several jobs */
|
||||
j = open("/mnt/this_is_hd",O_CREAT|O_TRUNC|O_APPEND|O_WRONLY,0644);
|
||||
if(j < 0) {
|
||||
Fatal("Couldn't open /mnt/this_is_hd for writing");
|
||||
}
|
||||
for(q=mountpoint,p = devicename; *p; p++,q++) {
|
||||
sprintf(pbuf,"%s\n%s\n",*p,*q);
|
||||
write(j,pbuf,strlen(pbuf));
|
||||
if(!strcmp(*q,"swap"))
|
||||
continue;
|
||||
sprintf(pbuf,"/dev/%s\t\t%s\tufs rw 1 1\n",*p,*q);
|
||||
write(i,pbuf,strlen(pbuf));
|
||||
}
|
||||
for(q=mountpoint,p = devicename; *p; p++,q++) {
|
||||
if(strcmp(*q,"swap"))
|
||||
continue;
|
||||
sprintf(pbuf,"/dev/%s\t\tnone\tswap sw 0 0\n",*p);
|
||||
write(i,pbuf,strlen(pbuf));
|
||||
}
|
||||
close(i);
|
||||
write(j,"\n",1);
|
||||
close(j);
|
||||
sprintf(pbuf,"proc\t\t/proc\tprocfs rw 0 0\n");
|
||||
write(i,pbuf,strlen(pbuf));
|
||||
|
||||
TellEm("unmount /mnt/usr");
|
||||
if (unmount("/mnt/usr", 0) == -1) {
|
||||
sprintf(errmsg, "Error unmounting /mnt/usr: %s\n", strerror(errno));
|
||||
Fatal(errmsg);
|
||||
}
|
||||
/* we have to unmount in reverse order */
|
||||
for(p = mountpoint; *p; p++)
|
||||
continue;
|
||||
|
||||
TellEm("unmount /mnt");
|
||||
if (unmount("/mnt", 0) == -1) {
|
||||
sprintf(errmsg, "Error unmounting /mnt: %s\n", strerror(errno));
|
||||
Fatal(errmsg);
|
||||
for(p--;p >= mountpoint;p--) {
|
||||
if(!strcmp(*q,"swap"))
|
||||
continue;
|
||||
strcpy(dbuf,"/mnt");
|
||||
strcat(dbuf,*p);
|
||||
TellEm("unmount %s",dbuf);
|
||||
if (unmount("/mnt", 0) == -1)
|
||||
Fatal("Error unmounting /mnt: %s", strerror(errno));
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
|
||||
* ----------------------------------------------------------------------------
|
||||
*
|
||||
* $Id$
|
||||
* $Id: utils.c,v 1.2 1994/10/20 05:00:00 phk Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -143,6 +143,8 @@ MountUfs(char *device, char *prefix, char *mountpoint, int do_mkdir)
|
||||
char dbuf[90];
|
||||
char pbuf[90];
|
||||
|
||||
memset(&ufsargs,0,sizeof ufsargs);
|
||||
|
||||
if (prefix)
|
||||
strcpy(pbuf,prefix);
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user