4 * Copyright (c) International Business Machines Corp., 2002,2005
5 * Author(s): Steve French (sfrench@us.ibm.com)
7 * This library is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published
9 * by the Free Software Foundation; either version 2.1 of the License, or
10 * (at your option) any later version.
12 * This library 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
15 * the GNU Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #define BAD_PROT CIFS_PROT+1
30 /* SMB command codes */
31 /* Some commands have minimal (wct=0,bcc=0), or uninteresting, responses
32 (ie which include no useful data other than the SMB error code itself).
33 Knowing this helps avoid response buffer allocations and copy in some cases */
34 #define SMB_COM_CREATE_DIRECTORY 0x00 /* trivial response */
35 #define SMB_COM_DELETE_DIRECTORY 0x01 /* trivial response */
36 #define SMB_COM_CLOSE 0x04 /* triv req/rsp, timestamp ignored */
37 #define SMB_COM_DELETE 0x06 /* trivial response */
38 #define SMB_COM_RENAME 0x07 /* trivial response */
39 #define SMB_COM_QUERY_INFORMATION 0x08 /* aka getattr */
40 #define SMB_COM_SETATTR 0x09 /* trivial response */
41 #define SMB_COM_LOCKING_ANDX 0x24 /* trivial response */
42 #define SMB_COM_COPY 0x29 /* trivial rsp, fail filename ignrd*/
43 #define SMB_COM_OPEN_ANDX 0x2D /* Legacy open for old servers */
44 #define SMB_COM_READ_ANDX 0x2E
45 #define SMB_COM_WRITE_ANDX 0x2F
46 #define SMB_COM_TRANSACTION2 0x32
47 #define SMB_COM_TRANSACTION2_SECONDARY 0x33
48 #define SMB_COM_FIND_CLOSE2 0x34 /* trivial response */
49 #define SMB_COM_TREE_DISCONNECT 0x71 /* trivial response */
50 #define SMB_COM_NEGOTIATE 0x72
51 #define SMB_COM_SESSION_SETUP_ANDX 0x73
52 #define SMB_COM_LOGOFF_ANDX 0x74 /* trivial response */
53 #define SMB_COM_TREE_CONNECT_ANDX 0x75
54 #define SMB_COM_NT_TRANSACT 0xA0
55 #define SMB_COM_NT_TRANSACT_SECONDARY 0xA1
56 #define SMB_COM_NT_CREATE_ANDX 0xA2
57 #define SMB_COM_NT_CANCEL 0xA4 /* no response */
58 #define SMB_COM_NT_RENAME 0xA5 /* trivial response */
60 /* Transact2 subcommand codes */
61 #define TRANS2_OPEN 0x00
62 #define TRANS2_FIND_FIRST 0x01
63 #define TRANS2_FIND_NEXT 0x02
64 #define TRANS2_QUERY_FS_INFORMATION 0x03
65 #define TRANS2_SET_FS_INFORMATION 0x04
66 #define TRANS2_QUERY_PATH_INFORMATION 0x05
67 #define TRANS2_SET_PATH_INFORMATION 0x06
68 #define TRANS2_QUERY_FILE_INFORMATION 0x07
69 #define TRANS2_SET_FILE_INFORMATION 0x08
70 #define TRANS2_GET_DFS_REFERRAL 0x10
71 #define TRANS2_REPORT_DFS_INCOSISTENCY 0x11
73 /* NT Transact subcommand codes */
74 #define NT_TRANSACT_CREATE 0x01
75 #define NT_TRANSACT_IOCTL 0x02
76 #define NT_TRANSACT_SET_SECURITY_DESC 0x03
77 #define NT_TRANSACT_NOTIFY_CHANGE 0x04
78 #define NT_TRANSACT_RENAME 0x05
79 #define NT_TRANSACT_QUERY_SECURITY_DESC 0x06
80 #define NT_TRANSACT_GET_USER_QUOTA 0x07
81 #define NT_TRANSACT_SET_USER_QUOTA 0x08
83 #define MAX_CIFS_SMALL_BUFFER_SIZE 448 /* big enough for most */
84 /* future chained NTCreateXReadX bigger, but for time being NTCreateX biggest */
85 /* among the requests (NTCreateX response is bigger with wct of 34) */
86 #define MAX_CIFS_HDR_SIZE 0x58 /* 4 len + 32 hdr + (2*24 wct) + 2 bct + 2 pad */
87 #define CIFS_SMALL_PATH 120 /* allows for (448-88)/3 */
89 /* internal cifs vfs structures */
90 /*****************************************************************
91 * All constants go here
92 *****************************************************************
96 * Starting value for maximum SMB size negotiation
98 #define CIFS_MAX_MSGSIZE (4*4096)
101 * Size of encrypted user password in bytes
103 #define CIFS_ENCPWD_SIZE (16)
106 * Size of the crypto key returned on the negotiate SMB in bytes
108 #define CIFS_CRYPTO_KEY_SIZE (8)
111 * Size of the session key (crypto key encrypted with the password
113 #define CIFS_SESSION_KEY_SIZE (24)
116 * Maximum user name length
118 #define CIFS_UNLEN (20)
123 #define SMBOPEN_WRITE_THROUGH 0x4000
124 #define SMBOPEN_DENY_ALL 0x0010
125 #define SMBOPEN_DENY_WRITE 0x0020
126 #define SMBOPEN_DENY_READ 0x0030
127 #define SMBOPEN_DENY_NONE 0x0040
128 #define SMBOPEN_READ 0x0000
129 #define SMBOPEN_WRITE 0x0001
130 #define SMBOPEN_READWRITE 0x0002
131 #define SMBOPEN_EXECUTE 0x0003
133 #define SMBOPEN_OCREATE 0x0010
134 #define SMBOPEN_OTRUNC 0x0002
135 #define SMBOPEN_OAPPEND 0x0001
138 * SMB flag definitions
140 #define SMBFLG_EXTD_LOCK 0x01 /* server supports lock-read write-unlock smb */
141 #define SMBFLG_RCV_POSTED 0x02 /* obsolete */
142 #define SMBFLG_RSVD 0x04
143 #define SMBFLG_CASELESS 0x08 /* all pathnames treated as caseless (off
144 implies case sensitive file handling request) */
145 #define SMBFLG_CANONICAL_PATH_FORMAT 0x10 /* obsolete */
146 #define SMBFLG_OLD_OPLOCK 0x20 /* obsolete */
147 #define SMBFLG_OLD_OPLOCK_NOTIFY 0x40 /* obsolete */
148 #define SMBFLG_RESPONSE 0x80 /* this PDU is a response from server */
151 * SMB flag2 definitions
153 #define SMBFLG2_KNOWS_LONG_NAMES cpu_to_le16(1) /* can send long (non-8.3)
154 path names in response */
155 #define SMBFLG2_KNOWS_EAS cpu_to_le16(2)
156 #define SMBFLG2_SECURITY_SIGNATURE cpu_to_le16(4)
157 #define SMBFLG2_IS_LONG_NAME cpu_to_le16(0x40)
158 #define SMBFLG2_EXT_SEC cpu_to_le16(0x800)
159 #define SMBFLG2_DFS cpu_to_le16(0x1000)
160 #define SMBFLG2_PAGING_IO cpu_to_le16(0x2000)
161 #define SMBFLG2_ERR_STATUS cpu_to_le16(0x4000)
162 #define SMBFLG2_UNICODE cpu_to_le16(0x8000)
165 * These are the file access permission bits defined in CIFS for the
166 * NTCreateAndX as well as the level 0x107
167 * TRANS2_QUERY_PATH_INFORMATION API. The level 0x107, SMB_QUERY_FILE_ALL_INFO
168 * responds with the AccessFlags.
169 * The AccessFlags specifies the access permissions a caller has to the
170 * file and can have any suitable combination of the following values:
173 #define FILE_READ_DATA 0x00000001 /* Data can be read from the file */
174 #define FILE_WRITE_DATA 0x00000002 /* Data can be written to the file */
175 #define FILE_APPEND_DATA 0x00000004 /* Data can be appended to the file */
176 #define FILE_READ_EA 0x00000008 /* Extended attributes associated */
177 /* with the file can be read */
178 #define FILE_WRITE_EA 0x00000010 /* Extended attributes associated */
179 /* with the file can be written */
180 #define FILE_EXECUTE 0x00000020 /*Data can be read into memory from */
181 /* the file using system paging I/O */
182 #define FILE_DELETE_CHILD 0x00000040
183 #define FILE_READ_ATTRIBUTES 0x00000080 /* Attributes associated with the */
184 /* file can be read */
185 #define FILE_WRITE_ATTRIBUTES 0x00000100 /* Attributes associated with the */
186 /* file can be written */
187 #define DELETE 0x00010000 /* The file can be deleted */
188 #define READ_CONTROL 0x00020000 /* The access control list and */
189 /* ownership associated with the */
190 /* file can be read */
191 #define WRITE_DAC 0x00040000 /* The access control list and */
192 /* ownership associated with the */
193 /* file can be written. */
194 #define WRITE_OWNER 0x00080000 /* Ownership information associated */
195 /* with the file can be written */
196 #define SYNCHRONIZE 0x00100000 /* The file handle can waited on to */
197 /* synchronize with the completion */
198 /* of an input/output request */
199 #define GENERIC_ALL 0x10000000
200 #define GENERIC_EXECUTE 0x20000000
201 #define GENERIC_WRITE 0x40000000
202 #define GENERIC_READ 0x80000000
203 /* In summary - Relevant file */
204 /* access flags from CIFS are */
205 /* file_read_data, file_write_data */
206 /* file_execute, file_read_attributes*/
207 /* write_dac, and delete. */
210 * Invalid readdir handle
212 #define CIFS_NO_HANDLE 0xFFFF
215 #define CIFS_IPC_RESOURCE "\x49\x50\x43\x24"
217 /* IPC$ in Unicode */
218 #define CIFS_IPC_UNICODE_RESOURCE "\x00\x49\x00\x50\x00\x43\x00\x24\x00\x00"
220 /* Unicode Null terminate 2 bytes of 0 */
221 #define UNICODE_NULL "\x00\x00"
222 #define ASCII_NULL 0x00
225 * Server type values (returned on EnumServer API
227 #define CIFS_SV_TYPE_DC 0x00000008
228 #define CIFS_SV_TYPE_BACKDC 0x00000010
231 * Alias type flags (From EnumAlias API call
233 #define CIFS_ALIAS_TYPE_FILE 0x0001
234 #define CIFS_SHARE_TYPE_FILE 0x0000
237 * File Attribute flags
239 #define ATTR_READONLY 0x0001
240 #define ATTR_HIDDEN 0x0002
241 #define ATTR_SYSTEM 0x0004
242 #define ATTR_VOLUME 0x0008
243 #define ATTR_DIRECTORY 0x0010
244 #define ATTR_ARCHIVE 0x0020
245 #define ATTR_DEVICE 0x0040
246 #define ATTR_NORMAL 0x0080
247 #define ATTR_TEMPORARY 0x0100
248 #define ATTR_SPARSE 0x0200
249 #define ATTR_REPARSE 0x0400
250 #define ATTR_COMPRESSED 0x0800
251 #define ATTR_OFFLINE 0x1000 /* ie file not immediately available -
252 on offline storage */
253 #define ATTR_NOT_CONTENT_INDEXED 0x2000
254 #define ATTR_ENCRYPTED 0x4000
255 #define ATTR_POSIX_SEMANTICS 0x01000000
256 #define ATTR_BACKUP_SEMANTICS 0x02000000
257 #define ATTR_DELETE_ON_CLOSE 0x04000000
258 #define ATTR_SEQUENTIAL_SCAN 0x08000000
259 #define ATTR_RANDOM_ACCESS 0x10000000
260 #define ATTR_NO_BUFFERING 0x20000000
261 #define ATTR_WRITE_THROUGH 0x80000000
263 /* ShareAccess flags */
264 #define FILE_NO_SHARE 0x00000000
265 #define FILE_SHARE_READ 0x00000001
266 #define FILE_SHARE_WRITE 0x00000002
267 #define FILE_SHARE_DELETE 0x00000004
268 #define FILE_SHARE_ALL 0x00000007
270 /* CreateDisposition flags */
271 #define FILE_SUPERSEDE 0x00000000
272 #define FILE_OPEN 0x00000001
273 #define FILE_CREATE 0x00000002
274 #define FILE_OPEN_IF 0x00000003
275 #define FILE_OVERWRITE 0x00000004
276 #define FILE_OVERWRITE_IF 0x00000005
279 #define CREATE_NOT_FILE 0x00000001 /* if set must not be file */
280 #define CREATE_WRITE_THROUGH 0x00000002
281 #define CREATE_SEQUENTIAL 0x00000004
282 #define CREATE_SYNC_ALERT 0x00000010
283 #define CREATE_ASYNC_ALERT 0x00000020
284 #define CREATE_NOT_DIR 0x00000040 /* if set must not be directory */
285 #define CREATE_NO_EA_KNOWLEDGE 0x00000200
286 #define CREATE_EIGHT_DOT_THREE 0x00000400
287 #define CREATE_RANDOM_ACCESS 0x00000800
288 #define CREATE_DELETE_ON_CLOSE 0x00001000
289 #define CREATE_OPEN_BY_ID 0x00002000
290 #define OPEN_REPARSE_POINT 0x00200000
291 #define CREATE_OPTIONS_MASK 0x007FFFFF
292 #define CREATE_OPTION_SPECIAL 0x20000000 /* system. NB not sent over wire */
294 /* ImpersonationLevel flags */
295 #define SECURITY_ANONYMOUS 0
296 #define SECURITY_IDENTIFICATION 1
297 #define SECURITY_IMPERSONATION 2
298 #define SECURITY_DELEGATION 3
301 #define SECURITY_CONTEXT_TRACKING 0x01
302 #define SECURITY_EFFECTIVE_ONLY 0x02
305 * Default PID value, used in all SMBs where the PID is not important
307 #define CIFS_DFT_PID 0x1234
310 * We use the same routine for Copy and Move SMBs. This flag is used to
313 #define CIFS_COPY_OP 1
314 #define CIFS_RENAME_OP 2
316 #define GETU16(var) (*((__u16 *)var)) /* BB check for endian issues */
317 #define GETU32(var) (*((__u32 *)var)) /* BB check for endian issues */
320 __u32 smb_buf_length; /* big endian on wire *//* BB length is only two
321 or three bytes - with one or two byte type preceding it that are
322 zero - we could mask the type byte off just in case BB */
330 } __attribute__((packed)) DosError;
332 } __attribute__((packed)) Status;
334 __le16 Flags2; /* note: le */
338 __le32 SequenceNumber; /* le */
339 __u32 Reserved; /* zero */
340 } __attribute__((packed)) Sequence;
341 __u8 SecuritySignature[8]; /* le */
342 } __attribute__((packed)) Signature;
349 } __attribute__((packed));
350 /* given a pointer to an smb_hdr retrieve the value of byte count */
351 #define BCC(smb_var) ( *(__u16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2* smb_var->WordCount) ) )
352 #define BCC_LE(smb_var) ( *(__le16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2* smb_var->WordCount) ) )
353 /* given a pointer to an smb_hdr retrieve the pointer to the byte area */
354 #define pByteArea(smb_var) ((unsigned char *)smb_var + sizeof(struct smb_hdr) + (2* smb_var->WordCount) + 2 )
357 * Computer Name Length
362 * Share Name Length @S8A
363 * Note: This length is limited by the SMB used to get @S8A
364 * the Share info. NetShareEnum only returns 13 @S8A
365 * chars, including the null termination. @S8A
367 #define SNLEN 12 /*@S8A */
372 #define MAXCOMMENTLEN 40
375 * The OS/2 maximum path name
377 #define MAX_PATHCONF 256
380 * SMB frame definitions (following must be packed structs)
381 * See the SNIA CIFS Specification for details.
383 * The Naming convention is the lower case version of the
384 * smb command code name for the struct and this is typedef to the
385 * uppercase version of the same name with the prefix SMB_ removed
386 * for brevity. Although typedefs are not commonly used for
387 * structure definitions in the Linux kernel, their use in the
388 * CIFS standards document, which this code is based on, may
389 * make this one of the cases where typedefs for structures make
390 * sense to improve readability for readers of the standards doc.
391 * Typedefs can always be removed later if they are too distracting
392 * and they are only used for the CIFSs PDUs themselves, not
393 * internal cifs vfs structures
397 typedef struct negotiate_req {
398 struct smb_hdr hdr; /* wct = 0 */
400 unsigned char DialectsArray[1];
401 } __attribute__((packed)) NEGOTIATE_REQ;
403 typedef struct negotiate_rsp {
404 struct smb_hdr hdr; /* wct = 17 */
409 __le32 MaxBufferSize;
412 __le32 Capabilities; /* see below */
413 __le32 SystemTimeLow;
414 __le32 SystemTimeHigh;
415 __le16 ServerTimeZone;
416 __u8 EncryptionKeyLength;
419 unsigned char EncryptionKey[1]; /* cap extended security off */
420 /* followed by Domain name - if extended security is off */
421 /* followed by 16 bytes of server GUID */
422 /* then security blob if cap_extended_security negotiated */
424 unsigned char GUID[16];
425 unsigned char SecurityBlob[1];
426 } __attribute__((packed)) extended_response;
427 } __attribute__((packed)) u;
428 } __attribute__((packed)) NEGOTIATE_RSP;
430 /* SecurityMode bits */
431 #define SECMODE_USER 0x01 /* off indicates share level security */
432 #define SECMODE_PW_ENCRYPT 0x02
433 #define SECMODE_SIGN_ENABLED 0x04 /* SMB security signatures enabled */
434 #define SECMODE_SIGN_REQUIRED 0x08 /* SMB security signatures required */
436 /* Negotiate response Capabilities */
437 #define CAP_RAW_MODE 0x00000001
438 #define CAP_MPX_MODE 0x00000002
439 #define CAP_UNICODE 0x00000004
440 #define CAP_LARGE_FILES 0x00000008
441 #define CAP_NT_SMBS 0x00000010 /* implies CAP_NT_FIND */
442 #define CAP_RPC_REMOTE_APIS 0x00000020
443 #define CAP_STATUS32 0x00000040
444 #define CAP_LEVEL_II_OPLOCKS 0x00000080
445 #define CAP_LOCK_AND_READ 0x00000100
446 #define CAP_NT_FIND 0x00000200
447 #define CAP_DFS 0x00001000
448 #define CAP_INFOLEVEL_PASSTHRU 0x00002000
449 #define CAP_LARGE_READ_X 0x00004000
450 #define CAP_LARGE_WRITE_X 0x00008000
451 #define CAP_UNIX 0x00800000
452 #define CAP_RESERVED 0x02000000
453 #define CAP_BULK_TRANSFER 0x20000000
454 #define CAP_COMPRESSED_DATA 0x40000000
455 #define CAP_EXTENDED_SECURITY 0x80000000
457 typedef union smb_com_session_setup_andx {
458 struct { /* request format */
459 struct smb_hdr hdr; /* wct = 12 */
463 __le16 MaxBufferSize;
467 __le16 SecurityBlobLength;
469 __le32 Capabilities; /* see below */
471 unsigned char SecurityBlob[1]; /* followed by */
472 /* STRING NativeOS */
473 /* STRING NativeLanMan */
474 } __attribute__((packed)) req; /* NTLM request format (with
477 struct { /* request format */
478 struct smb_hdr hdr; /* wct = 13 */
482 __le16 MaxBufferSize;
486 __le16 CaseInsensitivePasswordLength; /* ASCII password len */
487 __le16 CaseSensitivePasswordLength; /* Unicode password length*/
488 __u32 Reserved; /* see below */
491 unsigned char CaseInsensitivePassword[1]; /* followed by: */
492 /* unsigned char * CaseSensitivePassword; */
493 /* STRING AccountName */
494 /* STRING PrimaryDomain */
495 /* STRING NativeOS */
496 /* STRING NativeLanMan */
497 } __attribute__((packed)) req_no_secext; /* NTLM request format (without
500 struct { /* default (NTLM) response format */
501 struct smb_hdr hdr; /* wct = 4 */
505 __le16 Action; /* see below */
506 __le16 SecurityBlobLength;
508 unsigned char SecurityBlob[1]; /* followed by */
509 /* unsigned char * NativeOS; */
510 /* unsigned char * NativeLanMan; */
511 /* unsigned char * PrimaryDomain; */
512 } __attribute__((packed)) resp; /* NTLM response format (with or without extended security */
514 struct { /* request format */
515 struct smb_hdr hdr; /* wct = 10 */
519 __le16 MaxBufferSize;
523 __le16 PassswordLength;
526 unsigned char AccountPassword[1]; /* followed by */
527 /* STRING AccountName */
528 /* STRING PrimaryDomain */
529 /* STRING NativeOS */
530 /* STRING NativeLanMan */
531 } __attribute__((packed)) old_req; /* pre-NTLM (LANMAN2.1) request format */
533 struct { /* default (NTLM) response format */
534 struct smb_hdr hdr; /* wct = 3 */
538 __le16 Action; /* see below */
540 unsigned char NativeOS[1]; /* followed by */
541 /* unsigned char * NativeLanMan; */
542 /* unsigned char * PrimaryDomain; */
543 } __attribute__((packed)) old_resp; /* pre-NTLM (LANMAN2.1) response format */
544 } __attribute__((packed)) SESSION_SETUP_ANDX;
546 #define CIFS_NETWORK_OPSYS "CIFS VFS Client for Linux"
548 /* Capabilities bits (for NTLM SessSetup request) */
549 #define CAP_UNICODE 0x00000004
550 #define CAP_LARGE_FILES 0x00000008
551 #define CAP_NT_SMBS 0x00000010
552 #define CAP_STATUS32 0x00000040
553 #define CAP_LEVEL_II_OPLOCKS 0x00000080
554 #define CAP_NT_FIND 0x00000200 /* reserved should be zero
555 (because NT_SMBs implies the same thing?) */
556 #define CAP_BULK_TRANSFER 0x20000000
557 #define CAP_EXTENDED_SECURITY 0x80000000
560 #define GUEST_LOGIN 1
562 typedef struct smb_com_tconx_req {
563 struct smb_hdr hdr; /* wct = 4 */
567 __le16 Flags; /* see below */
568 __le16 PasswordLength;
570 unsigned char Password[1]; /* followed by */
571 /* STRING Path *//* \\server\share name */
573 } __attribute__((packed)) TCONX_REQ;
575 typedef struct smb_com_tconx_rsp {
576 struct smb_hdr hdr; /* wct = 3 *//* note that Win2000 has sent wct=7 in some cases on responses. Four unspecified words followed OptionalSupport */
580 __le16 OptionalSupport; /* see below */
582 unsigned char Service[1]; /* always ASCII, not Unicode */
583 /* STRING NativeFileSystem */
584 } __attribute__((packed)) TCONX_RSP;
586 /* tree connect Flags */
587 #define DISCONNECT_TID 0x0001
588 #define TCON_EXTENDED_SECINFO 0x0008
589 /* OptionalSupport bits */
590 #define SMB_SUPPORT_SEARCH_BITS 0x0001 /* "must have" directory search bits
591 (exclusive searches supported) */
592 #define SMB_SHARE_IS_IN_DFS 0x0002
594 typedef struct smb_com_logoff_andx_req {
595 struct smb_hdr hdr; /* wct = 2 */
600 } __attribute__((packed)) LOGOFF_ANDX_REQ;
602 typedef struct smb_com_logoff_andx_rsp {
603 struct smb_hdr hdr; /* wct = 2 */
608 } __attribute__((packed)) LOGOFF_ANDX_RSP;
610 typedef union smb_com_tree_disconnect { /* as an altetnative can use flag on
611 tree_connect PDU to effect disconnect */
612 /* tdis is probably simplest SMB PDU */
614 struct smb_hdr hdr; /* wct = 0 */
615 __u16 ByteCount; /* bcc = 0 */
616 } __attribute__((packed)) req;
618 struct smb_hdr hdr; /* wct = 0 */
619 __u16 ByteCount; /* bcc = 0 */
620 } __attribute__((packed)) resp;
621 } __attribute__((packed)) TREE_DISCONNECT;
623 typedef struct smb_com_close_req {
624 struct smb_hdr hdr; /* wct = 3 */
626 __u32 LastWriteTime; /* should be zero */
627 __u16 ByteCount; /* 0 */
628 } __attribute__((packed)) CLOSE_REQ;
630 typedef struct smb_com_close_rsp {
631 struct smb_hdr hdr; /* wct = 0 */
632 __u16 ByteCount; /* bct = 0 */
633 } __attribute__((packed)) CLOSE_RSP;
635 typedef struct smb_com_findclose_req {
636 struct smb_hdr hdr; /* wct = 1 */
638 __u16 ByteCount; /* 0 */
639 } __attribute__((packed)) FINDCLOSE_REQ;
642 #define REQ_MORE_INFO 0x00000001 /* legacy (OPEN_AND_X) only */
643 #define REQ_OPLOCK 0x00000002
644 #define REQ_BATCHOPLOCK 0x00000004
645 #define REQ_OPENDIRONLY 0x00000008
647 typedef struct smb_com_open_req { /* also handles create */
648 struct smb_hdr hdr; /* wct = 24 */
652 __u8 Reserved; /* Must Be Zero */
655 __le32 RootDirectoryFid;
656 __le32 DesiredAccess;
657 __le64 AllocationSize;
658 __le32 FileAttributes;
660 __le32 CreateDisposition;
661 __le32 CreateOptions;
662 __le32 ImpersonationLevel;
666 } __attribute__((packed)) OPEN_REQ;
668 /* open response: oplock levels */
669 #define OPLOCK_NONE 0
670 #define OPLOCK_EXCLUSIVE 1
671 #define OPLOCK_BATCH 2
672 #define OPLOCK_READ 3 /* level 2 oplock */
674 /* open response for CreateAction shifted left */
675 #define CIFS_CREATE_ACTION 0x20000 /* file created */
677 typedef struct smb_com_open_rsp {
678 struct smb_hdr hdr; /* wct = 34 BB */
686 __le64 LastAccessTime;
687 __le64 LastWriteTime;
689 __le32 FileAttributes;
690 __le64 AllocationSize;
695 __u16 ByteCount; /* bct = 0 */
696 } __attribute__((packed)) OPEN_RSP;
698 /* format of legacy open request */
699 typedef struct smb_com_openx_req {
700 struct smb_hdr hdr; /* wct = 15 */
706 __le16 Sattr; /* search attributes */
707 __le16 FileAttributes; /* dos attrs */
708 __le32 CreateTime; /* os2 format */
713 __le16 ByteCount; /* file name follows */
715 } __attribute__((packed)) OPENX_REQ;
717 typedef struct smb_com_openx_rsp {
718 struct smb_hdr hdr; /* wct = 15 */
723 __le16 FileAttributes;
724 __le32 LastWriteTime; /* os2 format */
733 } __attribute__((packed)) OPENX_RSP;
735 /* Legacy write request for older servers */
736 typedef struct smb_com_writex_req {
737 struct smb_hdr hdr; /* wct = 12 */
743 __u32 Reserved; /* Timeout */
744 __le16 WriteMode; /* 1 = write through */
747 __le16 DataLengthLow;
750 __u8 Pad; /* BB check for whether padded to DWORD boundary and optimum performance here */
752 } __attribute__((packed)) WRITEX_REQ;
754 typedef struct smb_com_write_req {
755 struct smb_hdr hdr; /* wct = 14 */
764 __le16 DataLengthHigh;
765 __le16 DataLengthLow;
769 __u8 Pad; /* BB check for whether padded to DWORD boundary and optimum performance here */
771 } __attribute__((packed)) WRITE_REQ;
773 typedef struct smb_com_write_rsp {
774 struct smb_hdr hdr; /* wct = 6 */
783 } __attribute__((packed)) WRITE_RSP;
785 /* legacy read request for older servers */
786 typedef struct smb_com_readx_req {
787 struct smb_hdr hdr; /* wct = 10 */
794 __le16 MinCount; /* obsolete */
798 } __attribute__((packed)) READX_REQ;
800 typedef struct smb_com_read_req {
801 struct smb_hdr hdr; /* wct = 12 */
808 __le16 MinCount; /* obsolete */
813 } __attribute__((packed)) READ_REQ;
815 typedef struct smb_com_read_rsp {
816 struct smb_hdr hdr; /* wct = 12 */
821 __le16 DataCompactionMode;
825 __le16 DataLengthHigh;
828 __u8 Pad; /* BB check for whether padded to DWORD boundary and optimum performance here */
830 } __attribute__((packed)) READ_RSP;
832 typedef struct locking_andx_range {
839 } __attribute__((packed)) LOCKING_ANDX_RANGE;
841 #define LOCKING_ANDX_SHARED_LOCK 0x01
842 #define LOCKING_ANDX_OPLOCK_RELEASE 0x02
843 #define LOCKING_ANDX_CHANGE_LOCKTYPE 0x04
844 #define LOCKING_ANDX_CANCEL_LOCK 0x08
845 #define LOCKING_ANDX_LARGE_FILES 0x10 /* always on for us */
847 typedef struct smb_com_lock_req {
848 struct smb_hdr hdr; /* wct = 8 */
856 __le16 NumberOfUnlocks;
857 __le16 NumberOfLocks;
859 LOCKING_ANDX_RANGE Locks[1];
860 } __attribute__((packed)) LOCK_REQ;
863 typedef struct cifs_posix_lock {
864 __le16 lock_type; /* 0 = Read, 1 = Write, 2 = Unlock */
865 __le16 lock_flags; /* 1 = Wait (only valid for setlock) */
869 /* BB what about additional owner info to identify network client */
870 } __attribute__((packed)) CIFS_POSIX_LOCK;
872 typedef struct smb_com_lock_rsp {
873 struct smb_hdr hdr; /* wct = 2 */
878 } __attribute__((packed)) LOCK_RSP;
880 typedef struct smb_com_rename_req {
881 struct smb_hdr hdr; /* wct = 1 */
882 __le16 SearchAttributes; /* target file attributes */
884 __u8 BufferFormat; /* 4 = ASCII or Unicode */
885 unsigned char OldFileName[1];
886 /* followed by __u8 BufferFormat2 */
887 /* followed by NewFileName */
888 } __attribute__((packed)) RENAME_REQ;
890 /* copy request flags */
891 #define COPY_MUST_BE_FILE 0x0001
892 #define COPY_MUST_BE_DIR 0x0002
893 #define COPY_TARGET_MODE_ASCII 0x0004 /* if not set, binary */
894 #define COPY_SOURCE_MODE_ASCII 0x0008 /* if not set, binary */
895 #define COPY_VERIFY_WRITES 0x0010
896 #define COPY_TREE 0x0020
898 typedef struct smb_com_copy_req {
899 struct smb_hdr hdr; /* wct = 3 */
904 __u8 BufferFormat; /* 4 = ASCII or Unicode */
905 unsigned char OldFileName[1];
906 /* followed by __u8 BufferFormat2 */
907 /* followed by NewFileName string */
908 } __attribute__((packed)) COPY_REQ;
910 typedef struct smb_com_copy_rsp {
911 struct smb_hdr hdr; /* wct = 1 */
912 __le16 CopyCount; /* number of files copied */
913 __u16 ByteCount; /* may be zero */
914 __u8 BufferFormat; /* 0x04 - only present if errored file follows */
915 unsigned char ErrorFileName[1]; /* only present if error in copy */
916 } __attribute__((packed)) COPY_RSP;
918 #define CREATE_HARD_LINK 0x103
919 #define MOVEFILE_COPY_ALLOWED 0x0002
920 #define MOVEFILE_REPLACE_EXISTING 0x0001
922 typedef struct smb_com_nt_rename_req { /* A5 - also used for create hardlink */
923 struct smb_hdr hdr; /* wct = 4 */
924 __le16 SearchAttributes; /* target file attributes */
925 __le16 Flags; /* spec says Information Level */
928 __u8 BufferFormat; /* 4 = ASCII or Unicode */
929 unsigned char OldFileName[1];
930 /* followed by __u8 BufferFormat2 */
931 /* followed by NewFileName */
932 } __attribute__((packed)) NT_RENAME_REQ;
934 typedef struct smb_com_rename_rsp {
935 struct smb_hdr hdr; /* wct = 0 */
936 __u16 ByteCount; /* bct = 0 */
937 } __attribute__((packed)) RENAME_RSP;
939 typedef struct smb_com_delete_file_req {
940 struct smb_hdr hdr; /* wct = 1 */
941 __le16 SearchAttributes;
943 __u8 BufferFormat; /* 4 = ASCII */
944 unsigned char fileName[1];
945 } __attribute__((packed)) DELETE_FILE_REQ;
947 typedef struct smb_com_delete_file_rsp {
948 struct smb_hdr hdr; /* wct = 0 */
949 __u16 ByteCount; /* bct = 0 */
950 } __attribute__((packed)) DELETE_FILE_RSP;
952 typedef struct smb_com_delete_directory_req {
953 struct smb_hdr hdr; /* wct = 0 */
955 __u8 BufferFormat; /* 4 = ASCII */
956 unsigned char DirName[1];
957 } __attribute__((packed)) DELETE_DIRECTORY_REQ;
959 typedef struct smb_com_delete_directory_rsp {
960 struct smb_hdr hdr; /* wct = 0 */
961 __u16 ByteCount; /* bct = 0 */
962 } __attribute__((packed)) DELETE_DIRECTORY_RSP;
964 typedef struct smb_com_create_directory_req {
965 struct smb_hdr hdr; /* wct = 0 */
967 __u8 BufferFormat; /* 4 = ASCII */
968 unsigned char DirName[1];
969 } __attribute__((packed)) CREATE_DIRECTORY_REQ;
971 typedef struct smb_com_create_directory_rsp {
972 struct smb_hdr hdr; /* wct = 0 */
973 __u16 ByteCount; /* bct = 0 */
974 } __attribute__((packed)) CREATE_DIRECTORY_RSP;
976 typedef struct smb_com_query_information_req {
977 struct smb_hdr hdr; /* wct = 0 */
978 __le16 ByteCount; /* 1 + namelen + 1 */
979 __u8 BufferFormat; /* 4 = ASCII */
980 unsigned char FileName[1];
981 } __attribute__((packed)) QUERY_INFORMATION_REQ;
983 typedef struct smb_com_query_information_rsp {
984 struct smb_hdr hdr; /* wct = 10 */
986 __le32 last_write_time;
989 __le16 ByteCount; /* bcc = 0 */
990 } __attribute__((packed)) QUERY_INFORMATION_RSP;
992 typedef struct smb_com_setattr_req {
993 struct smb_hdr hdr; /* wct = 8 */
997 __le16 reserved[5]; /* must be zero */
999 __u8 BufferFormat; /* 4 = ASCII */
1000 unsigned char fileName[1];
1001 } __attribute__((packed)) SETATTR_REQ;
1003 typedef struct smb_com_setattr_rsp {
1004 struct smb_hdr hdr; /* wct = 0 */
1005 __u16 ByteCount; /* bct = 0 */
1006 } __attribute__((packed)) SETATTR_RSP;
1008 /* empty wct response to setattr */
1010 /***************************************************/
1011 /* NT Transact structure defintions follow */
1012 /* Currently only ioctl and notify are implemented */
1013 /***************************************************/
1014 typedef struct smb_com_transaction_ioctl_req {
1015 struct smb_hdr hdr; /* wct = 23 */
1018 __le32 TotalParameterCount;
1019 __le32 TotalDataCount;
1020 __le32 MaxParameterCount;
1021 __le32 MaxDataCount;
1022 __le32 ParameterCount;
1023 __le32 ParameterOffset;
1026 __u8 SetupCount; /* four setup words follow subcommand */
1027 /* SNIA spec incorrectly included spurious pad here */
1028 __le16 SubCommand;/* 2 = IOCTL/FSCTL */
1029 __le32 FunctionCode;
1031 __u8 IsFsctl; /* 1 = File System Control, 0 = device control (IOCTL)*/
1032 __u8 IsRootFlag; /* 1 = apply command to root of share (must be DFS share)*/
1036 } __attribute__((packed)) TRANSACT_IOCTL_REQ;
1038 typedef struct smb_com_transaction_ioctl_rsp {
1039 struct smb_hdr hdr; /* wct = 19 */
1041 __le32 TotalParameterCount;
1042 __le32 TotalDataCount;
1043 __le32 ParameterCount;
1044 __le32 ParameterOffset;
1045 __le32 ParameterDisplacement;
1048 __le32 DataDisplacement;
1049 __u8 SetupCount; /* 1 */
1050 __le16 ReturnedDataLen;
1053 } __attribute__((packed)) TRANSACT_IOCTL_RSP;
1055 typedef struct smb_com_transaction_change_notify_req {
1056 struct smb_hdr hdr; /* wct = 23 */
1059 __le32 TotalParameterCount;
1060 __le32 TotalDataCount;
1061 __le32 MaxParameterCount;
1062 __le32 MaxDataCount;
1063 __le32 ParameterCount;
1064 __le32 ParameterOffset;
1067 __u8 SetupCount; /* four setup words follow subcommand */
1068 /* SNIA spec incorrectly included spurious pad here */
1069 __le16 SubCommand;/* 4 = Change Notify */
1070 __le32 CompletionFilter; /* operation to monitor */
1072 __u8 WatchTree; /* 1 = Monitor subdirectories */
1077 } __attribute__((packed)) TRANSACT_CHANGE_NOTIFY_REQ;
1079 typedef struct smb_com_transaction_change_notify_rsp {
1080 struct smb_hdr hdr; /* wct = 18 */
1082 __le32 TotalParameterCount;
1083 __le32 TotalDataCount;
1084 __le32 ParameterCount;
1085 __le32 ParameterOffset;
1086 __le32 ParameterDisplacement;
1089 __le32 DataDisplacement;
1090 __u8 SetupCount; /* 0 */
1093 } __attribute__((packed)) TRANSACT_CHANGE_NOTIFY_RSP;
1094 /* Completion Filter flags for Notify */
1095 #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
1096 #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
1097 #define FILE_NOTIFY_CHANGE_NAME 0x00000003
1098 #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
1099 #define FILE_NOTIFY_CHANGE_SIZE 0x00000008
1100 #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
1101 #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
1102 #define FILE_NOTIFY_CHANGE_CREATION 0x00000040
1103 #define FILE_NOTIFY_CHANGE_EA 0x00000080
1104 #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
1105 #define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200
1106 #define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400
1107 #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
1109 #define FILE_ACTION_ADDED 0x00000001
1110 #define FILE_ACTION_REMOVED 0x00000002
1111 #define FILE_ACTION_MODIFIED 0x00000003
1112 #define FILE_ACTION_RENAMED_OLD_NAME 0x00000004
1113 #define FILE_ACTION_RENAMED_NEW_NAME 0x00000005
1114 #define FILE_ACTION_ADDED_STREAM 0x00000006
1115 #define FILE_ACTION_REMOVED_STREAM 0x00000007
1116 #define FILE_ACTION_MODIFIED_STREAM 0x00000008
1118 /* response contains array of the following structures */
1119 struct file_notify_information {
1120 __le32 NextEntryOffset;
1122 __le32 FileNameLength;
1124 } __attribute__((packed));
1126 struct reparse_data {
1128 __u16 ReparseDataLength;
1130 __u16 AltNameOffset;
1132 __u16 TargetNameOffset;
1133 __u16 TargetNameLen;
1134 char LinkNamesBuf[1];
1135 } __attribute__((packed));
1137 struct cifs_quota_data {
1138 __u32 rsrvd1; /* 0 */
1140 __u64 rsrvd2; /* 0 */
1144 char sid[1]; /* variable size? */
1145 } __attribute__((packed));
1147 /* quota sub commands */
1148 #define QUOTA_LIST_CONTINUE 0
1149 #define QUOTA_LIST_START 0x100
1150 #define QUOTA_FOR_SID 0x101
1153 /* struct smb_hdr hdr precedes. Set wct = 14+ */
1154 __le16 TotalParameterCount;
1155 __le16 TotalDataCount;
1156 __le16 MaxParameterCount;
1157 __le16 MaxDataCount;
1163 __le16 ParameterCount;
1164 __le16 ParameterOffset;
1169 __le16 SubCommand; /* 1st setup word - SetupCount words follow */
1171 } __attribute__((packed));
1175 struct trans2_req t2_req;
1176 } __attribute__((packed));
1178 struct trans2_resp {
1179 /* struct smb_hdr hdr precedes. Note wct = 10 + setup count */
1180 __le16 TotalParameterCount;
1181 __le16 TotalDataCount;
1183 __le16 ParameterCount;
1184 __le16 ParameterOffset;
1185 __le16 ParameterDisplacement;
1188 __le16 DataDisplacement;
1191 /* SetupWords[SetupCount];
1194 /* data area follows */
1195 } __attribute__((packed));
1199 struct trans2_resp t2_rsp;
1200 } __attribute__((packed));
1202 /* PathInfo/FileInfo infolevels */
1203 #define SMB_INFO_STANDARD 1
1204 #define SMB_SET_FILE_EA 2
1205 #define SMB_QUERY_FILE_EA_SIZE 2
1206 #define SMB_INFO_QUERY_EAS_FROM_LIST 3
1207 #define SMB_INFO_QUERY_ALL_EAS 4
1208 #define SMB_INFO_IS_NAME_VALID 6
1209 #define SMB_QUERY_FILE_BASIC_INFO 0x101
1210 #define SMB_QUERY_FILE_STANDARD_INFO 0x102
1211 #define SMB_QUERY_FILE_EA_INFO 0x103
1212 #define SMB_QUERY_FILE_NAME_INFO 0x104
1213 #define SMB_QUERY_FILE_ALLOCATION_INFO 0x105
1214 #define SMB_QUERY_FILE_END_OF_FILEINFO 0x106
1215 #define SMB_QUERY_FILE_ALL_INFO 0x107
1216 #define SMB_QUERY_ALT_NAME_INFO 0x108
1217 #define SMB_QUERY_FILE_STREAM_INFO 0x109
1218 #define SMB_QUERY_FILE_COMPRESSION_INFO 0x10B
1219 #define SMB_QUERY_FILE_UNIX_BASIC 0x200
1220 #define SMB_QUERY_FILE_UNIX_LINK 0x201
1221 #define SMB_QUERY_POSIX_ACL 0x204
1222 #define SMB_QUERY_XATTR 0x205
1223 #define SMB_QUERY_ATTR_FLAGS 0x206 /* append,immutable etc. */
1224 #define SMB_QUERY_POSIX_PERMISSION 0x207
1225 #define SMB_QUERY_POSIX_LOCK 0x208
1226 #define SMB_QUERY_FILE_INTERNAL_INFO 0x3ee
1227 #define SMB_QUERY_FILE_ACCESS_INFO 0x3f0
1228 #define SMB_QUERY_FILE_NAME_INFO2 0x3f1 /* 0x30 bytes */
1229 #define SMB_QUERY_FILE_POSITION_INFO 0x3f6
1230 #define SMB_QUERY_FILE_MODE_INFO 0x3f8
1231 #define SMB_QUERY_FILE_ALGN_INFO 0x3f9
1234 #define SMB_SET_FILE_BASIC_INFO 0x101
1235 #define SMB_SET_FILE_DISPOSITION_INFO 0x102
1236 #define SMB_SET_FILE_ALLOCATION_INFO 0x103
1237 #define SMB_SET_FILE_END_OF_FILE_INFO 0x104
1238 #define SMB_SET_FILE_UNIX_BASIC 0x200
1239 #define SMB_SET_FILE_UNIX_LINK 0x201
1240 #define SMB_SET_FILE_UNIX_HLINK 0x203
1241 #define SMB_SET_POSIX_ACL 0x204
1242 #define SMB_SET_XATTR 0x205
1243 #define SMB_SET_ATTR_FLAGS 0x206 /* append, immutable etc. */
1244 #define SMB_SET_POSIX_LOCK 0x208
1245 #define SMB_SET_FILE_BASIC_INFO2 0x3ec
1246 #define SMB_SET_FILE_RENAME_INFORMATION 0x3f2 /* BB check if qpathinfo level too */
1247 #define SMB_FILE_ALL_INFO2 0x3fa
1248 #define SMB_SET_FILE_ALLOCATION_INFO2 0x3fb
1249 #define SMB_SET_FILE_END_OF_FILE_INFO2 0x3fc
1250 #define SMB_FILE_MOVE_CLUSTER_INFO 0x407
1251 #define SMB_FILE_QUOTA_INFO 0x408
1252 #define SMB_FILE_REPARSEPOINT_INFO 0x409
1253 #define SMB_FILE_MAXIMUM_INFO 0x40d
1255 /* Find File infolevels */
1256 #define SMB_FIND_FILE_DIRECTORY_INFO 0x101
1257 #define SMB_FIND_FILE_FULL_DIRECTORY_INFO 0x102
1258 #define SMB_FIND_FILE_NAMES_INFO 0x103
1259 #define SMB_FIND_FILE_BOTH_DIRECTORY_INFO 0x104
1260 #define SMB_FIND_FILE_ID_FULL_DIR_INFO 0x105
1261 #define SMB_FIND_FILE_ID_BOTH_DIR_INFO 0x106
1262 #define SMB_FIND_FILE_UNIX 0x202
1264 typedef struct smb_com_transaction2_qpi_req {
1265 struct smb_hdr hdr; /* wct = 14+ */
1266 __le16 TotalParameterCount;
1267 __le16 TotalDataCount;
1268 __le16 MaxParameterCount;
1269 __le16 MaxDataCount;
1275 __le16 ParameterCount;
1276 __le16 ParameterOffset;
1281 __le16 SubCommand; /* one setup word */
1284 __le16 InformationLevel;
1287 } __attribute__((packed)) TRANSACTION2_QPI_REQ;
1289 typedef struct smb_com_transaction2_qpi_rsp {
1290 struct smb_hdr hdr; /* wct = 10 + SetupCount */
1291 struct trans2_resp t2;
1293 __u16 Reserved2; /* parameter word reserved - present for infolevels > 100 */
1294 } __attribute__((packed)) TRANSACTION2_QPI_RSP;
1296 typedef struct smb_com_transaction2_spi_req {
1297 struct smb_hdr hdr; /* wct = 15 */
1298 __le16 TotalParameterCount;
1299 __le16 TotalDataCount;
1300 __le16 MaxParameterCount;
1301 __le16 MaxDataCount;
1307 __le16 ParameterCount;
1308 __le16 ParameterOffset;
1313 __le16 SubCommand; /* one setup word */
1317 __le16 InformationLevel;
1320 } __attribute__((packed)) TRANSACTION2_SPI_REQ;
1322 typedef struct smb_com_transaction2_spi_rsp {
1323 struct smb_hdr hdr; /* wct = 10 + SetupCount */
1324 struct trans2_resp t2;
1326 __u16 Reserved2; /* parameter word reserved - present for infolevels > 100 */
1327 } __attribute__((packed)) TRANSACTION2_SPI_RSP;
1329 struct set_file_rename {
1330 __le32 overwrite; /* 1 = overwrite dest */
1331 __u32 root_fid; /* zero */
1332 __le32 target_name_len;
1333 char target_name[0]; /* Must be unicode */
1334 } __attribute__((packed));
1336 struct smb_com_transaction2_sfi_req {
1337 struct smb_hdr hdr; /* wct = 15 */
1338 __le16 TotalParameterCount;
1339 __le16 TotalDataCount;
1340 __le16 MaxParameterCount;
1341 __le16 MaxDataCount;
1347 __le16 ParameterCount;
1348 __le16 ParameterOffset;
1353 __le16 SubCommand; /* one setup word */
1358 __le16 InformationLevel;
1360 } __attribute__((packed));
1362 struct smb_com_transaction2_sfi_rsp {
1363 struct smb_hdr hdr; /* wct = 10 + SetupCount */
1364 struct trans2_resp t2;
1366 __u16 Reserved2; /* parameter word reserved -
1367 present for infolevels > 100 */
1368 } __attribute__((packed));
1370 struct smb_t2_qfi_req {
1372 struct trans2_req t2;
1375 __le16 InformationLevel;
1376 } __attribute__((packed));
1378 struct smb_t2_qfi_rsp {
1379 struct smb_hdr hdr; /* wct = 10 + SetupCount */
1380 struct trans2_resp t2;
1382 __u16 Reserved2; /* parameter word reserved -
1383 present for infolevels > 100 */
1384 } __attribute__((packed));
1387 * Flags on T2 FINDFIRST and FINDNEXT
1389 #define CIFS_SEARCH_CLOSE_ALWAYS 0x0001
1390 #define CIFS_SEARCH_CLOSE_AT_END 0x0002
1391 #define CIFS_SEARCH_RETURN_RESUME 0x0004
1392 #define CIFS_SEARCH_CONTINUE_FROM_LAST 0x0008
1393 #define CIFS_SEARCH_BACKUP_SEARCH 0x0010
1396 * Size of the resume key on FINDFIRST and FINDNEXT calls
1398 #define CIFS_SMB_RESUME_KEY_SIZE 4
1400 typedef struct smb_com_transaction2_ffirst_req {
1401 struct smb_hdr hdr; /* wct = 15 */
1402 __le16 TotalParameterCount;
1403 __le16 TotalDataCount;
1404 __le16 MaxParameterCount;
1405 __le16 MaxDataCount;
1411 __le16 ParameterCount;
1412 __le16 ParameterOffset;
1415 __u8 SetupCount; /* one */
1417 __le16 SubCommand; /* TRANS2_FIND_FIRST */
1420 __le16 SearchAttributes;
1423 __le16 InformationLevel;
1424 __le32 SearchStorageType;
1426 } __attribute__((packed)) TRANSACTION2_FFIRST_REQ;
1428 typedef struct smb_com_transaction2_ffirst_rsp {
1429 struct smb_hdr hdr; /* wct = 10 */
1430 struct trans2_resp t2;
1432 } __attribute__((packed)) TRANSACTION2_FFIRST_RSP;
1434 typedef struct smb_com_transaction2_ffirst_rsp_parms {
1438 __le16 EAErrorOffset;
1439 __le16 LastNameOffset;
1440 } __attribute__((packed)) T2_FFIRST_RSP_PARMS;
1442 typedef struct smb_com_transaction2_fnext_req {
1443 struct smb_hdr hdr; /* wct = 15 */
1444 __le16 TotalParameterCount;
1445 __le16 TotalDataCount;
1446 __le16 MaxParameterCount;
1447 __le16 MaxDataCount;
1453 __le16 ParameterCount;
1454 __le16 ParameterOffset;
1457 __u8 SetupCount; /* one */
1459 __le16 SubCommand; /* TRANS2_FIND_NEXT */
1464 __le16 InformationLevel;
1467 char ResumeFileName[1];
1468 } __attribute__((packed)) TRANSACTION2_FNEXT_REQ;
1470 typedef struct smb_com_transaction2_fnext_rsp {
1471 struct smb_hdr hdr; /* wct = 10 */
1472 struct trans2_resp t2;
1474 } __attribute__((packed)) TRANSACTION2_FNEXT_RSP;
1476 typedef struct smb_com_transaction2_fnext_rsp_parms {
1479 __le16 EAErrorOffset;
1480 __le16 LastNameOffset;
1481 } __attribute__((packed)) T2_FNEXT_RSP_PARMS;
1483 /* QFSInfo Levels */
1484 #define SMB_INFO_ALLOCATION 1
1485 #define SMB_INFO_VOLUME 2
1486 #define SMB_QUERY_FS_VOLUME_INFO 0x102
1487 #define SMB_QUERY_FS_SIZE_INFO 0x103
1488 #define SMB_QUERY_FS_DEVICE_INFO 0x104
1489 #define SMB_QUERY_FS_ATTRIBUTE_INFO 0x105
1490 #define SMB_QUERY_CIFS_UNIX_INFO 0x200
1491 #define SMB_QUERY_POSIX_FS_INFO 0x201
1492 #define SMB_QUERY_LABEL_INFO 0x3ea
1493 #define SMB_QUERY_FS_QUOTA_INFO 0x3ee
1494 #define SMB_QUERY_FS_FULL_SIZE_INFO 0x3ef
1495 #define SMB_QUERY_OBJECTID_INFO 0x3f0
1497 typedef struct smb_com_transaction2_qfsi_req {
1498 struct smb_hdr hdr; /* wct = 14+ */
1499 __le16 TotalParameterCount;
1500 __le16 TotalDataCount;
1501 __le16 MaxParameterCount;
1502 __le16 MaxDataCount;
1508 __le16 ParameterCount;
1509 __le16 ParameterOffset;
1514 __le16 SubCommand; /* one setup word */
1517 __le16 InformationLevel;
1518 } __attribute__((packed)) TRANSACTION2_QFSI_REQ;
1520 typedef struct smb_com_transaction_qfsi_rsp {
1521 struct smb_hdr hdr; /* wct = 10 + SetupCount */
1522 struct trans2_resp t2;
1524 __u8 Pad; /* may be three bytes *//* followed by data area */
1525 } __attribute__((packed)) TRANSACTION2_QFSI_RSP;
1528 /* SETFSInfo Levels */
1529 #define SMB_SET_CIFS_UNIX_INFO 0x200
1530 typedef struct smb_com_transaction2_setfsi_req {
1531 struct smb_hdr hdr; /* wct = 15 */
1532 __le16 TotalParameterCount;
1533 __le16 TotalDataCount;
1534 __le16 MaxParameterCount;
1535 __le16 MaxDataCount;
1541 __le16 ParameterCount; /* 4 */
1542 __le16 ParameterOffset;
1543 __le16 DataCount; /* 12 */
1545 __u8 SetupCount; /* one */
1547 __le16 SubCommand; /* TRANS2_SET_FS_INFORMATION */
1550 __u16 FileNum; /* Parameters start. */
1551 __le16 InformationLevel;/* Parameters end. */
1552 __le16 ClientUnixMajor; /* Data start. */
1553 __le16 ClientUnixMinor;
1554 __le64 ClientUnixCap; /* Data end */
1555 } __attribute__((packed)) TRANSACTION2_SETFSI_REQ;
1557 typedef struct smb_com_transaction2_setfsi_rsp {
1558 struct smb_hdr hdr; /* wct = 10 */
1559 struct trans2_resp t2;
1561 } __attribute__((packed)) TRANSACTION2_SETFSI_RSP;
1564 typedef struct smb_com_transaction2_get_dfs_refer_req {
1565 struct smb_hdr hdr; /* wct = 15 */
1566 __le16 TotalParameterCount;
1567 __le16 TotalDataCount;
1568 __le16 MaxParameterCount;
1569 __le16 MaxDataCount;
1575 __le16 ParameterCount;
1576 __le16 ParameterOffset;
1581 __le16 SubCommand; /* one setup word */
1583 __u8 Pad[3]; /* Win2K has sent 0x0F01 (max resp length perhaps?) followed by one byte pad - doesn't seem to matter though */
1584 __le16 MaxReferralLevel;
1585 char RequestFileName[1];
1586 } __attribute__((packed)) TRANSACTION2_GET_DFS_REFER_REQ;
1588 typedef struct dfs_referral_level_3 {
1589 __le16 VersionNumber;
1590 __le16 ReferralSize;
1591 __le16 ServerType; /* 0x0001 = CIFS server */
1592 __le16 ReferralFlags; /* or proximity - not clear which since always set to zero - SNIA spec says 0x01 means strip off PathConsumed chars before submitting RequestFileName to remote node */
1595 __le16 DfsPathOffset;
1596 __le16 DfsAlternatePathOffset;
1597 __le16 NetworkAddressOffset;
1598 } __attribute__((packed)) REFERRAL3;
1600 typedef struct smb_com_transaction_get_dfs_refer_rsp {
1601 struct smb_hdr hdr; /* wct = 10 */
1602 struct trans2_resp t2;
1605 __le16 PathConsumed;
1606 __le16 NumberOfReferrals;
1609 REFERRAL3 referrals[1]; /* array of level 3 dfs_referral structures */
1610 /* followed by the strings pointed to by the referral structures */
1611 } __attribute__((packed)) TRANSACTION2_GET_DFS_REFER_RSP;
1614 #define DFSREF_REFERRAL_SERVER 0x0001
1615 #define DFSREF_STORAGE_SERVER 0x0002
1617 /* IOCTL information */
1618 /* List of ioctl function codes that look to be of interest to remote clients like this. */
1619 /* Need to do some experimentation to make sure they all work remotely. */
1620 /* Some of the following such as the encryption/compression ones would be */
1621 /* invoked from tools via a specialized hook into the VFS rather than via the */
1622 /* standard vfs entry points */
1623 #define FSCTL_REQUEST_OPLOCK_LEVEL_1 0x00090000
1624 #define FSCTL_REQUEST_OPLOCK_LEVEL_2 0x00090004
1625 #define FSCTL_REQUEST_BATCH_OPLOCK 0x00090008
1626 #define FSCTL_LOCK_VOLUME 0x00090018
1627 #define FSCTL_UNLOCK_VOLUME 0x0009001C
1628 #define FSCTL_GET_COMPRESSION 0x0009003C
1629 #define FSCTL_SET_COMPRESSION 0x0009C040
1630 #define FSCTL_REQUEST_FILTER_OPLOCK 0x0009008C
1631 #define FSCTL_FILESYS_GET_STATISTICS 0x00090090
1632 #define FSCTL_SET_REPARSE_POINT 0x000900A4
1633 #define FSCTL_GET_REPARSE_POINT 0x000900A8
1634 #define FSCTL_DELETE_REPARSE_POINT 0x000900AC
1635 #define FSCTL_SET_SPARSE 0x000900C4
1636 #define FSCTL_SET_ZERO_DATA 0x000900C8
1637 #define FSCTL_SET_ENCRYPTION 0x000900D7
1638 #define FSCTL_ENCRYPTION_FSCTL_IO 0x000900DB
1639 #define FSCTL_WRITE_RAW_ENCRYPTED 0x000900DF
1640 #define FSCTL_READ_RAW_ENCRYPTED 0x000900E3
1641 #define FSCTL_SIS_COPYFILE 0x00090100
1642 #define FSCTL_SIS_LINK_FILES 0x0009C104
1644 #define IO_REPARSE_TAG_MOUNT_POINT 0xA0000003
1645 #define IO_REPARSE_TAG_HSM 0xC0000004
1646 #define IO_REPARSE_TAG_SIS 0x80000007
1649 ************************************************************************
1650 * All structs for everything above the SMB PDUs themselves
1651 * (such as the T2 level specific data) go here
1652 ************************************************************************
1656 * Information on a server
1661 unsigned char versionMajor;
1662 unsigned char versionMinor;
1664 unsigned int commentOffset;
1665 } __attribute__((packed));
1668 * The following structure is the format of the data returned on a NetShareEnum
1669 * with level "90" (x5A)
1675 unsigned short type;
1676 unsigned int commentOffset;
1677 } __attribute__((packed));
1682 unsigned int commentOffset;
1683 unsigned char type[2];
1684 } __attribute__((packed));
1686 struct aliasInfo92 {
1687 int aliasNameOffset;
1688 int serverNameOffset;
1689 int shareNameOffset;
1690 } __attribute__((packed));
1693 __le64 TotalAllocationUnits;
1694 __le64 FreeAllocationUnits;
1695 __le32 SectorsPerAllocationUnit;
1696 __le32 BytesPerSector;
1697 } __attribute__((packed)) FILE_SYSTEM_INFO; /* size info, level 0x103 */
1701 __le32 SectorsPerAllocationUnit;
1702 __le32 TotalAllocationUnits;
1703 __le32 FreeAllocationUnits;
1704 __le16 BytesPerSector;
1705 } __attribute__((packed)) FILE_SYSTEM_ALLOC_INFO;
1708 __le16 MajorVersionNumber;
1709 __le16 MinorVersionNumber;
1711 } __attribute__((packed)) FILE_SYSTEM_UNIX_INFO; /* Unix extensions info, level 0x200 */
1713 /* Version numbers for CIFS UNIX major and minor. */
1714 #define CIFS_UNIX_MAJOR_VERSION 1
1715 #define CIFS_UNIX_MINOR_VERSION 0
1717 /* Linux/Unix extensions capability flags */
1718 #define CIFS_UNIX_FCNTL_CAP 0x00000001 /* support for fcntl locks */
1719 #define CIFS_UNIX_POSIX_ACL_CAP 0x00000002 /* support getfacl/setfacl */
1720 #define CIFS_UNIX_XATTR_CAP 0x00000004 /* support new namespace */
1721 #define CIFS_UNIX_EXTATTR_CAP 0x00000008 /* support chattr/chflag */
1722 #define CIFS_UNIX_POSIX_PATHNAMES_CAP 0x00000010 /* Use POSIX pathnames on the wire. */
1724 #define CIFS_POSIX_EXTENSIONS 0x00000010 /* support for new QFSInfo */
1727 /* For undefined recommended transfer size return -1 in that field */
1728 __le32 OptimalTransferSize; /* bsize on some os, iosize on other os */
1730 /* The next three fields are in terms of the block size.
1731 (above). If block size is unknown, 4096 would be a
1732 reasonable block size for a server to report.
1733 Note that returning the blocks/blocksavail removes need
1734 to make a second call (to QFSInfo level 0x103 to get this info.
1735 UserBlockAvail is typically less than or equal to BlocksAvail,
1736 if no distinction is made return the same value in each */
1738 __le64 BlocksAvail; /* bfree */
1739 __le64 UserBlocksAvail; /* bavail */
1740 /* For undefined Node fields or FSID return -1 */
1741 __le64 TotalFileNodes;
1742 __le64 FreeFileNodes;
1743 __le64 FileSysIdentifier; /* fsid */
1744 /* NB Namelen comes from FILE_SYSTEM_ATTRIBUTE_INFO call */
1745 /* NB flags can come from FILE_SYSTEM_DEVICE_INFO call */
1746 } __attribute__((packed)) FILE_SYSTEM_POSIX_INFO;
1748 /* DeviceType Flags */
1749 #define FILE_DEVICE_CD_ROM 0x00000002
1750 #define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003
1751 #define FILE_DEVICE_DFS 0x00000006
1752 #define FILE_DEVICE_DISK 0x00000007
1753 #define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008
1754 #define FILE_DEVICE_FILE_SYSTEM 0x00000009
1755 #define FILE_DEVICE_NAMED_PIPE 0x00000011
1756 #define FILE_DEVICE_NETWORK 0x00000012
1757 #define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
1758 #define FILE_DEVICE_NULL 0x00000015
1759 #define FILE_DEVICE_PARALLEL_PORT 0x00000016
1760 #define FILE_DEVICE_PRINTER 0x00000018
1761 #define FILE_DEVICE_SERIAL_PORT 0x0000001b
1762 #define FILE_DEVICE_STREAMS 0x0000001e
1763 #define FILE_DEVICE_TAPE 0x0000001f
1764 #define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020
1765 #define FILE_DEVICE_VIRTUAL_DISK 0x00000024
1766 #define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028
1770 __le32 DeviceCharacteristics;
1771 } __attribute__((packed)) FILE_SYSTEM_DEVICE_INFO; /* device info, level 0x104 */
1775 __le32 MaxPathNameComponentLength;
1776 __le32 FileSystemNameLen;
1777 char FileSystemName[52]; /* do not really need to save this - so potentially get only subset of name */
1778 } __attribute__((packed)) FILE_SYSTEM_ATTRIBUTE_INFO;
1780 /******************************************************************************/
1781 /* QueryFileInfo/QueryPathinfo (also for SetPath/SetFile) data buffer formats */
1782 /******************************************************************************/
1783 typedef struct { /* data block encoding of response to level 263 QPathInfo */
1784 __le64 CreationTime;
1785 __le64 LastAccessTime;
1786 __le64 LastWriteTime;
1790 __le64 AllocationSize;
1791 __le64 EndOfFile; /* size ie offset to first free byte in file */
1792 __le32 NumberOfLinks; /* hard links */
1800 __le64 CurrentByteOffset;
1802 __le32 AlignmentRequirement;
1803 __le32 FileNameLength;
1805 } __attribute__((packed)) FILE_ALL_INFO; /* level 0x107 QPathInfo */
1807 /* defines for enumerating possible values of the Unix type field below */
1810 #define UNIX_SYMLINK 2
1811 #define UNIX_CHARDEV 3
1812 #define UNIX_BLOCKDEV 4
1814 #define UNIX_SOCKET 6
1818 __le64 LastStatusChange; /*SNIA specs DCE time for the 3 time fields */
1819 __le64 LastAccessTime;
1820 __le64 LastModificationTime;
1829 } __attribute__((packed)) FILE_UNIX_BASIC_INFO; /* level 0x200 QPathInfo */
1833 } __attribute__((packed)) FILE_UNIX_LINK_INFO; /* level 0x201 QPathInfo */
1835 /* The following three structures are needed only for
1836 setting time to NT4 and some older servers via
1837 the primitive DOS time format */
1842 } __attribute__((packed)) SMB_DATE;
1848 } __attribute__((packed)) SMB_TIME;
1851 __le16 CreationDate; /* SMB Date see above */
1852 __le16 CreationTime; /* SMB Time */
1853 __le16 LastAccessDate;
1854 __le16 LastAccessTime;
1855 __le16 LastWriteDate;
1856 __le16 LastWriteTime;
1857 __le32 DataSize; /* File Size (EOF) */
1858 __le32 AllocationSize;
1859 __le16 Attributes; /* verify not u32 */
1861 } __attribute__((packed)) FILE_INFO_STANDARD; /* level 1 SetPath/FileInfo */
1864 __le64 CreationTime;
1865 __le64 LastAccessTime;
1866 __le64 LastWriteTime;
1870 } __attribute__((packed)) FILE_BASIC_INFO; /* size info, level 0x101 */
1872 struct file_allocation_info {
1873 __le64 AllocationSize; /* Note old Samba srvr rounds this up too much */
1874 } __attribute__((packed)); /* size used on disk, level 0x103 for set, 0x105 for query */
1876 struct file_end_of_file_info {
1877 __le64 FileSize; /* offset to end of file */
1878 } __attribute__((packed)); /* size info, level 0x104 for set, 0x106 for query */
1880 struct file_alt_name_info {
1882 } __attribute__((packed)); /* level 0x0108 */
1884 struct file_stream_info {
1885 __le32 number_of_streams; /* BB check sizes and verify location */
1886 /* followed by info on streams themselves
1890 }; /* level 0x109 */
1892 struct file_compression_info {
1893 __le64 compressed_size;
1899 } __attribute__((packed)); /* level 0x10b */
1901 /* POSIX ACL set/query path info structures */
1902 #define CIFS_ACL_VERSION 1
1903 struct cifs_posix_ace { /* access control entry (ACE) */
1906 __le64 cifs_uid; /* or gid */
1907 } __attribute__((packed));
1909 struct cifs_posix_acl { /* access conrol list (ACL) */
1911 __le16 access_entry_count; /* access ACL - count of entries */
1912 __le16 default_entry_count; /* default ACL - count of entries */
1913 struct cifs_posix_ace ace_array[0];
1915 struct cifs_posix_ace default_ace_arraay[] */
1916 } __attribute__((packed)); /* level 0x204 */
1918 /* types of access control entries already defined in posix_acl.h */
1919 /* #define CIFS_POSIX_ACL_USER_OBJ 0x01
1920 #define CIFS_POSIX_ACL_USER 0x02
1921 #define CIFS_POSIX_ACL_GROUP_OBJ 0x04
1922 #define CIFS_POSIX_ACL_GROUP 0x08
1923 #define CIFS_POSIX_ACL_MASK 0x10
1924 #define CIFS_POSIX_ACL_OTHER 0x20 */
1926 /* types of perms */
1927 /* #define CIFS_POSIX_ACL_EXECUTE 0x01
1928 #define CIFS_POSIX_ACL_WRITE 0x02
1929 #define CIFS_POSIX_ACL_READ 0x04 */
1931 /* end of POSIX ACL definitions */
1933 struct file_internal_info {
1934 __u64 UniqueId; /* inode number */
1935 } __attribute__((packed)); /* level 0x3ee */
1936 struct file_mode_info {
1938 } __attribute__((packed)); /* level 0x3f8 */
1940 struct file_attrib_tag {
1943 } __attribute__((packed)); /* level 0x40b */
1946 /********************************************************/
1947 /* FindFirst/FindNext transact2 data buffer formats */
1948 /********************************************************/
1951 __le32 NextEntryOffset;
1952 __u32 ResumeKey; /* as with FileIndex - no need to convert */
1955 __le64 LastStatusChange; /*SNIA specs DCE time for the 3 time fields */
1956 __le64 LastAccessTime;
1957 __le64 LastModificationTime;
1967 } __attribute__((packed)) FILE_UNIX_INFO; /* level 0x202 */
1970 __le32 NextEntryOffset;
1972 __le64 CreationTime;
1973 __le64 LastAccessTime;
1974 __le64 LastWriteTime;
1977 __le64 AllocationSize;
1978 __le32 ExtFileAttributes;
1979 __le32 FileNameLength;
1981 } __attribute__((packed)) FILE_DIRECTORY_INFO; /* level 0x101 FF response data area */
1984 __le32 NextEntryOffset;
1986 __le64 CreationTime;
1987 __le64 LastAccessTime;
1988 __le64 LastWriteTime;
1991 __le64 AllocationSize;
1992 __le32 ExtFileAttributes;
1993 __le32 FileNameLength;
1994 __le32 EaSize; /* length of the xattrs */
1996 } __attribute__((packed)) FILE_FULL_DIRECTORY_INFO; /* level 0x102 FF response data area */
1999 __le32 NextEntryOffset;
2001 __le64 CreationTime;
2002 __le64 LastAccessTime;
2003 __le64 LastWriteTime;
2006 __le64 AllocationSize;
2007 __le32 ExtFileAttributes;
2008 __le32 FileNameLength;
2009 __le32 EaSize; /* EA size */
2011 __u64 UniqueId; /* inode num - le since Samba puts ino in low 32 bit*/
2013 } __attribute__((packed)) SEARCH_ID_FULL_DIR_INFO; /* level 0x105 FF response data area */
2016 __le32 NextEntryOffset;
2018 __le64 CreationTime;
2019 __le64 LastAccessTime;
2020 __le64 LastWriteTime;
2023 __le64 AllocationSize;
2024 __le32 ExtFileAttributes;
2025 __le32 FileNameLength;
2026 __le32 EaSize; /* length of the xattrs */
2027 __u8 ShortNameLength;
2031 } __attribute__((packed)) FILE_BOTH_DIRECTORY_INFO; /* level 0x104 FF response data area */
2035 unsigned char type[8]; /* IntxCHR or IntxBLK */
2038 } __attribute__((packed));
2041 unsigned char name_len;
2043 } __attribute__((packed));
2046 unsigned long list_len;
2048 } __attribute__((packed));
2051 unsigned char EA_flags;
2055 /* optionally followed by value */
2056 } __attribute__((packed));
2057 /* flags for _FEA.fEA */
2058 #define FEA_NEEDEA 0x80 /* need EA bit */
2063 } __attribute__((packed));
2065 /* used to hold an arbitrary blob of data */
2069 void (*free) (struct data_blob * data_blob);
2070 } __attribute__((packed));
2073 #ifdef CONFIG_CIFS_POSIX
2075 For better POSIX semantics from Linux client, (even better
2076 than the existing CIFS Unix Extensions) we need updated PDUs for:
2078 1) PosixCreateX - to set and return the mode, inode#, device info and
2079 perhaps add a CreateDevice - to create Pipes and other special .inodes
2080 Also note POSIX open flags
2081 2) Close - to return the last write time to do cache across close more safely
2082 3) FindFirst return unique inode number - what about resume key, two
2083 forms short (matches readdir) and full (enough info to cache inodes)
2086 And under consideration:
2087 5) FindClose2 (return nanosecond timestamp ??)
2088 6) Use nanosecond timestamps throughout all time fields if
2089 corresponding attribute flag is set
2090 7) sendfile - handle based copy
2094 what about fixing 64 bit alignment
2096 There are also various legacy SMB/CIFS requests used as is
2098 From existing Lanman and NTLM dialects:
2099 --------------------------------------
2101 SESSION_SETUP_ANDX (BB which?)
2102 TREE_CONNECT_ANDX (BB which wct?)
2103 TREE_DISCONNECT (BB add volume timestamp on response)
2105 DELETE (note delete open file behavior)
2109 LOCKING_AND_X (note posix lock semantics)
2110 RENAME (note rename across dirs and open file rename posix behaviors)
2111 NT_RENAME (for hardlinks) Is this good enough for all features?
2113 TRANSACTION2 (18 cases)
2114 SMB_SET_FILE_END_OF_FILE_INFO2 SMB_SET_PATH_END_OF_FILE_INFO2
2115 (BB verify that never need to set allocation size)
2116 SMB_SET_FILE_BASIC_INFO2 (setting times - BB can it be done via Unix ext?)
2118 COPY (note support for copy across directories) - FUTURE, OPTIONAL
2119 setting/getting OS/2 EAs - FUTURE (BB can this handle
2120 setting Linux xattrs perfectly) - OPTIONAL
2121 dnotify - FUTURE, OPTIONAL
2122 quota - FUTURE, OPTIONAL
2124 Note that various requests implemented for NT interop such as
2125 NT_TRANSACT (IOCTL) QueryReparseInfo
2126 are unneeded to servers compliant with the CIFS POSIX extensions
2128 From CIFS Unix Extensions:
2129 -------------------------
2130 T2 SET_PATH_INFO (SMB_SET_FILE_UNIX_LINK) for symlinks
2131 T2 SET_PATH_INFO (SMB_SET_FILE_BASIC_INFO2)
2132 T2 QUERY_PATH_INFO (SMB_QUERY_FILE_UNIX_LINK)
2133 T2 QUERY_PATH_INFO (SMB_QUERY_FILE_UNIX_BASIC) - BB check for missing inode fields
2134 Actually need QUERY_FILE_UNIX_INFO since has inode num
2135 BB what about a) blksize/blkbits/blocks
2141 T2 FIND_FIRST/FIND_NEXT FIND_FILE_UNIX
2142 TRANS2_GET_DFS_REFERRAL - OPTIONAL but recommended
2143 T2_QFS_INFO QueryDevice/AttributeInfo - OPTIONAL
2148 /* xsymlink is a symlink format (used by MacOS) that can be used
2149 to save symlink info in a regular file when
2150 mounted to operating systems that do not
2151 support the cifs Unix extensions or EAs (for xattr
2152 based symlinks). For such a file to be recognized
2153 as containing symlink data:
2155 1) file size must be 1067,
2156 2) signature must begin file data,
2157 3) length field must be set to ASCII representation
2158 of a number which is less than or equal to 1024,
2159 4) md5 must match that of the path data */
2163 char signature[4]; /* XSym */ /* not null terminated */
2165 /* ASCII representation of length (4 bytes decimal) terminated by \n not null */
2168 /* md5 of valid subset of path ie path[0] through path[length-1] */
2171 /* if room left, then end with \n then 0x20s by convention but not required */
2173 } __attribute__((packed));
2175 typedef struct file_xattr_info {
2176 /* BB do we need another field for flags? BB */
2177 __u32 xattr_name_len;
2178 __u32 xattr_value_len;
2180 /* followed by xattr_value[xattr_value_len], no pad */
2181 } __attribute__((packed)) FILE_XATTR_INFO; /* extended attribute, info level 0x205 */
2184 /* flags for chattr command */
2185 #define EXT_SECURE_DELETE 0x00000001 /* EXT3_SECRM_FL */
2186 #define EXT_ENABLE_UNDELETE 0x00000002 /* EXT3_UNRM_FL */
2187 /* Reserved for compress file 0x4 */
2188 #define EXT_SYNCHRONOUS 0x00000008 /* EXT3_SYNC_FL */
2189 #define EXT_IMMUTABLE_FL 0x00000010 /* EXT3_IMMUTABLE_FL */
2190 #define EXT_OPEN_APPEND_ONLY 0x00000020 /* EXT3_APPEND_FL */
2191 #define EXT_DO_NOT_BACKUP 0x00000040 /* EXT3_NODUMP_FL */
2192 #define EXT_NO_UPDATE_ATIME 0x00000080 /* EXT3_NOATIME_FL */
2193 /* 0x100 through 0x800 reserved for compression flags and are GET-ONLY */
2194 #define EXT_HASH_TREE_INDEXED_DIR 0x00001000 /* GET-ONLY EXT3_INDEX_FL */
2195 /* 0x2000 reserved for IMAGIC_FL */
2196 #define EXT_JOURNAL_THIS_FILE 0x00004000 /* GET-ONLY EXT3_JOURNAL_DATA_FL */
2197 /* 0x8000 reserved for EXT3_NOTAIL_FL */
2198 #define EXT_SYNCHRONOUS_DIR 0x00010000 /* EXT3_DIRSYNC_FL */
2199 #define EXT_TOPDIR 0x00020000 /* EXT3_TOPDIR_FL */
2201 #define EXT_SET_MASK 0x000300FF
2202 #define EXT_GET_MASK 0x0003DFFF
2204 typedef struct file_chattr_info {
2205 __le64 mask; /* list of all possible attribute bits */
2206 __le64 mode; /* list of actual attribute bits on this inode */
2207 } __attribute__((packed)) FILE_CHATTR_INFO; /* ext attributes (chattr, chflags) level 0x206 */
2211 #endif /* _CIFSPDU_H */