Push the mount path for mount_mfs through realpath().

This matches what other fs do.
Fixes PR/20362
This commit is contained in:
dsl 2009-12-20 15:21:13 +00:00
parent 3a5d99a092
commit e9c65c5007
2 changed files with 18 additions and 10 deletions

View File

@ -1,15 +1,17 @@
# $NetBSD: Makefile,v 1.34 2009/06/06 11:09:16 haad Exp $
# $NetBSD: Makefile,v 1.35 2009/12/20 15:21:13 dsl Exp $
# @(#)Makefile 8.2 (Berkeley) 3/27/94
.include <bsd.own.mk>
PROG= newfs
SRCS= dkcksum.c newfs.c mkfs.c ffs_bswap.c ffs_appleufs.c partutil.c
SRCS+= pathadj.c
MAN= newfs.8 mount_mfs.8
DISKLABEL=${NETBSDSRCDIR}/sbin/disklabel
FSCK=${NETBSDSRCDIR}/sbin/fsck
CPPFLAGS+=-DMFS -I${.CURDIR} -I${DISKLABEL} -I${FSCK}
MOUNT=${NETBSDSRCDIR}/sbin/mount
CPPFLAGS+=-DMFS -I${.CURDIR} -I${DISKLABEL} -I${FSCK} -I${MOUNT}
DPADD+= ${LIBUTIL}
LDADD+= -lutil
@ -17,7 +19,7 @@ LDADD+= -lutil
LDADD+=-lprop
DPADD+=${LIBPROP}
.PATH: ${DISKLABEL} ${NETBSDSRCDIR}/sys/ufs/ffs ${FSCK}
.PATH: ${DISKLABEL} ${NETBSDSRCDIR}/sys/ufs/ffs ${FSCK} ${MOUNT}
LINKS= ${BINDIR}/newfs ${BINDIR}/mount_mfs
MLINKS= mount_mfs.8 mfs.8

View File

@ -1,4 +1,4 @@
/* $NetBSD: newfs.c,v 1.105 2009/05/07 06:56:56 lukem Exp $ */
/* $NetBSD: newfs.c,v 1.106 2009/12/20 15:21:13 dsl Exp $ */
/*
* Copyright (c) 1983, 1989, 1993, 1994
@ -78,7 +78,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1989, 1993, 1994\
#if 0
static char sccsid[] = "@(#)newfs.c 8.13 (Berkeley) 5/1/95";
#else
__RCSID("$NetBSD: newfs.c,v 1.105 2009/05/07 06:56:56 lukem Exp $");
__RCSID("$NetBSD: newfs.c,v 1.106 2009/12/20 15:21:13 dsl Exp $");
#endif
#endif /* not lint */
@ -117,6 +117,10 @@ __RCSID("$NetBSD: newfs.c,v 1.105 2009/05/07 06:56:56 lukem Exp $");
#include <util.h>
#include <mntopts.h>
#ifdef MFS
#include <mountprog.h>
#endif
#include "dkcksum.h"
#include "extern.h"
#include "partutil.h"
@ -238,6 +242,7 @@ main(int argc, char *argv[])
#ifdef MFS
struct mfs_args args;
char mountfromname[100];
char mounttoname[MAXPATHLEN];
pid_t pid, res;
struct statvfs sf;
int status;
@ -653,6 +658,7 @@ main(int argc, char *argv[])
#ifdef MFS
if (mfs) {
pathadj(argv[1], mounttoname);
switch (pid = fork()) {
case -1:
perror("mfs");
@ -676,10 +682,10 @@ main(int argc, char *argv[])
* can mount a filesystem which hides our
* ramdisk before we see the success.
*/
if (statvfs(argv[1], &sf) < 0)
err(88, "statvfs %s", argv[1]);
if (statvfs(mounttoname, &sf) < 0)
err(88, "statvfs %s", mounttoname);
if (!strcmp(sf.f_mntfromname, mountfromname) &&
!strncmp(sf.f_mntonname, argv[1],
!strncmp(sf.f_mntonname, mounttoname,
MNAMELEN) &&
!strcmp(sf.f_fstypename, "mfs"))
exit(0);
@ -692,7 +698,7 @@ main(int argc, char *argv[])
if (WIFEXITED(status)) {
if (WEXITSTATUS(status) == 0)
exit(0);
errx(1, "%s: mount: %s", argv[1],
errx(1, "%s: mount: %s", mounttoname,
strerror(WEXITSTATUS(status)));
} else
errx(11, "abnormal termination");
@ -708,7 +714,7 @@ main(int argc, char *argv[])
args.base = membase;
args.size = fssize * sectorsize;
if (mount(MOUNT_MFS, argv[1], mntflags | MNT_ASYNC,
if (mount(MOUNT_MFS, mounttoname, mntflags | MNT_ASYNC,
&args, sizeof args) == -1)
exit(errno); /* parent prints message */
}