summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sbin/sysinstall/main.c19
-rw-r--r--sbin/sysinstall/stage2.c77
-rw-r--r--sbin/sysinstall/utils.c4
3 files changed, 67 insertions, 33 deletions
diff --git a/sbin/sysinstall/main.c b/sbin/sysinstall/main.c
index fca953fe9385..61fe8245d86d 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.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;
}
diff --git a/sbin/sysinstall/stage2.c b/sbin/sysinstall/stage2.c
index 2adb6555e2a8..3a7e0e4b49a3 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$
+ * $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);
}
@@ -53,28 +57,45 @@ stage2()
TellEm("write /mnt/etc/fstab");
i = open("/mnt/etc/fstab",O_CREAT|O_TRUNC|O_APPEND|O_WRONLY,0644);
if(i < 0) {
- 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));
- close(i);
+ Fatal("Couldn't open /mnt/etc/fstab for writing");
+ }
- TellEm("unmount /mnt/usr");
- if (unmount("/mnt/usr", 0) == -1) {
- sprintf(errmsg, "Error unmounting /mnt/usr: %s\n", strerror(errno));
- Fatal(errmsg);
+ /* 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");
- if (unmount("/mnt", 0) == -1) {
- sprintf(errmsg, "Error unmounting /mnt: %s\n", strerror(errno));
- Fatal(errmsg);
+ /* we have to unmount in reverse order */
+ for(p = mountpoint; *p; p++)
+ continue;
+
+ 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));
}
}
diff --git a/sbin/sysinstall/utils.c b/sbin/sysinstall/utils.c
index 4f441ecd4713..c5a0382f9201 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$
+ * $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