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