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