@@ -18,7 +18,12 @@ int weakrandomkey(unsigned char *keyout, int len);
char *generic_make_pathname(const char *, const char *);
_Bool generic_setup_basedir(const char *, const char *, char *, const size_t);
-extern int is_mountpoint(char *path);
+struct stat;
+
+extern int check_is_mountpoint(const char *path,
+ int (mystat)(const char *, struct stat *));
+#define is_mountpoint(path) \
+ check_is_mountpoint(path, NULL)
/* size of the file pointer buffers for rpc procfs files */
#define RPC_CHAN_BUF_SIZE 32768
@@ -9,8 +9,10 @@
#include "misc.h"
int
-is_mountpoint(char *path)
+check_is_mountpoint(const char *path, int (mystat)(const char *, struct stat *))
{
+ if (!mystat)
+ mystat = lstat;
/* Check if 'path' is a current mountpoint.
* Possibly we should also check it is the mountpoint of the
* filesystem holding the target directory, but there doesn't
@@ -26,8 +28,8 @@ is_mountpoint(char *path)
dotdot = xmalloc(strlen(path)+4);
strcat(strcpy(dotdot, path), "/..");
- if (lstat(path, &stb) != 0 ||
- lstat(dotdot, &pstb) != 0)
+ if (mystat(path, &stb) != 0 ||
+ mystat(dotdot, &pstb) != 0)
rv = 0;
else
if (stb.st_dev != pstb.st_dev ||
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> --- support/include/misc.h | 7 ++++++- support/misc/mountpoint.c | 8 +++++--- 2 files changed, 11 insertions(+), 4 deletions(-)