From: Volker Lendecke Date: Sun, 12 Nov 2023 10:30:11 +0000 (+0100) Subject: smbd: Simplify smbd_dirptr_get_entry() X-Git-Tag: talloc-2.4.2~728 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b1e5ed4490ff92f001d9f0d282059c4cc17e19a7;p=thirdparty%2Fsamba.git smbd: Simplify smbd_dirptr_get_entry() Both mode_fn's are now the same. Fold them into smbd_dirptr_get_entry() Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c index 2fc364a42fd..5fe1aeb2641 100644 --- a/source3/smbd/dir.c +++ b/source3/smbd/dir.c @@ -517,12 +517,6 @@ bool smbd_dirptr_get_entry(TALLOC_CTX *ctx, const char *dname, const char *mask, char **_fname), - bool (*mode_fn)(TALLOC_CTX *ctx, - void *private_data, - struct files_struct *dirfsp, - struct smb_filename *smb_fname, - bool get_dosmode, - uint32_t *_mode), void *private_data, char **_fname, struct smb_filename **_smb_fname, @@ -755,17 +749,11 @@ bool smbd_dirptr_get_entry(TALLOC_CTX *ctx, continue; } - ok = mode_fn(ctx, - private_data, - dir_hnd->fsp, - smb_fname, - get_dosmode, - &mode); - if (!ok) { - TALLOC_FREE(smb_fname); - TALLOC_FREE(dname); - TALLOC_FREE(fname); - continue; + if (get_dosmode) { + mode = fdos_mode(smb_fname->fsp); + if (smb_fname->fsp != NULL) { + smb_fname->st = smb_fname->fsp->fsp_name->st; + } } done: diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h index f58e3176f31..0c7e791711f 100644 --- a/source3/smbd/globals.h +++ b/source3/smbd/globals.h @@ -171,12 +171,6 @@ bool smbd_dirptr_get_entry(TALLOC_CTX *ctx, const char *dname, const char *mask, char **_fname), - bool (*mode_fn)(TALLOC_CTX *ctx, - void *private_data, - struct files_struct *dirfsp, - struct smb_filename *smb_fname, - bool get_dosmode, - uint32_t *_mode), void *private_data, char **_fname, struct smb_filename **_smb_fname, diff --git a/source3/smbd/smb1_reply.c b/source3/smbd/smb1_reply.c index dc54e1b340d..52a06fed821 100644 --- a/source3/smbd/smb1_reply.c +++ b/source3/smbd/smb1_reply.c @@ -1199,23 +1199,6 @@ static bool smbd_dirptr_8_3_match_fn(TALLOC_CTX *ctx, return false; } -static bool smbd_dirptr_8_3_mode_fn(TALLOC_CTX *ctx, - void *private_data, - struct files_struct *dirfsp, - struct smb_filename *smb_fname, - bool get_dosmode, - uint32_t *_mode) -{ - if (get_dosmode) { - SMB_ASSERT(smb_fname != NULL); - *_mode = fdos_mode(smb_fname->fsp); - if (smb_fname->fsp != NULL) { - smb_fname->st = smb_fname->fsp->fsp_name->st; - } - } - return true; -} - static bool get_dir_entry(TALLOC_CTX *ctx, connection_struct *conn, struct dptr_struct *dirptr, @@ -1242,7 +1225,6 @@ again: ask_sharemode, true, smbd_dirptr_8_3_match_fn, - smbd_dirptr_8_3_mode_fn, conn, &fname, &smb_fname, diff --git a/source3/smbd/smb2_trans2.c b/source3/smbd/smb2_trans2.c index 8b044948c3d..0dc3fa62b3f 100644 --- a/source3/smbd/smb2_trans2.c +++ b/source3/smbd/smb2_trans2.c @@ -1010,23 +1010,6 @@ static bool smbd_dirptr_lanman2_match_fn(TALLOC_CTX *ctx, return true; } -static bool smbd_dirptr_lanman2_mode_fn(TALLOC_CTX *ctx, - void *private_data, - struct files_struct *dirfsp, - struct smb_filename *smb_fname, - bool get_dosmode, - uint32_t *_mode) -{ - if (get_dosmode) { - SMB_ASSERT(smb_fname != NULL); - *_mode = fdos_mode(smb_fname->fsp); - if (smb_fname->fsp != NULL) { - smb_fname->st = smb_fname->fsp->fsp_name->st; - } - } - return true; -} - static uint32_t get_dirent_ea_size(uint32_t mode, files_struct *fsp) { if (!(mode & FILE_ATTRIBUTE_REPARSE_POINT)) { @@ -1840,7 +1823,6 @@ NTSTATUS smbd_dirptr_lanman2_entry(TALLOC_CTX *ctx, ask_sharemode, get_dosmode, smbd_dirptr_lanman2_match_fn, - smbd_dirptr_lanman2_mode_fn, &state, &fname, &smb_fname,