use cli_list_old() when negotiating the older protocols
[tprouty/samba.git] / source / libsmb / clifile.c
index 60e9251995d6ca365a60a3c0d523ca8b6c0b52cd..3471ecdc679a2d068548ab498a665007680f1466 100644 (file)
@@ -172,6 +172,7 @@ open a file
 int cli_nt_create(struct cli_state *cli, char *fname, uint32 DesiredAccess)
 {
        char *p;
+       int len;
 
        memset(cli->outbuf,'\0',smb_size);
        memset(cli->inbuf,'\0',smb_size);
@@ -194,10 +195,15 @@ int cli_nt_create(struct cli_state *cli, char *fname, uint32 DesiredAccess)
        SIVAL(cli->outbuf,smb_ntcreate_CreateDisposition, 0x01);
        SIVAL(cli->outbuf,smb_ntcreate_CreateOptions, 0x0);
        SIVAL(cli->outbuf,smb_ntcreate_ImpersonationLevel, 0x02);
-       SSVAL(cli->outbuf,smb_ntcreate_NameLength, strlen(fname));
 
        p = smb_buf(cli->outbuf);
-       p += clistr_push(cli, p, fname, -1, CLISTR_TERMINATE | CLISTR_CONVERT);
+       /* this alignment and termination is critical for netapp filers. Don't change */
+       p += clistr_align(cli, PTR_DIFF(p, cli->outbuf));
+       len = clistr_push(cli, p, fname, -1, CLISTR_CONVERT);
+       p += len;
+       SSVAL(cli->outbuf,smb_ntcreate_NameLength, len);
+       /* sigh. this copes with broken netapp filer behaviour */
+       p += clistr_push(cli, p, "", -1, CLISTR_TERMINATE);
 
        cli_setup_bcc(cli, p);
 
@@ -213,56 +219,6 @@ int cli_nt_create(struct cli_state *cli, char *fname, uint32 DesiredAccess)
        return SVAL(cli->inbuf,smb_vwv2 + 1);
 }
 
-/****************************************************************************
-open a file
-****************************************************************************/
-int cli_nt_create_uni(struct cli_state *cli, char *fname, uint32 DesiredAccess)
-{
-       pstring uni;
-       char *p;
-
-       memset(cli->outbuf,'\0',smb_size);
-       memset(cli->inbuf,'\0',smb_size);
-
-       set_message(cli->outbuf,24,0,True);
-
-       CVAL(cli->outbuf,smb_com) = SMBntcreateX;
-       SSVAL(cli->outbuf,smb_tid,cli->cnum);
-       cli_setup_packet(cli);
-
-       SSVAL(cli->outbuf,smb_vwv0,0xFF);
-       if (cli->use_oplocks)
-               SIVAL(cli->outbuf,smb_ntcreate_Flags, REQUEST_OPLOCK|REQUEST_BATCH_OPLOCK);
-       else 
-               SIVAL(cli->outbuf,smb_ntcreate_Flags, 0);
-       SIVAL(cli->outbuf,smb_ntcreate_RootDirectoryFid, 0x0);
-       SIVAL(cli->outbuf,smb_ntcreate_DesiredAccess, DesiredAccess);
-       SIVAL(cli->outbuf,smb_ntcreate_FileAttributes, 0x0);
-       SIVAL(cli->outbuf,smb_ntcreate_ShareAccess, 0x03);
-       SIVAL(cli->outbuf,smb_ntcreate_CreateDisposition, 0x01);
-       SIVAL(cli->outbuf,smb_ntcreate_CreateOptions, 0x0);
-       SIVAL(cli->outbuf,smb_ntcreate_ImpersonationLevel, 0x02);
-       SSVAL(cli->outbuf,smb_ntcreate_NameLength, strlen(fname) * 2);
-
-       p = smb_buf(cli->outbuf);
-       p++; /* Alignment */
-       pstrcpy(uni, fname);
-       unix_to_dos(uni, True);
-       p += dos_struni2(p, uni, (strlen(fname) + 1) * 2);
-       cli_setup_bcc(cli, p);
-       cli_send_smb(cli);
-       if (!cli_receive_smb(cli)) {
-               return -1;
-       }
-
-       if (CVAL(cli->inbuf,smb_rcls) != 0) {
-               return -1;
-       }
-
-       return SVAL(cli->inbuf,smb_vwv2 + 1);
-}
-
-
 /****************************************************************************
 open a file
 WARNING: if you open with O_WRONLY then getattrE won't work!