The branch, master has been updated
       via  0a7290c libcli: Remove an unused variable
       via  8ae692c smbd: validate_lock_entries does not need mem_ctx anymore
       via  c5fb0f9 smbd: Simplify validate_lock_entries
       via  2282128 smbd: Factor out brl_delete_lock_struct
       via  3c2f4e3 smbd: Simplify validate_lock_entries
       via  9a27ed9 torture3: Add some brlock entries in cleanup2
       via  9f2e907 smbstatus: Fix an uninitialized variable
       via  4964b06 libcli: Make cli_smb2_close_fnum async
       via  379cbb6 lib: Align nt_time_to_unix_timespec with 
unix_timespec_to_nt_time
       via  dcd6373 lib: Align unix_timespec_to_nt_time with 
nt_time_to_unix_timespec
       via  9f3e894 libcli: Make smb2cli_create return blobs
      from  f0f18c5 vfs_snapper: use a talloc hierarchy for arrays

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 0a7290ca7de4993b41c6ae54a00a2af65ec1e6c5
Author: Volker Lendecke <[email protected]>
Date:   Mon Jun 30 18:53:29 2014 +0000

    libcli: Remove an unused variable
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>
    
    Autobuild-User(master): Jeremy Allison <[email protected]>
    Autobuild-Date(master): Tue Jul  1 00:43:18 CEST 2014 on sn-devel-104

commit 8ae692cc91ad2dff0bdb9a6d3ccfcf1bcb58a654
Author: Volker Lendecke <[email protected]>
Date:   Sun Jun 29 11:38:35 2014 +0200

    smbd: validate_lock_entries does not need mem_ctx anymore
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit c5fb0f9cc023fcac1260239b0c543759b38f09e6
Author: Volker Lendecke <[email protected]>
Date:   Sun Jun 29 11:36:24 2014 +0200

    smbd: Simplify validate_lock_entries
    
    Signed-off-by: Volker Lendecke <[email protected]>

commit 2282128ed03d06b16c019d9f3294ca0ea46f029f
Author: Volker Lendecke <[email protected]>
Date:   Sun Jun 29 11:31:18 2014 +0200

    smbd: Factor out brl_delete_lock_struct
    
    memmove calculations are never nice, and this is going to be used in
    validate_lock_entries soon :-)
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 3c2f4e328be51740ce67568fe886c5f5e745ed4f
Author: Volker Lendecke <[email protected]>
Date:   Sun Jun 29 11:22:13 2014 +0200

    smbd: Simplify validate_lock_entries
    
    ... saves >100 bytes object code :-)
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 9a27ed9c860d3d5a80326b19ce1a6d0553e55a38
Author: Volker Lendecke <[email protected]>
Date:   Sun Jun 29 11:07:08 2014 +0200

    torture3: Add some brlock entries in cleanup2
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 9f2e90754bcb7bf5f7159d07f0bc5fe754e71bf5
Author: Volker Lendecke <[email protected]>
Date:   Sun Jun 29 08:56:03 2014 +0000

    smbstatus: Fix an uninitialized variable
    
    We only print valid share mode entries, stale ones don't count. In
    traverse, let the callback decide about staleness.
    
    https://bugzilla.samba.org/show_bug.cgi?id=10680
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 4964b0606652169cc8dc59ee45bceae80ac4c46a
Author: Volker Lendecke <[email protected]>
Date:   Fri Jun 27 09:47:36 2014 +0000

    libcli: Make cli_smb2_close_fnum async
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 379cbb6397ce6228cf02125f4f29b2438b384d1c
Author: Volker Lendecke <[email protected]>
Date:   Wed Jun 18 12:21:06 2014 +0000

    lib: Align nt_time_to_unix_timespec with unix_timespec_to_nt_time
    
    Both take and return values now
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit dcd6373613622852181a4dacdcf92ec2b9cb0112
Author: Volker Lendecke <[email protected]>
Date:   Wed Jun 18 12:21:06 2014 +0000

    lib: Align unix_timespec_to_nt_time with nt_time_to_unix_timespec
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 9f3e89446847425881e07cafadddc2af8723e8c2
Author: Volker Lendecke <[email protected]>
Date:   Fri Jun 27 09:32:34 2014 +0000

    libcli: Make smb2cli_create return blobs
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

-----------------------------------------------------------------------

Summary of changes:
 lib/util/time.c                   |   21 +++----
 lib/util/time.h                   |    4 +-
 libcli/auth/netlogon_creds_cli.c  |    1 -
 libcli/smb/smb2cli_create.c       |   15 ++++-
 libcli/smb/smbXcli_base.h         |    8 ++-
 libcli/smb/tstream_smbXcli_np.c   |    2 +-
 source3/client/client.c           |   16 +++---
 source3/lib/time.c                |    4 +-
 source3/libsmb/cli_smb2_fnum.c    |  118 ++++++++++++++++++++++++++++---------
 source3/libsmb/cli_smb2_fnum.h    |    5 ++
 source3/locking/brlock.c          |   86 ++++++++++-----------------
 source3/locking/share_mode_lock.c |    1 +
 source3/smbd/dosmode.c            |    6 +-
 source3/smbd/smb2_create.c        |    2 +-
 source3/torture/test_cleanup.c    |   28 ++++++++-
 source3/torture/test_smb2.c       |   32 +++++-----
 16 files changed, 216 insertions(+), 133 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/util/time.c b/lib/util/time.c
index 993a55a..03345ec 100644
--- a/lib/util/time.c
+++ b/lib/util/time.c
@@ -134,7 +134,7 @@ struct timespec convert_time_t_to_timespec(time_t t)
 **/
 time_t nt_time_to_unix(NTTIME nt)
 {
-       return convert_timespec_to_time_t(nt_time_to_unix_timespec(&nt));
+       return convert_timespec_to_time_t(nt_time_to_unix_timespec(nt));
 }
 
 
@@ -784,18 +784,18 @@ _PUBLIC_ int get_time_zone(time_t t)
        return tm_diff(&tm_utc,tm);
 }
 
-struct timespec nt_time_to_unix_timespec(const NTTIME *nt)
+struct timespec nt_time_to_unix_timespec(NTTIME nt)
 {
        int64_t d;
        struct timespec ret;
 
-       if (*nt == 0 || *nt == (int64_t)-1) {
+       if (nt == 0 || nt == (int64_t)-1) {
                ret.tv_sec = 0;
                ret.tv_nsec = 0;
                return ret;
        }
 
-       d = (int64_t)*nt;
+       d = (int64_t)nt;
        /* d is now in 100ns units, since jan 1st 1601".
           Save off the ns fraction. */
 
@@ -940,21 +940,18 @@ void round_timespec_to_usec(struct timespec *ts)
  Put a 8 byte filetime from a struct timespec. Uses GMT.
 ****************************************************************************/
 
-_PUBLIC_ void unix_timespec_to_nt_time(NTTIME *nt, struct timespec ts)
+_PUBLIC_ NTTIME unix_timespec_to_nt_time(struct timespec ts)
 {
        uint64_t d;
 
        if (ts.tv_sec ==0 && ts.tv_nsec == 0) {
-               *nt = 0;
-               return;
+               return 0;
        }
        if (ts.tv_sec == TIME_T_MAX) {
-               *nt = 0x7fffffffffffffffLL;
-               return;
+               return 0x7fffffffffffffffLL;
        }
        if (ts.tv_sec == (time_t)-1) {
-               *nt = (uint64_t)-1;
-               return;
+               return (uint64_t)-1;
        }
 
        d = ts.tv_sec;
@@ -963,5 +960,5 @@ _PUBLIC_ void unix_timespec_to_nt_time(NTTIME *nt, struct 
timespec ts)
        /* d is now in 100ns units. */
        d += (ts.tv_nsec / 100);
 
-       *nt = d;
+       return d;
 }
diff --git a/lib/util/time.h b/lib/util/time.h
index bab8281..8595bb0 100644
--- a/lib/util/time.h
+++ b/lib/util/time.h
@@ -298,7 +298,7 @@ bool nt_time_equal(NTTIME *t1, NTTIME *t2);
 
 void interpret_dos_date(uint32_t date,int *year,int *month,int *day,int 
*hour,int *minute,int *second);
 
-struct timespec nt_time_to_unix_timespec(const NTTIME *nt);
+struct timespec nt_time_to_unix_timespec(NTTIME nt);
 
 time_t convert_timespec_to_time_t(struct timespec ts);
 
@@ -314,6 +314,6 @@ struct timespec timespec_min(const struct timespec *ts1,
 int timespec_compare(const struct timespec *ts1, const struct timespec *ts2);
 void round_timespec_to_sec(struct timespec *ts);
 void round_timespec_to_usec(struct timespec *ts);
-void unix_timespec_to_nt_time(NTTIME *nt, struct timespec ts);
+NTTIME unix_timespec_to_nt_time(struct timespec ts);
 
 #endif /* _SAMBA_TIME_H_ */
diff --git a/libcli/auth/netlogon_creds_cli.c b/libcli/auth/netlogon_creds_cli.c
index 05a30da..d709e6a 100644
--- a/libcli/auth/netlogon_creds_cli.c
+++ b/libcli/auth/netlogon_creds_cli.c
@@ -2603,7 +2603,6 @@ struct tevent_req 
*netlogon_creds_cli_DsrUpdateReadOnlyServerDnsRecords_send(TAL
        struct tevent_req *req;
        struct netlogon_creds_cli_DsrUpdateReadOnlyServerDnsRecords_state 
*state;
        struct tevent_req *subreq;
-       bool ok;
 
        req = tevent_req_create(mem_ctx, &state,
                                struct 
netlogon_creds_cli_DsrUpdateReadOnlyServerDnsRecords_state);
diff --git a/libcli/smb/smb2cli_create.c b/libcli/smb/smb2cli_create.c
index bcd674e..0db546c 100644
--- a/libcli/smb/smb2cli_create.c
+++ b/libcli/smb/smb2cli_create.c
@@ -238,7 +238,9 @@ static void smb2cli_create_done(struct tevent_req *subreq)
 NTSTATUS smb2cli_create_recv(struct tevent_req *req,
                             uint64_t *fid_persistent,
                             uint64_t *fid_volatile,
-                            struct smb_create_returns *cr)
+                            struct smb_create_returns *cr,
+                            TALLOC_CTX *mem_ctx,
+                            struct smb2_create_blobs *blobs)
 {
        struct smb2cli_create_state *state =
                tevent_req_data(req,
@@ -253,6 +255,10 @@ NTSTATUS smb2cli_create_recv(struct tevent_req *req,
        if (cr) {
                *cr = state->cr;
        }
+       if (blobs) {
+               blobs->num_blobs = state->blobs.num_blobs;
+               blobs->blobs = talloc_move(mem_ctx, &state->blobs.blobs);
+       }
        return NT_STATUS_OK;
 }
 
@@ -271,7 +277,9 @@ NTSTATUS smb2cli_create(struct smbXcli_conn *conn,
                        struct smb2_create_blobs *blobs,
                        uint64_t *fid_persistent,
                        uint64_t *fid_volatile,
-                       struct smb_create_returns *cr)
+                       struct smb_create_returns *cr,
+                       TALLOC_CTX *mem_ctx,
+                       struct smb2_create_blobs *ret_blobs)
 {
        TALLOC_CTX *frame = talloc_stackframe();
        struct tevent_context *ev;
@@ -302,7 +310,8 @@ NTSTATUS smb2cli_create(struct smbXcli_conn *conn,
        if (!tevent_req_poll_ntstatus(req, ev, &status)) {
                goto fail;
        }
-       status = smb2cli_create_recv(req, fid_persistent, fid_volatile, cr);
+       status = smb2cli_create_recv(req, fid_persistent, fid_volatile, cr,
+                                    mem_ctx, ret_blobs);
  fail:
        TALLOC_FREE(frame);
        return status;
diff --git a/libcli/smb/smbXcli_base.h b/libcli/smb/smbXcli_base.h
index 8cde85e..06015b1 100644
--- a/libcli/smb/smbXcli_base.h
+++ b/libcli/smb/smbXcli_base.h
@@ -461,7 +461,9 @@ struct tevent_req *smb2cli_create_send(
 NTSTATUS smb2cli_create_recv(struct tevent_req *req,
                             uint64_t *fid_persistent,
                             uint64_t *fid_volatile,
-                            struct smb_create_returns *cr);
+                            struct smb_create_returns *cr,
+                            TALLOC_CTX *mem_ctx,
+                            struct smb2_create_blobs *blobs);
 NTSTATUS smb2cli_create(struct smbXcli_conn *conn,
                        uint32_t timeout_msec,
                        struct smbXcli_session *session,
@@ -477,7 +479,9 @@ NTSTATUS smb2cli_create(struct smbXcli_conn *conn,
                        struct smb2_create_blobs *blobs,
                        uint64_t *fid_persistent,
                        uint64_t *fid_volatile,
-                       struct smb_create_returns *cr);
+                       struct smb_create_returns *cr,
+                       TALLOC_CTX *mem_ctx,
+                       struct smb2_create_blobs *ret_blobs);
 
 struct tevent_req *smb2cli_close_send(TALLOC_CTX *mem_ctx,
                                      struct tevent_context *ev,
diff --git a/libcli/smb/tstream_smbXcli_np.c b/libcli/smb/tstream_smbXcli_np.c
index c32fd6f..77a326b 100644
--- a/libcli/smb/tstream_smbXcli_np.c
+++ b/libcli/smb/tstream_smbXcli_np.c
@@ -279,7 +279,7 @@ static void tstream_smbXcli_np_open_done(struct tevent_req 
*subreq)
                status = smb2cli_create_recv(subreq,
                                             &state->fid_persistent,
                                             &state->fid_volatile,
-                                            NULL);
+                                            NULL, NULL, NULL);
        }
        TALLOC_FREE(subreq);
        if (!NT_STATUS_IS_OK(status)) {
diff --git a/source3/client/client.c b/source3/client/client.c
index 17985b9..c90c450 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -1725,16 +1725,16 @@ static int do_allinfo(const char *name)
                return false;
        }
 
-       unix_timespec_to_nt_time(&tmp, b_time);
+       tmp = unix_timespec_to_nt_time(b_time);
        d_printf("create_time:    %s\n", nt_time_string(talloc_tos(), tmp));
 
-       unix_timespec_to_nt_time(&tmp, a_time);
+       tmp = unix_timespec_to_nt_time(a_time);
        d_printf("access_time:    %s\n", nt_time_string(talloc_tos(), tmp));
 
-       unix_timespec_to_nt_time(&tmp, m_time);
+       tmp = unix_timespec_to_nt_time(m_time);
        d_printf("write_time:     %s\n", nt_time_string(talloc_tos(), tmp));
 
-       unix_timespec_to_nt_time(&tmp, c_time);
+       tmp = unix_timespec_to_nt_time(c_time);
        d_printf("change_time:    %s\n", nt_time_string(talloc_tos(), tmp));
 
        d_printf("attributes: %s (%x)\n", attr_str(talloc_tos(), mode), mode);
@@ -1804,13 +1804,13 @@ static int do_allinfo(const char *name)
                        TALLOC_FREE(snap_name);
                        continue;
                }
-               unix_timespec_to_nt_time(&tmp, b_time);
+               tmp = unix_timespec_to_nt_time(b_time);
                d_printf("create_time:    %s\n", nt_time_string(talloc_tos(), 
tmp));
-               unix_timespec_to_nt_time(&tmp, a_time);
+               tmp = unix_timespec_to_nt_time(a_time);
                d_printf("access_time:    %s\n", nt_time_string(talloc_tos(), 
tmp));
-               unix_timespec_to_nt_time(&tmp, m_time);
+               tmp =unix_timespec_to_nt_time(m_time);
                d_printf("write_time:     %s\n", nt_time_string(talloc_tos(), 
tmp));
-               unix_timespec_to_nt_time(&tmp, c_time);
+               tmp = unix_timespec_to_nt_time(c_time);
                d_printf("change_time:    %s\n", nt_time_string(talloc_tos(), 
tmp));
                d_printf("size: %d\n", (int)size);
        }
diff --git a/source3/lib/time.c b/source3/lib/time.c
index dab9b31..30ad1ec 100644
--- a/source3/lib/time.c
+++ b/source3/lib/time.c
@@ -172,7 +172,7 @@ void put_long_date_timespec(enum timestamp_set_resolution 
res, char *p, struct t
 {
        NTTIME nt;
        round_timespec(res, &ts);
-       unix_timespec_to_nt_time(&nt, ts);
+       nt = unix_timespec_to_nt_time(ts);
        SBVAL(p, 0, nt);
 }
 
@@ -250,7 +250,7 @@ struct timespec interpret_long_date(const char *p)
                ret.tv_nsec = 0;
                return ret;
        }
-       return nt_time_to_unix_timespec(&nt);
+       return nt_time_to_unix_timespec(nt);
 }
 
 /*******************************************************************
diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c
index 87edf4e..3a04ea1 100644
--- a/source3/libsmb/cli_smb2_fnum.c
+++ b/source3/libsmb/cli_smb2_fnum.c
@@ -234,7 +234,7 @@ static void cli_smb2_create_fnum_done(struct tevent_req 
*subreq)
        NTSTATUS status;
 
        status = smb2cli_create_recv(subreq, &h.fid_persistent,
-                                    &h.fid_volatile, &state->cr);
+                                    &h.fid_volatile, &state->cr, NULL, NULL);
        TALLOC_FREE(subreq);
        if (tevent_req_nterror(req, status)) {
                return;
@@ -318,45 +318,109 @@ NTSTATUS cli_smb2_create_fnum(struct cli_state *cli,
 
 /***************************************************************
  Small wrapper that allows SMB2 close to use a uint16_t fnum.
- Synchronous only.
 ***************************************************************/
 
-NTSTATUS cli_smb2_close_fnum(struct cli_state *cli, uint16_t fnum)
+struct cli_smb2_close_fnum_state {
+       struct cli_state *cli;
+       uint16_t fnum;
+       struct smb2_hnd *ph;
+};
+
+static void cli_smb2_close_fnum_done(struct tevent_req *subreq);
+
+struct tevent_req *cli_smb2_close_fnum_send(TALLOC_CTX *mem_ctx,
+                                           struct tevent_context *ev,
+                                           struct cli_state *cli,
+                                           uint16_t fnum)
 {
-       struct smb2_hnd *ph = NULL;
+       struct tevent_req *req, *subreq;
+       struct cli_smb2_close_fnum_state *state;
        NTSTATUS status;
 
-       if (smbXcli_conn_has_async_calls(cli->conn)) {
-               /*
-                * Can't use sync call while an async call is in flight
-                */
-               return NT_STATUS_INVALID_PARAMETER;
+       req = tevent_req_create(mem_ctx, &state,
+                               struct cli_smb2_close_fnum_state);
+       if (req == NULL) {
+               return NULL;
        }
+       state->cli = cli;
+       state->fnum = fnum;
 
        if (smbXcli_conn_protocol(cli->conn) < PROTOCOL_SMB2_02) {
-               return NT_STATUS_INVALID_PARAMETER;
+               tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
+               return tevent_req_post(req, ev);
        }
 
-       status = map_fnum_to_smb2_handle(cli,
-                                       fnum,
-                                       &ph);
-       if (!NT_STATUS_IS_OK(status)) {
-               return status;
+       status = map_fnum_to_smb2_handle(cli, fnum, &state->ph);
+       if (tevent_req_nterror(req, status)) {
+               return tevent_req_post(req, ev);
        }
 
-       status = smb2cli_close(cli->conn,
-                               cli->timeout,
-                               cli->smb2.session,
-                               cli->smb2.tcon,
-                               0,
-                               ph->fid_persistent,
-                               ph->fid_volatile);
+       subreq = smb2cli_close_send(state, ev, cli->conn, cli->timeout,
+                                   cli->smb2.session, cli->smb2.tcon,
+                                   0, state->ph->fid_persistent,
+                                   state->ph->fid_volatile);
+       if (tevent_req_nomem(subreq, req)) {
+               return tevent_req_post(req, ev);
+       }
+       tevent_req_set_callback(subreq, cli_smb2_close_fnum_done, req);
+       return req;
+}
+
+static void cli_smb2_close_fnum_done(struct tevent_req *subreq)
+{
+       struct tevent_req *req = tevent_req_callback_data(
+               subreq, struct tevent_req);
+       struct cli_smb2_close_fnum_state *state = tevent_req_data(
+               req, struct cli_smb2_close_fnum_state);
+       NTSTATUS status;
+
+       status = smb2cli_close_recv(subreq);
+       if (tevent_req_nterror(req, status)) {
+               return;
+       }
 
        /* Delete the fnum -> handle mapping. */
-       if (NT_STATUS_IS_OK(status)) {
-               status = delete_smb2_handle_mapping(cli, &ph, fnum);
+       status = delete_smb2_handle_mapping(state->cli, &state->ph,
+                                           state->fnum);
+       if (tevent_req_nterror(req, status)) {
+               return;
        }
+       tevent_req_done(req);
+}
+
+NTSTATUS cli_smb2_close_fnum_recv(struct tevent_req *req)
+{
+       return tevent_req_simple_recv_ntstatus(req);
+}
+
+NTSTATUS cli_smb2_close_fnum(struct cli_state *cli, uint16_t fnum)
+{
+       TALLOC_CTX *frame = talloc_stackframe();
+       struct tevent_context *ev;
+       struct tevent_req *req;
+       NTSTATUS status = NT_STATUS_NO_MEMORY;
 
+       if (smbXcli_conn_has_async_calls(cli->conn)) {
+               /*
+                * Can't use sync call while an async call is in flight
+                */
+               status = NT_STATUS_INVALID_PARAMETER;
+               goto fail;
+       }
+       ev = samba_tevent_context_init(frame);
+       if (ev == NULL) {
+               goto fail;
+       }
+       req = cli_smb2_close_fnum_send(frame, ev, cli, fnum);
+       if (req == NULL) {
+               goto fail;
+       }
+       if (!tevent_req_poll_ntstatus(req, ev, &status)) {
+               goto fail;
+       }
+       status = cli_smb2_close_fnum_recv(req);
+ fail:
+       TALLOC_FREE(frame);
        return status;
 }
 
@@ -822,9 +886,9 @@ NTSTATUS cli_smb2_qpathinfo_basic(struct cli_state *cli,
 
        ZERO_STRUCTP(sbuf);
 
-       sbuf->st_ex_atime = nt_time_to_unix_timespec(&cr.last_access_time);
-       sbuf->st_ex_mtime = nt_time_to_unix_timespec(&cr.last_write_time);
-       sbuf->st_ex_ctime = nt_time_to_unix_timespec(&cr.change_time);
+       sbuf->st_ex_atime = nt_time_to_unix_timespec(cr.last_access_time);
+       sbuf->st_ex_mtime = nt_time_to_unix_timespec(cr.last_write_time);
+       sbuf->st_ex_ctime = nt_time_to_unix_timespec(cr.change_time);
        sbuf->st_ex_size = cr.end_of_file;
        *attributes = cr.file_attributes;
 
diff --git a/source3/libsmb/cli_smb2_fnum.h b/source3/libsmb/cli_smb2_fnum.h
index 9394918..173dba0 100644
--- a/source3/libsmb/cli_smb2_fnum.h
+++ b/source3/libsmb/cli_smb2_fnum.h
@@ -48,6 +48,11 @@ NTSTATUS cli_smb2_create_fnum(struct cli_state *cli,
                        uint16_t *pfid,
                        struct smb_create_returns *cr);
 
+struct tevent_req *cli_smb2_close_fnum_send(TALLOC_CTX *mem_ctx,
+                                           struct tevent_context *ev,
+                                           struct cli_state *cli,
+                                           uint16_t fnum);
+NTSTATUS cli_smb2_close_fnum_recv(struct tevent_req *req);
 NTSTATUS cli_smb2_close_fnum(struct cli_state *cli, uint16_t fnum);
 NTSTATUS cli_smb2_mkdir(struct cli_state *cli, const char *dirname);
 NTSTATUS cli_smb2_rmdir(struct cli_state *cli, const char *dirname);
diff --git a/source3/locking/brlock.c b/source3/locking/brlock.c
index e0e042d..e134aac 100644
--- a/source3/locking/brlock.c
+++ b/source3/locking/brlock.c
@@ -999,6 +999,17 @@ NTSTATUS brl_lock(struct messaging_context *msg_ctx,
        return ret;
 }
 
+static void brl_delete_lock_struct(struct lock_struct *locks,
+                                  unsigned num_locks,
+                                  unsigned del_idx)
+{
+       if (del_idx >= num_locks) {
+               return;
+       }
+       memmove(&locks[del_idx], &locks[del_idx+1],
+               sizeof(*locks) * (num_locks - del_idx - 1));
+}
+
 /****************************************************************************
  Unlock a range of bytes - Windows semantics.
 ****************************************************************************/
@@ -1066,12 +1077,7 @@ bool brl_unlock_windows_default(struct messaging_context 
*msg_ctx,
   unlock_continue:
 #endif
 
-       /* Actually delete the lock. */
-       if (i < br_lck->num_locks - 1) {
-               memmove(&locks[i], &locks[i+1],
-                       sizeof(*locks)*((br_lck->num_locks-1) - i));
-       }
-
+       brl_delete_lock_struct(locks, br_lck->num_locks, i);
        br_lck->num_locks -= 1;
        br_lck->modified = True;
 
@@ -1704,99 +1710,73 @@ bool brl_reconnect_disconnected(struct files_struct 
*fsp)
 /****************************************************************************
  Ensure this set of lock entries is valid.
 ****************************************************************************/
-static bool validate_lock_entries(TALLOC_CTX *mem_ctx,
-                                 unsigned int *pnum_entries, struct 
lock_struct **pplocks,
+static bool validate_lock_entries(unsigned int *pnum_entries, struct 
lock_struct **pplocks,
                                  bool keep_disconnected)
 {
        unsigned int i;
-       unsigned int num_valid_entries = 0;
        struct lock_struct *locks = *pplocks;
+       unsigned int num_entries = *pnum_entries;
        TALLOC_CTX *frame;
        struct server_id *ids;
        bool *exists;
 
-       if (*pnum_entries == 0) {
+       if (num_entries == 0) {
                return true;
        }
 
        frame = talloc_stackframe();
 
-       ids = talloc_array(frame, struct server_id, *pnum_entries);
+       ids = talloc_array(frame, struct server_id, num_entries);
        if (ids == NULL) {
                DEBUG(0, ("validate_lock_entries: "
                          "talloc_array(struct server_id, %u) failed\n",
-                         *pnum_entries));
+                         num_entries));
                talloc_free(frame);
                return false;
        }
 
-       exists = talloc_array(frame, bool, *pnum_entries);
+       exists = talloc_array(frame, bool, num_entries);


-- 
Samba Shared Repository

Reply via email to