Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * fs/cifs/cifspdu.h |
| 3 | * |
Steve French | bf82067 | 2005-12-01 22:32:42 -0800 | [diff] [blame] | 4 | * Copyright (c) International Business Machines Corp., 2002,2005 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | * Author(s): Steve French (sfrench@us.ibm.com) |
| 6 | * |
| 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. |
| 11 | * |
| 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. |
| 16 | * |
| 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 |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | */ |
| 21 | |
| 22 | #ifndef _CIFSPDU_H |
| 23 | #define _CIFSPDU_H |
| 24 | |
| 25 | #include <net/sock.h> |
| 26 | |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 27 | #ifdef CONFIG_CIFS_WEAK_PW_HASH |
| 28 | #define LANMAN_PROT 0 |
Steve French | 9ac00b7 | 2006-09-30 04:13:17 +0000 | [diff] [blame] | 29 | #define LANMAN2_PROT 1 |
| 30 | #define CIFS_PROT 2 |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 31 | #else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #define CIFS_PROT 0 |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 33 | #endif |
| 34 | #define POSIX_PROT CIFS_PROT+1 |
| 35 | #define BAD_PROT 0xFFFF |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | |
| 37 | /* SMB command codes */ |
| 38 | /* Some commands have minimal (wct=0,bcc=0), or uninteresting, responses |
| 39 | (ie which include no useful data other than the SMB error code itself). |
| 40 | Knowing this helps avoid response buffer allocations and copy in some cases */ |
| 41 | #define SMB_COM_CREATE_DIRECTORY 0x00 /* trivial response */ |
| 42 | #define SMB_COM_DELETE_DIRECTORY 0x01 /* trivial response */ |
| 43 | #define SMB_COM_CLOSE 0x04 /* triv req/rsp, timestamp ignored */ |
| 44 | #define SMB_COM_DELETE 0x06 /* trivial response */ |
| 45 | #define SMB_COM_RENAME 0x07 /* trivial response */ |
Steve French | 6b8edfe | 2005-08-23 20:26:03 -0700 | [diff] [blame] | 46 | #define SMB_COM_QUERY_INFORMATION 0x08 /* aka getattr */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | #define SMB_COM_SETATTR 0x09 /* trivial response */ |
| 48 | #define SMB_COM_LOCKING_ANDX 0x24 /* trivial response */ |
| 49 | #define SMB_COM_COPY 0x29 /* trivial rsp, fail filename ignrd*/ |
Steve French | a9d02ad | 2005-08-24 23:06:05 -0700 | [diff] [blame] | 50 | #define SMB_COM_OPEN_ANDX 0x2D /* Legacy open for old servers */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | #define SMB_COM_READ_ANDX 0x2E |
| 52 | #define SMB_COM_WRITE_ANDX 0x2F |
| 53 | #define SMB_COM_TRANSACTION2 0x32 |
| 54 | #define SMB_COM_TRANSACTION2_SECONDARY 0x33 |
| 55 | #define SMB_COM_FIND_CLOSE2 0x34 /* trivial response */ |
| 56 | #define SMB_COM_TREE_DISCONNECT 0x71 /* trivial response */ |
| 57 | #define SMB_COM_NEGOTIATE 0x72 |
| 58 | #define SMB_COM_SESSION_SETUP_ANDX 0x73 |
| 59 | #define SMB_COM_LOGOFF_ANDX 0x74 /* trivial response */ |
| 60 | #define SMB_COM_TREE_CONNECT_ANDX 0x75 |
| 61 | #define SMB_COM_NT_TRANSACT 0xA0 |
| 62 | #define SMB_COM_NT_TRANSACT_SECONDARY 0xA1 |
| 63 | #define SMB_COM_NT_CREATE_ANDX 0xA2 |
Steve French | ff5dbd9 | 2005-08-24 17:10:36 -0700 | [diff] [blame] | 64 | #define SMB_COM_NT_CANCEL 0xA4 /* no response */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | #define SMB_COM_NT_RENAME 0xA5 /* trivial response */ |
| 66 | |
| 67 | /* Transact2 subcommand codes */ |
| 68 | #define TRANS2_OPEN 0x00 |
| 69 | #define TRANS2_FIND_FIRST 0x01 |
| 70 | #define TRANS2_FIND_NEXT 0x02 |
| 71 | #define TRANS2_QUERY_FS_INFORMATION 0x03 |
Jeremy Allison | ac67055 | 2005-06-22 17:26:35 -0700 | [diff] [blame] | 72 | #define TRANS2_SET_FS_INFORMATION 0x04 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | #define TRANS2_QUERY_PATH_INFORMATION 0x05 |
| 74 | #define TRANS2_SET_PATH_INFORMATION 0x06 |
| 75 | #define TRANS2_QUERY_FILE_INFORMATION 0x07 |
| 76 | #define TRANS2_SET_FILE_INFORMATION 0x08 |
| 77 | #define TRANS2_GET_DFS_REFERRAL 0x10 |
| 78 | #define TRANS2_REPORT_DFS_INCOSISTENCY 0x11 |
| 79 | |
| 80 | /* NT Transact subcommand codes */ |
| 81 | #define NT_TRANSACT_CREATE 0x01 |
| 82 | #define NT_TRANSACT_IOCTL 0x02 |
| 83 | #define NT_TRANSACT_SET_SECURITY_DESC 0x03 |
| 84 | #define NT_TRANSACT_NOTIFY_CHANGE 0x04 |
| 85 | #define NT_TRANSACT_RENAME 0x05 |
| 86 | #define NT_TRANSACT_QUERY_SECURITY_DESC 0x06 |
| 87 | #define NT_TRANSACT_GET_USER_QUOTA 0x07 |
| 88 | #define NT_TRANSACT_SET_USER_QUOTA 0x08 |
| 89 | |
Steve French | ec637e3 | 2005-12-12 20:53:18 -0800 | [diff] [blame] | 90 | #define MAX_CIFS_SMALL_BUFFER_SIZE 448 /* big enough for most */ |
| 91 | /* future chained NTCreateXReadX bigger, but for time being NTCreateX biggest */ |
| 92 | /* among the requests (NTCreateX response is bigger with wct of 34) */ |
| 93 | #define MAX_CIFS_HDR_SIZE 0x58 /* 4 len + 32 hdr + (2*24 wct) + 2 bct + 2 pad */ |
| 94 | #define CIFS_SMALL_PATH 120 /* allows for (448-88)/3 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | |
| 96 | /* internal cifs vfs structures */ |
| 97 | /***************************************************************** |
| 98 | * All constants go here |
| 99 | ***************************************************************** |
| 100 | */ |
| 101 | |
| 102 | /* |
| 103 | * Starting value for maximum SMB size negotiation |
| 104 | */ |
| 105 | #define CIFS_MAX_MSGSIZE (4*4096) |
| 106 | |
| 107 | /* |
| 108 | * Size of encrypted user password in bytes |
| 109 | */ |
| 110 | #define CIFS_ENCPWD_SIZE (16) |
| 111 | |
| 112 | /* |
| 113 | * Size of the crypto key returned on the negotiate SMB in bytes |
| 114 | */ |
| 115 | #define CIFS_CRYPTO_KEY_SIZE (8) |
| 116 | |
| 117 | /* |
| 118 | * Size of the session key (crypto key encrypted with the password |
| 119 | */ |
Steve French | 7c7b25b | 2006-06-01 19:20:10 +0000 | [diff] [blame] | 120 | #define CIFS_SESS_KEY_SIZE (24) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | |
| 122 | /* |
| 123 | * Maximum user name length |
| 124 | */ |
| 125 | #define CIFS_UNLEN (20) |
| 126 | |
| 127 | /* |
| 128 | * Flags on SMB open |
| 129 | */ |
| 130 | #define SMBOPEN_WRITE_THROUGH 0x4000 |
| 131 | #define SMBOPEN_DENY_ALL 0x0010 |
| 132 | #define SMBOPEN_DENY_WRITE 0x0020 |
| 133 | #define SMBOPEN_DENY_READ 0x0030 |
| 134 | #define SMBOPEN_DENY_NONE 0x0040 |
| 135 | #define SMBOPEN_READ 0x0000 |
| 136 | #define SMBOPEN_WRITE 0x0001 |
| 137 | #define SMBOPEN_READWRITE 0x0002 |
| 138 | #define SMBOPEN_EXECUTE 0x0003 |
| 139 | |
| 140 | #define SMBOPEN_OCREATE 0x0010 |
| 141 | #define SMBOPEN_OTRUNC 0x0002 |
| 142 | #define SMBOPEN_OAPPEND 0x0001 |
| 143 | |
| 144 | /* |
| 145 | * SMB flag definitions |
| 146 | */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 147 | #define SMBFLG_EXTD_LOCK 0x01 /* server supports lock-read write-unlock smb */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | #define SMBFLG_RCV_POSTED 0x02 /* obsolete */ |
| 149 | #define SMBFLG_RSVD 0x04 |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 150 | #define SMBFLG_CASELESS 0x08 /* all pathnames treated as caseless (off |
| 151 | implies case sensitive file handling request) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | #define SMBFLG_CANONICAL_PATH_FORMAT 0x10 /* obsolete */ |
| 153 | #define SMBFLG_OLD_OPLOCK 0x20 /* obsolete */ |
| 154 | #define SMBFLG_OLD_OPLOCK_NOTIFY 0x40 /* obsolete */ |
| 155 | #define SMBFLG_RESPONSE 0x80 /* this PDU is a response from server */ |
| 156 | |
| 157 | /* |
| 158 | * SMB flag2 definitions |
| 159 | */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 160 | #define SMBFLG2_KNOWS_LONG_NAMES cpu_to_le16(1) /* can send long (non-8.3) |
| 161 | path names in response */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | #define SMBFLG2_KNOWS_EAS cpu_to_le16(2) |
| 163 | #define SMBFLG2_SECURITY_SIGNATURE cpu_to_le16(4) |
| 164 | #define SMBFLG2_IS_LONG_NAME cpu_to_le16(0x40) |
| 165 | #define SMBFLG2_EXT_SEC cpu_to_le16(0x800) |
| 166 | #define SMBFLG2_DFS cpu_to_le16(0x1000) |
| 167 | #define SMBFLG2_PAGING_IO cpu_to_le16(0x2000) |
| 168 | #define SMBFLG2_ERR_STATUS cpu_to_le16(0x4000) |
| 169 | #define SMBFLG2_UNICODE cpu_to_le16(0x8000) |
| 170 | |
| 171 | /* |
| 172 | * These are the file access permission bits defined in CIFS for the |
| 173 | * NTCreateAndX as well as the level 0x107 |
| 174 | * TRANS2_QUERY_PATH_INFORMATION API. The level 0x107, SMB_QUERY_FILE_ALL_INFO |
| 175 | * responds with the AccessFlags. |
| 176 | * The AccessFlags specifies the access permissions a caller has to the |
| 177 | * file and can have any suitable combination of the following values: |
| 178 | */ |
| 179 | |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 180 | #define FILE_READ_DATA 0x00000001 /* Data can be read from the file */ |
| 181 | #define FILE_WRITE_DATA 0x00000002 /* Data can be written to the file */ |
| 182 | #define FILE_APPEND_DATA 0x00000004 /* Data can be appended to the file */ |
| 183 | #define FILE_READ_EA 0x00000008 /* Extended attributes associated */ |
| 184 | /* with the file can be read */ |
| 185 | #define FILE_WRITE_EA 0x00000010 /* Extended attributes associated */ |
| 186 | /* with the file can be written */ |
| 187 | #define FILE_EXECUTE 0x00000020 /*Data can be read into memory from */ |
| 188 | /* the file using system paging I/O */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | #define FILE_DELETE_CHILD 0x00000040 |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 190 | #define FILE_READ_ATTRIBUTES 0x00000080 /* Attributes associated with the */ |
| 191 | /* file can be read */ |
| 192 | #define FILE_WRITE_ATTRIBUTES 0x00000100 /* Attributes associated with the */ |
| 193 | /* file can be written */ |
| 194 | #define DELETE 0x00010000 /* The file can be deleted */ |
| 195 | #define READ_CONTROL 0x00020000 /* The access control list and */ |
| 196 | /* ownership associated with the */ |
| 197 | /* file can be read */ |
| 198 | #define WRITE_DAC 0x00040000 /* The access control list and */ |
| 199 | /* ownership associated with the */ |
| 200 | /* file can be written. */ |
| 201 | #define WRITE_OWNER 0x00080000 /* Ownership information associated */ |
| 202 | /* with the file can be written */ |
| 203 | #define SYNCHRONIZE 0x00100000 /* The file handle can waited on to */ |
| 204 | /* synchronize with the completion */ |
| 205 | /* of an input/output request */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | #define GENERIC_ALL 0x10000000 |
| 207 | #define GENERIC_EXECUTE 0x20000000 |
| 208 | #define GENERIC_WRITE 0x40000000 |
| 209 | #define GENERIC_READ 0x80000000 |
| 210 | /* In summary - Relevant file */ |
| 211 | /* access flags from CIFS are */ |
| 212 | /* file_read_data, file_write_data */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 213 | /* file_execute, file_read_attributes*/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | /* write_dac, and delete. */ |
| 215 | |
| 216 | /* |
| 217 | * Invalid readdir handle |
| 218 | */ |
| 219 | #define CIFS_NO_HANDLE 0xFFFF |
| 220 | |
| 221 | /* IPC$ in ASCII */ |
| 222 | #define CIFS_IPC_RESOURCE "\x49\x50\x43\x24" |
| 223 | |
| 224 | /* IPC$ in Unicode */ |
| 225 | #define CIFS_IPC_UNICODE_RESOURCE "\x00\x49\x00\x50\x00\x43\x00\x24\x00\x00" |
| 226 | |
| 227 | /* Unicode Null terminate 2 bytes of 0 */ |
| 228 | #define UNICODE_NULL "\x00\x00" |
| 229 | #define ASCII_NULL 0x00 |
| 230 | |
| 231 | /* |
| 232 | * Server type values (returned on EnumServer API |
| 233 | */ |
| 234 | #define CIFS_SV_TYPE_DC 0x00000008 |
| 235 | #define CIFS_SV_TYPE_BACKDC 0x00000010 |
| 236 | |
| 237 | /* |
| 238 | * Alias type flags (From EnumAlias API call |
| 239 | */ |
| 240 | #define CIFS_ALIAS_TYPE_FILE 0x0001 |
| 241 | #define CIFS_SHARE_TYPE_FILE 0x0000 |
| 242 | |
| 243 | /* |
| 244 | * File Attribute flags |
| 245 | */ |
| 246 | #define ATTR_READONLY 0x0001 |
| 247 | #define ATTR_HIDDEN 0x0002 |
| 248 | #define ATTR_SYSTEM 0x0004 |
| 249 | #define ATTR_VOLUME 0x0008 |
| 250 | #define ATTR_DIRECTORY 0x0010 |
| 251 | #define ATTR_ARCHIVE 0x0020 |
| 252 | #define ATTR_DEVICE 0x0040 |
| 253 | #define ATTR_NORMAL 0x0080 |
| 254 | #define ATTR_TEMPORARY 0x0100 |
| 255 | #define ATTR_SPARSE 0x0200 |
| 256 | #define ATTR_REPARSE 0x0400 |
| 257 | #define ATTR_COMPRESSED 0x0800 |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 258 | #define ATTR_OFFLINE 0x1000 /* ie file not immediately available - |
| 259 | on offline storage */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | #define ATTR_NOT_CONTENT_INDEXED 0x2000 |
| 261 | #define ATTR_ENCRYPTED 0x4000 |
| 262 | #define ATTR_POSIX_SEMANTICS 0x01000000 |
| 263 | #define ATTR_BACKUP_SEMANTICS 0x02000000 |
| 264 | #define ATTR_DELETE_ON_CLOSE 0x04000000 |
| 265 | #define ATTR_SEQUENTIAL_SCAN 0x08000000 |
| 266 | #define ATTR_RANDOM_ACCESS 0x10000000 |
| 267 | #define ATTR_NO_BUFFERING 0x20000000 |
| 268 | #define ATTR_WRITE_THROUGH 0x80000000 |
| 269 | |
| 270 | /* ShareAccess flags */ |
| 271 | #define FILE_NO_SHARE 0x00000000 |
| 272 | #define FILE_SHARE_READ 0x00000001 |
| 273 | #define FILE_SHARE_WRITE 0x00000002 |
| 274 | #define FILE_SHARE_DELETE 0x00000004 |
| 275 | #define FILE_SHARE_ALL 0x00000007 |
| 276 | |
| 277 | /* CreateDisposition flags */ |
| 278 | #define FILE_SUPERSEDE 0x00000000 |
| 279 | #define FILE_OPEN 0x00000001 |
| 280 | #define FILE_CREATE 0x00000002 |
| 281 | #define FILE_OPEN_IF 0x00000003 |
| 282 | #define FILE_OVERWRITE 0x00000004 |
| 283 | #define FILE_OVERWRITE_IF 0x00000005 |
| 284 | |
| 285 | /* CreateOptions */ |
| 286 | #define CREATE_NOT_FILE 0x00000001 /* if set must not be file */ |
| 287 | #define CREATE_WRITE_THROUGH 0x00000002 |
Steve French | eda3c02 | 2005-07-21 15:20:28 -0700 | [diff] [blame] | 288 | #define CREATE_SEQUENTIAL 0x00000004 |
| 289 | #define CREATE_SYNC_ALERT 0x00000010 |
| 290 | #define CREATE_ASYNC_ALERT 0x00000020 |
| 291 | #define CREATE_NOT_DIR 0x00000040 /* if set must not be directory */ |
| 292 | #define CREATE_NO_EA_KNOWLEDGE 0x00000200 |
| 293 | #define CREATE_EIGHT_DOT_THREE 0x00000400 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | #define CREATE_RANDOM_ACCESS 0x00000800 |
| 295 | #define CREATE_DELETE_ON_CLOSE 0x00001000 |
Steve French | eda3c02 | 2005-07-21 15:20:28 -0700 | [diff] [blame] | 296 | #define CREATE_OPEN_BY_ID 0x00002000 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | #define OPEN_REPARSE_POINT 0x00200000 |
Steve French | eda3c02 | 2005-07-21 15:20:28 -0700 | [diff] [blame] | 298 | #define CREATE_OPTIONS_MASK 0x007FFFFF |
| 299 | #define CREATE_OPTION_SPECIAL 0x20000000 /* system. NB not sent over wire */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 300 | |
| 301 | /* ImpersonationLevel flags */ |
| 302 | #define SECURITY_ANONYMOUS 0 |
| 303 | #define SECURITY_IDENTIFICATION 1 |
| 304 | #define SECURITY_IMPERSONATION 2 |
| 305 | #define SECURITY_DELEGATION 3 |
| 306 | |
| 307 | /* SecurityFlags */ |
| 308 | #define SECURITY_CONTEXT_TRACKING 0x01 |
| 309 | #define SECURITY_EFFECTIVE_ONLY 0x02 |
| 310 | |
| 311 | /* |
| 312 | * Default PID value, used in all SMBs where the PID is not important |
| 313 | */ |
| 314 | #define CIFS_DFT_PID 0x1234 |
| 315 | |
| 316 | /* |
| 317 | * We use the same routine for Copy and Move SMBs. This flag is used to |
| 318 | * distinguish |
| 319 | */ |
| 320 | #define CIFS_COPY_OP 1 |
| 321 | #define CIFS_RENAME_OP 2 |
| 322 | |
| 323 | #define GETU16(var) (*((__u16 *)var)) /* BB check for endian issues */ |
| 324 | #define GETU32(var) (*((__u32 *)var)) /* BB check for endian issues */ |
| 325 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | struct smb_hdr { |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 327 | __u32 smb_buf_length; /* big endian on wire *//* BB length is only two |
| 328 | or three bytes - with one or two byte type preceding it that are |
| 329 | zero - we could mask the type byte off just in case BB */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | __u8 Protocol[4]; |
| 331 | __u8 Command; |
| 332 | union { |
| 333 | struct { |
| 334 | __u8 ErrorClass; |
| 335 | __u8 Reserved; |
| 336 | __le16 Error; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 337 | } __attribute__((packed)) DosError; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | __le32 CifsError; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 339 | } __attribute__((packed)) Status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | __u8 Flags; |
| 341 | __le16 Flags2; /* note: le */ |
| 342 | __le16 PidHigh; |
| 343 | union { |
| 344 | struct { |
| 345 | __le32 SequenceNumber; /* le */ |
| 346 | __u32 Reserved; /* zero */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 347 | } __attribute__((packed)) Sequence; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | __u8 SecuritySignature[8]; /* le */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 349 | } __attribute__((packed)) Signature; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | __u8 pad[2]; |
| 351 | __u16 Tid; |
| 352 | __le16 Pid; |
| 353 | __u16 Uid; |
| 354 | __u16 Mid; |
| 355 | __u8 WordCount; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 356 | } __attribute__((packed)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 357 | /* given a pointer to an smb_hdr retrieve the value of byte count */ |
| 358 | #define BCC(smb_var) ( *(__u16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2* smb_var->WordCount) ) ) |
Steve French | e4eb295 | 2005-04-28 22:41:09 -0700 | [diff] [blame] | 359 | #define BCC_LE(smb_var) ( *(__le16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2* smb_var->WordCount) ) ) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | /* given a pointer to an smb_hdr retrieve the pointer to the byte area */ |
| 361 | #define pByteArea(smb_var) ((unsigned char *)smb_var + sizeof(struct smb_hdr) + (2* smb_var->WordCount) + 2 ) |
| 362 | |
| 363 | /* |
| 364 | * Computer Name Length |
| 365 | */ |
| 366 | #define CNLEN 15 |
| 367 | |
| 368 | /* |
| 369 | * Share Name Length @S8A |
| 370 | * Note: This length is limited by the SMB used to get @S8A |
| 371 | * the Share info. NetShareEnum only returns 13 @S8A |
| 372 | * chars, including the null termination. @S8A |
| 373 | */ |
| 374 | #define SNLEN 12 /*@S8A */ |
| 375 | |
| 376 | /* |
| 377 | * Comment Length |
| 378 | */ |
| 379 | #define MAXCOMMENTLEN 40 |
| 380 | |
| 381 | /* |
| 382 | * The OS/2 maximum path name |
| 383 | */ |
| 384 | #define MAX_PATHCONF 256 |
| 385 | |
| 386 | /* |
| 387 | * SMB frame definitions (following must be packed structs) |
| 388 | * See the SNIA CIFS Specification for details. |
| 389 | * |
| 390 | * The Naming convention is the lower case version of the |
| 391 | * smb command code name for the struct and this is typedef to the |
| 392 | * uppercase version of the same name with the prefix SMB_ removed |
| 393 | * for brevity. Although typedefs are not commonly used for |
| 394 | * structure definitions in the Linux kernel, their use in the |
| 395 | * CIFS standards document, which this code is based on, may |
| 396 | * make this one of the cases where typedefs for structures make |
| 397 | * sense to improve readability for readers of the standards doc. |
| 398 | * Typedefs can always be removed later if they are too distracting |
| 399 | * and they are only used for the CIFSs PDUs themselves, not |
| 400 | * internal cifs vfs structures |
| 401 | * |
| 402 | */ |
| 403 | |
| 404 | typedef struct negotiate_req { |
| 405 | struct smb_hdr hdr; /* wct = 0 */ |
| 406 | __le16 ByteCount; |
| 407 | unsigned char DialectsArray[1]; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 408 | } __attribute__((packed)) NEGOTIATE_REQ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 409 | |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 410 | /* Dialect index is 13 for LANMAN */ |
| 411 | |
Steve French | b815f1e | 2006-10-02 05:53:29 +0000 | [diff] [blame] | 412 | #define MIN_TZ_ADJ (15 * 60) /* minimum grid for timezones in seconds */ |
| 413 | |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 414 | typedef struct lanman_neg_rsp { |
| 415 | struct smb_hdr hdr; /* wct = 13 */ |
| 416 | __le16 DialectIndex; |
| 417 | __le16 SecurityMode; |
| 418 | __le16 MaxBufSize; |
| 419 | __le16 MaxMpxCount; |
| 420 | __le16 MaxNumberVcs; |
| 421 | __le16 RawMode; |
| 422 | __le32 SessionKey; |
Steve French | 175ec9e | 2006-09-30 01:07:38 +0000 | [diff] [blame] | 423 | struct { |
| 424 | __le16 Time; |
| 425 | __le16 Date; |
| 426 | } __attribute__((packed)) SrvTime; |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 427 | __le16 ServerTimeZone; |
| 428 | __le16 EncryptionKeyLength; |
| 429 | __le16 Reserved; |
| 430 | __u16 ByteCount; |
| 431 | unsigned char EncryptionKey[1]; |
| 432 | } __attribute__((packed)) LANMAN_NEG_RSP; |
| 433 | |
Steve French | 254e55e | 2006-06-04 05:53:15 +0000 | [diff] [blame] | 434 | #define READ_RAW_ENABLE 1 |
| 435 | #define WRITE_RAW_ENABLE 2 |
| 436 | #define RAW_ENABLE (READ_RAW_ENABLE | WRITE_RAW_ENABLE) |
| 437 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 438 | typedef struct negotiate_rsp { |
| 439 | struct smb_hdr hdr; /* wct = 17 */ |
| 440 | __le16 DialectIndex; |
| 441 | __u8 SecurityMode; |
| 442 | __le16 MaxMpxCount; |
| 443 | __le16 MaxNumberVcs; |
| 444 | __le32 MaxBufferSize; |
| 445 | __le32 MaxRawSize; |
| 446 | __le32 SessionKey; |
| 447 | __le32 Capabilities; /* see below */ |
| 448 | __le32 SystemTimeLow; |
| 449 | __le32 SystemTimeHigh; |
| 450 | __le16 ServerTimeZone; |
| 451 | __u8 EncryptionKeyLength; |
| 452 | __u16 ByteCount; |
| 453 | union { |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 454 | unsigned char EncryptionKey[1]; /* cap extended security off */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | /* followed by Domain name - if extended security is off */ |
| 456 | /* followed by 16 bytes of server GUID */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 457 | /* then security blob if cap_extended_security negotiated */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 458 | struct { |
| 459 | unsigned char GUID[16]; |
| 460 | unsigned char SecurityBlob[1]; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 461 | } __attribute__((packed)) extended_response; |
| 462 | } __attribute__((packed)) u; |
| 463 | } __attribute__((packed)) NEGOTIATE_RSP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 464 | |
| 465 | /* SecurityMode bits */ |
| 466 | #define SECMODE_USER 0x01 /* off indicates share level security */ |
| 467 | #define SECMODE_PW_ENCRYPT 0x02 |
| 468 | #define SECMODE_SIGN_ENABLED 0x04 /* SMB security signatures enabled */ |
| 469 | #define SECMODE_SIGN_REQUIRED 0x08 /* SMB security signatures required */ |
| 470 | |
| 471 | /* Negotiate response Capabilities */ |
| 472 | #define CAP_RAW_MODE 0x00000001 |
| 473 | #define CAP_MPX_MODE 0x00000002 |
| 474 | #define CAP_UNICODE 0x00000004 |
| 475 | #define CAP_LARGE_FILES 0x00000008 |
| 476 | #define CAP_NT_SMBS 0x00000010 /* implies CAP_NT_FIND */ |
| 477 | #define CAP_RPC_REMOTE_APIS 0x00000020 |
| 478 | #define CAP_STATUS32 0x00000040 |
| 479 | #define CAP_LEVEL_II_OPLOCKS 0x00000080 |
| 480 | #define CAP_LOCK_AND_READ 0x00000100 |
| 481 | #define CAP_NT_FIND 0x00000200 |
| 482 | #define CAP_DFS 0x00001000 |
| 483 | #define CAP_INFOLEVEL_PASSTHRU 0x00002000 |
| 484 | #define CAP_LARGE_READ_X 0x00004000 |
| 485 | #define CAP_LARGE_WRITE_X 0x00008000 |
| 486 | #define CAP_UNIX 0x00800000 |
| 487 | #define CAP_RESERVED 0x02000000 |
| 488 | #define CAP_BULK_TRANSFER 0x20000000 |
| 489 | #define CAP_COMPRESSED_DATA 0x40000000 |
| 490 | #define CAP_EXTENDED_SECURITY 0x80000000 |
| 491 | |
| 492 | typedef union smb_com_session_setup_andx { |
| 493 | struct { /* request format */ |
| 494 | struct smb_hdr hdr; /* wct = 12 */ |
| 495 | __u8 AndXCommand; |
| 496 | __u8 AndXReserved; |
| 497 | __le16 AndXOffset; |
| 498 | __le16 MaxBufferSize; |
| 499 | __le16 MaxMpxCount; |
| 500 | __le16 VcNumber; |
| 501 | __u32 SessionKey; |
| 502 | __le16 SecurityBlobLength; |
| 503 | __u32 Reserved; |
| 504 | __le32 Capabilities; /* see below */ |
| 505 | __le16 ByteCount; |
| 506 | unsigned char SecurityBlob[1]; /* followed by */ |
| 507 | /* STRING NativeOS */ |
| 508 | /* STRING NativeLanMan */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 509 | } __attribute__((packed)) req; /* NTLM request format (with |
| 510 | extended security */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | |
| 512 | struct { /* request format */ |
| 513 | struct smb_hdr hdr; /* wct = 13 */ |
| 514 | __u8 AndXCommand; |
| 515 | __u8 AndXReserved; |
| 516 | __le16 AndXOffset; |
| 517 | __le16 MaxBufferSize; |
| 518 | __le16 MaxMpxCount; |
| 519 | __le16 VcNumber; |
| 520 | __u32 SessionKey; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 521 | __le16 CaseInsensitivePasswordLength; /* ASCII password len */ |
| 522 | __le16 CaseSensitivePasswordLength; /* Unicode password length*/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 523 | __u32 Reserved; /* see below */ |
| 524 | __le32 Capabilities; |
| 525 | __le16 ByteCount; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 526 | unsigned char CaseInsensitivePassword[1]; /* followed by: */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 527 | /* unsigned char * CaseSensitivePassword; */ |
| 528 | /* STRING AccountName */ |
| 529 | /* STRING PrimaryDomain */ |
| 530 | /* STRING NativeOS */ |
| 531 | /* STRING NativeLanMan */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 532 | } __attribute__((packed)) req_no_secext; /* NTLM request format (without |
| 533 | extended security */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 534 | |
| 535 | struct { /* default (NTLM) response format */ |
| 536 | struct smb_hdr hdr; /* wct = 4 */ |
| 537 | __u8 AndXCommand; |
| 538 | __u8 AndXReserved; |
| 539 | __le16 AndXOffset; |
| 540 | __le16 Action; /* see below */ |
| 541 | __le16 SecurityBlobLength; |
| 542 | __u16 ByteCount; |
| 543 | unsigned char SecurityBlob[1]; /* followed by */ |
| 544 | /* unsigned char * NativeOS; */ |
| 545 | /* unsigned char * NativeLanMan; */ |
| 546 | /* unsigned char * PrimaryDomain; */ |
Steve French | f64b23a | 2006-06-05 05:27:37 +0000 | [diff] [blame] | 547 | } __attribute__((packed)) resp; /* NTLM response with or without extended sec*/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 548 | |
| 549 | struct { /* request format */ |
| 550 | struct smb_hdr hdr; /* wct = 10 */ |
| 551 | __u8 AndXCommand; |
| 552 | __u8 AndXReserved; |
| 553 | __le16 AndXOffset; |
| 554 | __le16 MaxBufferSize; |
| 555 | __le16 MaxMpxCount; |
| 556 | __le16 VcNumber; |
| 557 | __u32 SessionKey; |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 558 | __le16 PasswordLength; |
| 559 | __u32 Reserved; /* encrypt key len and offset */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 560 | __le16 ByteCount; |
| 561 | unsigned char AccountPassword[1]; /* followed by */ |
| 562 | /* STRING AccountName */ |
| 563 | /* STRING PrimaryDomain */ |
| 564 | /* STRING NativeOS */ |
| 565 | /* STRING NativeLanMan */ |
Steve French | 0a4b92c | 2006-01-12 15:44:21 -0800 | [diff] [blame] | 566 | } __attribute__((packed)) old_req; /* pre-NTLM (LANMAN2.1) req format */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 567 | |
| 568 | struct { /* default (NTLM) response format */ |
| 569 | struct smb_hdr hdr; /* wct = 3 */ |
| 570 | __u8 AndXCommand; |
| 571 | __u8 AndXReserved; |
| 572 | __le16 AndXOffset; |
| 573 | __le16 Action; /* see below */ |
| 574 | __u16 ByteCount; |
| 575 | unsigned char NativeOS[1]; /* followed by */ |
| 576 | /* unsigned char * NativeLanMan; */ |
| 577 | /* unsigned char * PrimaryDomain; */ |
Steve French | 0a4b92c | 2006-01-12 15:44:21 -0800 | [diff] [blame] | 578 | } __attribute__((packed)) old_resp; /* pre-NTLM (LANMAN2.1) response */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 579 | } __attribute__((packed)) SESSION_SETUP_ANDX; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 580 | |
Steve French | f64b23a | 2006-06-05 05:27:37 +0000 | [diff] [blame] | 581 | /* format of NLTMv2 Response ie "case sensitive password" hash when NTLMv2 */ |
| 582 | |
Steve French | 33ec32f | 2006-12-08 04:14:28 +0000 | [diff] [blame] | 583 | #define NTLMSSP_SERVER_TYPE 1 |
| 584 | #define NTLMSSP_DOMAIN_TYPE 2 |
| 585 | #define NTLMSSP_FQ_DOMAIN_TYPE 3 |
| 586 | #define NTLMSSP_DNS_DOMAIN_TYPE 4 |
| 587 | #define NTLMSSP_DNS_PARENT_TYPE 5 |
| 588 | |
Steve French | f64b23a | 2006-06-05 05:27:37 +0000 | [diff] [blame] | 589 | struct ntlmssp2_name { |
| 590 | __le16 type; |
| 591 | __le16 length; |
| 592 | /* char name[length]; */ |
| 593 | } __attribute__((packed)); |
| 594 | |
| 595 | struct ntlmv2_resp { |
| 596 | char ntlmv2_hash[CIFS_ENCPWD_SIZE]; |
Steve French | 6d027cf | 2006-06-05 16:26:05 +0000 | [diff] [blame] | 597 | __le32 blob_signature; |
Steve French | f64b23a | 2006-06-05 05:27:37 +0000 | [diff] [blame] | 598 | __u32 reserved; |
| 599 | __le64 time; |
| 600 | __u64 client_chal; /* random */ |
| 601 | __u32 reserved2; |
Steve French | 33ec32f | 2006-12-08 04:14:28 +0000 | [diff] [blame] | 602 | struct ntlmssp2_name names[2]; |
Steve French | f64b23a | 2006-06-05 05:27:37 +0000 | [diff] [blame] | 603 | /* array of name entries could follow ending in minimum 4 byte struct */ |
| 604 | } __attribute__((packed)); |
| 605 | |
| 606 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 607 | #define CIFS_NETWORK_OPSYS "CIFS VFS Client for Linux" |
| 608 | |
| 609 | /* Capabilities bits (for NTLM SessSetup request) */ |
| 610 | #define CAP_UNICODE 0x00000004 |
| 611 | #define CAP_LARGE_FILES 0x00000008 |
| 612 | #define CAP_NT_SMBS 0x00000010 |
| 613 | #define CAP_STATUS32 0x00000040 |
| 614 | #define CAP_LEVEL_II_OPLOCKS 0x00000080 |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 615 | #define CAP_NT_FIND 0x00000200 /* reserved should be zero |
| 616 | (because NT_SMBs implies the same thing?) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 617 | #define CAP_BULK_TRANSFER 0x20000000 |
| 618 | #define CAP_EXTENDED_SECURITY 0x80000000 |
| 619 | |
| 620 | /* Action bits */ |
| 621 | #define GUEST_LOGIN 1 |
| 622 | |
| 623 | typedef struct smb_com_tconx_req { |
| 624 | struct smb_hdr hdr; /* wct = 4 */ |
| 625 | __u8 AndXCommand; |
| 626 | __u8 AndXReserved; |
| 627 | __le16 AndXOffset; |
| 628 | __le16 Flags; /* see below */ |
| 629 | __le16 PasswordLength; |
| 630 | __le16 ByteCount; |
| 631 | unsigned char Password[1]; /* followed by */ |
| 632 | /* STRING Path *//* \\server\share name */ |
| 633 | /* STRING Service */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 634 | } __attribute__((packed)) TCONX_REQ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 635 | |
| 636 | typedef struct smb_com_tconx_rsp { |
Steve French | f64b23a | 2006-06-05 05:27:37 +0000 | [diff] [blame] | 637 | struct smb_hdr hdr; /* wct = 3 note that Win2000 has sent wct = 7 |
| 638 | in some cases on responses. Four unspecified |
| 639 | words followed OptionalSupport */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 640 | __u8 AndXCommand; |
| 641 | __u8 AndXReserved; |
| 642 | __le16 AndXOffset; |
| 643 | __le16 OptionalSupport; /* see below */ |
| 644 | __u16 ByteCount; |
| 645 | unsigned char Service[1]; /* always ASCII, not Unicode */ |
| 646 | /* STRING NativeFileSystem */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 647 | } __attribute__((packed)) TCONX_RSP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 648 | |
| 649 | /* tree connect Flags */ |
| 650 | #define DISCONNECT_TID 0x0001 |
| 651 | #define TCON_EXTENDED_SECINFO 0x0008 |
| 652 | /* OptionalSupport bits */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 653 | #define SMB_SUPPORT_SEARCH_BITS 0x0001 /* "must have" directory search bits |
| 654 | (exclusive searches supported) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 655 | #define SMB_SHARE_IS_IN_DFS 0x0002 |
| 656 | |
| 657 | typedef struct smb_com_logoff_andx_req { |
| 658 | struct smb_hdr hdr; /* wct = 2 */ |
| 659 | __u8 AndXCommand; |
| 660 | __u8 AndXReserved; |
| 661 | __u16 AndXOffset; |
| 662 | __u16 ByteCount; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 663 | } __attribute__((packed)) LOGOFF_ANDX_REQ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 664 | |
| 665 | typedef struct smb_com_logoff_andx_rsp { |
| 666 | struct smb_hdr hdr; /* wct = 2 */ |
| 667 | __u8 AndXCommand; |
| 668 | __u8 AndXReserved; |
| 669 | __u16 AndXOffset; |
| 670 | __u16 ByteCount; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 671 | } __attribute__((packed)) LOGOFF_ANDX_RSP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 672 | |
Steve French | 86c96b4 | 2005-11-18 20:25:31 -0800 | [diff] [blame] | 673 | typedef union smb_com_tree_disconnect { /* as an altetnative can use flag on |
| 674 | tree_connect PDU to effect disconnect */ |
| 675 | /* tdis is probably simplest SMB PDU */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 676 | struct { |
| 677 | struct smb_hdr hdr; /* wct = 0 */ |
| 678 | __u16 ByteCount; /* bcc = 0 */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 679 | } __attribute__((packed)) req; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 680 | struct { |
| 681 | struct smb_hdr hdr; /* wct = 0 */ |
| 682 | __u16 ByteCount; /* bcc = 0 */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 683 | } __attribute__((packed)) resp; |
| 684 | } __attribute__((packed)) TREE_DISCONNECT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 685 | |
| 686 | typedef struct smb_com_close_req { |
| 687 | struct smb_hdr hdr; /* wct = 3 */ |
| 688 | __u16 FileID; |
Steve French | b815f1e | 2006-10-02 05:53:29 +0000 | [diff] [blame] | 689 | __u32 LastWriteTime; /* should be zero or -1 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 690 | __u16 ByteCount; /* 0 */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 691 | } __attribute__((packed)) CLOSE_REQ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 692 | |
| 693 | typedef struct smb_com_close_rsp { |
| 694 | struct smb_hdr hdr; /* wct = 0 */ |
| 695 | __u16 ByteCount; /* bct = 0 */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 696 | } __attribute__((packed)) CLOSE_RSP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 697 | |
| 698 | typedef struct smb_com_findclose_req { |
| 699 | struct smb_hdr hdr; /* wct = 1 */ |
| 700 | __u16 FileID; |
| 701 | __u16 ByteCount; /* 0 */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 702 | } __attribute__((packed)) FINDCLOSE_REQ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 703 | |
| 704 | /* OpenFlags */ |
Steve French | a9d02ad | 2005-08-24 23:06:05 -0700 | [diff] [blame] | 705 | #define REQ_MORE_INFO 0x00000001 /* legacy (OPEN_AND_X) only */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 706 | #define REQ_OPLOCK 0x00000002 |
| 707 | #define REQ_BATCHOPLOCK 0x00000004 |
| 708 | #define REQ_OPENDIRONLY 0x00000008 |
| 709 | |
| 710 | typedef struct smb_com_open_req { /* also handles create */ |
| 711 | struct smb_hdr hdr; /* wct = 24 */ |
| 712 | __u8 AndXCommand; |
| 713 | __u8 AndXReserved; |
| 714 | __le16 AndXOffset; |
| 715 | __u8 Reserved; /* Must Be Zero */ |
| 716 | __le16 NameLength; |
| 717 | __le32 OpenFlags; |
| 718 | __le32 RootDirectoryFid; |
| 719 | __le32 DesiredAccess; |
| 720 | __le64 AllocationSize; |
| 721 | __le32 FileAttributes; |
| 722 | __le32 ShareAccess; |
| 723 | __le32 CreateDisposition; |
| 724 | __le32 CreateOptions; |
| 725 | __le32 ImpersonationLevel; |
| 726 | __u8 SecurityFlags; |
| 727 | __le16 ByteCount; |
| 728 | char fileName[1]; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 729 | } __attribute__((packed)) OPEN_REQ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 730 | |
| 731 | /* open response: oplock levels */ |
| 732 | #define OPLOCK_NONE 0 |
| 733 | #define OPLOCK_EXCLUSIVE 1 |
| 734 | #define OPLOCK_BATCH 2 |
| 735 | #define OPLOCK_READ 3 /* level 2 oplock */ |
| 736 | |
| 737 | /* open response for CreateAction shifted left */ |
| 738 | #define CIFS_CREATE_ACTION 0x20000 /* file created */ |
| 739 | |
| 740 | typedef struct smb_com_open_rsp { |
| 741 | struct smb_hdr hdr; /* wct = 34 BB */ |
| 742 | __u8 AndXCommand; |
| 743 | __u8 AndXReserved; |
| 744 | __le16 AndXOffset; |
| 745 | __u8 OplockLevel; |
| 746 | __u16 Fid; |
| 747 | __le32 CreateAction; |
| 748 | __le64 CreationTime; |
| 749 | __le64 LastAccessTime; |
| 750 | __le64 LastWriteTime; |
| 751 | __le64 ChangeTime; |
| 752 | __le32 FileAttributes; |
| 753 | __le64 AllocationSize; |
| 754 | __le64 EndOfFile; |
| 755 | __le16 FileType; |
| 756 | __le16 DeviceState; |
| 757 | __u8 DirectoryFlag; |
| 758 | __u16 ByteCount; /* bct = 0 */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 759 | } __attribute__((packed)) OPEN_RSP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 760 | |
Steve French | a9d02ad | 2005-08-24 23:06:05 -0700 | [diff] [blame] | 761 | /* format of legacy open request */ |
| 762 | typedef struct smb_com_openx_req { |
| 763 | struct smb_hdr hdr; /* wct = 15 */ |
| 764 | __u8 AndXCommand; |
| 765 | __u8 AndXReserved; |
| 766 | __le16 AndXOffset; |
| 767 | __le16 OpenFlags; |
| 768 | __le16 Mode; |
| 769 | __le16 Sattr; /* search attributes */ |
| 770 | __le16 FileAttributes; /* dos attrs */ |
| 771 | __le32 CreateTime; /* os2 format */ |
| 772 | __le16 OpenFunction; |
| 773 | __le32 EndOfFile; |
| 774 | __le32 Timeout; |
| 775 | __le32 Reserved; |
Steve French | 70ca734 | 2005-09-22 16:32:06 -0700 | [diff] [blame] | 776 | __le16 ByteCount; /* file name follows */ |
Steve French | a9d02ad | 2005-08-24 23:06:05 -0700 | [diff] [blame] | 777 | char fileName[1]; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 778 | } __attribute__((packed)) OPENX_REQ; |
Steve French | a9d02ad | 2005-08-24 23:06:05 -0700 | [diff] [blame] | 779 | |
| 780 | typedef struct smb_com_openx_rsp { |
| 781 | struct smb_hdr hdr; /* wct = 15 */ |
| 782 | __u8 AndXCommand; |
| 783 | __u8 AndXReserved; |
| 784 | __le16 AndXOffset; |
| 785 | __u16 Fid; |
| 786 | __le16 FileAttributes; |
| 787 | __le32 LastWriteTime; /* os2 format */ |
| 788 | __le32 EndOfFile; |
| 789 | __le16 Access; |
| 790 | __le16 FileType; |
| 791 | __le16 IPCState; |
| 792 | __le16 Action; |
| 793 | __u32 FileId; |
| 794 | __u16 Reserved; |
| 795 | __u16 ByteCount; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 796 | } __attribute__((packed)) OPENX_RSP; |
Steve French | a9d02ad | 2005-08-24 23:06:05 -0700 | [diff] [blame] | 797 | |
| 798 | /* Legacy write request for older servers */ |
| 799 | typedef struct smb_com_writex_req { |
| 800 | struct smb_hdr hdr; /* wct = 12 */ |
| 801 | __u8 AndXCommand; |
| 802 | __u8 AndXReserved; |
| 803 | __le16 AndXOffset; |
| 804 | __u16 Fid; |
| 805 | __le32 OffsetLow; |
| 806 | __u32 Reserved; /* Timeout */ |
| 807 | __le16 WriteMode; /* 1 = write through */ |
| 808 | __le16 Remaining; |
| 809 | __le16 Reserved2; |
| 810 | __le16 DataLengthLow; |
| 811 | __le16 DataOffset; |
| 812 | __le16 ByteCount; |
| 813 | __u8 Pad; /* BB check for whether padded to DWORD boundary and optimum performance here */ |
| 814 | char Data[0]; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 815 | } __attribute__((packed)) WRITEX_REQ; |
Steve French | a9d02ad | 2005-08-24 23:06:05 -0700 | [diff] [blame] | 816 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 817 | typedef struct smb_com_write_req { |
| 818 | struct smb_hdr hdr; /* wct = 14 */ |
| 819 | __u8 AndXCommand; |
| 820 | __u8 AndXReserved; |
| 821 | __le16 AndXOffset; |
| 822 | __u16 Fid; |
| 823 | __le32 OffsetLow; |
| 824 | __u32 Reserved; |
| 825 | __le16 WriteMode; |
| 826 | __le16 Remaining; |
| 827 | __le16 DataLengthHigh; |
| 828 | __le16 DataLengthLow; |
| 829 | __le16 DataOffset; |
| 830 | __le32 OffsetHigh; |
| 831 | __le16 ByteCount; |
| 832 | __u8 Pad; /* BB check for whether padded to DWORD boundary and optimum performance here */ |
| 833 | char Data[0]; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 834 | } __attribute__((packed)) WRITE_REQ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 835 | |
| 836 | typedef struct smb_com_write_rsp { |
| 837 | struct smb_hdr hdr; /* wct = 6 */ |
| 838 | __u8 AndXCommand; |
| 839 | __u8 AndXReserved; |
| 840 | __le16 AndXOffset; |
| 841 | __le16 Count; |
| 842 | __le16 Remaining; |
| 843 | __le16 CountHigh; |
| 844 | __u16 Reserved; |
| 845 | __u16 ByteCount; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 846 | } __attribute__((packed)) WRITE_RSP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 847 | |
Steve French | a9d02ad | 2005-08-24 23:06:05 -0700 | [diff] [blame] | 848 | /* legacy read request for older servers */ |
| 849 | typedef struct smb_com_readx_req { |
| 850 | struct smb_hdr hdr; /* wct = 10 */ |
| 851 | __u8 AndXCommand; |
| 852 | __u8 AndXReserved; |
| 853 | __le16 AndXOffset; |
| 854 | __u16 Fid; |
| 855 | __le32 OffsetLow; |
| 856 | __le16 MaxCount; |
| 857 | __le16 MinCount; /* obsolete */ |
| 858 | __le32 Reserved; |
| 859 | __le16 Remaining; |
| 860 | __le16 ByteCount; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 861 | } __attribute__((packed)) READX_REQ; |
Steve French | a9d02ad | 2005-08-24 23:06:05 -0700 | [diff] [blame] | 862 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 863 | typedef struct smb_com_read_req { |
| 864 | struct smb_hdr hdr; /* wct = 12 */ |
| 865 | __u8 AndXCommand; |
| 866 | __u8 AndXReserved; |
| 867 | __le16 AndXOffset; |
| 868 | __u16 Fid; |
| 869 | __le32 OffsetLow; |
| 870 | __le16 MaxCount; |
| 871 | __le16 MinCount; /* obsolete */ |
| 872 | __le32 MaxCountHigh; |
| 873 | __le16 Remaining; |
| 874 | __le32 OffsetHigh; |
| 875 | __le16 ByteCount; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 876 | } __attribute__((packed)) READ_REQ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 877 | |
| 878 | typedef struct smb_com_read_rsp { |
| 879 | struct smb_hdr hdr; /* wct = 12 */ |
| 880 | __u8 AndXCommand; |
| 881 | __u8 AndXReserved; |
| 882 | __le16 AndXOffset; |
| 883 | __le16 Remaining; |
| 884 | __le16 DataCompactionMode; |
| 885 | __le16 Reserved; |
| 886 | __le16 DataLength; |
| 887 | __le16 DataOffset; |
| 888 | __le16 DataLengthHigh; |
| 889 | __u64 Reserved2; |
| 890 | __u16 ByteCount; |
| 891 | __u8 Pad; /* BB check for whether padded to DWORD boundary and optimum performance here */ |
| 892 | char Data[1]; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 893 | } __attribute__((packed)) READ_RSP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 894 | |
| 895 | typedef struct locking_andx_range { |
| 896 | __le16 Pid; |
| 897 | __le16 Pad; |
| 898 | __le32 OffsetHigh; |
| 899 | __le32 OffsetLow; |
| 900 | __le32 LengthHigh; |
| 901 | __le32 LengthLow; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 902 | } __attribute__((packed)) LOCKING_ANDX_RANGE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 903 | |
| 904 | #define LOCKING_ANDX_SHARED_LOCK 0x01 |
| 905 | #define LOCKING_ANDX_OPLOCK_RELEASE 0x02 |
| 906 | #define LOCKING_ANDX_CHANGE_LOCKTYPE 0x04 |
| 907 | #define LOCKING_ANDX_CANCEL_LOCK 0x08 |
| 908 | #define LOCKING_ANDX_LARGE_FILES 0x10 /* always on for us */ |
| 909 | |
| 910 | typedef struct smb_com_lock_req { |
| 911 | struct smb_hdr hdr; /* wct = 8 */ |
| 912 | __u8 AndXCommand; |
| 913 | __u8 AndXReserved; |
| 914 | __le16 AndXOffset; |
| 915 | __u16 Fid; |
| 916 | __u8 LockType; |
| 917 | __u8 OplockLevel; |
| 918 | __le32 Timeout; |
| 919 | __le16 NumberOfUnlocks; |
| 920 | __le16 NumberOfLocks; |
| 921 | __le16 ByteCount; |
| 922 | LOCKING_ANDX_RANGE Locks[1]; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 923 | } __attribute__((packed)) LOCK_REQ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 924 | |
Steve French | 08547b0 | 2006-02-28 22:39:25 +0000 | [diff] [blame] | 925 | /* lock type */ |
| 926 | #define CIFS_RDLCK 0 |
| 927 | #define CIFS_WRLCK 1 |
| 928 | #define CIFS_UNLCK 2 |
Steve French | f654bac | 2005-04-28 22:41:04 -0700 | [diff] [blame] | 929 | typedef struct cifs_posix_lock { |
| 930 | __le16 lock_type; /* 0 = Read, 1 = Write, 2 = Unlock */ |
| 931 | __le16 lock_flags; /* 1 = Wait (only valid for setlock) */ |
| 932 | __le32 pid; |
| 933 | __le64 start; |
| 934 | __le64 length; |
| 935 | /* BB what about additional owner info to identify network client */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 936 | } __attribute__((packed)) CIFS_POSIX_LOCK; |
Steve French | f654bac | 2005-04-28 22:41:04 -0700 | [diff] [blame] | 937 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 938 | typedef struct smb_com_lock_rsp { |
| 939 | struct smb_hdr hdr; /* wct = 2 */ |
| 940 | __u8 AndXCommand; |
| 941 | __u8 AndXReserved; |
| 942 | __le16 AndXOffset; |
| 943 | __u16 ByteCount; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 944 | } __attribute__((packed)) LOCK_RSP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 945 | |
| 946 | typedef struct smb_com_rename_req { |
| 947 | struct smb_hdr hdr; /* wct = 1 */ |
| 948 | __le16 SearchAttributes; /* target file attributes */ |
| 949 | __le16 ByteCount; |
| 950 | __u8 BufferFormat; /* 4 = ASCII or Unicode */ |
| 951 | unsigned char OldFileName[1]; |
| 952 | /* followed by __u8 BufferFormat2 */ |
| 953 | /* followed by NewFileName */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 954 | } __attribute__((packed)) RENAME_REQ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 955 | |
| 956 | /* copy request flags */ |
| 957 | #define COPY_MUST_BE_FILE 0x0001 |
| 958 | #define COPY_MUST_BE_DIR 0x0002 |
| 959 | #define COPY_TARGET_MODE_ASCII 0x0004 /* if not set, binary */ |
| 960 | #define COPY_SOURCE_MODE_ASCII 0x0008 /* if not set, binary */ |
| 961 | #define COPY_VERIFY_WRITES 0x0010 |
| 962 | #define COPY_TREE 0x0020 |
| 963 | |
| 964 | typedef struct smb_com_copy_req { |
| 965 | struct smb_hdr hdr; /* wct = 3 */ |
| 966 | __u16 Tid2; |
| 967 | __le16 OpenFunction; |
| 968 | __le16 Flags; |
| 969 | __le16 ByteCount; |
| 970 | __u8 BufferFormat; /* 4 = ASCII or Unicode */ |
| 971 | unsigned char OldFileName[1]; |
| 972 | /* followed by __u8 BufferFormat2 */ |
| 973 | /* followed by NewFileName string */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 974 | } __attribute__((packed)) COPY_REQ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 975 | |
| 976 | typedef struct smb_com_copy_rsp { |
| 977 | struct smb_hdr hdr; /* wct = 1 */ |
| 978 | __le16 CopyCount; /* number of files copied */ |
| 979 | __u16 ByteCount; /* may be zero */ |
| 980 | __u8 BufferFormat; /* 0x04 - only present if errored file follows */ |
| 981 | unsigned char ErrorFileName[1]; /* only present if error in copy */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 982 | } __attribute__((packed)) COPY_RSP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 983 | |
| 984 | #define CREATE_HARD_LINK 0x103 |
| 985 | #define MOVEFILE_COPY_ALLOWED 0x0002 |
| 986 | #define MOVEFILE_REPLACE_EXISTING 0x0001 |
| 987 | |
| 988 | typedef struct smb_com_nt_rename_req { /* A5 - also used for create hardlink */ |
| 989 | struct smb_hdr hdr; /* wct = 4 */ |
| 990 | __le16 SearchAttributes; /* target file attributes */ |
| 991 | __le16 Flags; /* spec says Information Level */ |
| 992 | __le32 ClusterCount; |
| 993 | __le16 ByteCount; |
| 994 | __u8 BufferFormat; /* 4 = ASCII or Unicode */ |
| 995 | unsigned char OldFileName[1]; |
| 996 | /* followed by __u8 BufferFormat2 */ |
| 997 | /* followed by NewFileName */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 998 | } __attribute__((packed)) NT_RENAME_REQ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 999 | |
| 1000 | typedef struct smb_com_rename_rsp { |
| 1001 | struct smb_hdr hdr; /* wct = 0 */ |
| 1002 | __u16 ByteCount; /* bct = 0 */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1003 | } __attribute__((packed)) RENAME_RSP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1004 | |
| 1005 | typedef struct smb_com_delete_file_req { |
| 1006 | struct smb_hdr hdr; /* wct = 1 */ |
| 1007 | __le16 SearchAttributes; |
| 1008 | __le16 ByteCount; |
| 1009 | __u8 BufferFormat; /* 4 = ASCII */ |
| 1010 | unsigned char fileName[1]; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1011 | } __attribute__((packed)) DELETE_FILE_REQ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1012 | |
| 1013 | typedef struct smb_com_delete_file_rsp { |
| 1014 | struct smb_hdr hdr; /* wct = 0 */ |
| 1015 | __u16 ByteCount; /* bct = 0 */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1016 | } __attribute__((packed)) DELETE_FILE_RSP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1017 | |
| 1018 | typedef struct smb_com_delete_directory_req { |
| 1019 | struct smb_hdr hdr; /* wct = 0 */ |
| 1020 | __le16 ByteCount; |
| 1021 | __u8 BufferFormat; /* 4 = ASCII */ |
| 1022 | unsigned char DirName[1]; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1023 | } __attribute__((packed)) DELETE_DIRECTORY_REQ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1024 | |
| 1025 | typedef struct smb_com_delete_directory_rsp { |
| 1026 | struct smb_hdr hdr; /* wct = 0 */ |
| 1027 | __u16 ByteCount; /* bct = 0 */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1028 | } __attribute__((packed)) DELETE_DIRECTORY_RSP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1029 | |
| 1030 | typedef struct smb_com_create_directory_req { |
| 1031 | struct smb_hdr hdr; /* wct = 0 */ |
| 1032 | __le16 ByteCount; |
| 1033 | __u8 BufferFormat; /* 4 = ASCII */ |
| 1034 | unsigned char DirName[1]; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1035 | } __attribute__((packed)) CREATE_DIRECTORY_REQ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1036 | |
| 1037 | typedef struct smb_com_create_directory_rsp { |
| 1038 | struct smb_hdr hdr; /* wct = 0 */ |
| 1039 | __u16 ByteCount; /* bct = 0 */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1040 | } __attribute__((packed)) CREATE_DIRECTORY_RSP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1041 | |
Steve French | 6b8edfe | 2005-08-23 20:26:03 -0700 | [diff] [blame] | 1042 | typedef struct smb_com_query_information_req { |
| 1043 | struct smb_hdr hdr; /* wct = 0 */ |
| 1044 | __le16 ByteCount; /* 1 + namelen + 1 */ |
| 1045 | __u8 BufferFormat; /* 4 = ASCII */ |
| 1046 | unsigned char FileName[1]; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1047 | } __attribute__((packed)) QUERY_INFORMATION_REQ; |
Steve French | 6b8edfe | 2005-08-23 20:26:03 -0700 | [diff] [blame] | 1048 | |
| 1049 | typedef struct smb_com_query_information_rsp { |
| 1050 | struct smb_hdr hdr; /* wct = 10 */ |
| 1051 | __le16 attr; |
| 1052 | __le32 last_write_time; |
| 1053 | __le32 size; |
| 1054 | __u16 reserved[5]; |
| 1055 | __le16 ByteCount; /* bcc = 0 */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1056 | } __attribute__((packed)) QUERY_INFORMATION_RSP; |
Steve French | 6b8edfe | 2005-08-23 20:26:03 -0700 | [diff] [blame] | 1057 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1058 | typedef struct smb_com_setattr_req { |
| 1059 | struct smb_hdr hdr; /* wct = 8 */ |
| 1060 | __le16 attr; |
| 1061 | __le16 time_low; |
| 1062 | __le16 time_high; |
| 1063 | __le16 reserved[5]; /* must be zero */ |
| 1064 | __u16 ByteCount; |
| 1065 | __u8 BufferFormat; /* 4 = ASCII */ |
| 1066 | unsigned char fileName[1]; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1067 | } __attribute__((packed)) SETATTR_REQ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1068 | |
| 1069 | typedef struct smb_com_setattr_rsp { |
| 1070 | struct smb_hdr hdr; /* wct = 0 */ |
| 1071 | __u16 ByteCount; /* bct = 0 */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1072 | } __attribute__((packed)) SETATTR_RSP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1073 | |
| 1074 | /* empty wct response to setattr */ |
| 1075 | |
Steve French | 0a4b92c | 2006-01-12 15:44:21 -0800 | [diff] [blame] | 1076 | /*******************************************************/ |
| 1077 | /* NT Transact structure defintions follow */ |
| 1078 | /* Currently only ioctl, acl (get security descriptor) */ |
| 1079 | /* and notify are implemented */ |
| 1080 | /*******************************************************/ |
| 1081 | typedef struct smb_com_ntransact_req { |
| 1082 | struct smb_hdr hdr; /* wct >= 19 */ |
| 1083 | __u8 MaxSetupCount; |
| 1084 | __u16 Reserved; |
| 1085 | __le32 TotalParameterCount; |
| 1086 | __le32 TotalDataCount; |
| 1087 | __le32 MaxParameterCount; |
| 1088 | __le32 MaxDataCount; |
| 1089 | __le32 ParameterCount; |
| 1090 | __le32 ParameterOffset; |
| 1091 | __le32 DataCount; |
| 1092 | __le32 DataOffset; |
| 1093 | __u8 SetupCount; /* four setup words follow subcommand */ |
| 1094 | /* SNIA spec incorrectly included spurious pad here */ |
| 1095 | __le16 SubCommand; /* 2 = IOCTL/FSCTL */ |
| 1096 | /* SetupCount words follow then */ |
| 1097 | __le16 ByteCount; |
| 1098 | __u8 Pad[3]; |
| 1099 | __u8 Parms[0]; |
| 1100 | } __attribute__((packed)) NTRANSACT_REQ; |
| 1101 | |
| 1102 | typedef struct smb_com_ntransact_rsp { |
| 1103 | struct smb_hdr hdr; /* wct = 18 */ |
| 1104 | __u8 Reserved[3]; |
| 1105 | __le32 TotalParameterCount; |
| 1106 | __le32 TotalDataCount; |
| 1107 | __le32 ParameterCount; |
| 1108 | __le32 ParameterOffset; |
| 1109 | __le32 ParameterDisplacement; |
| 1110 | __le32 DataCount; |
| 1111 | __le32 DataOffset; |
| 1112 | __le32 DataDisplacement; |
| 1113 | __u8 SetupCount; /* 0 */ |
| 1114 | __u16 ByteCount; |
| 1115 | /* __u8 Pad[3]; */ |
| 1116 | /* parms and data follow */ |
| 1117 | } __attribute__((packed)) NTRANSACT_RSP; |
| 1118 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1119 | typedef struct smb_com_transaction_ioctl_req { |
| 1120 | struct smb_hdr hdr; /* wct = 23 */ |
| 1121 | __u8 MaxSetupCount; |
| 1122 | __u16 Reserved; |
| 1123 | __le32 TotalParameterCount; |
| 1124 | __le32 TotalDataCount; |
| 1125 | __le32 MaxParameterCount; |
| 1126 | __le32 MaxDataCount; |
| 1127 | __le32 ParameterCount; |
| 1128 | __le32 ParameterOffset; |
| 1129 | __le32 DataCount; |
| 1130 | __le32 DataOffset; |
| 1131 | __u8 SetupCount; /* four setup words follow subcommand */ |
| 1132 | /* SNIA spec incorrectly included spurious pad here */ |
Steve French | 0a4b92c | 2006-01-12 15:44:21 -0800 | [diff] [blame] | 1133 | __le16 SubCommand; /* 2 = IOCTL/FSCTL */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1134 | __le32 FunctionCode; |
| 1135 | __u16 Fid; |
Steve French | 0a4b92c | 2006-01-12 15:44:21 -0800 | [diff] [blame] | 1136 | __u8 IsFsctl; /* 1 = File System Control 0 = device control (IOCTL) */ |
| 1137 | __u8 IsRootFlag; /* 1 = apply command to root of share (must be DFS) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1138 | __le16 ByteCount; |
| 1139 | __u8 Pad[3]; |
| 1140 | __u8 Data[1]; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1141 | } __attribute__((packed)) TRANSACT_IOCTL_REQ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1142 | |
| 1143 | typedef struct smb_com_transaction_ioctl_rsp { |
| 1144 | struct smb_hdr hdr; /* wct = 19 */ |
| 1145 | __u8 Reserved[3]; |
| 1146 | __le32 TotalParameterCount; |
| 1147 | __le32 TotalDataCount; |
| 1148 | __le32 ParameterCount; |
| 1149 | __le32 ParameterOffset; |
| 1150 | __le32 ParameterDisplacement; |
| 1151 | __le32 DataCount; |
| 1152 | __le32 DataOffset; |
| 1153 | __le32 DataDisplacement; |
| 1154 | __u8 SetupCount; /* 1 */ |
| 1155 | __le16 ReturnedDataLen; |
| 1156 | __u16 ByteCount; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1157 | } __attribute__((packed)) TRANSACT_IOCTL_RSP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1158 | |
Steve French | 0a4b92c | 2006-01-12 15:44:21 -0800 | [diff] [blame] | 1159 | #define CIFS_ACL_OWNER 1 |
| 1160 | #define CIFS_ACL_GROUP 2 |
| 1161 | #define CIFS_ACL_DACL 4 |
| 1162 | #define CIFS_ACL_SACL 8 |
| 1163 | |
| 1164 | typedef struct smb_com_transaction_qsec_req { |
| 1165 | struct smb_hdr hdr; /* wct = 19 */ |
| 1166 | __u8 MaxSetupCount; |
| 1167 | __u16 Reserved; |
| 1168 | __le32 TotalParameterCount; |
| 1169 | __le32 TotalDataCount; |
| 1170 | __le32 MaxParameterCount; |
| 1171 | __le32 MaxDataCount; |
| 1172 | __le32 ParameterCount; |
| 1173 | __le32 ParameterOffset; |
| 1174 | __le32 DataCount; |
| 1175 | __le32 DataOffset; |
| 1176 | __u8 SetupCount; /* no setup words follow subcommand */ |
| 1177 | /* SNIA spec incorrectly included spurious pad here */ |
| 1178 | __le16 SubCommand; /* 6 = QUERY_SECURITY_DESC */ |
| 1179 | __le16 ByteCount; /* bcc = 3 + 8 */ |
| 1180 | __u8 Pad[3]; |
| 1181 | __u16 Fid; |
| 1182 | __u16 Reserved2; |
| 1183 | __le32 AclFlags; |
| 1184 | } __attribute__((packed)) QUERY_SEC_DESC_REQ; |
| 1185 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1186 | typedef struct smb_com_transaction_change_notify_req { |
| 1187 | struct smb_hdr hdr; /* wct = 23 */ |
| 1188 | __u8 MaxSetupCount; |
| 1189 | __u16 Reserved; |
| 1190 | __le32 TotalParameterCount; |
| 1191 | __le32 TotalDataCount; |
| 1192 | __le32 MaxParameterCount; |
| 1193 | __le32 MaxDataCount; |
| 1194 | __le32 ParameterCount; |
| 1195 | __le32 ParameterOffset; |
| 1196 | __le32 DataCount; |
| 1197 | __le32 DataOffset; |
| 1198 | __u8 SetupCount; /* four setup words follow subcommand */ |
| 1199 | /* SNIA spec incorrectly included spurious pad here */ |
| 1200 | __le16 SubCommand;/* 4 = Change Notify */ |
| 1201 | __le32 CompletionFilter; /* operation to monitor */ |
| 1202 | __u16 Fid; |
| 1203 | __u8 WatchTree; /* 1 = Monitor subdirectories */ |
| 1204 | __u8 Reserved2; |
| 1205 | __le16 ByteCount; |
Steve French | 0a4b92c | 2006-01-12 15:44:21 -0800 | [diff] [blame] | 1206 | /* __u8 Pad[3];*/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1207 | /* __u8 Data[1];*/ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1208 | } __attribute__((packed)) TRANSACT_CHANGE_NOTIFY_REQ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1209 | |
Steve French | 0a4b92c | 2006-01-12 15:44:21 -0800 | [diff] [blame] | 1210 | /* BB eventually change to use generic ntransact rsp struct |
| 1211 | and validation routine */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1212 | typedef struct smb_com_transaction_change_notify_rsp { |
| 1213 | struct smb_hdr hdr; /* wct = 18 */ |
| 1214 | __u8 Reserved[3]; |
| 1215 | __le32 TotalParameterCount; |
| 1216 | __le32 TotalDataCount; |
| 1217 | __le32 ParameterCount; |
| 1218 | __le32 ParameterOffset; |
| 1219 | __le32 ParameterDisplacement; |
| 1220 | __le32 DataCount; |
| 1221 | __le32 DataOffset; |
| 1222 | __le32 DataDisplacement; |
| 1223 | __u8 SetupCount; /* 0 */ |
| 1224 | __u16 ByteCount; |
| 1225 | /* __u8 Pad[3]; */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1226 | } __attribute__((packed)) TRANSACT_CHANGE_NOTIFY_RSP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1227 | /* Completion Filter flags for Notify */ |
| 1228 | #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001 |
| 1229 | #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002 |
| 1230 | #define FILE_NOTIFY_CHANGE_NAME 0x00000003 |
| 1231 | #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004 |
| 1232 | #define FILE_NOTIFY_CHANGE_SIZE 0x00000008 |
| 1233 | #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010 |
| 1234 | #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020 |
| 1235 | #define FILE_NOTIFY_CHANGE_CREATION 0x00000040 |
| 1236 | #define FILE_NOTIFY_CHANGE_EA 0x00000080 |
| 1237 | #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100 |
| 1238 | #define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200 |
| 1239 | #define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400 |
| 1240 | #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800 |
| 1241 | |
| 1242 | #define FILE_ACTION_ADDED 0x00000001 |
| 1243 | #define FILE_ACTION_REMOVED 0x00000002 |
| 1244 | #define FILE_ACTION_MODIFIED 0x00000003 |
| 1245 | #define FILE_ACTION_RENAMED_OLD_NAME 0x00000004 |
| 1246 | #define FILE_ACTION_RENAMED_NEW_NAME 0x00000005 |
| 1247 | #define FILE_ACTION_ADDED_STREAM 0x00000006 |
| 1248 | #define FILE_ACTION_REMOVED_STREAM 0x00000007 |
| 1249 | #define FILE_ACTION_MODIFIED_STREAM 0x00000008 |
| 1250 | |
| 1251 | /* response contains array of the following structures */ |
| 1252 | struct file_notify_information { |
| 1253 | __le32 NextEntryOffset; |
| 1254 | __le32 Action; |
| 1255 | __le32 FileNameLength; |
| 1256 | __u8 FileName[0]; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1257 | } __attribute__((packed)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1258 | |
| 1259 | struct reparse_data { |
| 1260 | __u32 ReparseTag; |
| 1261 | __u16 ReparseDataLength; |
| 1262 | __u16 Reserved; |
| 1263 | __u16 AltNameOffset; |
| 1264 | __u16 AltNameLen; |
| 1265 | __u16 TargetNameOffset; |
| 1266 | __u16 TargetNameLen; |
| 1267 | char LinkNamesBuf[1]; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1268 | } __attribute__((packed)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1269 | |
| 1270 | struct cifs_quota_data { |
| 1271 | __u32 rsrvd1; /* 0 */ |
| 1272 | __u32 sid_size; |
| 1273 | __u64 rsrvd2; /* 0 */ |
| 1274 | __u64 space_used; |
| 1275 | __u64 soft_limit; |
| 1276 | __u64 hard_limit; |
| 1277 | char sid[1]; /* variable size? */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1278 | } __attribute__((packed)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1279 | |
| 1280 | /* quota sub commands */ |
| 1281 | #define QUOTA_LIST_CONTINUE 0 |
| 1282 | #define QUOTA_LIST_START 0x100 |
| 1283 | #define QUOTA_FOR_SID 0x101 |
| 1284 | |
| 1285 | struct trans2_req { |
| 1286 | /* struct smb_hdr hdr precedes. Set wct = 14+ */ |
| 1287 | __le16 TotalParameterCount; |
| 1288 | __le16 TotalDataCount; |
| 1289 | __le16 MaxParameterCount; |
| 1290 | __le16 MaxDataCount; |
| 1291 | __u8 MaxSetupCount; |
| 1292 | __u8 Reserved; |
| 1293 | __le16 Flags; |
| 1294 | __le32 Timeout; |
| 1295 | __u16 Reserved2; |
| 1296 | __le16 ParameterCount; |
| 1297 | __le16 ParameterOffset; |
| 1298 | __le16 DataCount; |
| 1299 | __le16 DataOffset; |
| 1300 | __u8 SetupCount; |
| 1301 | __u8 Reserved3; |
| 1302 | __le16 SubCommand; /* 1st setup word - SetupCount words follow */ |
| 1303 | __le16 ByteCount; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1304 | } __attribute__((packed)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1305 | |
| 1306 | struct smb_t2_req { |
| 1307 | struct smb_hdr hdr; |
| 1308 | struct trans2_req t2_req; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1309 | } __attribute__((packed)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1310 | |
| 1311 | struct trans2_resp { |
| 1312 | /* struct smb_hdr hdr precedes. Note wct = 10 + setup count */ |
| 1313 | __le16 TotalParameterCount; |
| 1314 | __le16 TotalDataCount; |
| 1315 | __u16 Reserved; |
| 1316 | __le16 ParameterCount; |
| 1317 | __le16 ParameterOffset; |
| 1318 | __le16 ParameterDisplacement; |
| 1319 | __le16 DataCount; |
| 1320 | __le16 DataOffset; |
| 1321 | __le16 DataDisplacement; |
| 1322 | __u8 SetupCount; |
| 1323 | __u8 Reserved1; |
| 1324 | /* SetupWords[SetupCount]; |
| 1325 | __u16 ByteCount; |
| 1326 | __u16 Reserved2;*/ |
| 1327 | /* data area follows */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1328 | } __attribute__((packed)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1329 | |
| 1330 | struct smb_t2_rsp { |
| 1331 | struct smb_hdr hdr; |
| 1332 | struct trans2_resp t2_rsp; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1333 | } __attribute__((packed)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1334 | |
| 1335 | /* PathInfo/FileInfo infolevels */ |
| 1336 | #define SMB_INFO_STANDARD 1 |
| 1337 | #define SMB_SET_FILE_EA 2 |
| 1338 | #define SMB_QUERY_FILE_EA_SIZE 2 |
| 1339 | #define SMB_INFO_QUERY_EAS_FROM_LIST 3 |
| 1340 | #define SMB_INFO_QUERY_ALL_EAS 4 |
| 1341 | #define SMB_INFO_IS_NAME_VALID 6 |
| 1342 | #define SMB_QUERY_FILE_BASIC_INFO 0x101 |
| 1343 | #define SMB_QUERY_FILE_STANDARD_INFO 0x102 |
| 1344 | #define SMB_QUERY_FILE_EA_INFO 0x103 |
| 1345 | #define SMB_QUERY_FILE_NAME_INFO 0x104 |
| 1346 | #define SMB_QUERY_FILE_ALLOCATION_INFO 0x105 |
| 1347 | #define SMB_QUERY_FILE_END_OF_FILEINFO 0x106 |
| 1348 | #define SMB_QUERY_FILE_ALL_INFO 0x107 |
| 1349 | #define SMB_QUERY_ALT_NAME_INFO 0x108 |
| 1350 | #define SMB_QUERY_FILE_STREAM_INFO 0x109 |
| 1351 | #define SMB_QUERY_FILE_COMPRESSION_INFO 0x10B |
| 1352 | #define SMB_QUERY_FILE_UNIX_BASIC 0x200 |
| 1353 | #define SMB_QUERY_FILE_UNIX_LINK 0x201 |
| 1354 | #define SMB_QUERY_POSIX_ACL 0x204 |
| 1355 | #define SMB_QUERY_XATTR 0x205 |
| 1356 | #define SMB_QUERY_ATTR_FLAGS 0x206 /* append,immutable etc. */ |
Steve French | f654bac | 2005-04-28 22:41:04 -0700 | [diff] [blame] | 1357 | #define SMB_QUERY_POSIX_PERMISSION 0x207 |
| 1358 | #define SMB_QUERY_POSIX_LOCK 0x208 |
Steve French | 2fe87f0 | 2006-09-21 07:02:52 +0000 | [diff] [blame] | 1359 | /* #define SMB_POSIX_OPEN 0x209 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1360 | #define SMB_QUERY_FILE_INTERNAL_INFO 0x3ee |
| 1361 | #define SMB_QUERY_FILE_ACCESS_INFO 0x3f0 |
| 1362 | #define SMB_QUERY_FILE_NAME_INFO2 0x3f1 /* 0x30 bytes */ |
| 1363 | #define SMB_QUERY_FILE_POSITION_INFO 0x3f6 |
| 1364 | #define SMB_QUERY_FILE_MODE_INFO 0x3f8 |
| 1365 | #define SMB_QUERY_FILE_ALGN_INFO 0x3f9 |
| 1366 | |
| 1367 | |
| 1368 | #define SMB_SET_FILE_BASIC_INFO 0x101 |
| 1369 | #define SMB_SET_FILE_DISPOSITION_INFO 0x102 |
| 1370 | #define SMB_SET_FILE_ALLOCATION_INFO 0x103 |
| 1371 | #define SMB_SET_FILE_END_OF_FILE_INFO 0x104 |
| 1372 | #define SMB_SET_FILE_UNIX_BASIC 0x200 |
| 1373 | #define SMB_SET_FILE_UNIX_LINK 0x201 |
| 1374 | #define SMB_SET_FILE_UNIX_HLINK 0x203 |
| 1375 | #define SMB_SET_POSIX_ACL 0x204 |
| 1376 | #define SMB_SET_XATTR 0x205 |
| 1377 | #define SMB_SET_ATTR_FLAGS 0x206 /* append, immutable etc. */ |
Steve French | f654bac | 2005-04-28 22:41:04 -0700 | [diff] [blame] | 1378 | #define SMB_SET_POSIX_LOCK 0x208 |
Steve French | 2fe87f0 | 2006-09-21 07:02:52 +0000 | [diff] [blame] | 1379 | #define SMB_POSIX_OPEN 0x209 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1380 | #define SMB_SET_FILE_BASIC_INFO2 0x3ec |
| 1381 | #define SMB_SET_FILE_RENAME_INFORMATION 0x3f2 /* BB check if qpathinfo level too */ |
| 1382 | #define SMB_FILE_ALL_INFO2 0x3fa |
| 1383 | #define SMB_SET_FILE_ALLOCATION_INFO2 0x3fb |
| 1384 | #define SMB_SET_FILE_END_OF_FILE_INFO2 0x3fc |
| 1385 | #define SMB_FILE_MOVE_CLUSTER_INFO 0x407 |
| 1386 | #define SMB_FILE_QUOTA_INFO 0x408 |
| 1387 | #define SMB_FILE_REPARSEPOINT_INFO 0x409 |
| 1388 | #define SMB_FILE_MAXIMUM_INFO 0x40d |
| 1389 | |
| 1390 | /* Find File infolevels */ |
Steve French | 5bafd76 | 2006-06-07 00:18:43 +0000 | [diff] [blame] | 1391 | #define SMB_FIND_FILE_INFO_STANDARD 0x001 |
| 1392 | #define SMB_FIND_FILE_QUERY_EA_SIZE 0x002 |
| 1393 | #define SMB_FIND_FILE_QUERY_EAS_FROM_LIST 0x003 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1394 | #define SMB_FIND_FILE_DIRECTORY_INFO 0x101 |
| 1395 | #define SMB_FIND_FILE_FULL_DIRECTORY_INFO 0x102 |
| 1396 | #define SMB_FIND_FILE_NAMES_INFO 0x103 |
| 1397 | #define SMB_FIND_FILE_BOTH_DIRECTORY_INFO 0x104 |
| 1398 | #define SMB_FIND_FILE_ID_FULL_DIR_INFO 0x105 |
| 1399 | #define SMB_FIND_FILE_ID_BOTH_DIR_INFO 0x106 |
| 1400 | #define SMB_FIND_FILE_UNIX 0x202 |
| 1401 | |
| 1402 | typedef struct smb_com_transaction2_qpi_req { |
| 1403 | struct smb_hdr hdr; /* wct = 14+ */ |
| 1404 | __le16 TotalParameterCount; |
| 1405 | __le16 TotalDataCount; |
| 1406 | __le16 MaxParameterCount; |
| 1407 | __le16 MaxDataCount; |
| 1408 | __u8 MaxSetupCount; |
| 1409 | __u8 Reserved; |
| 1410 | __le16 Flags; |
| 1411 | __le32 Timeout; |
| 1412 | __u16 Reserved2; |
| 1413 | __le16 ParameterCount; |
| 1414 | __le16 ParameterOffset; |
| 1415 | __le16 DataCount; |
| 1416 | __le16 DataOffset; |
| 1417 | __u8 SetupCount; |
| 1418 | __u8 Reserved3; |
| 1419 | __le16 SubCommand; /* one setup word */ |
| 1420 | __le16 ByteCount; |
| 1421 | __u8 Pad; |
| 1422 | __le16 InformationLevel; |
| 1423 | __u32 Reserved4; |
| 1424 | char FileName[1]; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1425 | } __attribute__((packed)) TRANSACTION2_QPI_REQ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1426 | |
| 1427 | typedef struct smb_com_transaction2_qpi_rsp { |
| 1428 | struct smb_hdr hdr; /* wct = 10 + SetupCount */ |
| 1429 | struct trans2_resp t2; |
| 1430 | __u16 ByteCount; |
| 1431 | __u16 Reserved2; /* parameter word reserved - present for infolevels > 100 */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1432 | } __attribute__((packed)) TRANSACTION2_QPI_RSP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1433 | |
| 1434 | typedef struct smb_com_transaction2_spi_req { |
| 1435 | struct smb_hdr hdr; /* wct = 15 */ |
| 1436 | __le16 TotalParameterCount; |
| 1437 | __le16 TotalDataCount; |
| 1438 | __le16 MaxParameterCount; |
| 1439 | __le16 MaxDataCount; |
| 1440 | __u8 MaxSetupCount; |
| 1441 | __u8 Reserved; |
| 1442 | __le16 Flags; |
| 1443 | __le32 Timeout; |
| 1444 | __u16 Reserved2; |
| 1445 | __le16 ParameterCount; |
| 1446 | __le16 ParameterOffset; |
| 1447 | __le16 DataCount; |
| 1448 | __le16 DataOffset; |
| 1449 | __u8 SetupCount; |
| 1450 | __u8 Reserved3; |
| 1451 | __le16 SubCommand; /* one setup word */ |
| 1452 | __le16 ByteCount; |
| 1453 | __u8 Pad; |
| 1454 | __u16 Pad1; |
| 1455 | __le16 InformationLevel; |
| 1456 | __u32 Reserved4; |
| 1457 | char FileName[1]; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1458 | } __attribute__((packed)) TRANSACTION2_SPI_REQ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1459 | |
| 1460 | typedef struct smb_com_transaction2_spi_rsp { |
| 1461 | struct smb_hdr hdr; /* wct = 10 + SetupCount */ |
| 1462 | struct trans2_resp t2; |
| 1463 | __u16 ByteCount; |
| 1464 | __u16 Reserved2; /* parameter word reserved - present for infolevels > 100 */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1465 | } __attribute__((packed)) TRANSACTION2_SPI_RSP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1466 | |
| 1467 | struct set_file_rename { |
| 1468 | __le32 overwrite; /* 1 = overwrite dest */ |
| 1469 | __u32 root_fid; /* zero */ |
| 1470 | __le32 target_name_len; |
| 1471 | char target_name[0]; /* Must be unicode */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1472 | } __attribute__((packed)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1473 | |
| 1474 | struct smb_com_transaction2_sfi_req { |
| 1475 | struct smb_hdr hdr; /* wct = 15 */ |
| 1476 | __le16 TotalParameterCount; |
| 1477 | __le16 TotalDataCount; |
| 1478 | __le16 MaxParameterCount; |
| 1479 | __le16 MaxDataCount; |
| 1480 | __u8 MaxSetupCount; |
| 1481 | __u8 Reserved; |
| 1482 | __le16 Flags; |
| 1483 | __le32 Timeout; |
| 1484 | __u16 Reserved2; |
| 1485 | __le16 ParameterCount; |
| 1486 | __le16 ParameterOffset; |
| 1487 | __le16 DataCount; |
| 1488 | __le16 DataOffset; |
| 1489 | __u8 SetupCount; |
| 1490 | __u8 Reserved3; |
| 1491 | __le16 SubCommand; /* one setup word */ |
| 1492 | __le16 ByteCount; |
| 1493 | __u8 Pad; |
| 1494 | __u16 Pad1; |
| 1495 | __u16 Fid; |
| 1496 | __le16 InformationLevel; |
| 1497 | __u16 Reserved4; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1498 | } __attribute__((packed)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1499 | |
| 1500 | struct smb_com_transaction2_sfi_rsp { |
| 1501 | struct smb_hdr hdr; /* wct = 10 + SetupCount */ |
| 1502 | struct trans2_resp t2; |
| 1503 | __u16 ByteCount; |
Steve French | f654bac | 2005-04-28 22:41:04 -0700 | [diff] [blame] | 1504 | __u16 Reserved2; /* parameter word reserved - |
| 1505 | present for infolevels > 100 */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1506 | } __attribute__((packed)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1507 | |
Steve French | f654bac | 2005-04-28 22:41:04 -0700 | [diff] [blame] | 1508 | struct smb_t2_qfi_req { |
| 1509 | struct smb_hdr hdr; |
| 1510 | struct trans2_req t2; |
| 1511 | __u8 Pad; |
Steve French | f654bac | 2005-04-28 22:41:04 -0700 | [diff] [blame] | 1512 | __u16 Fid; |
| 1513 | __le16 InformationLevel; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1514 | } __attribute__((packed)); |
Steve French | f654bac | 2005-04-28 22:41:04 -0700 | [diff] [blame] | 1515 | |
| 1516 | struct smb_t2_qfi_rsp { |
| 1517 | struct smb_hdr hdr; /* wct = 10 + SetupCount */ |
| 1518 | struct trans2_resp t2; |
| 1519 | __u16 ByteCount; |
| 1520 | __u16 Reserved2; /* parameter word reserved - |
| 1521 | present for infolevels > 100 */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1522 | } __attribute__((packed)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1523 | |
| 1524 | /* |
| 1525 | * Flags on T2 FINDFIRST and FINDNEXT |
| 1526 | */ |
| 1527 | #define CIFS_SEARCH_CLOSE_ALWAYS 0x0001 |
| 1528 | #define CIFS_SEARCH_CLOSE_AT_END 0x0002 |
| 1529 | #define CIFS_SEARCH_RETURN_RESUME 0x0004 |
| 1530 | #define CIFS_SEARCH_CONTINUE_FROM_LAST 0x0008 |
| 1531 | #define CIFS_SEARCH_BACKUP_SEARCH 0x0010 |
| 1532 | |
| 1533 | /* |
| 1534 | * Size of the resume key on FINDFIRST and FINDNEXT calls |
| 1535 | */ |
| 1536 | #define CIFS_SMB_RESUME_KEY_SIZE 4 |
| 1537 | |
| 1538 | typedef struct smb_com_transaction2_ffirst_req { |
| 1539 | struct smb_hdr hdr; /* wct = 15 */ |
| 1540 | __le16 TotalParameterCount; |
| 1541 | __le16 TotalDataCount; |
| 1542 | __le16 MaxParameterCount; |
| 1543 | __le16 MaxDataCount; |
| 1544 | __u8 MaxSetupCount; |
| 1545 | __u8 Reserved; |
| 1546 | __le16 Flags; |
| 1547 | __le32 Timeout; |
| 1548 | __u16 Reserved2; |
| 1549 | __le16 ParameterCount; |
| 1550 | __le16 ParameterOffset; |
| 1551 | __le16 DataCount; |
| 1552 | __le16 DataOffset; |
| 1553 | __u8 SetupCount; /* one */ |
| 1554 | __u8 Reserved3; |
| 1555 | __le16 SubCommand; /* TRANS2_FIND_FIRST */ |
| 1556 | __le16 ByteCount; |
| 1557 | __u8 Pad; |
| 1558 | __le16 SearchAttributes; |
| 1559 | __le16 SearchCount; |
| 1560 | __le16 SearchFlags; |
| 1561 | __le16 InformationLevel; |
| 1562 | __le32 SearchStorageType; |
| 1563 | char FileName[1]; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1564 | } __attribute__((packed)) TRANSACTION2_FFIRST_REQ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1565 | |
| 1566 | typedef struct smb_com_transaction2_ffirst_rsp { |
| 1567 | struct smb_hdr hdr; /* wct = 10 */ |
| 1568 | struct trans2_resp t2; |
| 1569 | __u16 ByteCount; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1570 | } __attribute__((packed)) TRANSACTION2_FFIRST_RSP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1571 | |
| 1572 | typedef struct smb_com_transaction2_ffirst_rsp_parms { |
| 1573 | __u16 SearchHandle; |
| 1574 | __le16 SearchCount; |
| 1575 | __le16 EndofSearch; |
| 1576 | __le16 EAErrorOffset; |
| 1577 | __le16 LastNameOffset; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1578 | } __attribute__((packed)) T2_FFIRST_RSP_PARMS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1579 | |
| 1580 | typedef struct smb_com_transaction2_fnext_req { |
| 1581 | struct smb_hdr hdr; /* wct = 15 */ |
| 1582 | __le16 TotalParameterCount; |
| 1583 | __le16 TotalDataCount; |
| 1584 | __le16 MaxParameterCount; |
| 1585 | __le16 MaxDataCount; |
| 1586 | __u8 MaxSetupCount; |
| 1587 | __u8 Reserved; |
| 1588 | __le16 Flags; |
| 1589 | __le32 Timeout; |
| 1590 | __u16 Reserved2; |
| 1591 | __le16 ParameterCount; |
| 1592 | __le16 ParameterOffset; |
| 1593 | __le16 DataCount; |
| 1594 | __le16 DataOffset; |
| 1595 | __u8 SetupCount; /* one */ |
| 1596 | __u8 Reserved3; |
| 1597 | __le16 SubCommand; /* TRANS2_FIND_NEXT */ |
| 1598 | __le16 ByteCount; |
| 1599 | __u8 Pad; |
| 1600 | __u16 SearchHandle; |
| 1601 | __le16 SearchCount; |
| 1602 | __le16 InformationLevel; |
| 1603 | __u32 ResumeKey; |
| 1604 | __le16 SearchFlags; |
| 1605 | char ResumeFileName[1]; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1606 | } __attribute__((packed)) TRANSACTION2_FNEXT_REQ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1607 | |
| 1608 | typedef struct smb_com_transaction2_fnext_rsp { |
| 1609 | struct smb_hdr hdr; /* wct = 10 */ |
| 1610 | struct trans2_resp t2; |
| 1611 | __u16 ByteCount; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1612 | } __attribute__((packed)) TRANSACTION2_FNEXT_RSP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1613 | |
| 1614 | typedef struct smb_com_transaction2_fnext_rsp_parms { |
| 1615 | __le16 SearchCount; |
| 1616 | __le16 EndofSearch; |
| 1617 | __le16 EAErrorOffset; |
| 1618 | __le16 LastNameOffset; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1619 | } __attribute__((packed)) T2_FNEXT_RSP_PARMS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1620 | |
| 1621 | /* QFSInfo Levels */ |
| 1622 | #define SMB_INFO_ALLOCATION 1 |
| 1623 | #define SMB_INFO_VOLUME 2 |
| 1624 | #define SMB_QUERY_FS_VOLUME_INFO 0x102 |
| 1625 | #define SMB_QUERY_FS_SIZE_INFO 0x103 |
| 1626 | #define SMB_QUERY_FS_DEVICE_INFO 0x104 |
| 1627 | #define SMB_QUERY_FS_ATTRIBUTE_INFO 0x105 |
| 1628 | #define SMB_QUERY_CIFS_UNIX_INFO 0x200 |
| 1629 | #define SMB_QUERY_POSIX_FS_INFO 0x201 |
| 1630 | #define SMB_QUERY_LABEL_INFO 0x3ea |
| 1631 | #define SMB_QUERY_FS_QUOTA_INFO 0x3ee |
| 1632 | #define SMB_QUERY_FS_FULL_SIZE_INFO 0x3ef |
| 1633 | #define SMB_QUERY_OBJECTID_INFO 0x3f0 |
| 1634 | |
| 1635 | typedef struct smb_com_transaction2_qfsi_req { |
| 1636 | struct smb_hdr hdr; /* wct = 14+ */ |
| 1637 | __le16 TotalParameterCount; |
| 1638 | __le16 TotalDataCount; |
| 1639 | __le16 MaxParameterCount; |
| 1640 | __le16 MaxDataCount; |
| 1641 | __u8 MaxSetupCount; |
| 1642 | __u8 Reserved; |
| 1643 | __le16 Flags; |
| 1644 | __le32 Timeout; |
| 1645 | __u16 Reserved2; |
| 1646 | __le16 ParameterCount; |
| 1647 | __le16 ParameterOffset; |
| 1648 | __le16 DataCount; |
| 1649 | __le16 DataOffset; |
| 1650 | __u8 SetupCount; |
| 1651 | __u8 Reserved3; |
| 1652 | __le16 SubCommand; /* one setup word */ |
| 1653 | __le16 ByteCount; |
| 1654 | __u8 Pad; |
| 1655 | __le16 InformationLevel; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1656 | } __attribute__((packed)) TRANSACTION2_QFSI_REQ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1657 | |
| 1658 | typedef struct smb_com_transaction_qfsi_rsp { |
| 1659 | struct smb_hdr hdr; /* wct = 10 + SetupCount */ |
| 1660 | struct trans2_resp t2; |
| 1661 | __u16 ByteCount; |
| 1662 | __u8 Pad; /* may be three bytes *//* followed by data area */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1663 | } __attribute__((packed)) TRANSACTION2_QFSI_RSP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1664 | |
Jeremy Allison | ac67055 | 2005-06-22 17:26:35 -0700 | [diff] [blame] | 1665 | |
| 1666 | /* SETFSInfo Levels */ |
| 1667 | #define SMB_SET_CIFS_UNIX_INFO 0x200 |
| 1668 | typedef struct smb_com_transaction2_setfsi_req { |
| 1669 | struct smb_hdr hdr; /* wct = 15 */ |
| 1670 | __le16 TotalParameterCount; |
| 1671 | __le16 TotalDataCount; |
| 1672 | __le16 MaxParameterCount; |
| 1673 | __le16 MaxDataCount; |
| 1674 | __u8 MaxSetupCount; |
| 1675 | __u8 Reserved; |
| 1676 | __le16 Flags; |
| 1677 | __le32 Timeout; |
| 1678 | __u16 Reserved2; |
| 1679 | __le16 ParameterCount; /* 4 */ |
| 1680 | __le16 ParameterOffset; |
| 1681 | __le16 DataCount; /* 12 */ |
| 1682 | __le16 DataOffset; |
| 1683 | __u8 SetupCount; /* one */ |
| 1684 | __u8 Reserved3; |
| 1685 | __le16 SubCommand; /* TRANS2_SET_FS_INFORMATION */ |
| 1686 | __le16 ByteCount; |
| 1687 | __u8 Pad; |
| 1688 | __u16 FileNum; /* Parameters start. */ |
| 1689 | __le16 InformationLevel;/* Parameters end. */ |
| 1690 | __le16 ClientUnixMajor; /* Data start. */ |
| 1691 | __le16 ClientUnixMinor; |
| 1692 | __le64 ClientUnixCap; /* Data end */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1693 | } __attribute__((packed)) TRANSACTION2_SETFSI_REQ; |
Jeremy Allison | ac67055 | 2005-06-22 17:26:35 -0700 | [diff] [blame] | 1694 | |
| 1695 | typedef struct smb_com_transaction2_setfsi_rsp { |
| 1696 | struct smb_hdr hdr; /* wct = 10 */ |
| 1697 | struct trans2_resp t2; |
| 1698 | __u16 ByteCount; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1699 | } __attribute__((packed)) TRANSACTION2_SETFSI_RSP; |
Jeremy Allison | ac67055 | 2005-06-22 17:26:35 -0700 | [diff] [blame] | 1700 | |
| 1701 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1702 | typedef struct smb_com_transaction2_get_dfs_refer_req { |
| 1703 | struct smb_hdr hdr; /* wct = 15 */ |
| 1704 | __le16 TotalParameterCount; |
| 1705 | __le16 TotalDataCount; |
| 1706 | __le16 MaxParameterCount; |
| 1707 | __le16 MaxDataCount; |
| 1708 | __u8 MaxSetupCount; |
| 1709 | __u8 Reserved; |
| 1710 | __le16 Flags; |
| 1711 | __le32 Timeout; |
| 1712 | __u16 Reserved2; |
| 1713 | __le16 ParameterCount; |
| 1714 | __le16 ParameterOffset; |
| 1715 | __le16 DataCount; |
| 1716 | __le16 DataOffset; |
| 1717 | __u8 SetupCount; |
| 1718 | __u8 Reserved3; |
| 1719 | __le16 SubCommand; /* one setup word */ |
| 1720 | __le16 ByteCount; |
| 1721 | __u8 Pad[3]; /* Win2K has sent 0x0F01 (max resp length perhaps?) followed by one byte pad - doesn't seem to matter though */ |
| 1722 | __le16 MaxReferralLevel; |
| 1723 | char RequestFileName[1]; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1724 | } __attribute__((packed)) TRANSACTION2_GET_DFS_REFER_REQ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1725 | |
| 1726 | typedef struct dfs_referral_level_3 { |
| 1727 | __le16 VersionNumber; |
| 1728 | __le16 ReferralSize; |
| 1729 | __le16 ServerType; /* 0x0001 = CIFS server */ |
| 1730 | __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 */ |
| 1731 | __le16 TimeToLive; |
| 1732 | __le16 Proximity; |
| 1733 | __le16 DfsPathOffset; |
| 1734 | __le16 DfsAlternatePathOffset; |
| 1735 | __le16 NetworkAddressOffset; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1736 | } __attribute__((packed)) REFERRAL3; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1737 | |
| 1738 | typedef struct smb_com_transaction_get_dfs_refer_rsp { |
| 1739 | struct smb_hdr hdr; /* wct = 10 */ |
| 1740 | struct trans2_resp t2; |
| 1741 | __u16 ByteCount; |
| 1742 | __u8 Pad; |
| 1743 | __le16 PathConsumed; |
| 1744 | __le16 NumberOfReferrals; |
| 1745 | __le16 DFSFlags; |
| 1746 | __u16 Pad2; |
| 1747 | REFERRAL3 referrals[1]; /* array of level 3 dfs_referral structures */ |
| 1748 | /* followed by the strings pointed to by the referral structures */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1749 | } __attribute__((packed)) TRANSACTION2_GET_DFS_REFER_RSP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1750 | |
| 1751 | /* DFS Flags */ |
| 1752 | #define DFSREF_REFERRAL_SERVER 0x0001 |
| 1753 | #define DFSREF_STORAGE_SERVER 0x0002 |
| 1754 | |
| 1755 | /* IOCTL information */ |
| 1756 | /* List of ioctl function codes that look to be of interest to remote clients like this. */ |
| 1757 | /* Need to do some experimentation to make sure they all work remotely. */ |
| 1758 | /* Some of the following such as the encryption/compression ones would be */ |
| 1759 | /* invoked from tools via a specialized hook into the VFS rather than via the */ |
| 1760 | /* standard vfs entry points */ |
| 1761 | #define FSCTL_REQUEST_OPLOCK_LEVEL_1 0x00090000 |
| 1762 | #define FSCTL_REQUEST_OPLOCK_LEVEL_2 0x00090004 |
| 1763 | #define FSCTL_REQUEST_BATCH_OPLOCK 0x00090008 |
| 1764 | #define FSCTL_LOCK_VOLUME 0x00090018 |
| 1765 | #define FSCTL_UNLOCK_VOLUME 0x0009001C |
| 1766 | #define FSCTL_GET_COMPRESSION 0x0009003C |
| 1767 | #define FSCTL_SET_COMPRESSION 0x0009C040 |
| 1768 | #define FSCTL_REQUEST_FILTER_OPLOCK 0x0009008C |
| 1769 | #define FSCTL_FILESYS_GET_STATISTICS 0x00090090 |
| 1770 | #define FSCTL_SET_REPARSE_POINT 0x000900A4 |
| 1771 | #define FSCTL_GET_REPARSE_POINT 0x000900A8 |
| 1772 | #define FSCTL_DELETE_REPARSE_POINT 0x000900AC |
| 1773 | #define FSCTL_SET_SPARSE 0x000900C4 |
| 1774 | #define FSCTL_SET_ZERO_DATA 0x000900C8 |
| 1775 | #define FSCTL_SET_ENCRYPTION 0x000900D7 |
| 1776 | #define FSCTL_ENCRYPTION_FSCTL_IO 0x000900DB |
| 1777 | #define FSCTL_WRITE_RAW_ENCRYPTED 0x000900DF |
| 1778 | #define FSCTL_READ_RAW_ENCRYPTED 0x000900E3 |
| 1779 | #define FSCTL_SIS_COPYFILE 0x00090100 |
| 1780 | #define FSCTL_SIS_LINK_FILES 0x0009C104 |
| 1781 | |
| 1782 | #define IO_REPARSE_TAG_MOUNT_POINT 0xA0000003 |
| 1783 | #define IO_REPARSE_TAG_HSM 0xC0000004 |
| 1784 | #define IO_REPARSE_TAG_SIS 0x80000007 |
| 1785 | |
| 1786 | /* |
| 1787 | ************************************************************************ |
| 1788 | * All structs for everything above the SMB PDUs themselves |
| 1789 | * (such as the T2 level specific data) go here |
| 1790 | ************************************************************************ |
| 1791 | */ |
| 1792 | |
| 1793 | /* |
| 1794 | * Information on a server |
| 1795 | */ |
| 1796 | |
| 1797 | struct serverInfo { |
| 1798 | char name[16]; |
| 1799 | unsigned char versionMajor; |
| 1800 | unsigned char versionMinor; |
| 1801 | unsigned long type; |
| 1802 | unsigned int commentOffset; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1803 | } __attribute__((packed)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1804 | |
| 1805 | /* |
| 1806 | * The following structure is the format of the data returned on a NetShareEnum |
| 1807 | * with level "90" (x5A) |
| 1808 | */ |
| 1809 | |
| 1810 | struct shareInfo { |
| 1811 | char shareName[13]; |
| 1812 | char pad; |
| 1813 | unsigned short type; |
| 1814 | unsigned int commentOffset; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1815 | } __attribute__((packed)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1816 | |
| 1817 | struct aliasInfo { |
| 1818 | char aliasName[9]; |
| 1819 | char pad; |
| 1820 | unsigned int commentOffset; |
| 1821 | unsigned char type[2]; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1822 | } __attribute__((packed)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1823 | |
| 1824 | struct aliasInfo92 { |
| 1825 | int aliasNameOffset; |
| 1826 | int serverNameOffset; |
| 1827 | int shareNameOffset; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1828 | } __attribute__((packed)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1829 | |
| 1830 | typedef struct { |
| 1831 | __le64 TotalAllocationUnits; |
| 1832 | __le64 FreeAllocationUnits; |
| 1833 | __le32 SectorsPerAllocationUnit; |
| 1834 | __le32 BytesPerSector; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1835 | } __attribute__((packed)) FILE_SYSTEM_INFO; /* size info, level 0x103 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1836 | |
| 1837 | typedef struct { |
Steve French | 2096243 | 2005-09-21 22:05:57 -0700 | [diff] [blame] | 1838 | __le32 fsid; |
| 1839 | __le32 SectorsPerAllocationUnit; |
| 1840 | __le32 TotalAllocationUnits; |
| 1841 | __le32 FreeAllocationUnits; |
| 1842 | __le16 BytesPerSector; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1843 | } __attribute__((packed)) FILE_SYSTEM_ALLOC_INFO; |
Steve French | 2096243 | 2005-09-21 22:05:57 -0700 | [diff] [blame] | 1844 | |
| 1845 | typedef struct { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1846 | __le16 MajorVersionNumber; |
| 1847 | __le16 MinorVersionNumber; |
| 1848 | __le64 Capability; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1849 | } __attribute__((packed)) FILE_SYSTEM_UNIX_INFO; /* Unix extensions info, level 0x200 */ |
Jeremy Allison | ac67055 | 2005-06-22 17:26:35 -0700 | [diff] [blame] | 1850 | |
| 1851 | /* Version numbers for CIFS UNIX major and minor. */ |
| 1852 | #define CIFS_UNIX_MAJOR_VERSION 1 |
| 1853 | #define CIFS_UNIX_MINOR_VERSION 0 |
| 1854 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1855 | /* Linux/Unix extensions capability flags */ |
| 1856 | #define CIFS_UNIX_FCNTL_CAP 0x00000001 /* support for fcntl locks */ |
Steve French | f654bac | 2005-04-28 22:41:04 -0700 | [diff] [blame] | 1857 | #define CIFS_UNIX_POSIX_ACL_CAP 0x00000002 /* support getfacl/setfacl */ |
| 1858 | #define CIFS_UNIX_XATTR_CAP 0x00000004 /* support new namespace */ |
| 1859 | #define CIFS_UNIX_EXTATTR_CAP 0x00000008 /* support chattr/chflag */ |
Steve French | 82940a4 | 2006-03-02 03:24:57 +0000 | [diff] [blame] | 1860 | #define CIFS_UNIX_POSIX_PATHNAMES_CAP 0x00000010 /* Allow POSIX path chars */ |
| 1861 | #ifdef CONFIG_CIFS_POSIX |
| 1862 | #define CIFS_UNIX_CAP_MASK 0x0000001b |
| 1863 | #else |
| 1864 | #define CIFS_UNIX_CAP_MASK 0x00000013 |
| 1865 | #endif /* CONFIG_CIFS_POSIX */ |
| 1866 | |
Jeremy Allison | ac67055 | 2005-06-22 17:26:35 -0700 | [diff] [blame] | 1867 | |
Steve French | f28ac91 | 2005-04-28 22:41:07 -0700 | [diff] [blame] | 1868 | #define CIFS_POSIX_EXTENSIONS 0x00000010 /* support for new QFSInfo */ |
Jeremy Allison | ac67055 | 2005-06-22 17:26:35 -0700 | [diff] [blame] | 1869 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1870 | typedef struct { |
| 1871 | /* For undefined recommended transfer size return -1 in that field */ |
| 1872 | __le32 OptimalTransferSize; /* bsize on some os, iosize on other os */ |
| 1873 | __le32 BlockSize; |
| 1874 | /* The next three fields are in terms of the block size. |
| 1875 | (above). If block size is unknown, 4096 would be a |
| 1876 | reasonable block size for a server to report. |
| 1877 | Note that returning the blocks/blocksavail removes need |
| 1878 | to make a second call (to QFSInfo level 0x103 to get this info. |
| 1879 | UserBlockAvail is typically less than or equal to BlocksAvail, |
| 1880 | if no distinction is made return the same value in each */ |
| 1881 | __le64 TotalBlocks; |
| 1882 | __le64 BlocksAvail; /* bfree */ |
| 1883 | __le64 UserBlocksAvail; /* bavail */ |
| 1884 | /* For undefined Node fields or FSID return -1 */ |
| 1885 | __le64 TotalFileNodes; |
| 1886 | __le64 FreeFileNodes; |
| 1887 | __le64 FileSysIdentifier; /* fsid */ |
| 1888 | /* NB Namelen comes from FILE_SYSTEM_ATTRIBUTE_INFO call */ |
| 1889 | /* NB flags can come from FILE_SYSTEM_DEVICE_INFO call */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1890 | } __attribute__((packed)) FILE_SYSTEM_POSIX_INFO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1891 | |
| 1892 | /* DeviceType Flags */ |
| 1893 | #define FILE_DEVICE_CD_ROM 0x00000002 |
| 1894 | #define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003 |
| 1895 | #define FILE_DEVICE_DFS 0x00000006 |
| 1896 | #define FILE_DEVICE_DISK 0x00000007 |
| 1897 | #define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008 |
| 1898 | #define FILE_DEVICE_FILE_SYSTEM 0x00000009 |
| 1899 | #define FILE_DEVICE_NAMED_PIPE 0x00000011 |
| 1900 | #define FILE_DEVICE_NETWORK 0x00000012 |
| 1901 | #define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014 |
| 1902 | #define FILE_DEVICE_NULL 0x00000015 |
| 1903 | #define FILE_DEVICE_PARALLEL_PORT 0x00000016 |
| 1904 | #define FILE_DEVICE_PRINTER 0x00000018 |
| 1905 | #define FILE_DEVICE_SERIAL_PORT 0x0000001b |
| 1906 | #define FILE_DEVICE_STREAMS 0x0000001e |
| 1907 | #define FILE_DEVICE_TAPE 0x0000001f |
| 1908 | #define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020 |
| 1909 | #define FILE_DEVICE_VIRTUAL_DISK 0x00000024 |
| 1910 | #define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028 |
| 1911 | |
| 1912 | typedef struct { |
| 1913 | __le32 DeviceType; |
| 1914 | __le32 DeviceCharacteristics; |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 1915 | } __attribute__((packed)) FILE_SYSTEM_DEVICE_INFO; /* device info level 0x104 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1916 | |
| 1917 | typedef struct { |
| 1918 | __le32 Attributes; |
| 1919 | __le32 MaxPathNameComponentLength; |
| 1920 | __le32 FileSystemNameLen; |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 1921 | char FileSystemName[52]; /* do not have to save this - get subset? */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1922 | } __attribute__((packed)) FILE_SYSTEM_ATTRIBUTE_INFO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1923 | |
| 1924 | /******************************************************************************/ |
| 1925 | /* QueryFileInfo/QueryPathinfo (also for SetPath/SetFile) data buffer formats */ |
| 1926 | /******************************************************************************/ |
| 1927 | typedef struct { /* data block encoding of response to level 263 QPathInfo */ |
| 1928 | __le64 CreationTime; |
| 1929 | __le64 LastAccessTime; |
| 1930 | __le64 LastWriteTime; |
| 1931 | __le64 ChangeTime; |
| 1932 | __le32 Attributes; |
| 1933 | __u32 Pad1; |
| 1934 | __le64 AllocationSize; |
| 1935 | __le64 EndOfFile; /* size ie offset to first free byte in file */ |
| 1936 | __le32 NumberOfLinks; /* hard links */ |
| 1937 | __u8 DeletePending; |
| 1938 | __u8 Directory; |
| 1939 | __u16 Pad2; |
| 1940 | __u64 IndexNumber; |
| 1941 | __le32 EASize; |
| 1942 | __le32 AccessFlags; |
| 1943 | __u64 IndexNumber1; |
| 1944 | __le64 CurrentByteOffset; |
| 1945 | __le32 Mode; |
| 1946 | __le32 AlignmentRequirement; |
| 1947 | __le32 FileNameLength; |
| 1948 | char FileName[1]; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1949 | } __attribute__((packed)) FILE_ALL_INFO; /* level 0x107 QPathInfo */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1950 | |
| 1951 | /* defines for enumerating possible values of the Unix type field below */ |
| 1952 | #define UNIX_FILE 0 |
| 1953 | #define UNIX_DIR 1 |
| 1954 | #define UNIX_SYMLINK 2 |
| 1955 | #define UNIX_CHARDEV 3 |
| 1956 | #define UNIX_BLOCKDEV 4 |
| 1957 | #define UNIX_FIFO 5 |
| 1958 | #define UNIX_SOCKET 6 |
| 1959 | typedef struct { |
| 1960 | __le64 EndOfFile; |
| 1961 | __le64 NumOfBytes; |
| 1962 | __le64 LastStatusChange; /*SNIA specs DCE time for the 3 time fields */ |
| 1963 | __le64 LastAccessTime; |
| 1964 | __le64 LastModificationTime; |
| 1965 | __le64 Uid; |
| 1966 | __le64 Gid; |
| 1967 | __le32 Type; |
| 1968 | __le64 DevMajor; |
| 1969 | __le64 DevMinor; |
| 1970 | __u64 UniqueId; |
| 1971 | __le64 Permissions; |
| 1972 | __le64 Nlinks; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1973 | } __attribute__((packed)) FILE_UNIX_BASIC_INFO; /* level 0x200 QPathInfo */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1974 | |
| 1975 | typedef struct { |
| 1976 | char LinkDest[1]; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1977 | } __attribute__((packed)) FILE_UNIX_LINK_INFO; /* level 0x201 QPathInfo */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1978 | |
| 1979 | /* The following three structures are needed only for |
| 1980 | setting time to NT4 and some older servers via |
| 1981 | the primitive DOS time format */ |
| 1982 | typedef struct { |
| 1983 | __u16 Day:5; |
| 1984 | __u16 Month:4; |
| 1985 | __u16 Year:7; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1986 | } __attribute__((packed)) SMB_DATE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1987 | |
| 1988 | typedef struct { |
| 1989 | __u16 TwoSeconds:5; |
| 1990 | __u16 Minutes:6; |
| 1991 | __u16 Hours:5; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 1992 | } __attribute__((packed)) SMB_TIME; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1993 | |
| 1994 | typedef struct { |
| 1995 | __le16 CreationDate; /* SMB Date see above */ |
| 1996 | __le16 CreationTime; /* SMB Time */ |
| 1997 | __le16 LastAccessDate; |
| 1998 | __le16 LastAccessTime; |
| 1999 | __le16 LastWriteDate; |
| 2000 | __le16 LastWriteTime; |
| 2001 | __le32 DataSize; /* File Size (EOF) */ |
| 2002 | __le32 AllocationSize; |
| 2003 | __le16 Attributes; /* verify not u32 */ |
| 2004 | __le32 EASize; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 2005 | } __attribute__((packed)) FILE_INFO_STANDARD; /* level 1 SetPath/FileInfo */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2006 | |
| 2007 | typedef struct { |
| 2008 | __le64 CreationTime; |
| 2009 | __le64 LastAccessTime; |
| 2010 | __le64 LastWriteTime; |
| 2011 | __le64 ChangeTime; |
| 2012 | __le32 Attributes; |
| 2013 | __u32 Pad; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 2014 | } __attribute__((packed)) FILE_BASIC_INFO; /* size info, level 0x101 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2015 | |
| 2016 | struct file_allocation_info { |
| 2017 | __le64 AllocationSize; /* Note old Samba srvr rounds this up too much */ |
Steve French | 5bafd76 | 2006-06-07 00:18:43 +0000 | [diff] [blame] | 2018 | } __attribute__((packed)); /* size used on disk, for level 0x103 for set, |
| 2019 | 0x105 for query */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2020 | |
| 2021 | struct file_end_of_file_info { |
| 2022 | __le64 FileSize; /* offset to end of file */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 2023 | } __attribute__((packed)); /* size info, level 0x104 for set, 0x106 for query */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2024 | |
| 2025 | struct file_alt_name_info { |
| 2026 | __u8 alt_name[1]; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 2027 | } __attribute__((packed)); /* level 0x0108 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2028 | |
| 2029 | struct file_stream_info { |
| 2030 | __le32 number_of_streams; /* BB check sizes and verify location */ |
| 2031 | /* followed by info on streams themselves |
| 2032 | u64 size; |
| 2033 | u64 allocation_size |
| 2034 | stream info */ |
| 2035 | }; /* level 0x109 */ |
| 2036 | |
| 2037 | struct file_compression_info { |
| 2038 | __le64 compressed_size; |
| 2039 | __le16 format; |
| 2040 | __u8 unit_shift; |
| 2041 | __u8 ch_shift; |
| 2042 | __u8 cl_shift; |
| 2043 | __u8 pad[3]; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 2044 | } __attribute__((packed)); /* level 0x10b */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2045 | |
| 2046 | /* POSIX ACL set/query path info structures */ |
| 2047 | #define CIFS_ACL_VERSION 1 |
| 2048 | struct cifs_posix_ace { /* access control entry (ACE) */ |
| 2049 | __u8 cifs_e_tag; |
| 2050 | __u8 cifs_e_perm; |
| 2051 | __le64 cifs_uid; /* or gid */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 2052 | } __attribute__((packed)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2053 | |
| 2054 | struct cifs_posix_acl { /* access conrol list (ACL) */ |
| 2055 | __le16 version; |
| 2056 | __le16 access_entry_count; /* access ACL - count of entries */ |
| 2057 | __le16 default_entry_count; /* default ACL - count of entries */ |
| 2058 | struct cifs_posix_ace ace_array[0]; |
| 2059 | /* followed by |
| 2060 | struct cifs_posix_ace default_ace_arraay[] */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 2061 | } __attribute__((packed)); /* level 0x204 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2062 | |
| 2063 | /* types of access control entries already defined in posix_acl.h */ |
| 2064 | /* #define CIFS_POSIX_ACL_USER_OBJ 0x01 |
| 2065 | #define CIFS_POSIX_ACL_USER 0x02 |
| 2066 | #define CIFS_POSIX_ACL_GROUP_OBJ 0x04 |
| 2067 | #define CIFS_POSIX_ACL_GROUP 0x08 |
| 2068 | #define CIFS_POSIX_ACL_MASK 0x10 |
| 2069 | #define CIFS_POSIX_ACL_OTHER 0x20 */ |
| 2070 | |
| 2071 | /* types of perms */ |
| 2072 | /* #define CIFS_POSIX_ACL_EXECUTE 0x01 |
| 2073 | #define CIFS_POSIX_ACL_WRITE 0x02 |
| 2074 | #define CIFS_POSIX_ACL_READ 0x04 */ |
| 2075 | |
| 2076 | /* end of POSIX ACL definitions */ |
| 2077 | |
| 2078 | struct file_internal_info { |
| 2079 | __u64 UniqueId; /* inode number */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 2080 | } __attribute__((packed)); /* level 0x3ee */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2081 | struct file_mode_info { |
| 2082 | __le32 Mode; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 2083 | } __attribute__((packed)); /* level 0x3f8 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2084 | |
| 2085 | struct file_attrib_tag { |
| 2086 | __le32 Attribute; |
| 2087 | __le32 ReparseTag; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 2088 | } __attribute__((packed)); /* level 0x40b */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2089 | |
| 2090 | |
| 2091 | /********************************************************/ |
| 2092 | /* FindFirst/FindNext transact2 data buffer formats */ |
| 2093 | /********************************************************/ |
| 2094 | |
| 2095 | typedef struct { |
| 2096 | __le32 NextEntryOffset; |
| 2097 | __u32 ResumeKey; /* as with FileIndex - no need to convert */ |
| 2098 | __le64 EndOfFile; |
| 2099 | __le64 NumOfBytes; |
| 2100 | __le64 LastStatusChange; /*SNIA specs DCE time for the 3 time fields */ |
| 2101 | __le64 LastAccessTime; |
| 2102 | __le64 LastModificationTime; |
| 2103 | __le64 Uid; |
| 2104 | __le64 Gid; |
| 2105 | __le32 Type; |
| 2106 | __le64 DevMajor; |
| 2107 | __le64 DevMinor; |
| 2108 | __u64 UniqueId; |
| 2109 | __le64 Permissions; |
| 2110 | __le64 Nlinks; |
| 2111 | char FileName[1]; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 2112 | } __attribute__((packed)) FILE_UNIX_INFO; /* level 0x202 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2113 | |
| 2114 | typedef struct { |
| 2115 | __le32 NextEntryOffset; |
| 2116 | __u32 FileIndex; |
| 2117 | __le64 CreationTime; |
| 2118 | __le64 LastAccessTime; |
| 2119 | __le64 LastWriteTime; |
| 2120 | __le64 ChangeTime; |
| 2121 | __le64 EndOfFile; |
| 2122 | __le64 AllocationSize; |
| 2123 | __le32 ExtFileAttributes; |
| 2124 | __le32 FileNameLength; |
| 2125 | char FileName[1]; |
Steve French | 5bafd76 | 2006-06-07 00:18:43 +0000 | [diff] [blame] | 2126 | } __attribute__((packed)) FILE_DIRECTORY_INFO; /* level 0x101 FF resp data */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2127 | |
| 2128 | typedef struct { |
| 2129 | __le32 NextEntryOffset; |
| 2130 | __u32 FileIndex; |
| 2131 | __le64 CreationTime; |
| 2132 | __le64 LastAccessTime; |
| 2133 | __le64 LastWriteTime; |
| 2134 | __le64 ChangeTime; |
| 2135 | __le64 EndOfFile; |
| 2136 | __le64 AllocationSize; |
| 2137 | __le32 ExtFileAttributes; |
| 2138 | __le32 FileNameLength; |
| 2139 | __le32 EaSize; /* length of the xattrs */ |
| 2140 | char FileName[1]; |
Steve French | 5bafd76 | 2006-06-07 00:18:43 +0000 | [diff] [blame] | 2141 | } __attribute__((packed)) FILE_FULL_DIRECTORY_INFO; /* level 0x102 rsp data */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2142 | |
| 2143 | typedef struct { |
| 2144 | __le32 NextEntryOffset; |
| 2145 | __u32 FileIndex; |
| 2146 | __le64 CreationTime; |
| 2147 | __le64 LastAccessTime; |
| 2148 | __le64 LastWriteTime; |
| 2149 | __le64 ChangeTime; |
| 2150 | __le64 EndOfFile; |
| 2151 | __le64 AllocationSize; |
| 2152 | __le32 ExtFileAttributes; |
| 2153 | __le32 FileNameLength; |
| 2154 | __le32 EaSize; /* EA size */ |
| 2155 | __le32 Reserved; |
| 2156 | __u64 UniqueId; /* inode num - le since Samba puts ino in low 32 bit*/ |
| 2157 | char FileName[1]; |
Steve French | 5bafd76 | 2006-06-07 00:18:43 +0000 | [diff] [blame] | 2158 | } __attribute__((packed)) SEARCH_ID_FULL_DIR_INFO; /* level 0x105 FF rsp data */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2159 | |
| 2160 | typedef struct { |
| 2161 | __le32 NextEntryOffset; |
| 2162 | __u32 FileIndex; |
| 2163 | __le64 CreationTime; |
| 2164 | __le64 LastAccessTime; |
| 2165 | __le64 LastWriteTime; |
| 2166 | __le64 ChangeTime; |
| 2167 | __le64 EndOfFile; |
| 2168 | __le64 AllocationSize; |
| 2169 | __le32 ExtFileAttributes; |
| 2170 | __le32 FileNameLength; |
| 2171 | __le32 EaSize; /* length of the xattrs */ |
| 2172 | __u8 ShortNameLength; |
| 2173 | __u8 Reserved; |
| 2174 | __u8 ShortName[12]; |
| 2175 | char FileName[1]; |
Steve French | 5bafd76 | 2006-06-07 00:18:43 +0000 | [diff] [blame] | 2176 | } __attribute__((packed)) FILE_BOTH_DIRECTORY_INFO; /* level 0x104 FFrsp data */ |
| 2177 | |
| 2178 | typedef struct { |
| 2179 | __u32 ResumeKey; |
| 2180 | __le16 CreationDate; /* SMB Date */ |
| 2181 | __le16 CreationTime; /* SMB Time */ |
| 2182 | __le16 LastAccessDate; |
| 2183 | __le16 LastAccessTime; |
| 2184 | __le16 LastWriteDate; |
| 2185 | __le16 LastWriteTime; |
| 2186 | __le32 DataSize; /* File Size (EOF) */ |
| 2187 | __le32 AllocationSize; |
| 2188 | __le16 Attributes; /* verify not u32 */ |
| 2189 | __u8 FileNameLength; |
| 2190 | char FileName[1]; |
| 2191 | } __attribute__((packed)) FIND_FILE_STANDARD_INFO; /* level 0x1 FF resp data */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2192 | |
| 2193 | |
Steve French | 86c96b4 | 2005-11-18 20:25:31 -0800 | [diff] [blame] | 2194 | struct win_dev { |
| 2195 | unsigned char type[8]; /* IntxCHR or IntxBLK */ |
| 2196 | __le64 major; |
| 2197 | __le64 minor; |
| 2198 | } __attribute__((packed)); |
| 2199 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2200 | struct gea { |
| 2201 | unsigned char name_len; |
| 2202 | char name[1]; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 2203 | } __attribute__((packed)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2204 | |
| 2205 | struct gealist { |
| 2206 | unsigned long list_len; |
| 2207 | struct gea list[1]; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 2208 | } __attribute__((packed)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2209 | |
| 2210 | struct fea { |
| 2211 | unsigned char EA_flags; |
| 2212 | __u8 name_len; |
| 2213 | __le16 value_len; |
| 2214 | char name[1]; |
| 2215 | /* optionally followed by value */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 2216 | } __attribute__((packed)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2217 | /* flags for _FEA.fEA */ |
| 2218 | #define FEA_NEEDEA 0x80 /* need EA bit */ |
| 2219 | |
| 2220 | struct fealist { |
| 2221 | __le32 list_len; |
| 2222 | struct fea list[1]; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 2223 | } __attribute__((packed)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2224 | |
| 2225 | /* used to hold an arbitrary blob of data */ |
| 2226 | struct data_blob { |
| 2227 | __u8 *data; |
| 2228 | size_t length; |
| 2229 | void (*free) (struct data_blob * data_blob); |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 2230 | } __attribute__((packed)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2231 | |
| 2232 | |
| 2233 | #ifdef CONFIG_CIFS_POSIX |
| 2234 | /* |
| 2235 | For better POSIX semantics from Linux client, (even better |
| 2236 | than the existing CIFS Unix Extensions) we need updated PDUs for: |
| 2237 | |
| 2238 | 1) PosixCreateX - to set and return the mode, inode#, device info and |
| 2239 | perhaps add a CreateDevice - to create Pipes and other special .inodes |
| 2240 | Also note POSIX open flags |
| 2241 | 2) Close - to return the last write time to do cache across close more safely |
Steve French | 1982c34 | 2005-08-17 12:38:22 -0700 | [diff] [blame] | 2242 | 3) FindFirst return unique inode number - what about resume key, two |
| 2243 | forms short (matches readdir) and full (enough info to cache inodes) |
| 2244 | 4) Mkdir - set mode |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2245 | |
| 2246 | And under consideration: |
Steve French | 1982c34 | 2005-08-17 12:38:22 -0700 | [diff] [blame] | 2247 | 5) FindClose2 (return nanosecond timestamp ??) |
| 2248 | 6) Use nanosecond timestamps throughout all time fields if |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2249 | corresponding attribute flag is set |
Steve French | 1982c34 | 2005-08-17 12:38:22 -0700 | [diff] [blame] | 2250 | 7) sendfile - handle based copy |
| 2251 | 8) Direct i/o |
| 2252 | 9) Misc fcntls? |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2253 | |
| 2254 | what about fixing 64 bit alignment |
| 2255 | |
| 2256 | There are also various legacy SMB/CIFS requests used as is |
| 2257 | |
| 2258 | From existing Lanman and NTLM dialects: |
| 2259 | -------------------------------------- |
| 2260 | NEGOTIATE |
| 2261 | SESSION_SETUP_ANDX (BB which?) |
| 2262 | TREE_CONNECT_ANDX (BB which wct?) |
| 2263 | TREE_DISCONNECT (BB add volume timestamp on response) |
| 2264 | LOGOFF_ANDX |
| 2265 | DELETE (note delete open file behavior) |
| 2266 | DELETE_DIRECTORY |
| 2267 | READ_AND_X |
| 2268 | WRITE_AND_X |
| 2269 | LOCKING_AND_X (note posix lock semantics) |
| 2270 | RENAME (note rename across dirs and open file rename posix behaviors) |
| 2271 | NT_RENAME (for hardlinks) Is this good enough for all features? |
| 2272 | FIND_CLOSE2 |
| 2273 | TRANSACTION2 (18 cases) |
| 2274 | SMB_SET_FILE_END_OF_FILE_INFO2 SMB_SET_PATH_END_OF_FILE_INFO2 |
| 2275 | (BB verify that never need to set allocation size) |
| 2276 | SMB_SET_FILE_BASIC_INFO2 (setting times - BB can it be done via Unix ext?) |
| 2277 | |
| 2278 | COPY (note support for copy across directories) - FUTURE, OPTIONAL |
| 2279 | setting/getting OS/2 EAs - FUTURE (BB can this handle |
| 2280 | setting Linux xattrs perfectly) - OPTIONAL |
| 2281 | dnotify - FUTURE, OPTIONAL |
| 2282 | quota - FUTURE, OPTIONAL |
| 2283 | |
| 2284 | Note that various requests implemented for NT interop such as |
| 2285 | NT_TRANSACT (IOCTL) QueryReparseInfo |
| 2286 | are unneeded to servers compliant with the CIFS POSIX extensions |
| 2287 | |
| 2288 | From CIFS Unix Extensions: |
| 2289 | ------------------------- |
| 2290 | T2 SET_PATH_INFO (SMB_SET_FILE_UNIX_LINK) for symlinks |
| 2291 | T2 SET_PATH_INFO (SMB_SET_FILE_BASIC_INFO2) |
| 2292 | T2 QUERY_PATH_INFO (SMB_QUERY_FILE_UNIX_LINK) |
| 2293 | T2 QUERY_PATH_INFO (SMB_QUERY_FILE_UNIX_BASIC) - BB check for missing inode fields |
| 2294 | Actually need QUERY_FILE_UNIX_INFO since has inode num |
| 2295 | BB what about a) blksize/blkbits/blocks |
| 2296 | b) i_version |
| 2297 | c) i_rdev |
| 2298 | d) notify mask? |
| 2299 | e) generation |
| 2300 | f) size_seqcount |
| 2301 | T2 FIND_FIRST/FIND_NEXT FIND_FILE_UNIX |
| 2302 | TRANS2_GET_DFS_REFERRAL - OPTIONAL but recommended |
| 2303 | T2_QFS_INFO QueryDevice/AttributeInfo - OPTIONAL |
| 2304 | |
| 2305 | |
| 2306 | */ |
| 2307 | |
Steve French | 1982c34 | 2005-08-17 12:38:22 -0700 | [diff] [blame] | 2308 | /* xsymlink is a symlink format (used by MacOS) that can be used |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2309 | to save symlink info in a regular file when |
| 2310 | mounted to operating systems that do not |
| 2311 | support the cifs Unix extensions or EAs (for xattr |
| 2312 | based symlinks). For such a file to be recognized |
| 2313 | as containing symlink data: |
| 2314 | |
| 2315 | 1) file size must be 1067, |
| 2316 | 2) signature must begin file data, |
| 2317 | 3) length field must be set to ASCII representation |
| 2318 | of a number which is less than or equal to 1024, |
| 2319 | 4) md5 must match that of the path data */ |
| 2320 | |
| 2321 | struct xsymlink { |
| 2322 | /* 1067 bytes */ |
| 2323 | char signature[4]; /* XSym */ /* not null terminated */ |
| 2324 | char cr0; /* \n */ |
| 2325 | /* ASCII representation of length (4 bytes decimal) terminated by \n not null */ |
| 2326 | char length[4]; |
| 2327 | char cr1; /* \n */ |
| 2328 | /* md5 of valid subset of path ie path[0] through path[length-1] */ |
| 2329 | __u8 md5[32]; |
| 2330 | char cr2; /* \n */ |
| 2331 | /* if room left, then end with \n then 0x20s by convention but not required */ |
| 2332 | char path[1024]; |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 2333 | } __attribute__((packed)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2334 | |
Steve French | f654bac | 2005-04-28 22:41:04 -0700 | [diff] [blame] | 2335 | typedef struct file_xattr_info { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2336 | /* BB do we need another field for flags? BB */ |
| 2337 | __u32 xattr_name_len; |
| 2338 | __u32 xattr_value_len; |
| 2339 | char xattr_name[0]; |
| 2340 | /* followed by xattr_value[xattr_value_len], no pad */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 2341 | } __attribute__((packed)) FILE_XATTR_INFO; /* extended attribute, info level 0x205 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2342 | |
| 2343 | |
Steve French | f654bac | 2005-04-28 22:41:04 -0700 | [diff] [blame] | 2344 | /* flags for chattr command */ |
| 2345 | #define EXT_SECURE_DELETE 0x00000001 /* EXT3_SECRM_FL */ |
| 2346 | #define EXT_ENABLE_UNDELETE 0x00000002 /* EXT3_UNRM_FL */ |
| 2347 | /* Reserved for compress file 0x4 */ |
| 2348 | #define EXT_SYNCHRONOUS 0x00000008 /* EXT3_SYNC_FL */ |
| 2349 | #define EXT_IMMUTABLE_FL 0x00000010 /* EXT3_IMMUTABLE_FL */ |
| 2350 | #define EXT_OPEN_APPEND_ONLY 0x00000020 /* EXT3_APPEND_FL */ |
| 2351 | #define EXT_DO_NOT_BACKUP 0x00000040 /* EXT3_NODUMP_FL */ |
| 2352 | #define EXT_NO_UPDATE_ATIME 0x00000080 /* EXT3_NOATIME_FL */ |
| 2353 | /* 0x100 through 0x800 reserved for compression flags and are GET-ONLY */ |
| 2354 | #define EXT_HASH_TREE_INDEXED_DIR 0x00001000 /* GET-ONLY EXT3_INDEX_FL */ |
| 2355 | /* 0x2000 reserved for IMAGIC_FL */ |
| 2356 | #define EXT_JOURNAL_THIS_FILE 0x00004000 /* GET-ONLY EXT3_JOURNAL_DATA_FL */ |
| 2357 | /* 0x8000 reserved for EXT3_NOTAIL_FL */ |
| 2358 | #define EXT_SYNCHRONOUS_DIR 0x00010000 /* EXT3_DIRSYNC_FL */ |
| 2359 | #define EXT_TOPDIR 0x00020000 /* EXT3_TOPDIR_FL */ |
| 2360 | |
| 2361 | #define EXT_SET_MASK 0x000300FF |
| 2362 | #define EXT_GET_MASK 0x0003DFFF |
| 2363 | |
| 2364 | typedef struct file_chattr_info { |
| 2365 | __le64 mask; /* list of all possible attribute bits */ |
| 2366 | __le64 mode; /* list of actual attribute bits on this inode */ |
Steve French | 0753ca7 | 2005-10-27 13:55:12 -0700 | [diff] [blame] | 2367 | } __attribute__((packed)) FILE_CHATTR_INFO; /* ext attributes (chattr, chflags) level 0x206 */ |
Steve French | f654bac | 2005-04-28 22:41:04 -0700 | [diff] [blame] | 2368 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2369 | #endif |
| 2370 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2371 | #endif /* _CIFSPDU_H */ |