Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libpuffs stat mount target path only if we're actually g...



details:   https://anonhg.NetBSD.org/src/rev/2ac4fff19dcb
branches:  trunk
changeset: 756106:2ac4fff19dcb
user:      pooka <pooka%NetBSD.org@localhost>
date:      Tue Jul 06 18:22:20 2010 +0000

description:
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.

diffstat:

 lib/libpuffs/puffs.c |  27 ++++++++++++++-------------
 1 files changed, 14 insertions(+), 13 deletions(-)

diffs (62 lines):

diff -r d21daeae0157 -r 2ac4fff19dcb lib/libpuffs/puffs.c
--- a/lib/libpuffs/puffs.c      Tue Jul 06 18:09:04 2010 +0000
+++ b/lib/libpuffs/puffs.c      Tue Jul 06 18:22:20 2010 +0000
@@ -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);



Home | Main Index | Thread Index | Old Index