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