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.
This commit is contained in:
manu 2014-12-22 08:16:21 +00:00
parent 55e0969cef
commit 8ee430e576

View File

@ -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);
}