mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-12-03 08:22:44 +00:00
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.
This commit is contained in:
parent
709f4fb343
commit
b9ecc1ed61
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=5591
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user