Module Name:    src
Committed By:   dsl
Date:           Sun Dec 20 15:21:13 UTC 2009

Modified Files:
        src/sbin/newfs: Makefile newfs.c

Log Message:
Push the mount path for mount_mfs through realpath().
This matches what other fs do.
Fixes PR/20362


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sbin/newfs/Makefile
cvs rdiff -u -r1.105 -r1.106 src/sbin/newfs/newfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs/Makefile
diff -u src/sbin/newfs/Makefile:1.34 src/sbin/newfs/Makefile:1.35
--- src/sbin/newfs/Makefile:1.34	Sat Jun  6 11:09:16 2009
+++ src/sbin/newfs/Makefile	Sun Dec 20 15:21:13 2009
@@ -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+=-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

Index: src/sbin/newfs/newfs.c
diff -u src/sbin/newfs/newfs.c:1.105 src/sbin/newfs/newfs.c:1.106
--- src/sbin/newfs/newfs.c:1.105	Thu May  7 06:56:56 2009
+++ src/sbin/newfs/newfs.c	Sun Dec 20 15:21:13 2009
@@ -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 @@
 #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 @@
 #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 @@
 #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 @@
 #ifdef MFS
 	if (mfs) {
 
+		pathadj(argv[1], mounttoname);
 		switch (pid = fork()) {
 		case -1:
 			perror("mfs");
@@ -676,10 +682,10 @@
 				 * 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 @@
 				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 @@
 
 		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 */
 	}

Reply via email to