aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/libzfs/libzfs_mount.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/libzfs/libzfs_mount.c b/lib/libzfs/libzfs_mount.c
index a2bb471b3..5fc96f1ab 100644
--- a/lib/libzfs/libzfs_mount.c
+++ b/lib/libzfs/libzfs_mount.c
@@ -22,7 +22,7 @@
/*
* Copyright 2015 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2014 by Delphix. All rights reserved.
+ * Copyright (c) 2014, 2015 by Delphix. All rights reserved.
*/
/*
@@ -64,6 +64,7 @@
#include <dirent.h>
#include <dlfcn.h>
#include <errno.h>
+#include <fcntl.h>
#include <libgen.h>
#include <libintl.h>
#include <stdio.h>
@@ -179,9 +180,16 @@ dir_is_empty(const char *dirname)
{
DIR *dirp;
struct dirent64 *dp;
+ int dirfd;
- if ((dirp = opendir(dirname)) == NULL)
+ if ((dirfd = openat(AT_FDCWD, dirname,
+ O_RDONLY | O_NDELAY | O_LARGEFILE | O_CLOEXEC, 0)) < 0) {
return (B_TRUE);
+ }
+
+ if ((dirp = fdopendir(dirfd)) == NULL) {
+ return (B_TRUE);
+ }
while ((dp = readdir64(dirp)) != NULL) {