summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2000-09-29 04:41:52 +0000
committerAndrew Tridgell <tridge@samba.org>2000-09-29 04:41:52 +0000
commit3f35a785b1afc97caae2ea24ff406e5f967b27e8 (patch)
tree3b30fe8e98a874091af8cae419db879052a0a7ed
parent6f1fe1f44ce9f016e41be003ded3bbefb15505c7 (diff)
downloadsamba-3f35a785b1afc97caae2ea24ff406e5f967b27e8.tar.gz
samba-3f35a785b1afc97caae2ea24ff406e5f967b27e8.tar.bz2
samba-3f35a785b1afc97caae2ea24ff406e5f967b27e8.zip
added cli_lock64() and cli_unlock64()
(This used to be commit 91f0a3cc2f59a49f6ce8550e7d07b9b01e0b285f)
-rw-r--r--source3/libsmb/clifile.c96
1 files changed, 96 insertions, 0 deletions
diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c
index 214c30d930..63f6f8cc6c 100644
--- a/source3/libsmb/clifile.c
+++ b/source3/libsmb/clifile.c
@@ -409,6 +409,102 @@ BOOL cli_unlock(struct cli_state *cli, int fnum, uint32 offset, uint32 len)
}
+/****************************************************************************
+ lock a file with 64 bit offsets
+****************************************************************************/
+BOOL cli_lock64(struct cli_state *cli, int fnum,
+ SMB_BIG_UINT offset, SMB_BIG_UINT len, int timeout, enum brl_type lock_type)
+{
+ char *p;
+ int saved_timeout = cli->timeout;
+ int ltype;
+
+ ltype = (lock_type == READ_LOCK? 1 : 0);
+ ltype |= LOCKING_ANDX_LARGE_FILES;
+
+ memset(cli->outbuf,'\0',smb_size);
+ memset(cli->inbuf,'\0', smb_size);
+
+ set_message(cli->outbuf,8,20,True);
+
+ CVAL(cli->outbuf,smb_com) = SMBlockingX;
+ SSVAL(cli->outbuf,smb_tid,cli->cnum);
+ cli_setup_packet(cli);
+
+ CVAL(cli->outbuf,smb_vwv0) = 0xFF;
+ SSVAL(cli->outbuf,smb_vwv2,fnum);
+ CVAL(cli->outbuf,smb_vwv3) = ltype;
+ SIVALS(cli->outbuf, smb_vwv4, timeout);
+ SSVAL(cli->outbuf,smb_vwv6,0);
+ SSVAL(cli->outbuf,smb_vwv7,1);
+
+ p = smb_buf(cli->outbuf);
+ SIVAL(p, 0, cli->pid);
+ SIVAL(p, 4, (offset>>32));
+ SIVAL(p, 8, (offset&0xffffffff));
+ SIVAL(p, 12, (len>>32));
+ SIVAL(p, 16, (len&0xffffffff));
+ cli_send_smb(cli);
+
+ cli->timeout = (timeout == -1) ? 0x7FFFFFFF : (timeout + 2*1000);
+
+ if (!cli_receive_smb(cli)) {
+ cli->timeout = saved_timeout;
+ return False;
+ }
+
+ cli->timeout = saved_timeout;
+
+ if (CVAL(cli->inbuf,smb_rcls) != 0) {
+ return False;
+ }
+
+ return True;
+}
+
+/****************************************************************************
+ unlock a file with 64 bit offsets
+****************************************************************************/
+BOOL cli_unlock64(struct cli_state *cli, int fnum, SMB_BIG_UINT offset, SMB_BIG_UINT len)
+{
+ char *p;
+
+ memset(cli->outbuf,'\0',smb_size);
+ memset(cli->inbuf,'\0',smb_size);
+
+ set_message(cli->outbuf,8,20,True);
+
+ CVAL(cli->outbuf,smb_com) = SMBlockingX;
+ SSVAL(cli->outbuf,smb_tid,cli->cnum);
+ cli_setup_packet(cli);
+
+ CVAL(cli->outbuf,smb_vwv0) = 0xFF;
+ SSVAL(cli->outbuf,smb_vwv2,fnum);
+ CVAL(cli->outbuf,smb_vwv3) = LOCKING_ANDX_LARGE_FILES;
+ SIVALS(cli->outbuf, smb_vwv4, 0);
+ SSVAL(cli->outbuf,smb_vwv6,1);
+ SSVAL(cli->outbuf,smb_vwv7,0);
+
+ p = smb_buf(cli->outbuf);
+ SIVAL(p, 0, cli->pid);
+ SIVAL(p, 4, (offset>>32));
+ SIVAL(p, 8, (offset&0xffffffff));
+ SIVAL(p, 12, (len>>32));
+ SIVAL(p, 16, (len&0xffffffff));
+
+ cli_send_smb(cli);
+ if (!cli_receive_smb(cli)) {
+ return False;
+ }
+
+ if (CVAL(cli->inbuf,smb_rcls) != 0) {
+ return False;
+ }
+
+ return True;
+}
+
+