Added a cli_nt_create_uni() to do a ntcreate&x with a unicode filename,
authorTim Potter <tpot@samba.org>
Thu, 21 Dec 2000 05:22:15 +0000 (05:22 +0000)
committerTim Potter <tpot@samba.org>
Thu, 21 Dec 2000 05:22:15 +0000 (05:22 +0000)
regardless of the settings negotiated in the flags2 smb field.
(This used to be commit c4476c6315a6e99dd4a1d0e3185a0d17c073205d)

source3/libsmb/clifile.c

index cb492f1539b9a80f8ebbac6fe027ed2b40cda308..ce9a79ede34fb4d42f27243f05025cec4d45063f 100644 (file)
@@ -163,8 +163,6 @@ BOOL cli_rmdir(struct cli_state *cli, char *dname)
        return True;
 }
 
-
-
 /****************************************************************************
 open a file
 ****************************************************************************/
@@ -212,6 +210,55 @@ 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,(strlen(fname) + 1) * 2 + 1,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);
+       dos_struni2(p, uni, (strlen(fname) + 1) * 2);
+
+       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