1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

smbd: Slightly simplify smbd_dirptr_get_entry()

Implementing virtually empty directories for "dont descend" looks
easier to me this way. It should also be an optimization, because now
we don't walk the whole directory anymore after . and .., which always
come first anyway.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
This commit is contained in:
Volker Lendecke 2023-06-21 17:48:24 +02:00
parent 7b6cedf538
commit 290ca547a8

View File

@ -546,12 +546,19 @@ bool smbd_dirptr_get_entry(TALLOC_CTX *ctx,
return true;
}
if (dont_descend && (dptr_FileNumber(dirptr) >= 2)) {
/*
* . and .. were returned first, we're done showing
* the directory as empty.
*/
return false;
}
pathlen = strlen(dpath);
slashlen = ( dpath[pathlen-1] != '/') ? 1 : 0;
while (true) {
char *dname = NULL;
bool isdots;
char *fname = NULL;
char *pathreal = NULL;
struct smb_filename *atname = NULL;
@ -574,12 +581,6 @@ bool smbd_dirptr_get_entry(TALLOC_CTX *ctx,
return false;
}
isdots = (ISDOT(dname) || ISDOTDOT(dname));
if (dont_descend && !isdots) {
TALLOC_FREE(dname);
continue;
}
if (IS_VETO_PATH(conn, dname)) {
TALLOC_FREE(dname);
continue;