summaryrefslogtreecommitdiff
path: root/source3/smbd/dir.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/smbd/dir.c')
-rw-r--r--source3/smbd/dir.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c
index b4a8f942c2..e7902871d3 100644
--- a/source3/smbd/dir.c
+++ b/source3/smbd/dir.c
@@ -576,6 +576,9 @@ const char *dptr_ReadDirName(TALLOC_CTX *ctx,
{
char *name = NULL;
char *pathreal = NULL;
+ char *found_name = NULL;
+ int ret;
+
SET_STAT_INVALID(*pst);
if (dptr->has_wild || dptr->did_stat) {
@@ -640,6 +643,20 @@ const char *dptr_ReadDirName(TALLOC_CTX *ctx,
goto clean;
}
+ /*
+ * Try case-insensitive stat if the fs has the ability. This avoids
+ * scanning the whole directory.
+ */
+ ret = SMB_VFS_GET_REAL_FILENAME(dptr->conn, dptr->path, dptr->wcard,
+ ctx, &found_name);
+ if (ret == 0) {
+ name = found_name;
+ goto clean;
+ } else if (errno == ENOENT) {
+ /* The case-insensitive lookup was authoritative. */
+ goto clean;
+ }
+
TALLOC_FREE(pathreal);
return dptr_normal_ReadDirName(dptr, poffset, pst);