packaging: Add missing quotes in smbprint
[Samba.git] / source4 / libcli / clifile.c
blobc6a5cd5a5e7fe3a947491cb8e5278943ed4dfd0d
1 /*
2 Unix SMB/CIFS implementation.
3 client file operations
4 Copyright (C) Andrew Tridgell 1994-1998
5 Copyright (C) Jeremy Allison 2001-2002
6 Copyright (C) James Myers 2003
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "includes.h"
23 #include "system/filesys.h"
24 #include "libcli/raw/libcliraw.h"
25 #include "libcli/libcli.h"
26 #include "system/dir.h"
28 /****************************************************************************
29 Hard/Symlink a file (UNIX extensions).
30 ****************************************************************************/
32 static NTSTATUS smbcli_link_internal(struct smbcli_tree *tree,
33 const char *fname_src,
34 const char *fname_dst, bool hard_link)
36 union smb_setfileinfo parms;
37 NTSTATUS status;
39 if (hard_link) {
40 parms.generic.level = RAW_SFILEINFO_UNIX_HLINK;
41 parms.unix_hlink.in.file.path = fname_src;
42 parms.unix_hlink.in.link_dest = fname_dst;
43 } else {
44 parms.generic.level = RAW_SFILEINFO_UNIX_LINK;
45 parms.unix_link.in.file.path = fname_src;
46 parms.unix_link.in.link_dest = fname_dst;
49 status = smb_raw_setpathinfo(tree, &parms);
51 return status;
54 /****************************************************************************
55 Symlink a file (UNIX extensions).
56 ****************************************************************************/
57 NTSTATUS smbcli_unix_symlink(struct smbcli_tree *tree, const char *fname_src,
58 const char *fname_dst)
60 return smbcli_link_internal(tree, fname_src, fname_dst, false);
63 /****************************************************************************
64 Hard a file (UNIX extensions).
65 ****************************************************************************/
66 NTSTATUS smbcli_unix_hardlink(struct smbcli_tree *tree, const char *fname_src,
67 const char *fname_dst)
69 return smbcli_link_internal(tree, fname_src, fname_dst, true);
73 /****************************************************************************
74 Chmod or chown a file internal (UNIX extensions).
75 ****************************************************************************/
76 static NTSTATUS smbcli_unix_chmod_chown_internal(struct smbcli_tree *tree,
77 const char *fname,
78 uint32_t mode, uint32_t uid,
79 uint32_t gid)
81 union smb_setfileinfo parms;
82 NTSTATUS status;
84 parms.generic.level = SMB_SFILEINFO_UNIX_BASIC;
85 parms.unix_basic.in.file.path = fname;
86 parms.unix_basic.in.uid = uid;
87 parms.unix_basic.in.gid = gid;
88 parms.unix_basic.in.mode = mode;
90 status = smb_raw_setpathinfo(tree, &parms);
92 return status;
95 /****************************************************************************
96 chmod a file (UNIX extensions).
97 ****************************************************************************/
99 NTSTATUS smbcli_unix_chmod(struct smbcli_tree *tree, const char *fname, mode_t mode)
101 return smbcli_unix_chmod_chown_internal(tree, fname,
102 unix_perms_to_wire(mode),
103 SMB_UID_NO_CHANGE,
104 SMB_GID_NO_CHANGE);
107 /****************************************************************************
108 chown a file (UNIX extensions).
109 ****************************************************************************/
110 NTSTATUS smbcli_unix_chown(struct smbcli_tree *tree, const char *fname, uid_t uid,
111 gid_t gid)
113 return smbcli_unix_chmod_chown_internal(tree, fname, SMB_MODE_NO_CHANGE,
114 (uint32_t)uid, (uint32_t)gid);
118 /****************************************************************************
119 Rename a file.
120 ****************************************************************************/
121 NTSTATUS smbcli_rename(struct smbcli_tree *tree, const char *fname_src,
122 const char *fname_dst)
124 union smb_rename parms;
126 parms.generic.level = RAW_RENAME_RENAME;
127 parms.rename.in.attrib = FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY;
128 parms.rename.in.pattern1 = fname_src;
129 parms.rename.in.pattern2 = fname_dst;
131 return smb_raw_rename(tree, &parms);
135 /****************************************************************************
136 Delete a file.
137 ****************************************************************************/
138 NTSTATUS smbcli_unlink(struct smbcli_tree *tree, const char *fname)
140 union smb_unlink parms;
142 parms.unlink.in.pattern = fname;
143 parms.unlink.in.attrib = FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY;
145 return smb_raw_unlink(tree, &parms);
148 struct wcard_delete_state {
149 struct smbcli_tree *tree;
150 NTSTATUS status;
151 char *error_name; /* To help debugging. */
154 static void del_fn(struct clilist_file_info *finfo,
155 const char *pattern,
156 void *priv)
158 NTSTATUS status;
159 union smb_unlink parms;
160 char *filename = NULL;
161 char *dirname = NULL;
162 char *p = NULL;
163 struct wcard_delete_state *state = (struct wcard_delete_state *)priv;
165 if (ISDOT(finfo->name) || ISDOTDOT(finfo->name)) {
166 return;
168 dirname = talloc_strdup(state, pattern);
169 if (dirname == NULL) {
170 TALLOC_FREE(state->error_name);
171 state->status = NT_STATUS_NO_MEMORY;
172 return;
174 p = strrchr_m(dirname, '\\');
175 if (p != NULL) {
176 /* Remove the terminating '\' */
177 *p = '\0';
179 if (dirname[0] != '\0') {
180 filename = talloc_asprintf(dirname,
181 "%s\\%s",
182 dirname,
183 finfo->name);
184 } else {
185 filename = talloc_asprintf(dirname,
186 "%s",
187 finfo->name);
189 if (filename == NULL) {
190 TALLOC_FREE(dirname);
191 TALLOC_FREE(state->error_name);
192 state->status = NT_STATUS_NO_MEMORY;
193 return;
195 parms.unlink.in.pattern = filename;
196 parms.unlink.in.attrib = FILE_ATTRIBUTE_SYSTEM |
197 FILE_ATTRIBUTE_HIDDEN;
198 status = smb_raw_unlink(state->tree, &parms);
199 if (NT_STATUS_IS_OK(state->status)) {
200 state->status = status;
201 if (!NT_STATUS_IS_OK(status)) {
203 * Save off the name we failed to
204 * delete to help debugging.
206 state->error_name = talloc_move(state, &filename);
209 TALLOC_FREE(dirname);
212 /****************************************************************************
213 Delete a file, possibly with a wildcard pattern.
214 ****************************************************************************/
215 NTSTATUS smbcli_unlink_wcard(struct smbcli_tree *tree, const char *pattern)
217 NTSTATUS status;
218 int ret;
219 struct wcard_delete_state *state = NULL;
221 if (strchr(pattern, '*') == NULL) {
222 /* No wildcard, just call smbcli_unlink(). */
223 return smbcli_unlink(tree, pattern);
225 state = talloc_zero(tree, struct wcard_delete_state);
226 if (state == NULL) {
227 return NT_STATUS_NO_MEMORY;
229 state->tree = tree;
230 ret = smbcli_list(tree,
231 pattern,
232 FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN,
233 del_fn,
234 state);
235 status = state->status;
236 TALLOC_FREE(state);
237 if (ret < 0) {
238 return NT_STATUS_UNSUCCESSFUL;
240 return status;
243 /****************************************************************************
244 Create a directory.
245 ****************************************************************************/
246 NTSTATUS smbcli_mkdir(struct smbcli_tree *tree, const char *dname)
248 union smb_mkdir parms;
250 parms.mkdir.level = RAW_MKDIR_MKDIR;
251 parms.mkdir.in.path = dname;
253 return smb_raw_mkdir(tree, &parms);
257 /****************************************************************************
258 Remove a directory.
259 ****************************************************************************/
260 NTSTATUS smbcli_rmdir(struct smbcli_tree *tree, const char *dname)
262 struct smb_rmdir parms;
264 parms.in.path = dname;
266 return smb_raw_rmdir(tree, &parms);
270 /****************************************************************************
271 Set or clear the delete on close flag.
272 ****************************************************************************/
273 NTSTATUS smbcli_nt_delete_on_close(struct smbcli_tree *tree, int fnum,
274 bool flag)
276 union smb_setfileinfo parms;
277 NTSTATUS status;
279 parms.disposition_info.level = RAW_SFILEINFO_DISPOSITION_INFO;
280 parms.disposition_info.in.file.fnum = fnum;
281 parms.disposition_info.in.delete_on_close = flag;
283 status = smb_raw_setfileinfo(tree, &parms);
285 return status;
289 /****************************************************************************
290 Create/open a file - exposing the full horror of the NT API :-).
291 Used in CIFS-on-CIFS NTVFS.
292 ****************************************************************************/
293 int smbcli_nt_create_full(struct smbcli_tree *tree, const char *fname,
294 uint32_t CreatFlags, uint32_t DesiredAccess,
295 uint32_t FileAttributes, uint32_t ShareAccess,
296 uint32_t CreateDisposition, uint32_t CreateOptions,
297 uint8_t SecurityFlags)
299 union smb_open open_parms;
300 TALLOC_CTX *mem_ctx;
301 NTSTATUS status;
303 mem_ctx = talloc_init("raw_open");
304 if (!mem_ctx) return -1;
306 open_parms.ntcreatex.level = RAW_OPEN_NTCREATEX;
307 open_parms.ntcreatex.in.flags = CreatFlags;
308 open_parms.ntcreatex.in.root_fid.fnum = 0;
309 open_parms.ntcreatex.in.access_mask = DesiredAccess;
310 open_parms.ntcreatex.in.file_attr = FileAttributes;
311 open_parms.ntcreatex.in.alloc_size = 0;
312 open_parms.ntcreatex.in.share_access = ShareAccess;
313 open_parms.ntcreatex.in.open_disposition = CreateDisposition;
314 open_parms.ntcreatex.in.create_options = CreateOptions;
315 open_parms.ntcreatex.in.impersonation = 0;
316 open_parms.ntcreatex.in.security_flags = SecurityFlags;
317 open_parms.ntcreatex.in.fname = fname;
319 status = smb_raw_open(tree, mem_ctx, &open_parms);
320 talloc_free(mem_ctx);
322 if (NT_STATUS_IS_OK(status)) {
323 return open_parms.ntcreatex.out.file.fnum;
326 return -1;
330 /****************************************************************************
331 Open a file (using SMBopenx)
332 WARNING: if you open with O_WRONLY then getattrE won't work!
333 ****************************************************************************/
334 int smbcli_open(struct smbcli_tree *tree, const char *fname, int flags,
335 int share_mode)
337 union smb_open open_parms;
338 unsigned int openfn=0;
339 unsigned int accessmode=0;
340 TALLOC_CTX *mem_ctx;
341 NTSTATUS status;
343 mem_ctx = talloc_init("raw_open");
344 if (!mem_ctx) return -1;
346 if (flags & O_CREAT) {
347 openfn |= OPENX_OPEN_FUNC_CREATE;
349 if (!(flags & O_EXCL)) {
350 if (flags & O_TRUNC) {
351 openfn |= OPENX_OPEN_FUNC_TRUNC;
352 } else {
353 openfn |= OPENX_OPEN_FUNC_OPEN;
357 accessmode = (share_mode<<OPENX_MODE_DENY_SHIFT);
359 if ((flags & O_ACCMODE) == O_RDWR) {
360 accessmode |= OPENX_MODE_ACCESS_RDWR;
361 } else if ((flags & O_ACCMODE) == O_WRONLY) {
362 accessmode |= OPENX_MODE_ACCESS_WRITE;
365 #if defined(O_SYNC)
366 if ((flags & O_SYNC) == O_SYNC) {
367 accessmode |= OPENX_MODE_WRITE_THRU;
369 #endif
371 if (share_mode == DENY_FCB) {
372 accessmode = OPENX_MODE_ACCESS_FCB | OPENX_MODE_DENY_FCB;
375 open_parms.openx.level = RAW_OPEN_OPENX;
376 open_parms.openx.in.flags = 0;
377 open_parms.openx.in.open_mode = accessmode;
378 open_parms.openx.in.search_attrs = FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN;
379 open_parms.openx.in.file_attrs = 0;
380 open_parms.openx.in.write_time = 0;
381 open_parms.openx.in.open_func = openfn;
382 open_parms.openx.in.size = 0;
383 open_parms.openx.in.timeout = 0;
384 open_parms.openx.in.fname = fname;
386 status = smb_raw_open(tree, mem_ctx, &open_parms);
387 talloc_free(mem_ctx);
389 if (NT_STATUS_IS_OK(status)) {
390 return open_parms.openx.out.file.fnum;
393 return -1;
397 /****************************************************************************
398 Close a file.
399 ****************************************************************************/
400 NTSTATUS smbcli_close(struct smbcli_tree *tree, int fnum)
402 union smb_close close_parms;
403 NTSTATUS status;
405 close_parms.close.level = RAW_CLOSE_CLOSE;
406 close_parms.close.in.file.fnum = fnum;
407 close_parms.close.in.write_time = 0;
408 status = smb_raw_close(tree, &close_parms);
409 return status;
412 /****************************************************************************
413 send a lock with a specified locktype
414 this is used for testing LOCKING_ANDX_CANCEL_LOCK
415 ****************************************************************************/
416 NTSTATUS smbcli_locktype(struct smbcli_tree *tree, int fnum,
417 uint32_t offset, uint32_t len, int timeout,
418 uint8_t locktype)
420 union smb_lock parms;
421 struct smb_lock_entry lock[1];
422 NTSTATUS status;
424 parms.lockx.level = RAW_LOCK_LOCKX;
425 parms.lockx.in.file.fnum = fnum;
426 parms.lockx.in.mode = locktype;
427 parms.lockx.in.timeout = timeout;
428 parms.lockx.in.ulock_cnt = 0;
429 parms.lockx.in.lock_cnt = 1;
430 lock[0].pid = tree->session->pid;
431 lock[0].offset = offset;
432 lock[0].count = len;
433 parms.lockx.in.locks = &lock[0];
435 status = smb_raw_lock(tree, &parms);
437 return status;
441 /****************************************************************************
442 Lock a file.
443 ****************************************************************************/
444 NTSTATUS smbcli_lock(struct smbcli_tree *tree, int fnum,
445 uint32_t offset, uint32_t len, int timeout,
446 enum brl_type lock_type)
448 union smb_lock parms;
449 struct smb_lock_entry lock[1];
450 NTSTATUS status;
452 parms.lockx.level = RAW_LOCK_LOCKX;
453 parms.lockx.in.file.fnum = fnum;
454 parms.lockx.in.mode = (lock_type == READ_LOCK? 1 : 0);
455 parms.lockx.in.timeout = timeout;
456 parms.lockx.in.ulock_cnt = 0;
457 parms.lockx.in.lock_cnt = 1;
458 lock[0].pid = tree->session->pid;
459 lock[0].offset = offset;
460 lock[0].count = len;
461 parms.lockx.in.locks = &lock[0];
463 status = smb_raw_lock(tree, &parms);
465 return status;
469 /****************************************************************************
470 Unlock a file.
471 ****************************************************************************/
472 NTSTATUS smbcli_unlock(struct smbcli_tree *tree, int fnum, uint32_t offset, uint32_t len)
474 union smb_lock parms;
475 struct smb_lock_entry lock[1];
476 NTSTATUS status;
478 parms.lockx.level = RAW_LOCK_LOCKX;
479 parms.lockx.in.file.fnum = fnum;
480 parms.lockx.in.mode = 0;
481 parms.lockx.in.timeout = 0;
482 parms.lockx.in.ulock_cnt = 1;
483 parms.lockx.in.lock_cnt = 0;
484 lock[0].pid = tree->session->pid;
485 lock[0].offset = offset;
486 lock[0].count = len;
487 parms.lockx.in.locks = &lock[0];
489 status = smb_raw_lock(tree, &parms);
490 return status;
494 /****************************************************************************
495 Lock a file with 64 bit offsets.
496 ****************************************************************************/
497 NTSTATUS smbcli_lock64(struct smbcli_tree *tree, int fnum,
498 off_t offset, off_t len, int timeout,
499 enum brl_type lock_type)
501 union smb_lock parms;
502 int ltype;
503 struct smb_lock_entry lock[1];
504 NTSTATUS status;
506 if (!(tree->session->transport->negotiate.capabilities & CAP_LARGE_FILES)) {
507 return smbcli_lock(tree, fnum, offset, len, timeout, lock_type);
510 parms.lockx.level = RAW_LOCK_LOCKX;
511 parms.lockx.in.file.fnum = fnum;
513 ltype = (lock_type == READ_LOCK? 1 : 0);
514 ltype |= LOCKING_ANDX_LARGE_FILES;
515 parms.lockx.in.mode = ltype;
516 parms.lockx.in.timeout = timeout;
517 parms.lockx.in.ulock_cnt = 0;
518 parms.lockx.in.lock_cnt = 1;
519 lock[0].pid = tree->session->pid;
520 lock[0].offset = offset;
521 lock[0].count = len;
522 parms.lockx.in.locks = &lock[0];
524 status = smb_raw_lock(tree, &parms);
526 return status;
530 /****************************************************************************
531 Unlock a file with 64 bit offsets.
532 ****************************************************************************/
533 NTSTATUS smbcli_unlock64(struct smbcli_tree *tree, int fnum, off_t offset,
534 off_t len)
536 union smb_lock parms;
537 struct smb_lock_entry lock[1];
538 NTSTATUS status;
540 if (!(tree->session->transport->negotiate.capabilities & CAP_LARGE_FILES)) {
541 return smbcli_unlock(tree, fnum, offset, len);
544 parms.lockx.level = RAW_LOCK_LOCKX;
545 parms.lockx.in.file.fnum = fnum;
546 parms.lockx.in.mode = LOCKING_ANDX_LARGE_FILES;
547 parms.lockx.in.timeout = 0;
548 parms.lockx.in.ulock_cnt = 1;
549 parms.lockx.in.lock_cnt = 0;
550 lock[0].pid = tree->session->pid;
551 lock[0].offset = offset;
552 lock[0].count = len;
553 parms.lockx.in.locks = &lock[0];
555 status = smb_raw_lock(tree, &parms);
557 return status;
561 /****************************************************************************
562 Do a SMBgetattrE call.
563 ****************************************************************************/
564 NTSTATUS smbcli_getattrE(struct smbcli_tree *tree, int fnum,
565 uint16_t *attr, size_t *size,
566 time_t *c_time, time_t *a_time, time_t *m_time)
568 union smb_fileinfo parms;
569 NTSTATUS status;
571 parms.getattre.level = RAW_FILEINFO_GETATTRE;
572 parms.getattre.in.file.fnum = fnum;
574 status = smb_raw_fileinfo(tree, NULL, &parms);
576 if (!NT_STATUS_IS_OK(status))
577 return status;
579 if (size) {
580 *size = parms.getattre.out.size;
583 if (attr) {
584 *attr = parms.getattre.out.attrib;
587 if (c_time) {
588 *c_time = parms.getattre.out.create_time;
591 if (a_time) {
592 *a_time = parms.getattre.out.access_time;
595 if (m_time) {
596 *m_time = parms.getattre.out.write_time;
599 return status;
602 /****************************************************************************
603 Do a SMBgetatr call
604 ****************************************************************************/
605 NTSTATUS smbcli_getatr(struct smbcli_tree *tree, const char *fname,
606 uint16_t *attr, size_t *size, time_t *t)
608 union smb_fileinfo parms;
609 NTSTATUS status;
611 parms.getattr.level = RAW_FILEINFO_GETATTR;
612 parms.getattr.in.file.path = fname;
614 status = smb_raw_pathinfo(tree, NULL, &parms);
616 if (!NT_STATUS_IS_OK(status)) {
617 return status;
620 if (size) {
621 *size = parms.getattr.out.size;
624 if (t) {
625 *t = parms.getattr.out.write_time;
628 if (attr) {
629 *attr = parms.getattr.out.attrib;
632 return status;
636 /****************************************************************************
637 Do a SMBsetatr call.
638 ****************************************************************************/
639 NTSTATUS smbcli_setatr(struct smbcli_tree *tree, const char *fname, uint16_t mode,
640 time_t t)
642 union smb_setfileinfo parms;
644 parms.setattr.level = RAW_SFILEINFO_SETATTR;
645 parms.setattr.in.file.path = fname;
646 parms.setattr.in.attrib = mode;
647 parms.setattr.in.write_time = t;
649 return smb_raw_setpathinfo(tree, &parms);
652 /****************************************************************************
653 Do a setfileinfo basic_info call.
654 ****************************************************************************/
655 NTSTATUS smbcli_fsetatr(struct smbcli_tree *tree, int fnum, uint16_t mode,
656 NTTIME create_time, NTTIME access_time,
657 NTTIME write_time, NTTIME change_time)
659 union smb_setfileinfo parms;
661 parms.basic_info.level = RAW_SFILEINFO_BASIC_INFO;
662 parms.basic_info.in.file.fnum = fnum;
663 parms.basic_info.in.attrib = mode;
664 parms.basic_info.in.create_time = create_time;
665 parms.basic_info.in.access_time = access_time;
666 parms.basic_info.in.write_time = write_time;
667 parms.basic_info.in.change_time = change_time;
669 return smb_raw_setfileinfo(tree, &parms);
673 /****************************************************************************
674 truncate a file to a given size
675 ****************************************************************************/
676 NTSTATUS smbcli_ftruncate(struct smbcli_tree *tree, int fnum, uint64_t size)
678 union smb_setfileinfo parms;
680 parms.end_of_file_info.level = RAW_SFILEINFO_END_OF_FILE_INFO;
681 parms.end_of_file_info.in.file.fnum = fnum;
682 parms.end_of_file_info.in.size = size;
684 return smb_raw_setfileinfo(tree, &parms);
688 /****************************************************************************
689 Check for existence of a dir.
690 ****************************************************************************/
691 NTSTATUS smbcli_chkpath(struct smbcli_tree *tree, const char *path)
693 union smb_chkpath parms;
694 char *path2;
695 NTSTATUS status;
697 path2 = strdup(path);
698 trim_string(path2,NULL,"\\");
699 if (!*path2) {
700 free(path2);
701 path2 = strdup("\\");
704 parms.chkpath.in.path = path2;
706 status = smb_raw_chkpath(tree, &parms);
708 free(path2);
710 return status;
714 /****************************************************************************
715 Query disk space.
716 ****************************************************************************/
717 NTSTATUS smbcli_dskattr(struct smbcli_tree *tree, uint32_t *bsize,
718 uint64_t *total, uint64_t *avail)
720 union smb_fsinfo fsinfo_parms;
721 TALLOC_CTX *mem_ctx;
722 NTSTATUS status;
724 mem_ctx = talloc_init("smbcli_dskattr");
726 fsinfo_parms.dskattr.level = RAW_QFS_SIZE_INFO;
727 status = smb_raw_fsinfo(tree, mem_ctx, &fsinfo_parms);
728 if (NT_STATUS_IS_OK(status)) {
729 *bsize = fsinfo_parms.size_info.out.bytes_per_sector * fsinfo_parms.size_info.out.sectors_per_unit;
730 *total = fsinfo_parms.size_info.out.total_alloc_units;
731 *avail = fsinfo_parms.size_info.out.avail_alloc_units;
734 talloc_free(mem_ctx);
736 return status;
740 /****************************************************************************
741 Create and open a temporary file.
742 ****************************************************************************/
743 int smbcli_ctemp(struct smbcli_tree *tree, const char *path, char **tmp_path)
745 union smb_open open_parms;
746 TALLOC_CTX *mem_ctx;
747 NTSTATUS status;
748 int ret = -1;
750 mem_ctx = talloc_init("raw_open");
751 if (!mem_ctx) return ret;
753 open_parms.openx.level = RAW_OPEN_CTEMP;
754 open_parms.ctemp.in.attrib = 0;
755 open_parms.ctemp.in.directory = path;
756 open_parms.ctemp.in.write_time = 0;
758 status = smb_raw_open(tree, mem_ctx, &open_parms);
759 if (NT_STATUS_IS_OK(status)) {
760 if (tmp_path) {
761 *tmp_path = strdup(open_parms.ctemp.out.name);
763 ret = open_parms.ctemp.out.file.fnum;
765 talloc_free(mem_ctx);
766 return ret;