diff options
| author | pooka <pooka@NetBSD.org> | 2010-07-06 18:22:20 +0000 |
|---|---|---|
| committer | pooka <pooka@NetBSD.org> | 2010-07-06 18:22:20 +0000 |
| commit | d8a0b8cdce80fbca4d7621dad6c2ee7615f8c57d (patch) | |
| tree | 4961c07ec8e4fc7d8c8d070952961b9bea9261a8 /lib | |
| parent | 8983a2496d66647a9a0768b660a815541e700b73 (diff) | |
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 (limited to 'lib')
| -rw-r--r-- | lib/libpuffs/puffs.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/lib/libpuffs/puffs.c b/lib/libpuffs/puffs.c index c7c4eb48736..54e8c6e908d 100644 --- a/lib/libpuffs/puffs.c +++ b/lib/libpuffs/puffs.c @@ -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 @@ int 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 @@ puffs_mount(struct puffs_usermount *pu, const char *dir, int mntflags, 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 @@ do { \ 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); |
