return status;
}
-/****************************************************************************
- Lock a file with 64 bit offsets.
-****************************************************************************/
-
-NTSTATUS cli_lock64(struct cli_state *cli, uint16_t fnum,
- uint64_t offset, uint64_t len, int timeout,
- enum brl_type lock_type)
-{
- uint16_t vwv[8];
- uint8_t bytes[20];
- unsigned int set_timeout = 0;
- unsigned int saved_timeout = 0;
- int ltype;
- NTSTATUS status;
-
- if (! (smb1cli_conn_capabilities(cli->conn) & CAP_LARGE_FILES)) {
- return cli_lock32(cli, fnum, offset, len, timeout, lock_type);
- }
-
- ltype = (lock_type == READ_LOCK? 1 : 0);
- ltype |= LOCKING_ANDX_LARGE_FILES;
-
- SCVAL(vwv + 0, 0, 0xff);
- SCVAL(vwv + 0, 1, 0);
- SSVAL(vwv + 1, 0, 0);
- SSVAL(vwv + 2, 0, fnum);
- SCVAL(vwv + 3, 0, ltype);
- SCVAL(vwv + 3, 1, 0);
- SIVALS(vwv + 4, 0, timeout);
- SSVAL(vwv + 6, 0, 0);
- SSVAL(vwv + 7, 0, 1);
-
- SIVAL(bytes, 0, cli_getpid(cli));
- SOFF_T_R(bytes, 4, offset);
- SOFF_T_R(bytes, 12, len);
-
- if (timeout != 0) {
- if (timeout == -1) {
- set_timeout = 0x7FFFFFFF;
- } else {
- set_timeout = timeout + 2*1000;
- }
- saved_timeout = cli_set_timeout(cli, set_timeout);
- }
-
- status = cli_smb(talloc_tos(), cli, SMBlockingX, 0, 8, vwv,
- 20, bytes, NULL, 0, NULL, NULL, NULL, NULL);
-
- if (saved_timeout != 0) {
- cli_set_timeout(cli, saved_timeout);
- }
-
- return status;
-}
-
-/****************************************************************************
- Unlock a file with 64 bit offsets.
-****************************************************************************/
-
-struct cli_unlock64_state {
- uint16_t vwv[8];
- uint8_t data[20];
-};
-
-static void cli_unlock64_done(struct tevent_req *subreq);
-
-struct tevent_req *cli_unlock64_send(TALLOC_CTX *mem_ctx,
- struct tevent_context *ev,
- struct cli_state *cli,
- uint16_t fnum,
- uint64_t offset,
- uint64_t len)
-
-{
- struct tevent_req *req = NULL, *subreq = NULL;
- struct cli_unlock64_state *state = NULL;
- uint8_t additional_flags = 0;
-
- req = tevent_req_create(mem_ctx, &state, struct cli_unlock64_state);
- if (req == NULL) {
- return NULL;
- }
-
- SCVAL(state->vwv+0, 0, 0xff);
- SSVAL(state->vwv+2, 0, fnum);
- SCVAL(state->vwv+3, 0,LOCKING_ANDX_LARGE_FILES);
- SIVALS(state->vwv+4, 0, 0);
- SSVAL(state->vwv+6, 0, 1);
- SSVAL(state->vwv+7, 0, 0);
-
- SIVAL(state->data, 0, cli_getpid(cli));
- SOFF_T_R(state->data, 4, offset);
- SOFF_T_R(state->data, 12, len);
-
- subreq = cli_smb_send(state, ev, cli, SMBlockingX, additional_flags, 0,
- 8, state->vwv, 20, state->data);
- if (tevent_req_nomem(subreq, req)) {
- return tevent_req_post(req, ev);
- }
- tevent_req_set_callback(subreq, cli_unlock64_done, req);
- return req;
-}
-
-static void cli_unlock64_done(struct tevent_req *subreq)
-{
- struct tevent_req *req = tevent_req_callback_data(
- subreq, struct tevent_req);
- NTSTATUS status;
-
- status = cli_smb_recv(subreq, NULL, NULL, 0, NULL, NULL, NULL, NULL);
- TALLOC_FREE(subreq);
- if (tevent_req_nterror(req, status)) {
- return;
- }
- tevent_req_done(req);
-}
-
-NTSTATUS cli_unlock64_recv(struct tevent_req *req)
-{
- return tevent_req_simple_recv_ntstatus(req);
-}
-
-NTSTATUS cli_unlock64(struct cli_state *cli,
- uint16_t fnum,
- uint64_t offset,
- uint64_t len)
-{
- TALLOC_CTX *frame = talloc_stackframe();
- struct tevent_context *ev;
- struct tevent_req *req;
- NTSTATUS status = NT_STATUS_OK;
-
- if (! (smb1cli_conn_capabilities(cli->conn) & CAP_LARGE_FILES)) {
- return cli_unlock(cli, fnum, offset, len);
- }
-
- 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) {
- status = NT_STATUS_NO_MEMORY;
- goto fail;
- }
-
- req = cli_unlock64_send(frame, ev, cli,
- fnum, offset, len);
- if (req == NULL) {
- status = NT_STATUS_NO_MEMORY;
- goto fail;
- }
-
- if (!tevent_req_poll_ntstatus(req, ev, &status)) {
- goto fail;
- }
-
- status = cli_unlock64_recv(req);
-
- fail:
- TALLOC_FREE(frame);
- return status;
-}
-
/****************************************************************************
Get/unlock a POSIX lock on a file - internal function.
****************************************************************************/