2 Unix SMB/CIFS implementation.
4 Copyright (C) Andrew Tridgell 1994-1998
5 Copyright (C) Jeremy Allison 2001-2002
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 /****************************************************************************
25 Hard/Symlink a file (UNIX extensions).
26 Creates new name (sym)linked to oldname.
27 ****************************************************************************/
29 static BOOL
cli_link_internal(struct cli_state
*cli
, const char *oldname
, const char *newname
, BOOL hard_link
)
31 unsigned int data_len
= 0;
32 unsigned int param_len
= 0;
33 uint16 setup
= TRANSACT2_SETPATHINFO
;
34 char param
[sizeof(pstring
)+6];
36 char *rparam
=NULL
, *rdata
=NULL
;
38 size_t oldlen
= 2*(strlen(oldname
)+1);
39 size_t newlen
= 2*(strlen(newname
)+1);
41 memset(param
, 0, sizeof(param
));
42 SSVAL(param
,0,hard_link
? SMB_SET_FILE_UNIX_HLINK
: SMB_SET_FILE_UNIX_LINK
);
45 p
+= clistr_push(cli
, p
, newname
, MIN(newlen
, sizeof(param
)-6), STR_TERMINATE
);
46 param_len
= PTR_DIFF(p
, param
);
49 p
+= clistr_push(cli
, p
, oldname
, MIN(oldlen
,sizeof(data
)), STR_TERMINATE
);
50 data_len
= PTR_DIFF(p
, data
);
52 if (!cli_send_trans(cli
, SMBtrans2
,
54 -1, 0, /* fid, flags */
55 &setup
, 1, 0, /* setup, length, max */
56 param
, param_len
, 2, /* param, length, max */
57 (char *)&data
, data_len
, cli
->max_xmit
/* data, length, max */
62 if (!cli_receive_trans(cli
, SMBtrans2
,
74 /****************************************************************************
75 Map standard UNIX permissions onto wire representations.
76 ****************************************************************************/
78 uint32
unix_perms_to_wire(mode_t perms
)
82 ret
|= ((perms
& S_IXOTH
) ? UNIX_X_OTH
: 0);
83 ret
|= ((perms
& S_IWOTH
) ? UNIX_W_OTH
: 0);
84 ret
|= ((perms
& S_IROTH
) ? UNIX_R_OTH
: 0);
85 ret
|= ((perms
& S_IXGRP
) ? UNIX_X_GRP
: 0);
86 ret
|= ((perms
& S_IWGRP
) ? UNIX_W_GRP
: 0);
87 ret
|= ((perms
& S_IRGRP
) ? UNIX_R_GRP
: 0);
88 ret
|= ((perms
& S_IXUSR
) ? UNIX_X_USR
: 0);
89 ret
|= ((perms
& S_IWUSR
) ? UNIX_W_USR
: 0);
90 ret
|= ((perms
& S_IRUSR
) ? UNIX_R_USR
: 0);
92 ret
|= ((perms
& S_ISVTX
) ? UNIX_STICKY
: 0);
95 ret
|= ((perms
& S_ISGID
) ? UNIX_SET_GID
: 0);
98 ret
|= ((perms
& S_ISUID
) ? UNIX_SET_UID
: 0);
103 /****************************************************************************
104 Map wire permissions to standard UNIX.
105 ****************************************************************************/
107 mode_t
wire_perms_to_unix(uint32 perms
)
109 mode_t ret
= (mode_t
)0;
111 ret
|= ((perms
& UNIX_X_OTH
) ? S_IXOTH
: 0);
112 ret
|= ((perms
& UNIX_W_OTH
) ? S_IWOTH
: 0);
113 ret
|= ((perms
& UNIX_R_OTH
) ? S_IROTH
: 0);
114 ret
|= ((perms
& UNIX_X_GRP
) ? S_IXGRP
: 0);
115 ret
|= ((perms
& UNIX_W_GRP
) ? S_IWGRP
: 0);
116 ret
|= ((perms
& UNIX_R_GRP
) ? S_IRGRP
: 0);
117 ret
|= ((perms
& UNIX_X_USR
) ? S_IXUSR
: 0);
118 ret
|= ((perms
& UNIX_W_USR
) ? S_IWUSR
: 0);
119 ret
|= ((perms
& UNIX_R_USR
) ? S_IRUSR
: 0);
121 ret
|= ((perms
& UNIX_STICKY
) ? S_ISVTX
: 0);
124 ret
|= ((perms
& UNIX_SET_GID
) ? S_ISGID
: 0);
127 ret
|= ((perms
& UNIX_SET_UID
) ? S_ISUID
: 0);
132 /****************************************************************************
133 Return the file type from the wire filetype for UNIX extensions.
134 ****************************************************************************/
136 static mode_t
unix_filetype_from_wire(uint32 wire_type
)
144 case UNIX_TYPE_SYMLINK
:
148 case UNIX_TYPE_CHARDEV
:
152 case UNIX_TYPE_BLKDEV
:
160 case UNIX_TYPE_SOCKET
:
168 /****************************************************************************
169 Do a POSIX getfacl (UNIX extensions).
170 ****************************************************************************/
172 BOOL
cli_unix_getfacl(struct cli_state
*cli
, const char *name
, size_t *prb_size
, char **retbuf
)
174 unsigned int param_len
= 0;
175 unsigned int data_len
= 0;
176 uint16 setup
= TRANSACT2_QPATHINFO
;
177 char param
[sizeof(pstring
)+6];
178 char *rparam
=NULL
, *rdata
=NULL
;
183 SSVAL(p
, 0, SMB_QUERY_POSIX_ACL
);
185 p
+= clistr_push(cli
, p
, name
, sizeof(pstring
)-6, STR_TERMINATE
);
186 param_len
= PTR_DIFF(p
, param
);
188 if (!cli_send_trans(cli
, SMBtrans2
,
190 -1, 0, /* fid, flags */
191 &setup
, 1, 0, /* setup, length, max */
192 param
, param_len
, 2, /* param, length, max */
193 NULL
, 0, cli
->max_xmit
/* data, length, max */
198 if (!cli_receive_trans(cli
, SMBtrans2
,
200 &rdata
, &data_len
)) {
212 *prb_size
= (size_t)data_len
;
217 /****************************************************************************
218 Stat a file (UNIX extensions).
219 ****************************************************************************/
221 BOOL
cli_unix_stat(struct cli_state
*cli
, const char *name
, SMB_STRUCT_STAT
*sbuf
)
223 unsigned int param_len
= 0;
224 unsigned int data_len
= 0;
225 uint16 setup
= TRANSACT2_QPATHINFO
;
226 char param
[sizeof(pstring
)+6];
227 char *rparam
=NULL
, *rdata
=NULL
;
234 SSVAL(p
, 0, SMB_QUERY_FILE_UNIX_BASIC
);
236 p
+= clistr_push(cli
, p
, name
, sizeof(pstring
)-6, STR_TERMINATE
);
237 param_len
= PTR_DIFF(p
, param
);
239 if (!cli_send_trans(cli
, SMBtrans2
,
241 -1, 0, /* fid, flags */
242 &setup
, 1, 0, /* setup, length, max */
243 param
, param_len
, 2, /* param, length, max */
244 NULL
, 0, cli
->max_xmit
/* data, length, max */
249 if (!cli_receive_trans(cli
, SMBtrans2
,
251 &rdata
, &data_len
)) {
261 sbuf
->st_size
= IVAL2_TO_SMB_BIG_UINT(rdata
,0); /* total size, in bytes */
262 sbuf
->st_blocks
= IVAL2_TO_SMB_BIG_UINT(rdata
,8); /* number of blocks allocated */
263 #if defined (HAVE_STAT_ST_BLOCKS) && defined(STAT_ST_BLOCKSIZE)
264 sbuf
->st_blocks
/= STAT_ST_BLOCKSIZE
;
266 /* assume 512 byte blocks */
267 sbuf
->st_blocks
/= 512;
269 sbuf
->st_ctime
= interpret_long_date(rdata
+ 16); /* time of last change */
270 sbuf
->st_atime
= interpret_long_date(rdata
+ 24); /* time of last access */
271 sbuf
->st_mtime
= interpret_long_date(rdata
+ 32); /* time of last modification */
272 sbuf
->st_uid
= (uid_t
) IVAL(rdata
,40); /* user ID of owner */
273 sbuf
->st_gid
= (gid_t
) IVAL(rdata
,48); /* group ID of owner */
274 sbuf
->st_mode
|= unix_filetype_from_wire(IVAL(rdata
, 56));
275 #if defined(HAVE_MAKEDEV)
277 uint32 dev_major
= IVAL(rdata
,60);
278 uint32 dev_minor
= IVAL(rdata
,68);
279 sbuf
->st_rdev
= makedev(dev_major
, dev_minor
);
282 sbuf
->st_ino
= (SMB_INO_T
)IVAL2_TO_SMB_BIG_UINT(rdata
,76); /* inode */
283 sbuf
->st_mode
|= wire_perms_to_unix(IVAL(rdata
,84)); /* protection */
284 sbuf
->st_nlink
= IVAL(rdata
,92); /* number of hard links */
292 /****************************************************************************
293 Symlink a file (UNIX extensions).
294 ****************************************************************************/
296 BOOL
cli_unix_symlink(struct cli_state
*cli
, const char *oldname
, const char *newname
)
298 return cli_link_internal(cli
, oldname
, newname
, False
);
301 /****************************************************************************
302 Hard a file (UNIX extensions).
303 ****************************************************************************/
305 BOOL
cli_unix_hardlink(struct cli_state
*cli
, const char *oldname
, const char *newname
)
307 return cli_link_internal(cli
, oldname
, newname
, True
);
310 /****************************************************************************
311 Chmod or chown a file internal (UNIX extensions).
312 ****************************************************************************/
314 static BOOL
cli_unix_chmod_chown_internal(struct cli_state
*cli
, const char *fname
, uint32 mode
, uint32 uid
, uint32 gid
)
316 unsigned int data_len
= 0;
317 unsigned int param_len
= 0;
318 uint16 setup
= TRANSACT2_SETPATHINFO
;
319 char param
[sizeof(pstring
)+6];
321 char *rparam
=NULL
, *rdata
=NULL
;
324 memset(param
, 0, sizeof(param
));
325 memset(data
, 0, sizeof(data
));
326 SSVAL(param
,0,SMB_SET_FILE_UNIX_BASIC
);
329 p
+= clistr_push(cli
, p
, fname
, -1, STR_TERMINATE
);
330 param_len
= PTR_DIFF(p
, param
);
338 if (!cli_send_trans(cli
, SMBtrans2
,
340 -1, 0, /* fid, flags */
341 &setup
, 1, 0, /* setup, length, max */
342 param
, param_len
, 2, /* param, length, max */
343 (char *)&data
, data_len
, cli
->max_xmit
/* data, length, max */
348 if (!cli_receive_trans(cli
, SMBtrans2
,
350 &rdata
, &data_len
)) {
360 /****************************************************************************
361 chmod a file (UNIX extensions).
362 ****************************************************************************/
364 BOOL
cli_unix_chmod(struct cli_state
*cli
, const char *fname
, mode_t mode
)
366 return cli_unix_chmod_chown_internal(cli
, fname
,
367 unix_perms_to_wire(mode
), SMB_UID_NO_CHANGE
, SMB_GID_NO_CHANGE
);
370 /****************************************************************************
371 chown a file (UNIX extensions).
372 ****************************************************************************/
374 BOOL
cli_unix_chown(struct cli_state
*cli
, const char *fname
, uid_t uid
, gid_t gid
)
376 return cli_unix_chmod_chown_internal(cli
, fname
, SMB_MODE_NO_CHANGE
, (uint32
)uid
, (uint32
)gid
);
379 /****************************************************************************
381 ****************************************************************************/
383 BOOL
cli_rename(struct cli_state
*cli
, const char *fname_src
, const char *fname_dst
)
387 memset(cli
->outbuf
,'\0',smb_size
);
388 memset(cli
->inbuf
,'\0',smb_size
);
390 set_message(cli
->outbuf
,1, 0, True
);
392 SCVAL(cli
->outbuf
,smb_com
,SMBmv
);
393 SSVAL(cli
->outbuf
,smb_tid
,cli
->cnum
);
394 cli_setup_packet(cli
);
396 SSVAL(cli
->outbuf
,smb_vwv0
,aSYSTEM
| aHIDDEN
| aDIR
);
398 p
= smb_buf(cli
->outbuf
);
400 p
+= clistr_push(cli
, p
, fname_src
, -1, STR_TERMINATE
);
402 p
+= clistr_push(cli
, p
, fname_dst
, -1, STR_TERMINATE
);
404 cli_setup_bcc(cli
, p
);
407 if (!cli_receive_smb(cli
))
410 if (cli_is_error(cli
))
416 /****************************************************************************
418 ****************************************************************************/
420 BOOL
cli_ntrename(struct cli_state
*cli
, const char *fname_src
, const char *fname_dst
)
424 memset(cli
->outbuf
,'\0',smb_size
);
425 memset(cli
->inbuf
,'\0',smb_size
);
427 set_message(cli
->outbuf
, 4, 0, True
);
429 SCVAL(cli
->outbuf
,smb_com
,SMBntrename
);
430 SSVAL(cli
->outbuf
,smb_tid
,cli
->cnum
);
431 cli_setup_packet(cli
);
433 SSVAL(cli
->outbuf
,smb_vwv0
,aSYSTEM
| aHIDDEN
| aDIR
);
434 SSVAL(cli
->outbuf
,smb_vwv1
, RENAME_FLAG_RENAME
);
436 p
= smb_buf(cli
->outbuf
);
438 p
+= clistr_push(cli
, p
, fname_src
, -1, STR_TERMINATE
);
440 p
+= clistr_push(cli
, p
, fname_dst
, -1, STR_TERMINATE
);
442 cli_setup_bcc(cli
, p
);
445 if (!cli_receive_smb(cli
))
448 if (cli_is_error(cli
))
454 /****************************************************************************
456 ****************************************************************************/
458 BOOL
cli_nt_hardlink(struct cli_state
*cli
, const char *fname_src
, const char *fname_dst
)
462 memset(cli
->outbuf
,'\0',smb_size
);
463 memset(cli
->inbuf
,'\0',smb_size
);
465 set_message(cli
->outbuf
, 4, 0, True
);
467 SCVAL(cli
->outbuf
,smb_com
,SMBntrename
);
468 SSVAL(cli
->outbuf
,smb_tid
,cli
->cnum
);
469 cli_setup_packet(cli
);
471 SSVAL(cli
->outbuf
,smb_vwv0
,aSYSTEM
| aHIDDEN
| aDIR
);
472 SSVAL(cli
->outbuf
,smb_vwv1
, RENAME_FLAG_HARD_LINK
);
474 p
= smb_buf(cli
->outbuf
);
476 p
+= clistr_push(cli
, p
, fname_src
, -1, STR_TERMINATE
);
478 p
+= clistr_push(cli
, p
, fname_dst
, -1, STR_TERMINATE
);
480 cli_setup_bcc(cli
, p
);
483 if (!cli_receive_smb(cli
))
486 if (cli_is_error(cli
))
492 /****************************************************************************
494 ****************************************************************************/
496 BOOL
cli_unlink(struct cli_state
*cli
, const char *fname
)
500 memset(cli
->outbuf
,'\0',smb_size
);
501 memset(cli
->inbuf
,'\0',smb_size
);
503 set_message(cli
->outbuf
,1, 0,True
);
505 SCVAL(cli
->outbuf
,smb_com
,SMBunlink
);
506 SSVAL(cli
->outbuf
,smb_tid
,cli
->cnum
);
507 cli_setup_packet(cli
);
509 SSVAL(cli
->outbuf
,smb_vwv0
,aSYSTEM
| aHIDDEN
);
511 p
= smb_buf(cli
->outbuf
);
513 p
+= clistr_push(cli
, p
, fname
, -1, STR_TERMINATE
);
515 cli_setup_bcc(cli
, p
);
517 if (!cli_receive_smb(cli
)) {
521 if (cli_is_error(cli
)) {
528 /****************************************************************************
530 ****************************************************************************/
532 BOOL
cli_mkdir(struct cli_state
*cli
, const char *dname
)
536 memset(cli
->outbuf
,'\0',smb_size
);
537 memset(cli
->inbuf
,'\0',smb_size
);
539 set_message(cli
->outbuf
,0, 0,True
);
541 SCVAL(cli
->outbuf
,smb_com
,SMBmkdir
);
542 SSVAL(cli
->outbuf
,smb_tid
,cli
->cnum
);
543 cli_setup_packet(cli
);
545 p
= smb_buf(cli
->outbuf
);
547 p
+= clistr_push(cli
, p
, dname
, -1, STR_TERMINATE
);
549 cli_setup_bcc(cli
, p
);
552 if (!cli_receive_smb(cli
)) {
556 if (cli_is_error(cli
)) {
563 /****************************************************************************
565 ****************************************************************************/
567 BOOL
cli_rmdir(struct cli_state
*cli
, const char *dname
)
571 memset(cli
->outbuf
,'\0',smb_size
);
572 memset(cli
->inbuf
,'\0',smb_size
);
574 set_message(cli
->outbuf
,0, 0, True
);
576 SCVAL(cli
->outbuf
,smb_com
,SMBrmdir
);
577 SSVAL(cli
->outbuf
,smb_tid
,cli
->cnum
);
578 cli_setup_packet(cli
);
580 p
= smb_buf(cli
->outbuf
);
582 p
+= clistr_push(cli
, p
, dname
, -1, STR_TERMINATE
);
584 cli_setup_bcc(cli
, p
);
587 if (!cli_receive_smb(cli
)) {
591 if (cli_is_error(cli
)) {
598 /****************************************************************************
599 Set or clear the delete on close flag.
600 ****************************************************************************/
602 int cli_nt_delete_on_close(struct cli_state
*cli
, int fnum
, BOOL flag
)
604 unsigned int data_len
= 1;
605 unsigned int param_len
= 6;
606 uint16 setup
= TRANSACT2_SETFILEINFO
;
609 char *rparam
=NULL
, *rdata
=NULL
;
611 memset(param
, 0, param_len
);
613 SSVAL(param
,2,SMB_SET_FILE_DISPOSITION_INFO
);
617 if (!cli_send_trans(cli
, SMBtrans2
,
619 -1, 0, /* fid, flags */
620 &setup
, 1, 0, /* setup, length, max */
621 param
, param_len
, 2, /* param, length, max */
622 (char *)&data
, data_len
, cli
->max_xmit
/* data, length, max */
627 if (!cli_receive_trans(cli
, SMBtrans2
,
629 &rdata
, &data_len
)) {
639 /****************************************************************************
640 Open a file - exposing the full horror of the NT API :-).
642 ****************************************************************************/
644 int cli_nt_create_full(struct cli_state
*cli
, const char *fname
,
645 uint32 CreatFlags
, uint32 DesiredAccess
,
646 uint32 FileAttributes
, uint32 ShareAccess
,
647 uint32 CreateDisposition
, uint32 CreateOptions
,
653 memset(cli
->outbuf
,'\0',smb_size
);
654 memset(cli
->inbuf
,'\0',smb_size
);
656 set_message(cli
->outbuf
,24,0,True
);
658 SCVAL(cli
->outbuf
,smb_com
,SMBntcreateX
);
659 SSVAL(cli
->outbuf
,smb_tid
,cli
->cnum
);
660 cli_setup_packet(cli
);
662 SSVAL(cli
->outbuf
,smb_vwv0
,0xFF);
663 if (cli
->use_oplocks
)
664 CreatFlags
|= (REQUEST_OPLOCK
|REQUEST_BATCH_OPLOCK
);
666 SIVAL(cli
->outbuf
,smb_ntcreate_Flags
, CreatFlags
);
667 SIVAL(cli
->outbuf
,smb_ntcreate_RootDirectoryFid
, 0x0);
668 SIVAL(cli
->outbuf
,smb_ntcreate_DesiredAccess
, DesiredAccess
);
669 SIVAL(cli
->outbuf
,smb_ntcreate_FileAttributes
, FileAttributes
);
670 SIVAL(cli
->outbuf
,smb_ntcreate_ShareAccess
, ShareAccess
);
671 SIVAL(cli
->outbuf
,smb_ntcreate_CreateDisposition
, CreateDisposition
);
672 SIVAL(cli
->outbuf
,smb_ntcreate_CreateOptions
, CreateOptions
);
673 SIVAL(cli
->outbuf
,smb_ntcreate_ImpersonationLevel
, 0x02);
674 SCVAL(cli
->outbuf
,smb_ntcreate_SecurityFlags
, SecuityFlags
);
676 p
= smb_buf(cli
->outbuf
);
677 /* this alignment and termination is critical for netapp filers. Don't change */
678 p
+= clistr_align_out(cli
, p
, 0);
679 len
= clistr_push(cli
, p
, fname
, -1, 0);
681 SSVAL(cli
->outbuf
,smb_ntcreate_NameLength
, len
);
682 /* sigh. this copes with broken netapp filer behaviour */
683 p
+= clistr_push(cli
, p
, "", -1, STR_TERMINATE
);
685 cli_setup_bcc(cli
, p
);
688 if (!cli_receive_smb(cli
)) {
692 if (cli_is_error(cli
)) {
696 return SVAL(cli
->inbuf
,smb_vwv2
+ 1);
699 /****************************************************************************
701 ****************************************************************************/
703 int cli_nt_create(struct cli_state
*cli
, const char *fname
, uint32 DesiredAccess
)
705 return cli_nt_create_full(cli
, fname
, 0, DesiredAccess
, 0,
706 FILE_SHARE_READ
|FILE_SHARE_WRITE
, FILE_OPEN
, 0x0, 0x0);
709 /****************************************************************************
711 WARNING: if you open with O_WRONLY then getattrE won't work!
712 ****************************************************************************/
714 int cli_open(struct cli_state
*cli
, const char *fname
, int flags
, int share_mode
)
718 unsigned accessmode
=0;
722 if (!(flags
& O_EXCL
)) {
729 accessmode
= (share_mode
<<4);
731 if ((flags
& O_ACCMODE
) == O_RDWR
) {
733 } else if ((flags
& O_ACCMODE
) == O_WRONLY
) {
738 if ((flags
& O_SYNC
) == O_SYNC
) {
739 accessmode
|= (1<<14);
743 if (share_mode
== DENY_FCB
) {
747 memset(cli
->outbuf
,'\0',smb_size
);
748 memset(cli
->inbuf
,'\0',smb_size
);
750 set_message(cli
->outbuf
,15,0,True
);
752 SCVAL(cli
->outbuf
,smb_com
,SMBopenX
);
753 SSVAL(cli
->outbuf
,smb_tid
,cli
->cnum
);
754 cli_setup_packet(cli
);
756 SSVAL(cli
->outbuf
,smb_vwv0
,0xFF);
757 SSVAL(cli
->outbuf
,smb_vwv2
,0); /* no additional info */
758 SSVAL(cli
->outbuf
,smb_vwv3
,accessmode
);
759 SSVAL(cli
->outbuf
,smb_vwv4
,aSYSTEM
| aHIDDEN
);
760 SSVAL(cli
->outbuf
,smb_vwv5
,0);
761 SSVAL(cli
->outbuf
,smb_vwv8
,openfn
);
763 if (cli
->use_oplocks
) {
764 /* if using oplocks then ask for a batch oplock via
765 core and extended methods */
766 SCVAL(cli
->outbuf
,smb_flg
, CVAL(cli
->outbuf
,smb_flg
)|
767 FLAG_REQUEST_OPLOCK
|FLAG_REQUEST_BATCH_OPLOCK
);
768 SSVAL(cli
->outbuf
,smb_vwv2
,SVAL(cli
->outbuf
,smb_vwv2
) | 6);
771 p
= smb_buf(cli
->outbuf
);
772 p
+= clistr_push(cli
, p
, fname
, -1, STR_TERMINATE
);
774 cli_setup_bcc(cli
, p
);
777 if (!cli_receive_smb(cli
)) {
781 if (cli_is_error(cli
)) {
785 return SVAL(cli
->inbuf
,smb_vwv2
);
788 /****************************************************************************
790 ****************************************************************************/
792 BOOL
cli_close(struct cli_state
*cli
, int fnum
)
794 memset(cli
->outbuf
,'\0',smb_size
);
795 memset(cli
->inbuf
,'\0',smb_size
);
797 set_message(cli
->outbuf
,3,0,True
);
799 SCVAL(cli
->outbuf
,smb_com
,SMBclose
);
800 SSVAL(cli
->outbuf
,smb_tid
,cli
->cnum
);
801 cli_setup_packet(cli
);
803 SSVAL(cli
->outbuf
,smb_vwv0
,fnum
);
804 SIVALS(cli
->outbuf
,smb_vwv1
,-1);
807 if (!cli_receive_smb(cli
)) {
811 return !cli_is_error(cli
);
815 /****************************************************************************
816 send a lock with a specified locktype
817 this is used for testing LOCKING_ANDX_CANCEL_LOCK
818 ****************************************************************************/
819 NTSTATUS
cli_locktype(struct cli_state
*cli
, int fnum
,
820 uint32 offset
, uint32 len
, int timeout
, unsigned char locktype
)
823 int saved_timeout
= cli
->timeout
;
825 memset(cli
->outbuf
,'\0',smb_size
);
826 memset(cli
->inbuf
,'\0', smb_size
);
828 set_message(cli
->outbuf
,8,0,True
);
830 SCVAL(cli
->outbuf
,smb_com
,SMBlockingX
);
831 SSVAL(cli
->outbuf
,smb_tid
,cli
->cnum
);
832 cli_setup_packet(cli
);
834 SCVAL(cli
->outbuf
,smb_vwv0
,0xFF);
835 SSVAL(cli
->outbuf
,smb_vwv2
,fnum
);
836 SCVAL(cli
->outbuf
,smb_vwv3
,locktype
);
837 SIVALS(cli
->outbuf
, smb_vwv4
, timeout
);
838 SSVAL(cli
->outbuf
,smb_vwv6
,0);
839 SSVAL(cli
->outbuf
,smb_vwv7
,1);
841 p
= smb_buf(cli
->outbuf
);
842 SSVAL(p
, 0, cli
->pid
);
848 cli_setup_bcc(cli
, p
);
853 cli
->timeout
= (timeout
== -1) ? 0x7FFFFFFF : (timeout
+ 2*1000);
856 if (!cli_receive_smb(cli
)) {
857 cli
->timeout
= saved_timeout
;
858 return NT_STATUS_UNSUCCESSFUL
;
861 cli
->timeout
= saved_timeout
;
863 return cli_nt_error(cli
);
867 /****************************************************************************
869 note that timeout is in units of 2 milliseconds
870 ****************************************************************************/
871 BOOL
cli_lock(struct cli_state
*cli
, int fnum
,
872 uint32 offset
, uint32 len
, int timeout
, enum brl_type lock_type
)
875 int saved_timeout
= cli
->timeout
;
877 memset(cli
->outbuf
,'\0',smb_size
);
878 memset(cli
->inbuf
,'\0', smb_size
);
880 set_message(cli
->outbuf
,8,0,True
);
882 SCVAL(cli
->outbuf
,smb_com
,SMBlockingX
);
883 SSVAL(cli
->outbuf
,smb_tid
,cli
->cnum
);
884 cli_setup_packet(cli
);
886 SCVAL(cli
->outbuf
,smb_vwv0
,0xFF);
887 SSVAL(cli
->outbuf
,smb_vwv2
,fnum
);
888 SCVAL(cli
->outbuf
,smb_vwv3
,(lock_type
== READ_LOCK
? 1 : 0));
889 SIVALS(cli
->outbuf
, smb_vwv4
, timeout
);
890 SSVAL(cli
->outbuf
,smb_vwv6
,0);
891 SSVAL(cli
->outbuf
,smb_vwv7
,1);
893 p
= smb_buf(cli
->outbuf
);
894 SSVAL(p
, 0, cli
->pid
);
900 cli_setup_bcc(cli
, p
);
905 cli
->timeout
= (timeout
== -1) ? 0x7FFFFFFF : (timeout
*2 + 5*1000);
908 if (!cli_receive_smb(cli
)) {
909 cli
->timeout
= saved_timeout
;
913 cli
->timeout
= saved_timeout
;
915 if (cli_is_error(cli
)) {
922 /****************************************************************************
924 ****************************************************************************/
926 BOOL
cli_unlock(struct cli_state
*cli
, int fnum
, uint32 offset
, uint32 len
)
930 memset(cli
->outbuf
,'\0',smb_size
);
931 memset(cli
->inbuf
,'\0',smb_size
);
933 set_message(cli
->outbuf
,8,0,True
);
935 SCVAL(cli
->outbuf
,smb_com
,SMBlockingX
);
936 SSVAL(cli
->outbuf
,smb_tid
,cli
->cnum
);
937 cli_setup_packet(cli
);
939 SCVAL(cli
->outbuf
,smb_vwv0
,0xFF);
940 SSVAL(cli
->outbuf
,smb_vwv2
,fnum
);
941 SCVAL(cli
->outbuf
,smb_vwv3
,0);
942 SIVALS(cli
->outbuf
, smb_vwv4
, 0);
943 SSVAL(cli
->outbuf
,smb_vwv6
,1);
944 SSVAL(cli
->outbuf
,smb_vwv7
,0);
946 p
= smb_buf(cli
->outbuf
);
947 SSVAL(p
, 0, cli
->pid
);
951 cli_setup_bcc(cli
, p
);
953 if (!cli_receive_smb(cli
)) {
957 if (cli_is_error(cli
)) {
964 /****************************************************************************
965 Lock a file with 64 bit offsets.
966 ****************************************************************************/
968 BOOL
cli_lock64(struct cli_state
*cli
, int fnum
,
969 SMB_BIG_UINT offset
, SMB_BIG_UINT len
, int timeout
, enum brl_type lock_type
)
972 int saved_timeout
= cli
->timeout
;
975 if (! (cli
->capabilities
& CAP_LARGE_FILES
)) {
976 return cli_lock(cli
, fnum
, offset
, len
, timeout
, lock_type
);
979 ltype
= (lock_type
== READ_LOCK
? 1 : 0);
980 ltype
|= LOCKING_ANDX_LARGE_FILES
;
982 memset(cli
->outbuf
,'\0',smb_size
);
983 memset(cli
->inbuf
,'\0', smb_size
);
985 set_message(cli
->outbuf
,8,0,True
);
987 SCVAL(cli
->outbuf
,smb_com
,SMBlockingX
);
988 SSVAL(cli
->outbuf
,smb_tid
,cli
->cnum
);
989 cli_setup_packet(cli
);
991 SCVAL(cli
->outbuf
,smb_vwv0
,0xFF);
992 SSVAL(cli
->outbuf
,smb_vwv2
,fnum
);
993 SCVAL(cli
->outbuf
,smb_vwv3
,ltype
);
994 SIVALS(cli
->outbuf
, smb_vwv4
, timeout
);
995 SSVAL(cli
->outbuf
,smb_vwv6
,0);
996 SSVAL(cli
->outbuf
,smb_vwv7
,1);
998 p
= smb_buf(cli
->outbuf
);
999 SIVAL(p
, 0, cli
->pid
);
1000 SOFF_T_R(p
, 4, offset
);
1001 SOFF_T_R(p
, 12, len
);
1004 cli_setup_bcc(cli
, p
);
1008 cli
->timeout
= (timeout
== -1) ? 0x7FFFFFFF : (timeout
+ 5*1000);
1011 if (!cli_receive_smb(cli
)) {
1012 cli
->timeout
= saved_timeout
;
1016 cli
->timeout
= saved_timeout
;
1018 if (cli_is_error(cli
)) {
1025 /****************************************************************************
1026 Unlock a file with 64 bit offsets.
1027 ****************************************************************************/
1029 BOOL
cli_unlock64(struct cli_state
*cli
, int fnum
, SMB_BIG_UINT offset
, SMB_BIG_UINT len
)
1033 if (! (cli
->capabilities
& CAP_LARGE_FILES
)) {
1034 return cli_unlock(cli
, fnum
, offset
, len
);
1037 memset(cli
->outbuf
,'\0',smb_size
);
1038 memset(cli
->inbuf
,'\0',smb_size
);
1040 set_message(cli
->outbuf
,8,0,True
);
1042 SCVAL(cli
->outbuf
,smb_com
,SMBlockingX
);
1043 SSVAL(cli
->outbuf
,smb_tid
,cli
->cnum
);
1044 cli_setup_packet(cli
);
1046 SCVAL(cli
->outbuf
,smb_vwv0
,0xFF);
1047 SSVAL(cli
->outbuf
,smb_vwv2
,fnum
);
1048 SCVAL(cli
->outbuf
,smb_vwv3
,LOCKING_ANDX_LARGE_FILES
);
1049 SIVALS(cli
->outbuf
, smb_vwv4
, 0);
1050 SSVAL(cli
->outbuf
,smb_vwv6
,1);
1051 SSVAL(cli
->outbuf
,smb_vwv7
,0);
1053 p
= smb_buf(cli
->outbuf
);
1054 SIVAL(p
, 0, cli
->pid
);
1055 SOFF_T_R(p
, 4, offset
);
1056 SOFF_T_R(p
, 12, len
);
1058 cli_setup_bcc(cli
, p
);
1060 if (!cli_receive_smb(cli
)) {
1064 if (cli_is_error(cli
)) {
1072 /****************************************************************************
1073 Do a SMBgetattrE call.
1074 ****************************************************************************/
1076 BOOL
cli_getattrE(struct cli_state
*cli
, int fd
,
1077 uint16
*attr
, SMB_OFF_T
*size
,
1078 time_t *c_time
, time_t *a_time
, time_t *m_time
)
1080 memset(cli
->outbuf
,'\0',smb_size
);
1081 memset(cli
->inbuf
,'\0',smb_size
);
1083 set_message(cli
->outbuf
,1,0,True
);
1085 SCVAL(cli
->outbuf
,smb_com
,SMBgetattrE
);
1086 SSVAL(cli
->outbuf
,smb_tid
,cli
->cnum
);
1087 cli_setup_packet(cli
);
1089 SSVAL(cli
->outbuf
,smb_vwv0
,fd
);
1092 if (!cli_receive_smb(cli
)) {
1096 if (cli_is_error(cli
)) {
1101 *size
= IVAL(cli
->inbuf
, smb_vwv6
);
1105 *attr
= SVAL(cli
->inbuf
,smb_vwv10
);
1109 *c_time
= make_unix_date2(cli
->inbuf
+smb_vwv0
);
1113 *a_time
= make_unix_date2(cli
->inbuf
+smb_vwv2
);
1117 *m_time
= make_unix_date2(cli
->inbuf
+smb_vwv4
);
1123 /****************************************************************************
1125 ****************************************************************************/
1127 BOOL
cli_getatr(struct cli_state
*cli
, const char *fname
,
1128 uint16
*attr
, SMB_OFF_T
*size
, time_t *t
)
1132 memset(cli
->outbuf
,'\0',smb_size
);
1133 memset(cli
->inbuf
,'\0',smb_size
);
1135 set_message(cli
->outbuf
,0,0,True
);
1137 SCVAL(cli
->outbuf
,smb_com
,SMBgetatr
);
1138 SSVAL(cli
->outbuf
,smb_tid
,cli
->cnum
);
1139 cli_setup_packet(cli
);
1141 p
= smb_buf(cli
->outbuf
);
1143 p
+= clistr_push(cli
, p
, fname
, -1, STR_TERMINATE
);
1145 cli_setup_bcc(cli
, p
);
1148 if (!cli_receive_smb(cli
)) {
1152 if (cli_is_error(cli
)) {
1157 *size
= IVAL(cli
->inbuf
, smb_vwv3
);
1161 *t
= make_unix_date3(cli
->inbuf
+smb_vwv1
);
1165 *attr
= SVAL(cli
->inbuf
,smb_vwv0
);
1172 /****************************************************************************
1173 Do a SMBsetattrE call.
1174 ****************************************************************************/
1176 BOOL
cli_setattrE(struct cli_state
*cli
, int fd
,
1177 time_t c_time
, time_t a_time
, time_t m_time
)
1182 memset(cli
->outbuf
,'\0',smb_size
);
1183 memset(cli
->inbuf
,'\0',smb_size
);
1185 set_message(cli
->outbuf
,7,0,True
);
1187 SCVAL(cli
->outbuf
,smb_com
,SMBsetattrE
);
1188 SSVAL(cli
->outbuf
,smb_tid
,cli
->cnum
);
1189 cli_setup_packet(cli
);
1191 SSVAL(cli
->outbuf
,smb_vwv0
, fd
);
1192 put_dos_date2(cli
->outbuf
,smb_vwv1
, c_time
);
1193 put_dos_date2(cli
->outbuf
,smb_vwv3
, a_time
);
1194 put_dos_date2(cli
->outbuf
,smb_vwv5
, m_time
);
1196 p
= smb_buf(cli
->outbuf
);
1199 cli_setup_bcc(cli
, p
);
1202 if (!cli_receive_smb(cli
)) {
1206 if (cli_is_error(cli
)) {
1213 /****************************************************************************
1214 Do a SMBsetatr call.
1215 ****************************************************************************/
1217 BOOL
cli_setatr(struct cli_state
*cli
, const char *fname
, uint16 attr
, time_t t
)
1221 memset(cli
->outbuf
,'\0',smb_size
);
1222 memset(cli
->inbuf
,'\0',smb_size
);
1224 set_message(cli
->outbuf
,8,0,True
);
1226 SCVAL(cli
->outbuf
,smb_com
,SMBsetatr
);
1227 SSVAL(cli
->outbuf
,smb_tid
,cli
->cnum
);
1228 cli_setup_packet(cli
);
1230 SSVAL(cli
->outbuf
,smb_vwv0
, attr
);
1231 put_dos_date3(cli
->outbuf
,smb_vwv1
, t
);
1233 p
= smb_buf(cli
->outbuf
);
1235 p
+= clistr_push(cli
, p
, fname
, -1, STR_TERMINATE
);
1238 cli_setup_bcc(cli
, p
);
1241 if (!cli_receive_smb(cli
)) {
1245 if (cli_is_error(cli
)) {
1252 /****************************************************************************
1253 Check for existance of a dir.
1254 ****************************************************************************/
1255 BOOL
cli_chkpath(struct cli_state
*cli
, const char *path
)
1260 pstrcpy(path2
,path
);
1261 trim_char(path2
,'\0','\\');
1265 memset(cli
->outbuf
,'\0',smb_size
);
1266 set_message(cli
->outbuf
,0,0,True
);
1267 SCVAL(cli
->outbuf
,smb_com
,SMBchkpth
);
1268 SSVAL(cli
->outbuf
,smb_tid
,cli
->cnum
);
1269 cli_setup_packet(cli
);
1270 p
= smb_buf(cli
->outbuf
);
1272 p
+= clistr_push(cli
, p
, path2
, -1, STR_TERMINATE
);
1274 cli_setup_bcc(cli
, p
);
1277 if (!cli_receive_smb(cli
)) {
1281 if (cli_is_error(cli
)) return False
;
1286 /****************************************************************************
1288 ****************************************************************************/
1290 BOOL
cli_dskattr(struct cli_state
*cli
, int *bsize
, int *total
, int *avail
)
1292 memset(cli
->outbuf
,'\0',smb_size
);
1293 set_message(cli
->outbuf
,0,0,True
);
1294 SCVAL(cli
->outbuf
,smb_com
,SMBdskattr
);
1295 SSVAL(cli
->outbuf
,smb_tid
,cli
->cnum
);
1296 cli_setup_packet(cli
);
1299 if (!cli_receive_smb(cli
)) {
1303 *bsize
= SVAL(cli
->inbuf
,smb_vwv1
)*SVAL(cli
->inbuf
,smb_vwv2
);
1304 *total
= SVAL(cli
->inbuf
,smb_vwv0
);
1305 *avail
= SVAL(cli
->inbuf
,smb_vwv3
);
1310 /****************************************************************************
1311 Create and open a temporary file.
1312 ****************************************************************************/
1314 int cli_ctemp(struct cli_state
*cli
, const char *path
, char **tmp_path
)
1319 memset(cli
->outbuf
,'\0',smb_size
);
1320 memset(cli
->inbuf
,'\0',smb_size
);
1322 set_message(cli
->outbuf
,3,0,True
);
1324 SCVAL(cli
->outbuf
,smb_com
,SMBctemp
);
1325 SSVAL(cli
->outbuf
,smb_tid
,cli
->cnum
);
1326 cli_setup_packet(cli
);
1328 SSVAL(cli
->outbuf
,smb_vwv0
,0);
1329 SIVALS(cli
->outbuf
,smb_vwv1
,-1);
1331 p
= smb_buf(cli
->outbuf
);
1333 p
+= clistr_push(cli
, p
, path
, -1, STR_TERMINATE
);
1335 cli_setup_bcc(cli
, p
);
1338 if (!cli_receive_smb(cli
)) {
1342 if (cli_is_error(cli
)) {
1346 /* despite the spec, the result has a -1, followed by
1347 length, followed by name */
1348 p
= smb_buf(cli
->inbuf
);
1350 len
= smb_buflen(cli
->inbuf
) - 4;
1351 if (len
<= 0) return -1;
1355 clistr_pull(cli
, path2
, p
,
1356 sizeof(path2
), len
, STR_ASCII
);
1357 *tmp_path
= SMB_STRDUP(path2
);
1360 return SVAL(cli
->inbuf
,smb_vwv0
);
1365 send a raw ioctl - used by the torture code
1367 NTSTATUS
cli_raw_ioctl(struct cli_state
*cli
, int fnum
, uint32 code
, DATA_BLOB
*blob
)
1369 memset(cli
->outbuf
,'\0',smb_size
);
1370 memset(cli
->inbuf
,'\0',smb_size
);
1372 set_message(cli
->outbuf
, 3, 0, True
);
1373 SCVAL(cli
->outbuf
,smb_com
,SMBioctl
);
1374 cli_setup_packet(cli
);
1376 SSVAL(cli
->outbuf
, smb_vwv0
, fnum
);
1377 SSVAL(cli
->outbuf
, smb_vwv1
, code
>>16);
1378 SSVAL(cli
->outbuf
, smb_vwv2
, (code
&0xFFFF));
1381 if (!cli_receive_smb(cli
)) {
1382 return NT_STATUS_UNEXPECTED_NETWORK_ERROR
;
1385 if (cli_is_error(cli
)) {
1386 return cli_nt_error(cli
);
1389 *blob
= data_blob(NULL
, 0);
1391 return NT_STATUS_OK
;
1394 /*********************************************************
1395 Set an extended attribute utility fn.
1396 *********************************************************/
1398 static BOOL
cli_set_ea(struct cli_state
*cli
, uint16 setup
, char *param
, unsigned int param_len
,
1399 const char *ea_name
, const char *ea_val
, size_t ea_len
)
1401 unsigned int data_len
= 0;
1403 char *rparam
=NULL
, *rdata
=NULL
;
1405 size_t ea_namelen
= strlen(ea_name
);
1407 data_len
= 4 + 4 + ea_namelen
+ 1 + ea_len
;
1408 data
= SMB_MALLOC(data_len
);
1413 SIVAL(p
,0,data_len
);
1415 SCVAL(p
, 0, 0); /* EA flags. */
1416 SCVAL(p
, 1, ea_namelen
);
1417 SSVAL(p
, 2, ea_len
);
1418 memcpy(p
+4, ea_name
, ea_namelen
+1); /* Copy in the name. */
1419 memcpy(p
+4+ea_namelen
+1, ea_val
, ea_len
);
1421 if (!cli_send_trans(cli
, SMBtrans2
,
1423 -1, 0, /* fid, flags */
1424 &setup
, 1, 0, /* setup, length, max */
1425 param
, param_len
, 2, /* param, length, max */
1426 data
, data_len
, cli
->max_xmit
/* data, length, max */
1431 if (!cli_receive_trans(cli
, SMBtrans2
,
1432 &rparam
, ¶m_len
,
1433 &rdata
, &data_len
)) {
1444 /*********************************************************
1445 Set an extended attribute on a pathname.
1446 *********************************************************/
1448 BOOL
cli_set_ea_path(struct cli_state
*cli
, const char *path
, const char *ea_name
, const char *ea_val
, size_t ea_len
)
1450 uint16 setup
= TRANSACT2_SETPATHINFO
;
1451 unsigned int param_len
= 0;
1452 char param
[sizeof(pstring
)+6];
1453 size_t srclen
= 2*(strlen(path
)+1);
1456 memset(param
, 0, sizeof(param
));
1457 SSVAL(param
,0,SMB_INFO_SET_EA
);
1460 p
+= clistr_push(cli
, p
, path
, MIN(srclen
, sizeof(param
)-6), STR_TERMINATE
);
1461 param_len
= PTR_DIFF(p
, param
);
1463 return cli_set_ea(cli
, setup
, param
, param_len
, ea_name
, ea_val
, ea_len
);
1466 /*********************************************************
1467 Set an extended attribute on an fnum.
1468 *********************************************************/
1470 BOOL
cli_set_ea_fnum(struct cli_state
*cli
, int fnum
, const char *ea_name
, const char *ea_val
, size_t ea_len
)
1473 uint16 setup
= TRANSACT2_SETFILEINFO
;
1475 memset(param
, 0, 6);
1476 SSVAL(param
,0,fnum
);
1477 SSVAL(param
,2,SMB_INFO_SET_EA
);
1479 return cli_set_ea(cli
, setup
, param
, 6, ea_name
, ea_val
, ea_len
);
1482 /*********************************************************
1483 Get an extended attribute list tility fn.
1484 *********************************************************/
1486 static BOOL
cli_get_ea_list(struct cli_state
*cli
,
1487 uint16 setup
, char *param
, unsigned int param_len
,
1490 struct ea_struct
**pea_list
)
1492 unsigned int data_len
= 0;
1493 unsigned int rparam_len
, rdata_len
;
1494 char *rparam
=NULL
, *rdata
=NULL
;
1499 struct ea_struct
*ea_list
;
1504 if (!cli_send_trans(cli
, SMBtrans2
,
1506 -1, 0, /* fid, flags */
1507 &setup
, 1, 0, /* setup, length, max */
1508 param
, param_len
, 10, /* param, length, max */
1509 NULL
, data_len
, cli
->max_xmit
/* data, length, max */
1514 if (!cli_receive_trans(cli
, SMBtrans2
,
1515 &rparam
, &rparam_len
,
1516 &rdata
, &rdata_len
)) {
1520 if (!rdata
|| rdata_len
< 4) {
1524 ea_size
= (size_t)IVAL(rdata
,0);
1525 if (ea_size
> rdata_len
) {
1530 /* No EA's present. */
1538 /* Validate the EA list and count it. */
1539 for (num_eas
= 0; ea_size
>= 4; num_eas
++) {
1540 unsigned int ea_namelen
= CVAL(p
,1);
1541 unsigned int ea_valuelen
= SVAL(p
,2);
1542 if (ea_namelen
== 0) {
1545 if (4 + ea_namelen
+ 1 + ea_valuelen
> ea_size
) {
1548 ea_size
-= 4 + ea_namelen
+ 1 + ea_valuelen
;
1549 p
+= 4 + ea_namelen
+ 1 + ea_valuelen
;
1557 *pnum_eas
= num_eas
;
1559 /* Caller only wants number of EA's. */
1564 ea_list
= TALLOC_ARRAY(ctx
, struct ea_struct
, num_eas
);
1569 ea_size
= (size_t)IVAL(rdata
,0);
1572 for (num_eas
= 0; num_eas
< *pnum_eas
; num_eas
++ ) {
1573 struct ea_struct
*ea
= &ea_list
[num_eas
];
1574 fstring unix_ea_name
;
1575 unsigned int ea_namelen
= CVAL(p
,1);
1576 unsigned int ea_valuelen
= SVAL(p
,2);
1578 ea
->flags
= CVAL(p
,0);
1579 unix_ea_name
[0] = '\0';
1580 pull_ascii_fstring(unix_ea_name
, p
+ 4);
1581 ea
->name
= talloc_strdup(ctx
, unix_ea_name
);
1582 /* Ensure the value is null terminated (in case it's a string). */
1583 ea
->value
= data_blob_talloc(ctx
, NULL
, ea_valuelen
+ 1);
1584 if (!ea
->value
.data
) {
1588 memcpy(ea
->value
.data
, p
+4+ea_namelen
+1, ea_valuelen
);
1590 ea
->value
.data
[ea_valuelen
] = 0;
1592 p
+= 4 + ea_namelen
+ 1 + ea_valuelen
;
1595 *pea_list
= ea_list
;
1605 /*********************************************************
1606 Get an extended attribute list from a pathname.
1607 *********************************************************/
1609 BOOL
cli_get_ea_list_path(struct cli_state
*cli
, const char *path
,
1612 struct ea_struct
**pea_list
)
1614 uint16 setup
= TRANSACT2_QPATHINFO
;
1615 unsigned int param_len
= 0;
1616 char param
[sizeof(pstring
)+6];
1621 SSVAL(p
, 0, SMB_INFO_QUERY_ALL_EAS
);
1623 p
+= clistr_push(cli
, p
, path
, sizeof(pstring
)-6, STR_TERMINATE
);
1624 param_len
= PTR_DIFF(p
, param
);
1626 return cli_get_ea_list(cli
, setup
, param
, param_len
, ctx
, pnum_eas
, pea_list
);
1629 /*********************************************************
1630 Get an extended attribute list from an fnum.
1631 *********************************************************/
1633 BOOL
cli_get_ea_list_fnum(struct cli_state
*cli
, int fnum
,
1636 struct ea_struct
**pea_list
)
1638 uint16 setup
= TRANSACT2_QFILEINFO
;
1641 memset(param
, 0, 6);
1642 SSVAL(param
,0,fnum
);
1643 SSVAL(param
,2,SMB_INFO_SET_EA
);
1645 return cli_get_ea_list(cli
, setup
, param
, 6, ctx
, pnum_eas
, pea_list
);