From b9ecc1ed6104a15d76f8bb792c43922440dfbcb9 Mon Sep 17 00:00:00 2001 From: "Jordan K. Hubbard" Date: Sat, 14 Jan 1995 10:31:29 +0000 Subject: [PATCH] Make sure a partition we're about to mount on will always exist on the user's system. Make Mkdir() selectively not die in case of failure. --- sbin/sysinstall/stage2.c | 16 ++++++++++------ sbin/sysinstall/stage4.c | 6 +++--- sbin/sysinstall/sysinstall.h | 2 +- sbin/sysinstall/utils.c | 11 ++++++----- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/sbin/sysinstall/stage2.c b/sbin/sysinstall/stage2.c index b58d4022b152..03c286747133 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: stage2.c,v 1.16.2.1 1994/11/21 03:12:16 phk Exp $ + * $Id: stage2.c,v 1.20 1994/12/27 23:26:56 jkh Exp $ * */ @@ -82,10 +82,10 @@ stage2() MountUfs(p, dbuf, 1, 0); } - Mkdir("/mnt/etc"); - Mkdir("/mnt/dev"); - Mkdir("/mnt/mnt"); - Mkdir("/mnt/stand"); + Mkdir("/mnt/etc", TRUE); + Mkdir("/mnt/dev", TRUE); + Mkdir("/mnt/mnt", TRUE); + Mkdir("/mnt/stand", TRUE); TellEm("unzipping /stand/sysinstall onto hard disk"); exec(4, "/stand/gzip", "zcat", 0 ); @@ -137,13 +137,17 @@ stage2() Fatal("Couldn't open /mnt/etc/fstab for writing."); TellEm("Writing filesystems"); + chdir("/mnt"); 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 + else { fprintf(f1, "/dev/%s\t\t%s\t%s rw 1 1\n", Fname[Fsize[j]], Fmount[Fsize[j]], Ftype[Fsize[j]]); + Mkdir(Fmount[Fsize[j]], FALSE); + } } + chdir("/"); TellEm("Writing procfs"); fprintf(f1,"proc\t\t/proc\tprocfs rw 0 0\n"); fclose(f1); diff --git a/sbin/sysinstall/stage4.c b/sbin/sysinstall/stage4.c index 81222d0e3fd5..f5ae29d7f520 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: stage4.c,v 1.9 1994/11/17 23:36:48 ache Exp $ + * $Id: stage4.c,v 1.10 1994/11/18 10:12:56 jkh Exp $ * */ @@ -76,8 +76,8 @@ retry: Fatal("Pid %d, status %d, cpio=%d, gunzip=%d.\nerror:%s", i, j, cpid, zpid, strerror(errno)); - /* bininst MUST be the last file on the floppy */ - if (access("/stand/bininst", R_OK) == -1) { + /* bininst.sh MUST be the last file on the floppy */ + if (access("/stand/bininst.sh", R_OK) == -1) { AskAbort("CPIO floppy was bad! Please check media for defects and retry."); goto retry; } diff --git a/sbin/sysinstall/sysinstall.h b/sbin/sysinstall/sysinstall.h index d96e9df808d9..ec5a1961e089 100644 --- a/sbin/sysinstall/sysinstall.h +++ b/sbin/sysinstall/sysinstall.h @@ -96,7 +96,7 @@ char *StrAlloc __P((char *str)); 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 Mkdir __P((char *path, int die)); void Link __P((char *from, char *to)); void CopyFile __P((char *p1, char *p2)); u_long PartMb(struct disklabel *lbl,int part); diff --git a/sbin/sysinstall/utils.c b/sbin/sysinstall/utils.c index 1b8495016369..b92f05f34b8e 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.30.2.1 1994/11/21 03:12:24 phk Exp $ + * $Id: utils.c,v 1.34 1994/12/27 23:26:59 jkh Exp $ * */ @@ -173,7 +173,7 @@ MountUfs(char *device, char *mountpoint, int do_mkdir, int flags) memset(&ufsargs,0,sizeof ufsargs); if(do_mkdir && access(mountpoint,R_OK)) { - Mkdir(mountpoint); + Mkdir(mountpoint, TRUE); } strcpy(dbuf,"/dev/"); @@ -188,7 +188,7 @@ MountUfs(char *device, char *mountpoint, int do_mkdir, int flags) } void -Mkdir(char *ipath) +Mkdir(char *ipath, int die) { struct stat sb; int final=0; @@ -205,11 +205,12 @@ Mkdir(char *ipath) continue; *p = '\0'; if (stat(path, &sb)) { - if (errno != ENOENT) + if (errno != ENOENT && die) Fatal("Couldn't stat directory %s: %s\n", path,strerror(errno)); Debug("mkdir(%s..)",path); - if (mkdir(path, S_IRWXU | S_IRWXG | S_IRWXO) < 0) + if (mkdir(path, S_IRWXU | S_IRWXG | S_IRWXO) < 0 && + die) Fatal("Couldn't create directory %s: %s\n", path,strerror(errno)); }