smbd: Simplify smbd_dirptr_get_entry()
authorVolker Lendecke <vl@samba.org>
Sun, 12 Nov 2023 10:30:11 +0000 (11:30 +0100)
committerVolker Lendecke <vl@samba.org>
Wed, 15 Nov 2023 05:10:35 +0000 (05:10 +0000)
Both mode_fn's are now the same. Fold them into smbd_dirptr_get_entry()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/dir.c
source3/smbd/globals.h
source3/smbd/smb1_reply.c
source3/smbd/smb2_trans2.c

index 2fc364a42fd8a99024a8a2178af0ac8ae31f88c6..5fe1aeb2641ff48cdb4bb4a54fd5a5b139c53e5a 100644 (file)
@@ -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:
index f58e3176f31662dd0d7457c485283a3f27bb1eb6..0c7e791711feda56178da5fea7935bd5973188f2 100644 (file)
@@ -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,
index dc54e1b340ddc5ef4c6908cb89fbb61095440643..52a06fed8214ce1fb9dd02df7a814d201bf8c6f3 100644 (file)
@@ -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,
index 8b044948c3dd515e64b389ac68a6052508625ce0..0dc3fa62b3fed93a77bb10e01585250ee7432088 100644 (file)
@@ -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,