smbd: Pass "share_mode_data" to share_entry_forall callback
authorVolker Lendecke <vl@samba.org>
Wed, 25 Jul 2018 14:56:35 +0000 (16:56 +0200)
committerJeremy Allison <jra@samba.org>
Thu, 26 Jul 2018 20:44:25 +0000 (22:44 +0200)
Quite a bit of the contents have been passed explicitly anyway.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/locking/proto.h
source3/locking/share_mode_lock.c
source3/rpc_server/srvsvc/srv_srvsvc_nt.c
source3/utils/status.c

index 403729c934a5f887c58ca5bde486c6e52a0399a2..b615a4ae6d0b41ea9f917ae41d75fe486307b5dc 100644 (file)
@@ -212,10 +212,10 @@ int share_mode_forall(int (*fn)(struct file_id fid,
                                const struct share_mode_data *data,
                                void *private_data),
                      void *private_data);
-int share_entry_forall(int (*fn)(const struct share_mode_entry *,
-                                const struct file_id *id,
-                                const char *, const char *,
-                                const char *, void *),
+int share_entry_forall(int (*fn)(struct file_id fid,
+                                const struct share_mode_data *data,
+                                const struct share_mode_entry *entry,
+                                void *private_data),
                      void *private_data);
 bool share_mode_cleanup_disconnected(struct file_id id,
                                     uint64_t open_persistent_id);
index fce0c335ec374195890c62d5ef50ce4374a20bab..f62a3b4ff3d96096a64df181c2853279d33594be 100644 (file)
@@ -878,11 +878,9 @@ int share_mode_forall(int (*fn)(struct file_id fid,
 }
 
 struct share_entry_forall_state {
-       int (*fn)(const struct share_mode_entry *e,
-                 const struct file_id *id,
-                 const char *service_path,
-                 const char *base_name,
-                 const char *stream_name,
+       int (*fn)(struct file_id fid,
+                 const struct share_mode_data *data,
+                 const struct share_mode_entry *entry,
                  void *private_data);
        void *private_data;
 };
@@ -897,11 +895,9 @@ static int share_entry_traverse_fn(struct file_id fid,
        for (i=0; i<data->num_share_modes; i++) {
                int ret;
 
-               ret = state->fn(&data->share_modes[i],
-                               &data->id,
-                               data->servicepath,
-                               data->base_name,
-                               data->stream_name,
+               ret = state->fn(fid,
+                               data,
+                               &data->share_modes[i],
                                state->private_data);
                if (ret != 0) {
                        return ret;
@@ -916,11 +912,11 @@ static int share_entry_traverse_fn(struct file_id fid,
  share mode system.
 ********************************************************************/
 
-int share_entry_forall(int (*fn)(const struct share_mode_entry *,
-                                const struct file_id *id,
-                                const char *, const char *,
-                                const char *, void *),
-                      void *private_data)
+int share_entry_forall(int (*fn)(struct file_id fid,
+                                const struct share_mode_data *data,
+                                const struct share_mode_entry *entry,
+                                void *private_data),
+                     void *private_data)
 {
        struct share_entry_forall_state state = {
                .fn = fn, .private_data = private_data };
index e1963a40a0ced67bf95dbde54024223bed5a629f..7138f126be60bc9c2d52a7aeba4d0fb0cc1075f3 100644 (file)
@@ -81,11 +81,9 @@ struct share_conn_stat {
 /*******************************************************************
 ********************************************************************/
 
-static int enum_file_fn(const struct share_mode_entry *e,
-                       const struct file_id *id,
-                       const char *sharepath,
-                       const char *fname,
-                       const char *sname,
+static int enum_file_fn(struct file_id id,
+                       const struct share_mode_data *d,
+                       const struct share_mode_entry *e,
                        void *private_data)
 {
        struct file_enum_count *fenum =
@@ -124,19 +122,25 @@ static int enum_file_fn(const struct share_mode_entry *e,
        /* need to count the number of locks on a file */
 
        ZERO_STRUCT( fsp );
-       fsp.file_id = *id;
+       fsp.file_id = id;
 
        if ( (brl = brl_get_locks(talloc_tos(), &fsp)) != NULL ) {
                num_locks = brl_num_locks(brl);
                TALLOC_FREE(brl);
        }
 
-       if ( strcmp( fname, "." ) == 0 ) {
-               fullpath = talloc_asprintf(fenum->ctx, "C:%s", sharepath );
+       if ( strcmp(d->base_name, "." ) == 0 ) {
+               fullpath = talloc_asprintf(
+                       fenum->ctx,
+                       "C:%s",
+                       d->servicepath);
        } else {
-               fullpath = talloc_asprintf(fenum->ctx, "C:%s/%s%s",
-                                          sharepath, fname,
-                                          sname ? sname : "");
+               fullpath = talloc_asprintf(
+                       fenum->ctx,
+                       "C:%s/%s%s",
+                       d->servicepath,
+                       d->base_name,
+                       (d->stream_name != NULL) ? d->stream_name : "");
        }
        if (!fullpath) {
                return 0;
@@ -841,11 +845,9 @@ static WERROR init_srv_sess_info_0(struct pipes_struct *p,
  * find out the session on which this file is open and bump up its count
  **********************************************************************/
 
-static int count_sess_files_fn(const struct share_mode_entry *e,
-                              const struct file_id *id,
-                              const char *sharepath,
-                              const char *fname,
-                              const char *sname,
+static int count_sess_files_fn(struct file_id fid,
+                              const struct share_mode_data *d,
+                              const struct share_mode_entry *e,
                               void *data)
 {
        struct sess_file_info *info = data;
@@ -969,18 +971,16 @@ static WERROR init_srv_sess_info_1(struct pipes_struct *p,
  find the share connection on which this open exists.
  ********************************************************************/
 
-static int share_file_fn(const struct share_mode_entry *e,
-                        const struct file_id *id,
-                        const char *sharepath,
-                        const char *fname,
-                        const char *sname,
+static int share_file_fn(struct file_id fid,
+                        const struct share_mode_data *d,
+                        const struct share_mode_entry *e,
                         void *data)
 {
        struct share_file_stat *sfs = data;
        uint32_t i;
        uint32_t offset = sfs->total_entries - sfs->resp_entries;
 
-       if (strequal(sharepath, sfs->in_sharepath)) {
+       if (strequal(d->servicepath, sfs->in_sharepath)) {
                for (i=0; i < sfs->resp_entries; i++) {
                        if (serverid_equal(&e->pid, &sfs->svrid_arr[offset + i])) {
                                sfs->netconn_arr[i].num_open ++;
@@ -2681,11 +2681,9 @@ struct enum_file_close_state {
        struct messaging_context *msg_ctx;
 };
 
-static int enum_file_close_fn(const struct share_mode_entry *e,
-                             const struct file_id *id,
-                             const char *sharepath,
-                             const char *fname,
-                             const char *sname,
+static int enum_file_close_fn(struct file_id id,
+                             const struct share_mode_data *d,
+                             const struct share_mode_entry *e,
                              void *private_data)
 {
        char msg[MSG_SMB_SHARE_MODE_ENTRY_SIZE];
@@ -2702,10 +2700,10 @@ static int enum_file_close_fn(const struct share_mode_entry *e,
        }
 
        /* Ok - send the close message. */
-       DBG_DEBUG("request to close file %s, %s\n", sharepath,
-                 share_mode_str(talloc_tos(), 0, id, e));
+       DBG_DEBUG("request to close file %s, %s\n", d->servicepath,
+                 share_mode_str(talloc_tos(), 0, &id, e));
 
-       share_mode_entry_to_message(msg, id, e);
+       share_mode_entry_to_message(msg, &id, e);
 
        state->r->out.result = ntstatus_to_werror(
                messaging_send_buf(state->msg_ctx,
index d04efedee3f6e5f36fa0735f82d3dff021f3a852..9f8729c2910f1d45cef8c7941d1c2cb2454fe346 100644 (file)
@@ -116,12 +116,10 @@ static bool Ucrit_addPid( struct server_id pid )
        return True;
 }
 
-static int print_share_mode(const struct share_mode_entry *e,
-                           const struct file_id *id,
-                           const char *sharepath,
-                           const char *fname,
-                           const char *sname,
-                           void *dummy)
+static int print_share_mode(struct file_id fid,
+                           const struct share_mode_data *d,
+                           const struct share_mode_entry *e,
+                           void *private_data)
 {
        static int count;
 
@@ -195,8 +193,8 @@ static int print_share_mode(const struct share_mode_entry *e,
                }
 
                d_printf(" %s   %s%s   %s",
-                        sharepath, fname,
-                        sname ? sname : "",
+                        d->servicepath, d->base_name,
+                        (d->stream_name != NULL) ? d->stream_name : "",
                         time_to_asc((time_t)e->time.tv_sec));
        }