summaryrefslogtreecommitdiffstats
path: root/source3/libsmb/clifile.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2004-03-03 23:14:23 +0000
committerJeremy Allison <jra@samba.org>2004-03-03 23:14:23 +0000
commitf0039da19654f0d75617e96d67054d1d1990515d (patch)
tree475097adff0ea3a895842d9139eb5df769e9934b /source3/libsmb/clifile.c
parentfba5a722497c1e4577aa463921a0fec5f6d5fe55 (diff)
downloadsamba-f0039da19654f0d75617e96d67054d1d1990515d.tar.gz
samba-f0039da19654f0d75617e96d67054d1d1990515d.tar.xz
samba-f0039da19654f0d75617e96d67054d1d1990515d.zip
Added client "hardlink" commant to test doing NT rename with hard links.
Added hardlink_internals() code - UNIX extensions now use this too. Jeremy. (This used to be commit aad6eb2240393931940c982e25a981ce32264f38)
Diffstat (limited to 'source3/libsmb/clifile.c')
-rw-r--r--source3/libsmb/clifile.c44
1 files changed, 42 insertions, 2 deletions
diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c
index 9b766987efe..a3fa811e29f 100644
--- a/source3/libsmb/clifile.c
+++ b/source3/libsmb/clifile.c
@@ -36,16 +36,18 @@ static BOOL cli_link_internal(struct cli_state *cli, const char *fname_src, cons
pstring data;
char *rparam=NULL, *rdata=NULL;
char *p;
+ size_t srclen = 2*(strlen(fname_src)+1);
+ size_t destlen = 2*(strlen(fname_dst) + 1);
memset(param, 0, sizeof(param));
SSVAL(param,0,hard_link ? SMB_SET_FILE_UNIX_HLINK : SMB_SET_FILE_UNIX_LINK);
p = &param[6];
- p += clistr_push(cli, p, fname_src, -1, STR_TERMINATE);
+ p += clistr_push(cli, p, fname_src, MIN(srclen, sizeof(param)-6), STR_TERMINATE);
param_len = PTR_DIFF(p, param);
p = data;
- p += clistr_push(cli, p, fname_dst, -1, STR_TERMINATE);
+ p += clistr_push(cli, p, fname_dst, MIN(destlen,sizeof(data)), STR_TERMINATE);
data_len = PTR_DIFF(p, data);
if (!cli_send_trans(cli, SMBtrans2,
@@ -262,6 +264,44 @@ BOOL cli_ntrename(struct cli_state *cli, const char *fname_src, const char *fnam
}
/****************************************************************************
+ NT hardlink a file.
+****************************************************************************/
+
+BOOL cli_nt_hardlink(struct cli_state *cli, const char *fname_src, const char *fname_dst)
+{
+ char *p;
+
+ memset(cli->outbuf,'\0',smb_size);
+ memset(cli->inbuf,'\0',smb_size);
+
+ set_message(cli->outbuf, 4, 0, True);
+
+ SCVAL(cli->outbuf,smb_com,SMBntrename);
+ SSVAL(cli->outbuf,smb_tid,cli->cnum);
+ cli_setup_packet(cli);
+
+ SSVAL(cli->outbuf,smb_vwv0,aSYSTEM | aHIDDEN | aDIR);
+ SSVAL(cli->outbuf,smb_vwv1, RENAME_FLAG_HARD_LINK);
+
+ p = smb_buf(cli->outbuf);
+ *p++ = 4;
+ p += clistr_push(cli, p, fname_src, -1, STR_TERMINATE);
+ *p++ = 4;
+ p += clistr_push(cli, p, fname_dst, -1, STR_TERMINATE);
+
+ cli_setup_bcc(cli, p);
+
+ cli_send_smb(cli);
+ if (!cli_receive_smb(cli))
+ return False;
+
+ if (cli_is_error(cli))
+ return False;
+
+ return True;
+}
+
+/****************************************************************************
Delete a file.
****************************************************************************/