Module Name:    src
Committed By:   pooka
Date:           Tue Jul  6 18:22:21 UTC 2010

Modified Files:
        src/lib/libpuffs: puffs.c

Log Message:
stat mount target path only if we're actually goint to use it.
This avoids errors from the comfd case when the mount target does
not exist in our local namespace.


To generate a diff of this commit:
cvs rdiff -u -r1.112 -r1.113 src/lib/libpuffs/puffs.c

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

Modified files:

Index: src/lib/libpuffs/puffs.c
diff -u src/lib/libpuffs/puffs.c:1.112 src/lib/libpuffs/puffs.c:1.113
--- src/lib/libpuffs/puffs.c:1.112	Tue Jul  6 18:01:14 2010
+++ src/lib/libpuffs/puffs.c	Tue Jul  6 18:22:20 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: puffs.c,v 1.112 2010/07/06 18:01:14 pooka Exp $	*/
+/*	$NetBSD: puffs.c,v 1.113 2010/07/06 18:22:20 pooka Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006, 2007  Antti Kantee.  All Rights Reserved.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #if !defined(lint)
-__RCSID("$NetBSD: puffs.c,v 1.112 2010/07/06 18:01:14 pooka Exp $");
+__RCSID("$NetBSD: puffs.c,v 1.113 2010/07/06 18:22:20 pooka Exp $");
 #endif /* !lint */
 
 #include <sys/param.h>
@@ -511,7 +511,6 @@
 puffs_mount(struct puffs_usermount *pu, const char *dir, int mntflags,
 	puffs_cookie_t cookie)
 {
-	char rp[MAXPATHLEN];
 	int rv, fd, sverrno;
 	char *comfd;
 
@@ -522,16 +521,6 @@
 	if (geteuid() != 0)
 		mntflags |= MNT_NOSUID | MNT_NODEV;
 
-	if (realpath(dir, rp) == NULL) {
-		rv = -1;
-		goto out;
-	}
-
-	if (strcmp(dir, rp) != 0) {
-		warnx("puffs_mount: \"%s\" is a relative path.", dir);
-		warnx("puffs_mount: using \"%s\" instead.", rp);
-	}
-
 	/*
 	 * Undocumented...  Well, documented only here.
 	 *
@@ -583,6 +572,18 @@
 
 		rv = 0;
 	} else {
+		char rp[MAXPATHLEN];
+
+		if (realpath(dir, rp) == NULL) {
+			rv = -1;
+			goto out;
+		}
+
+		if (strcmp(dir, rp) != 0) {
+			warnx("puffs_mount: \"%s\" is a relative path.", dir);
+			warnx("puffs_mount: using \"%s\" instead.", rp);
+		}
+
 		fd = open(_PATH_PUFFS, O_RDWR);
 		if (fd == -1) {
 			warnx("puffs_mount: cannot open %s", _PATH_PUFFS);

Reply via email to