Module Name:    src
Committed By:   manu
Date:           Mon Dec 22 08:16:21 UTC 2014

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

Log Message:
Do not warn about relative path because of trailing slash

libpuffs calls realpath() to obtain an absolute path to use for mounting.
If the obtained path is different from the one given by the caller, a
warning is issued. This included the situation where the path passed by
the caller just have trailing slashes, a situation where we just want them
to be striped without a warning.


To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 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.118 src/lib/libpuffs/puffs.c:1.119
--- src/lib/libpuffs/puffs.c:1.118	Fri Oct 31 13:56:04 2014
+++ src/lib/libpuffs/puffs.c	Mon Dec 22 08:16:21 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: puffs.c,v 1.118 2014/10/31 13:56:04 manu Exp $	*/
+/*	$NetBSD: puffs.c,v 1.119 2014/12/22 08:16:21 manu 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.118 2014/10/31 13:56:04 manu Exp $");
+__RCSID("$NetBSD: puffs.c,v 1.119 2014/12/22 08:16:21 manu Exp $");
 #endif /* !lint */
 
 #include <sys/param.h>
@@ -574,13 +574,17 @@ do {									\
 		rv = 0;
 	} else {
 		char rp[MAXPATHLEN];
+		size_t rplen,dirlen;
 
 		if (realpath(dir, rp) == NULL) {
 			rv = -1;
 			goto out;
 		}
 
-		if (strcmp(dir, rp) != 0) {
+		rplen = strlen(rp);
+		dirlen = strlen(dir);
+		if (strncmp(dir, rp, rplen) != 0 ||
+		    strspn(dir + rplen, "/") != dirlen - rplen) {
 			warnx("puffs_mount: \"%s\" is a relative path.", dir);
 			warnx("puffs_mount: using \"%s\" instead.", rp);
 		}

Reply via email to