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