smb2pdu.h 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061
  1. /*
  2. * fs/cifs/smb2pdu.h
  3. *
  4. * Copyright (c) International Business Machines Corp., 2009, 2013
  5. * Etersoft, 2012
  6. * Author(s): Steve French (sfrench@us.ibm.com)
  7. * Pavel Shilovsky (pshilovsky@samba.org) 2012
  8. *
  9. * This library is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU Lesser General Public License as published
  11. * by the Free Software Foundation; either version 2.1 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
  17. * the GNU Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public License
  20. * along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. */
  23. #ifndef _SMB2PDU_H
  24. #define _SMB2PDU_H
  25. #include <net/sock.h>
  26. /*
  27. * Note that, due to trying to use names similar to the protocol specifications,
  28. * there are many mixed case field names in the structures below. Although
  29. * this does not match typical Linux kernel style, it is necessary to be
  30. * be able to match against the protocol specfication.
  31. *
  32. * SMB2 commands
  33. * Some commands have minimal (wct=0,bcc=0), or uninteresting, responses
  34. * (ie no useful data other than the SMB error code itself) and are marked such.
  35. * Knowing this helps avoid response buffer allocations and copy in some cases.
  36. */
  37. /* List of commands in host endian */
  38. #define SMB2_NEGOTIATE_HE 0x0000
  39. #define SMB2_SESSION_SETUP_HE 0x0001
  40. #define SMB2_LOGOFF_HE 0x0002 /* trivial request/resp */
  41. #define SMB2_TREE_CONNECT_HE 0x0003
  42. #define SMB2_TREE_DISCONNECT_HE 0x0004 /* trivial req/resp */
  43. #define SMB2_CREATE_HE 0x0005
  44. #define SMB2_CLOSE_HE 0x0006
  45. #define SMB2_FLUSH_HE 0x0007 /* trivial resp */
  46. #define SMB2_READ_HE 0x0008
  47. #define SMB2_WRITE_HE 0x0009
  48. #define SMB2_LOCK_HE 0x000A
  49. #define SMB2_IOCTL_HE 0x000B
  50. #define SMB2_CANCEL_HE 0x000C
  51. #define SMB2_ECHO_HE 0x000D
  52. #define SMB2_QUERY_DIRECTORY_HE 0x000E
  53. #define SMB2_CHANGE_NOTIFY_HE 0x000F
  54. #define SMB2_QUERY_INFO_HE 0x0010
  55. #define SMB2_SET_INFO_HE 0x0011
  56. #define SMB2_OPLOCK_BREAK_HE 0x0012
  57. /* The same list in little endian */
  58. #define SMB2_NEGOTIATE cpu_to_le16(SMB2_NEGOTIATE_HE)
  59. #define SMB2_SESSION_SETUP cpu_to_le16(SMB2_SESSION_SETUP_HE)
  60. #define SMB2_LOGOFF cpu_to_le16(SMB2_LOGOFF_HE)
  61. #define SMB2_TREE_CONNECT cpu_to_le16(SMB2_TREE_CONNECT_HE)
  62. #define SMB2_TREE_DISCONNECT cpu_to_le16(SMB2_TREE_DISCONNECT_HE)
  63. #define SMB2_CREATE cpu_to_le16(SMB2_CREATE_HE)
  64. #define SMB2_CLOSE cpu_to_le16(SMB2_CLOSE_HE)
  65. #define SMB2_FLUSH cpu_to_le16(SMB2_FLUSH_HE)
  66. #define SMB2_READ cpu_to_le16(SMB2_READ_HE)
  67. #define SMB2_WRITE cpu_to_le16(SMB2_WRITE_HE)
  68. #define SMB2_LOCK cpu_to_le16(SMB2_LOCK_HE)
  69. #define SMB2_IOCTL cpu_to_le16(SMB2_IOCTL_HE)
  70. #define SMB2_CANCEL cpu_to_le16(SMB2_CANCEL_HE)
  71. #define SMB2_ECHO cpu_to_le16(SMB2_ECHO_HE)
  72. #define SMB2_QUERY_DIRECTORY cpu_to_le16(SMB2_QUERY_DIRECTORY_HE)
  73. #define SMB2_CHANGE_NOTIFY cpu_to_le16(SMB2_CHANGE_NOTIFY_HE)
  74. #define SMB2_QUERY_INFO cpu_to_le16(SMB2_QUERY_INFO_HE)
  75. #define SMB2_SET_INFO cpu_to_le16(SMB2_SET_INFO_HE)
  76. #define SMB2_OPLOCK_BREAK cpu_to_le16(SMB2_OPLOCK_BREAK_HE)
  77. #define NUMBER_OF_SMB2_COMMANDS 0x0013
  78. /* BB FIXME - analyze following length BB */
  79. #define MAX_SMB2_HDR_SIZE 0x78 /* 4 len + 64 hdr + (2*24 wct) + 2 bct + 2 pad */
  80. #define SMB2_PROTO_NUMBER __constant_cpu_to_le32(0x424d53fe)
  81. /*
  82. * SMB2 Header Definition
  83. *
  84. * "MBZ" : Must be Zero
  85. * "BB" : BugBug, Something to check/review/analyze later
  86. * "PDU" : "Protocol Data Unit" (ie a network "frame")
  87. *
  88. */
  89. #define SMB2_HEADER_STRUCTURE_SIZE __constant_cpu_to_le16(64)
  90. struct smb2_hdr {
  91. __be32 smb2_buf_length; /* big endian on wire */
  92. /* length is only two or three bytes - with
  93. one or two byte type preceding it that MBZ */
  94. __u8 ProtocolId[4]; /* 0xFE 'S' 'M' 'B' */
  95. __le16 StructureSize; /* 64 */
  96. __le16 CreditCharge; /* MBZ */
  97. __le32 Status; /* Error from server */
  98. __le16 Command;
  99. __le16 CreditRequest; /* CreditResponse */
  100. __le32 Flags;
  101. __le32 NextCommand;
  102. __u64 MessageId; /* opaque - so can stay little endian */
  103. __le32 ProcessId;
  104. __u32 TreeId; /* opaque - so do not make little endian */
  105. __u64 SessionId; /* opaque - so do not make little endian */
  106. __u8 Signature[16];
  107. } __packed;
  108. struct smb2_pdu {
  109. struct smb2_hdr hdr;
  110. __le16 StructureSize2; /* size of wct area (varies, request specific) */
  111. } __packed;
  112. struct smb2_transform_hdr {
  113. __be32 smb2_buf_length; /* big endian on wire */
  114. /* length is only two or three bytes - with
  115. one or two byte type preceding it that MBZ */
  116. __u8 ProtocolId[4]; /* 0xFD 'S' 'M' 'B' */
  117. __u8 Signature[16];
  118. __u8 Nonce[11];
  119. __u8 Reserved[5];
  120. __le32 OriginalMessageSize;
  121. __u16 Reserved1;
  122. __le16 EncryptionAlgorithm;
  123. __u64 SessionId;
  124. } __packed;
  125. /* Encryption Algorithms */
  126. #define SMB2_ENCRYPTION_AES128_CCM __constant_cpu_to_le16(0x0001)
  127. /*
  128. * SMB2 flag definitions
  129. */
  130. #define SMB2_FLAGS_SERVER_TO_REDIR __constant_cpu_to_le32(0x00000001)
  131. #define SMB2_FLAGS_ASYNC_COMMAND __constant_cpu_to_le32(0x00000002)
  132. #define SMB2_FLAGS_RELATED_OPERATIONS __constant_cpu_to_le32(0x00000004)
  133. #define SMB2_FLAGS_SIGNED __constant_cpu_to_le32(0x00000008)
  134. #define SMB2_FLAGS_DFS_OPERATIONS __constant_cpu_to_le32(0x10000000)
  135. /*
  136. * Definitions for SMB2 Protocol Data Units (network frames)
  137. *
  138. * See MS-SMB2.PDF specification for protocol details.
  139. * The Naming convention is the lower case version of the SMB2
  140. * command code name for the struct. Note that structures must be packed.
  141. *
  142. */
  143. #define SMB2_ERROR_STRUCTURE_SIZE2 __constant_cpu_to_le16(9)
  144. struct smb2_err_rsp {
  145. struct smb2_hdr hdr;
  146. __le16 StructureSize;
  147. __le16 Reserved; /* MBZ */
  148. __le32 ByteCount; /* even if zero, at least one byte follows */
  149. __u8 ErrorData[1]; /* variable length */
  150. } __packed;
  151. struct smb2_symlink_err_rsp {
  152. __le32 SymLinkLength;
  153. __le32 SymLinkErrorTag;
  154. __le32 ReparseTag;
  155. __le16 ReparseDataLength;
  156. __le16 UnparsedPathLength;
  157. __le16 SubstituteNameOffset;
  158. __le16 SubstituteNameLength;
  159. __le16 PrintNameOffset;
  160. __le16 PrintNameLength;
  161. __le32 Flags;
  162. __u8 PathBuffer[0];
  163. } __packed;
  164. #define SMB2_CLIENT_GUID_SIZE 16
  165. struct smb2_negotiate_req {
  166. struct smb2_hdr hdr;
  167. __le16 StructureSize; /* Must be 36 */
  168. __le16 DialectCount;
  169. __le16 SecurityMode;
  170. __le16 Reserved; /* MBZ */
  171. __le32 Capabilities;
  172. __u8 ClientGUID[SMB2_CLIENT_GUID_SIZE];
  173. __le64 ClientStartTime; /* MBZ */
  174. __le16 Dialects[1]; /* One dialect (vers=) at a time for now */
  175. } __packed;
  176. /* Dialects */
  177. #define SMB20_PROT_ID 0x0202
  178. #define SMB21_PROT_ID 0x0210
  179. #define SMB30_PROT_ID 0x0300
  180. #define SMB302_PROT_ID 0x0302
  181. #define BAD_PROT_ID 0xFFFF
  182. /* SecurityMode flags */
  183. #define SMB2_NEGOTIATE_SIGNING_ENABLED 0x0001
  184. #define SMB2_NEGOTIATE_SIGNING_REQUIRED 0x0002
  185. /* Capabilities flags */
  186. #define SMB2_GLOBAL_CAP_DFS 0x00000001
  187. #define SMB2_GLOBAL_CAP_LEASING 0x00000002 /* Resp only New to SMB2.1 */
  188. #define SMB2_GLOBAL_CAP_LARGE_MTU 0X00000004 /* Resp only New to SMB2.1 */
  189. #define SMB2_GLOBAL_CAP_MULTI_CHANNEL 0x00000008 /* New to SMB3 */
  190. #define SMB2_GLOBAL_CAP_PERSISTENT_HANDLES 0x00000010 /* New to SMB3 */
  191. #define SMB2_GLOBAL_CAP_DIRECTORY_LEASING 0x00000020 /* New to SMB3 */
  192. #define SMB2_GLOBAL_CAP_ENCRYPTION 0x00000040 /* New to SMB3 */
  193. /* Internal types */
  194. #define SMB2_NT_FIND 0x00100000
  195. #define SMB2_LARGE_FILES 0x00200000
  196. struct smb2_negotiate_rsp {
  197. struct smb2_hdr hdr;
  198. __le16 StructureSize; /* Must be 65 */
  199. __le16 SecurityMode;
  200. __le16 DialectRevision;
  201. __le16 Reserved; /* MBZ */
  202. __u8 ServerGUID[16];
  203. __le32 Capabilities;
  204. __le32 MaxTransactSize;
  205. __le32 MaxReadSize;
  206. __le32 MaxWriteSize;
  207. __le64 SystemTime; /* MBZ */
  208. __le64 ServerStartTime;
  209. __le16 SecurityBufferOffset;
  210. __le16 SecurityBufferLength;
  211. __le32 Reserved2; /* may be any value, ignore */
  212. __u8 Buffer[1]; /* variable length GSS security buffer */
  213. } __packed;
  214. struct smb2_sess_setup_req {
  215. struct smb2_hdr hdr;
  216. __le16 StructureSize; /* Must be 25 */
  217. __u8 VcNumber;
  218. __u8 SecurityMode;
  219. __le32 Capabilities;
  220. __le32 Channel;
  221. __le16 SecurityBufferOffset;
  222. __le16 SecurityBufferLength;
  223. __le64 PreviousSessionId;
  224. __u8 Buffer[1]; /* variable length GSS security buffer */
  225. } __packed;
  226. /* Currently defined SessionFlags */
  227. #define SMB2_SESSION_FLAG_IS_GUEST 0x0001
  228. #define SMB2_SESSION_FLAG_IS_NULL 0x0002
  229. #define SMB2_SESSION_FLAG_ENCRYPT_DATA 0x0004
  230. struct smb2_sess_setup_rsp {
  231. struct smb2_hdr hdr;
  232. __le16 StructureSize; /* Must be 9 */
  233. __le16 SessionFlags;
  234. __le16 SecurityBufferOffset;
  235. __le16 SecurityBufferLength;
  236. __u8 Buffer[1]; /* variable length GSS security buffer */
  237. } __packed;
  238. struct smb2_logoff_req {
  239. struct smb2_hdr hdr;
  240. __le16 StructureSize; /* Must be 4 */
  241. __le16 Reserved;
  242. } __packed;
  243. struct smb2_logoff_rsp {
  244. struct smb2_hdr hdr;
  245. __le16 StructureSize; /* Must be 4 */
  246. __le16 Reserved;
  247. } __packed;
  248. struct smb2_tree_connect_req {
  249. struct smb2_hdr hdr;
  250. __le16 StructureSize; /* Must be 9 */
  251. __le16 Reserved;
  252. __le16 PathOffset;
  253. __le16 PathLength;
  254. __u8 Buffer[1]; /* variable length */
  255. } __packed;
  256. struct smb2_tree_connect_rsp {
  257. struct smb2_hdr hdr;
  258. __le16 StructureSize; /* Must be 16 */
  259. __u8 ShareType; /* see below */
  260. __u8 Reserved;
  261. __le32 ShareFlags; /* see below */
  262. __le32 Capabilities; /* see below */
  263. __le32 MaximalAccess;
  264. } __packed;
  265. /* Possible ShareType values */
  266. #define SMB2_SHARE_TYPE_DISK 0x01
  267. #define SMB2_SHARE_TYPE_PIPE 0x02
  268. #define SMB2_SHARE_TYPE_PRINT 0x03
  269. /*
  270. * Possible ShareFlags - exactly one and only one of the first 4 caching flags
  271. * must be set (any of the remaining, SHI1005, flags may be set individually
  272. * or in combination.
  273. */
  274. #define SMB2_SHAREFLAG_MANUAL_CACHING 0x00000000
  275. #define SMB2_SHAREFLAG_AUTO_CACHING 0x00000010
  276. #define SMB2_SHAREFLAG_VDO_CACHING 0x00000020
  277. #define SMB2_SHAREFLAG_NO_CACHING 0x00000030
  278. #define SHI1005_FLAGS_DFS 0x00000001
  279. #define SHI1005_FLAGS_DFS_ROOT 0x00000002
  280. #define SHI1005_FLAGS_RESTRICT_EXCLUSIVE_OPENS 0x00000100
  281. #define SHI1005_FLAGS_FORCE_SHARED_DELETE 0x00000200
  282. #define SHI1005_FLAGS_ALLOW_NAMESPACE_CACHING 0x00000400
  283. #define SHI1005_FLAGS_ACCESS_BASED_DIRECTORY_ENUM 0x00000800
  284. #define SHI1005_FLAGS_FORCE_LEVELII_OPLOCK 0x00001000
  285. #define SHI1005_FLAGS_ENABLE_HASH_V1 0x00002000
  286. #define SHI1005_FLAGS_ENABLE_HASH_V2 0x00004000
  287. #define SHI1005_FLAGS_ENCRYPT_DATA 0x00008000
  288. #define SHI1005_FLAGS_ALL 0x0000FF33
  289. /* Possible share capabilities */
  290. #define SMB2_SHARE_CAP_DFS cpu_to_le32(0x00000008) /* all dialects */
  291. #define SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY cpu_to_le32(0x00000010) /* 3.0 */
  292. #define SMB2_SHARE_CAP_SCALEOUT cpu_to_le32(0x00000020) /* 3.0 */
  293. #define SMB2_SHARE_CAP_CLUSTER cpu_to_le32(0x00000040) /* 3.0 */
  294. #define SMB2_SHARE_CAP_ASYMMETRIC cpu_to_le32(0x00000080) /* 3.02 */
  295. struct smb2_tree_disconnect_req {
  296. struct smb2_hdr hdr;
  297. __le16 StructureSize; /* Must be 4 */
  298. __le16 Reserved;
  299. } __packed;
  300. struct smb2_tree_disconnect_rsp {
  301. struct smb2_hdr hdr;
  302. __le16 StructureSize; /* Must be 4 */
  303. __le16 Reserved;
  304. } __packed;
  305. /* File Attrubutes */
  306. #define FILE_ATTRIBUTE_READONLY 0x00000001
  307. #define FILE_ATTRIBUTE_HIDDEN 0x00000002
  308. #define FILE_ATTRIBUTE_SYSTEM 0x00000004
  309. #define FILE_ATTRIBUTE_DIRECTORY 0x00000010
  310. #define FILE_ATTRIBUTE_ARCHIVE 0x00000020
  311. #define FILE_ATTRIBUTE_NORMAL 0x00000080
  312. #define FILE_ATTRIBUTE_TEMPORARY 0x00000100
  313. #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
  314. #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
  315. #define FILE_ATTRIBUTE_COMPRESSED 0x00000800
  316. #define FILE_ATTRIBUTE_OFFLINE 0x00001000
  317. #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
  318. #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
  319. #define FILE_ATTRIBUTE_INTEGRITY_STREAM 0x00008000
  320. #define FILE_ATTRIBUTE_NO_SCRUB_DATA 0x00020000
  321. /* Oplock levels */
  322. #define SMB2_OPLOCK_LEVEL_NONE 0x00
  323. #define SMB2_OPLOCK_LEVEL_II 0x01
  324. #define SMB2_OPLOCK_LEVEL_EXCLUSIVE 0x08
  325. #define SMB2_OPLOCK_LEVEL_BATCH 0x09
  326. #define SMB2_OPLOCK_LEVEL_LEASE 0xFF
  327. /* Non-spec internal type */
  328. #define SMB2_OPLOCK_LEVEL_NOCHANGE 0x99
  329. /* Desired Access Flags */
  330. #define FILE_READ_DATA_LE cpu_to_le32(0x00000001)
  331. #define FILE_WRITE_DATA_LE cpu_to_le32(0x00000002)
  332. #define FILE_APPEND_DATA_LE cpu_to_le32(0x00000004)
  333. #define FILE_READ_EA_LE cpu_to_le32(0x00000008)
  334. #define FILE_WRITE_EA_LE cpu_to_le32(0x00000010)
  335. #define FILE_EXECUTE_LE cpu_to_le32(0x00000020)
  336. #define FILE_READ_ATTRIBUTES_LE cpu_to_le32(0x00000080)
  337. #define FILE_WRITE_ATTRIBUTES_LE cpu_to_le32(0x00000100)
  338. #define FILE_DELETE_LE cpu_to_le32(0x00010000)
  339. #define FILE_READ_CONTROL_LE cpu_to_le32(0x00020000)
  340. #define FILE_WRITE_DAC_LE cpu_to_le32(0x00040000)
  341. #define FILE_WRITE_OWNER_LE cpu_to_le32(0x00080000)
  342. #define FILE_SYNCHRONIZE_LE cpu_to_le32(0x00100000)
  343. #define FILE_ACCESS_SYSTEM_SECURITY_LE cpu_to_le32(0x01000000)
  344. #define FILE_MAXIMAL_ACCESS_LE cpu_to_le32(0x02000000)
  345. #define FILE_GENERIC_ALL_LE cpu_to_le32(0x10000000)
  346. #define FILE_GENERIC_EXECUTE_LE cpu_to_le32(0x20000000)
  347. #define FILE_GENERIC_WRITE_LE cpu_to_le32(0x40000000)
  348. #define FILE_GENERIC_READ_LE cpu_to_le32(0x80000000)
  349. /* ShareAccess Flags */
  350. #define FILE_SHARE_READ_LE cpu_to_le32(0x00000001)
  351. #define FILE_SHARE_WRITE_LE cpu_to_le32(0x00000002)
  352. #define FILE_SHARE_DELETE_LE cpu_to_le32(0x00000004)
  353. #define FILE_SHARE_ALL_LE cpu_to_le32(0x00000007)
  354. /* CreateDisposition Flags */
  355. #define FILE_SUPERSEDE_LE cpu_to_le32(0x00000000)
  356. #define FILE_OPEN_LE cpu_to_le32(0x00000001)
  357. #define FILE_CREATE_LE cpu_to_le32(0x00000002)
  358. #define FILE_OPEN_IF_LE cpu_to_le32(0x00000003)
  359. #define FILE_OVERWRITE_LE cpu_to_le32(0x00000004)
  360. #define FILE_OVERWRITE_IF_LE cpu_to_le32(0x00000005)
  361. /* CreateOptions Flags */
  362. #define FILE_DIRECTORY_FILE_LE cpu_to_le32(0x00000001)
  363. /* same as #define CREATE_NOT_FILE_LE cpu_to_le32(0x00000001) */
  364. #define FILE_WRITE_THROUGH_LE cpu_to_le32(0x00000002)
  365. #define FILE_SEQUENTIAL_ONLY_LE cpu_to_le32(0x00000004)
  366. #define FILE_NO_INTERMEDIATE_BUFFERRING_LE cpu_to_le32(0x00000008)
  367. #define FILE_SYNCHRONOUS_IO_ALERT_LE cpu_to_le32(0x00000010)
  368. #define FILE_SYNCHRONOUS_IO_NON_ALERT_LE cpu_to_le32(0x00000020)
  369. #define FILE_NON_DIRECTORY_FILE_LE cpu_to_le32(0x00000040)
  370. #define FILE_COMPLETE_IF_OPLOCKED_LE cpu_to_le32(0x00000100)
  371. #define FILE_NO_EA_KNOWLEDGE_LE cpu_to_le32(0x00000200)
  372. #define FILE_RANDOM_ACCESS_LE cpu_to_le32(0x00000800)
  373. #define FILE_DELETE_ON_CLOSE_LE cpu_to_le32(0x00001000)
  374. #define FILE_OPEN_BY_FILE_ID_LE cpu_to_le32(0x00002000)
  375. #define FILE_OPEN_FOR_BACKUP_INTENT_LE cpu_to_le32(0x00004000)
  376. #define FILE_NO_COMPRESSION_LE cpu_to_le32(0x00008000)
  377. #define FILE_RESERVE_OPFILTER_LE cpu_to_le32(0x00100000)
  378. #define FILE_OPEN_REPARSE_POINT_LE cpu_to_le32(0x00200000)
  379. #define FILE_OPEN_NO_RECALL_LE cpu_to_le32(0x00400000)
  380. #define FILE_OPEN_FOR_FREE_SPACE_QUERY_LE cpu_to_le32(0x00800000)
  381. #define FILE_READ_RIGHTS_LE (FILE_READ_DATA_LE | FILE_READ_EA_LE \
  382. | FILE_READ_ATTRIBUTES_LE)
  383. #define FILE_WRITE_RIGHTS_LE (FILE_WRITE_DATA_LE | FILE_APPEND_DATA_LE \
  384. | FILE_WRITE_EA_LE | FILE_WRITE_ATTRIBUTES_LE)
  385. #define FILE_EXEC_RIGHTS_LE (FILE_EXECUTE_LE)
  386. /* Impersonation Levels */
  387. #define IL_ANONYMOUS cpu_to_le32(0x00000000)
  388. #define IL_IDENTIFICATION cpu_to_le32(0x00000001)
  389. #define IL_IMPERSONATION cpu_to_le32(0x00000002)
  390. #define IL_DELEGATE cpu_to_le32(0x00000003)
  391. /* Create Context Values */
  392. #define SMB2_CREATE_EA_BUFFER "ExtA" /* extended attributes */
  393. #define SMB2_CREATE_SD_BUFFER "SecD" /* security descriptor */
  394. #define SMB2_CREATE_DURABLE_HANDLE_REQUEST "DHnQ"
  395. #define SMB2_CREATE_DURABLE_HANDLE_RECONNECT "DHnC"
  396. #define SMB2_CREATE_ALLOCATION_SIZE "AISi"
  397. #define SMB2_CREATE_QUERY_MAXIMAL_ACCESS_REQUEST "MxAc"
  398. #define SMB2_CREATE_TIMEWARP_REQUEST "TWrp"
  399. #define SMB2_CREATE_QUERY_ON_DISK_ID "QFid"
  400. #define SMB2_CREATE_REQUEST_LEASE "RqLs"
  401. #define SMB2_CREATE_DURABLE_HANDLE_REQUEST_V2 "DH2Q"
  402. #define SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2 "DH2C"
  403. #define SMB2_CREATE_APP_INSTANCE_ID 0x45BCA66AEFA7F74A9008FA462E144D74
  404. #define SVHDX_OPEN_DEVICE_CONTEXT 0x83CE6F1AD851E0986E34401CC9BCFCE9
  405. struct smb2_create_req {
  406. struct smb2_hdr hdr;
  407. __le16 StructureSize; /* Must be 57 */
  408. __u8 SecurityFlags;
  409. __u8 RequestedOplockLevel;
  410. __le32 ImpersonationLevel;
  411. __le64 SmbCreateFlags;
  412. __le64 Reserved;
  413. __le32 DesiredAccess;
  414. __le32 FileAttributes;
  415. __le32 ShareAccess;
  416. __le32 CreateDisposition;
  417. __le32 CreateOptions;
  418. __le16 NameOffset;
  419. __le16 NameLength;
  420. __le32 CreateContextsOffset;
  421. __le32 CreateContextsLength;
  422. __u8 Buffer[0];
  423. } __packed;
  424. struct smb2_create_rsp {
  425. struct smb2_hdr hdr;
  426. __le16 StructureSize; /* Must be 89 */
  427. __u8 OplockLevel;
  428. __u8 Reserved;
  429. __le32 CreateAction;
  430. __le64 CreationTime;
  431. __le64 LastAccessTime;
  432. __le64 LastWriteTime;
  433. __le64 ChangeTime;
  434. __le64 AllocationSize;
  435. __le64 EndofFile;
  436. __le32 FileAttributes;
  437. __le32 Reserved2;
  438. __u64 PersistentFileId; /* opaque endianness */
  439. __u64 VolatileFileId; /* opaque endianness */
  440. __le32 CreateContextsOffset;
  441. __le32 CreateContextsLength;
  442. __u8 Buffer[1];
  443. } __packed;
  444. struct create_context {
  445. __le32 Next;
  446. __le16 NameOffset;
  447. __le16 NameLength;
  448. __le16 Reserved;
  449. __le16 DataOffset;
  450. __le32 DataLength;
  451. __u8 Buffer[0];
  452. } __packed;
  453. #define SMB2_LEASE_READ_CACHING_HE 0x01
  454. #define SMB2_LEASE_HANDLE_CACHING_HE 0x02
  455. #define SMB2_LEASE_WRITE_CACHING_HE 0x04
  456. #define SMB2_LEASE_NONE __constant_cpu_to_le32(0x00)
  457. #define SMB2_LEASE_READ_CACHING __constant_cpu_to_le32(0x01)
  458. #define SMB2_LEASE_HANDLE_CACHING __constant_cpu_to_le32(0x02)
  459. #define SMB2_LEASE_WRITE_CACHING __constant_cpu_to_le32(0x04)
  460. #define SMB2_LEASE_FLAG_BREAK_IN_PROGRESS __constant_cpu_to_le32(0x02)
  461. #define SMB2_LEASE_KEY_SIZE 16
  462. struct lease_context {
  463. __le64 LeaseKeyLow;
  464. __le64 LeaseKeyHigh;
  465. __le32 LeaseState;
  466. __le32 LeaseFlags;
  467. __le64 LeaseDuration;
  468. } __packed;
  469. struct lease_context_v2 {
  470. __le64 LeaseKeyLow;
  471. __le64 LeaseKeyHigh;
  472. __le32 LeaseState;
  473. __le32 LeaseFlags;
  474. __le64 LeaseDuration;
  475. __le64 ParentLeaseKeyLow;
  476. __le64 ParentLeaseKeyHigh;
  477. __le16 Epoch;
  478. __le16 Reserved;
  479. } __packed;
  480. struct create_lease {
  481. struct create_context ccontext;
  482. __u8 Name[8];
  483. struct lease_context lcontext;
  484. } __packed;
  485. struct create_lease_v2 {
  486. struct create_context ccontext;
  487. __u8 Name[8];
  488. struct lease_context_v2 lcontext;
  489. __u8 Pad[4];
  490. } __packed;
  491. struct create_durable {
  492. struct create_context ccontext;
  493. __u8 Name[8];
  494. union {
  495. __u8 Reserved[16];
  496. struct {
  497. __u64 PersistentFileId;
  498. __u64 VolatileFileId;
  499. } Fid;
  500. } Data;
  501. } __packed;
  502. #define COPY_CHUNK_RES_KEY_SIZE 24
  503. struct resume_key_req {
  504. char ResumeKey[COPY_CHUNK_RES_KEY_SIZE];
  505. __le32 ContextLength; /* MBZ */
  506. char Context[0]; /* ignored, Windows sets to 4 bytes of zero */
  507. } __packed;
  508. /* this goes in the ioctl buffer when doing a copychunk request */
  509. struct copychunk_ioctl {
  510. char SourceKey[COPY_CHUNK_RES_KEY_SIZE];
  511. __le32 ChunkCount; /* we are only sending 1 */
  512. __le32 Reserved;
  513. /* array will only be one chunk long for us */
  514. __le64 SourceOffset;
  515. __le64 TargetOffset;
  516. __le32 Length; /* how many bytes to copy */
  517. __u32 Reserved2;
  518. } __packed;
  519. /* this goes in the ioctl buffer when doing FSCTL_SET_ZERO_DATA */
  520. struct file_zero_data_information {
  521. __le64 FileOffset;
  522. __le64 BeyondFinalZero;
  523. } __packed;
  524. struct copychunk_ioctl_rsp {
  525. __le32 ChunksWritten;
  526. __le32 ChunkBytesWritten;
  527. __le32 TotalBytesWritten;
  528. } __packed;
  529. struct validate_negotiate_info_req {
  530. __le32 Capabilities;
  531. __u8 Guid[SMB2_CLIENT_GUID_SIZE];
  532. __le16 SecurityMode;
  533. __le16 DialectCount;
  534. __le16 Dialects[1]; /* dialect (someday maybe list) client asked for */
  535. } __packed;
  536. struct validate_negotiate_info_rsp {
  537. __le32 Capabilities;
  538. __u8 Guid[SMB2_CLIENT_GUID_SIZE];
  539. __le16 SecurityMode;
  540. __le16 Dialect; /* Dialect in use for the connection */
  541. } __packed;
  542. #define RSS_CAPABLE 0x00000001
  543. #define RDMA_CAPABLE 0x00000002
  544. struct network_interface_info_ioctl_rsp {
  545. __le32 Next; /* next interface. zero if this is last one */
  546. __le32 IfIndex;
  547. __le32 Capability; /* RSS or RDMA Capable */
  548. __le32 Reserved;
  549. __le64 LinkSpeed;
  550. char SockAddr_Storage[128];
  551. } __packed;
  552. #define NO_FILE_ID 0xFFFFFFFFFFFFFFFFULL /* general ioctls to srv not to file */
  553. struct compress_ioctl {
  554. __le16 CompressionState; /* See cifspdu.h for possible flag values */
  555. } __packed;
  556. struct smb2_ioctl_req {
  557. struct smb2_hdr hdr;
  558. __le16 StructureSize; /* Must be 57 */
  559. __u16 Reserved;
  560. __le32 CtlCode;
  561. __u64 PersistentFileId; /* opaque endianness */
  562. __u64 VolatileFileId; /* opaque endianness */
  563. __le32 InputOffset;
  564. __le32 InputCount;
  565. __le32 MaxInputResponse;
  566. __le32 OutputOffset;
  567. __le32 OutputCount;
  568. __le32 MaxOutputResponse;
  569. __le32 Flags;
  570. __u32 Reserved2;
  571. __u8 Buffer[0];
  572. } __packed;
  573. struct smb2_ioctl_rsp {
  574. struct smb2_hdr hdr;
  575. __le16 StructureSize; /* Must be 57 */
  576. __u16 Reserved;
  577. __le32 CtlCode;
  578. __u64 PersistentFileId; /* opaque endianness */
  579. __u64 VolatileFileId; /* opaque endianness */
  580. __le32 InputOffset;
  581. __le32 InputCount;
  582. __le32 OutputOffset;
  583. __le32 OutputCount;
  584. __le32 Flags;
  585. __u32 Reserved2;
  586. /* char * buffer[] */
  587. } __packed;
  588. /* Currently defined values for close flags */
  589. #define SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB cpu_to_le16(0x0001)
  590. struct smb2_close_req {
  591. struct smb2_hdr hdr;
  592. __le16 StructureSize; /* Must be 24 */
  593. __le16 Flags;
  594. __le32 Reserved;
  595. __u64 PersistentFileId; /* opaque endianness */
  596. __u64 VolatileFileId; /* opaque endianness */
  597. } __packed;
  598. struct smb2_close_rsp {
  599. struct smb2_hdr hdr;
  600. __le16 StructureSize; /* 60 */
  601. __le16 Flags;
  602. __le32 Reserved;
  603. __le64 CreationTime;
  604. __le64 LastAccessTime;
  605. __le64 LastWriteTime;
  606. __le64 ChangeTime;
  607. __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */
  608. __le64 EndOfFile;
  609. __le32 Attributes;
  610. } __packed;
  611. struct smb2_flush_req {
  612. struct smb2_hdr hdr;
  613. __le16 StructureSize; /* Must be 24 */
  614. __le16 Reserved1;
  615. __le32 Reserved2;
  616. __u64 PersistentFileId; /* opaque endianness */
  617. __u64 VolatileFileId; /* opaque endianness */
  618. } __packed;
  619. struct smb2_flush_rsp {
  620. struct smb2_hdr hdr;
  621. __le16 StructureSize;
  622. __le16 Reserved;
  623. } __packed;
  624. /* For read request Flags field below, following flag is defined for SMB3.02 */
  625. #define SMB2_READFLAG_READ_UNBUFFERED 0x01
  626. /* Channel field for read and write: exactly one of following flags can be set*/
  627. #define SMB2_CHANNEL_NONE 0x00000000
  628. #define SMB2_CHANNEL_RDMA_V1 0x00000001 /* SMB3 or later */
  629. #define SMB2_CHANNEL_RDMA_V1_INVALIDATE 0x00000001 /* SMB3.02 or later */
  630. struct smb2_read_req {
  631. struct smb2_hdr hdr;
  632. __le16 StructureSize; /* Must be 49 */
  633. __u8 Padding; /* offset from start of SMB2 header to place read */
  634. __u8 Flags; /* MBZ unless SMB3.02 or later */
  635. __le32 Length;
  636. __le64 Offset;
  637. __u64 PersistentFileId; /* opaque endianness */
  638. __u64 VolatileFileId; /* opaque endianness */
  639. __le32 MinimumCount;
  640. __le32 Channel; /* MBZ except for SMB3 or later */
  641. __le32 RemainingBytes;
  642. __le16 ReadChannelInfoOffset; /* Reserved MBZ */
  643. __le16 ReadChannelInfoLength; /* Reserved MBZ */
  644. __u8 Buffer[1];
  645. } __packed;
  646. struct smb2_read_rsp {
  647. struct smb2_hdr hdr;
  648. __le16 StructureSize; /* Must be 17 */
  649. __u8 DataOffset;
  650. __u8 Reserved;
  651. __le32 DataLength;
  652. __le32 DataRemaining;
  653. __u32 Reserved2;
  654. __u8 Buffer[1];
  655. } __packed;
  656. /* For write request Flags field below the following flags are defined: */
  657. #define SMB2_WRITEFLAG_WRITE_THROUGH 0x00000001 /* SMB2.1 or later */
  658. #define SMB2_WRITEFLAG_WRITE_UNBUFFERED 0x00000002 /* SMB3.02 or later */
  659. struct smb2_write_req {
  660. struct smb2_hdr hdr;
  661. __le16 StructureSize; /* Must be 49 */
  662. __le16 DataOffset; /* offset from start of SMB2 header to write data */
  663. __le32 Length;
  664. __le64 Offset;
  665. __u64 PersistentFileId; /* opaque endianness */
  666. __u64 VolatileFileId; /* opaque endianness */
  667. __le32 Channel; /* Reserved MBZ */
  668. __le32 RemainingBytes;
  669. __le16 WriteChannelInfoOffset; /* Reserved MBZ */
  670. __le16 WriteChannelInfoLength; /* Reserved MBZ */
  671. __le32 Flags;
  672. __u8 Buffer[1];
  673. } __packed;
  674. struct smb2_write_rsp {
  675. struct smb2_hdr hdr;
  676. __le16 StructureSize; /* Must be 17 */
  677. __u8 DataOffset;
  678. __u8 Reserved;
  679. __le32 DataLength;
  680. __le32 DataRemaining;
  681. __u32 Reserved2;
  682. __u8 Buffer[1];
  683. } __packed;
  684. #define SMB2_LOCKFLAG_SHARED_LOCK 0x0001
  685. #define SMB2_LOCKFLAG_EXCLUSIVE_LOCK 0x0002
  686. #define SMB2_LOCKFLAG_UNLOCK 0x0004
  687. #define SMB2_LOCKFLAG_FAIL_IMMEDIATELY 0x0010
  688. struct smb2_lock_element {
  689. __le64 Offset;
  690. __le64 Length;
  691. __le32 Flags;
  692. __le32 Reserved;
  693. } __packed;
  694. struct smb2_lock_req {
  695. struct smb2_hdr hdr;
  696. __le16 StructureSize; /* Must be 48 */
  697. __le16 LockCount;
  698. __le32 Reserved;
  699. __u64 PersistentFileId; /* opaque endianness */
  700. __u64 VolatileFileId; /* opaque endianness */
  701. /* Followed by at least one */
  702. struct smb2_lock_element locks[1];
  703. } __packed;
  704. struct smb2_lock_rsp {
  705. struct smb2_hdr hdr;
  706. __le16 StructureSize; /* Must be 4 */
  707. __le16 Reserved;
  708. } __packed;
  709. struct smb2_echo_req {
  710. struct smb2_hdr hdr;
  711. __le16 StructureSize; /* Must be 4 */
  712. __u16 Reserved;
  713. } __packed;
  714. struct smb2_echo_rsp {
  715. struct smb2_hdr hdr;
  716. __le16 StructureSize; /* Must be 4 */
  717. __u16 Reserved;
  718. } __packed;
  719. /* search (query_directory) Flags field */
  720. #define SMB2_RESTART_SCANS 0x01
  721. #define SMB2_RETURN_SINGLE_ENTRY 0x02
  722. #define SMB2_INDEX_SPECIFIED 0x04
  723. #define SMB2_REOPEN 0x10
  724. struct smb2_query_directory_req {
  725. struct smb2_hdr hdr;
  726. __le16 StructureSize; /* Must be 33 */
  727. __u8 FileInformationClass;
  728. __u8 Flags;
  729. __le32 FileIndex;
  730. __u64 PersistentFileId; /* opaque endianness */
  731. __u64 VolatileFileId; /* opaque endianness */
  732. __le16 FileNameOffset;
  733. __le16 FileNameLength;
  734. __le32 OutputBufferLength;
  735. __u8 Buffer[1];
  736. } __packed;
  737. struct smb2_query_directory_rsp {
  738. struct smb2_hdr hdr;
  739. __le16 StructureSize; /* Must be 9 */
  740. __le16 OutputBufferOffset;
  741. __le32 OutputBufferLength;
  742. __u8 Buffer[1];
  743. } __packed;
  744. /* Possible InfoType values */
  745. #define SMB2_O_INFO_FILE 0x01
  746. #define SMB2_O_INFO_FILESYSTEM 0x02
  747. #define SMB2_O_INFO_SECURITY 0x03
  748. #define SMB2_O_INFO_QUOTA 0x04
  749. struct smb2_query_info_req {
  750. struct smb2_hdr hdr;
  751. __le16 StructureSize; /* Must be 41 */
  752. __u8 InfoType;
  753. __u8 FileInfoClass;
  754. __le32 OutputBufferLength;
  755. __le16 InputBufferOffset;
  756. __u16 Reserved;
  757. __le32 InputBufferLength;
  758. __le32 AdditionalInformation;
  759. __le32 Flags;
  760. __u64 PersistentFileId; /* opaque endianness */
  761. __u64 VolatileFileId; /* opaque endianness */
  762. __u8 Buffer[1];
  763. } __packed;
  764. struct smb2_query_info_rsp {
  765. struct smb2_hdr hdr;
  766. __le16 StructureSize; /* Must be 9 */
  767. __le16 OutputBufferOffset;
  768. __le32 OutputBufferLength;
  769. __u8 Buffer[1];
  770. } __packed;
  771. struct smb2_set_info_req {
  772. struct smb2_hdr hdr;
  773. __le16 StructureSize; /* Must be 33 */
  774. __u8 InfoType;
  775. __u8 FileInfoClass;
  776. __le32 BufferLength;
  777. __le16 BufferOffset;
  778. __u16 Reserved;
  779. __le32 AdditionalInformation;
  780. __u64 PersistentFileId; /* opaque endianness */
  781. __u64 VolatileFileId; /* opaque endianness */
  782. __u8 Buffer[1];
  783. } __packed;
  784. struct smb2_set_info_rsp {
  785. struct smb2_hdr hdr;
  786. __le16 StructureSize; /* Must be 2 */
  787. } __packed;
  788. struct smb2_oplock_break {
  789. struct smb2_hdr hdr;
  790. __le16 StructureSize; /* Must be 24 */
  791. __u8 OplockLevel;
  792. __u8 Reserved;
  793. __le32 Reserved2;
  794. __u64 PersistentFid;
  795. __u64 VolatileFid;
  796. } __packed;
  797. #define SMB2_NOTIFY_BREAK_LEASE_FLAG_ACK_REQUIRED cpu_to_le32(0x01)
  798. struct smb2_lease_break {
  799. struct smb2_hdr hdr;
  800. __le16 StructureSize; /* Must be 44 */
  801. __le16 Reserved;
  802. __le32 Flags;
  803. __u8 LeaseKey[16];
  804. __le32 CurrentLeaseState;
  805. __le32 NewLeaseState;
  806. __le32 BreakReason;
  807. __le32 AccessMaskHint;
  808. __le32 ShareMaskHint;
  809. } __packed;
  810. struct smb2_lease_ack {
  811. struct smb2_hdr hdr;
  812. __le16 StructureSize; /* Must be 36 */
  813. __le16 Reserved;
  814. __le32 Flags;
  815. __u8 LeaseKey[16];
  816. __le32 LeaseState;
  817. __le64 LeaseDuration;
  818. } __packed;
  819. /*
  820. * PDU infolevel structure definitions
  821. * BB consider moving to a different header
  822. */
  823. /* File System Information Classes */
  824. #define FS_VOLUME_INFORMATION 1 /* Query */
  825. #define FS_LABEL_INFORMATION 2 /* Local only */
  826. #define FS_SIZE_INFORMATION 3 /* Query */
  827. #define FS_DEVICE_INFORMATION 4 /* Query */
  828. #define FS_ATTRIBUTE_INFORMATION 5 /* Query */
  829. #define FS_CONTROL_INFORMATION 6 /* Query, Set */
  830. #define FS_FULL_SIZE_INFORMATION 7 /* Query */
  831. #define FS_OBJECT_ID_INFORMATION 8 /* Query, Set */
  832. #define FS_DRIVER_PATH_INFORMATION 9 /* Local only */
  833. #define FS_VOLUME_FLAGS_INFORMATION 10 /* Local only */
  834. #define FS_SECTOR_SIZE_INFORMATION 11 /* SMB3 or later. Query */
  835. struct smb2_fs_full_size_info {
  836. __le64 TotalAllocationUnits;
  837. __le64 CallerAvailableAllocationUnits;
  838. __le64 ActualAvailableAllocationUnits;
  839. __le32 SectorsPerAllocationUnit;
  840. __le32 BytesPerSector;
  841. } __packed;
  842. #define SSINFO_FLAGS_ALIGNED_DEVICE 0x00000001
  843. #define SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE 0x00000002
  844. #define SSINFO_FLAGS_NO_SEEK_PENALTY 0x00000004
  845. #define SSINFO_FLAGS_TRIM_ENABLED 0x00000008
  846. /* sector size info struct */
  847. struct smb3_fs_ss_info {
  848. __le32 LogicalBytesPerSector;
  849. __le32 PhysicalBytesPerSectorForAtomicity;
  850. __le32 PhysicalBytesPerSectorForPerf;
  851. __le32 FileSystemEffectivePhysicalBytesPerSectorForAtomicity;
  852. __le32 Flags;
  853. __le32 ByteOffsetForSectorAlignment;
  854. __le32 ByteOffsetForPartitionAlignment;
  855. } __packed;
  856. /* partial list of QUERY INFO levels */
  857. #define FILE_DIRECTORY_INFORMATION 1
  858. #define FILE_FULL_DIRECTORY_INFORMATION 2
  859. #define FILE_BOTH_DIRECTORY_INFORMATION 3
  860. #define FILE_BASIC_INFORMATION 4
  861. #define FILE_STANDARD_INFORMATION 5
  862. #define FILE_INTERNAL_INFORMATION 6
  863. #define FILE_EA_INFORMATION 7
  864. #define FILE_ACCESS_INFORMATION 8
  865. #define FILE_NAME_INFORMATION 9
  866. #define FILE_RENAME_INFORMATION 10
  867. #define FILE_LINK_INFORMATION 11
  868. #define FILE_NAMES_INFORMATION 12
  869. #define FILE_DISPOSITION_INFORMATION 13
  870. #define FILE_POSITION_INFORMATION 14
  871. #define FILE_FULL_EA_INFORMATION 15
  872. #define FILE_MODE_INFORMATION 16
  873. #define FILE_ALIGNMENT_INFORMATION 17
  874. #define FILE_ALL_INFORMATION 18
  875. #define FILE_ALLOCATION_INFORMATION 19
  876. #define FILE_END_OF_FILE_INFORMATION 20
  877. #define FILE_ALTERNATE_NAME_INFORMATION 21
  878. #define FILE_STREAM_INFORMATION 22
  879. #define FILE_PIPE_INFORMATION 23
  880. #define FILE_PIPE_LOCAL_INFORMATION 24
  881. #define FILE_PIPE_REMOTE_INFORMATION 25
  882. #define FILE_MAILSLOT_QUERY_INFORMATION 26
  883. #define FILE_MAILSLOT_SET_INFORMATION 27
  884. #define FILE_COMPRESSION_INFORMATION 28
  885. #define FILE_OBJECT_ID_INFORMATION 29
  886. /* Number 30 not defined in documents */
  887. #define FILE_MOVE_CLUSTER_INFORMATION 31
  888. #define FILE_QUOTA_INFORMATION 32
  889. #define FILE_REPARSE_POINT_INFORMATION 33
  890. #define FILE_NETWORK_OPEN_INFORMATION 34
  891. #define FILE_ATTRIBUTE_TAG_INFORMATION 35
  892. #define FILE_TRACKING_INFORMATION 36
  893. #define FILEID_BOTH_DIRECTORY_INFORMATION 37
  894. #define FILEID_FULL_DIRECTORY_INFORMATION 38
  895. #define FILE_VALID_DATA_LENGTH_INFORMATION 39
  896. #define FILE_SHORT_NAME_INFORMATION 40
  897. #define FILE_SFIO_RESERVE_INFORMATION 44
  898. #define FILE_SFIO_VOLUME_INFORMATION 45
  899. #define FILE_HARD_LINK_INFORMATION 46
  900. #define FILE_NORMALIZED_NAME_INFORMATION 48
  901. #define FILEID_GLOBAL_TX_DIRECTORY_INFORMATION 50
  902. #define FILE_STANDARD_LINK_INFORMATION 54
  903. struct smb2_file_internal_info {
  904. __le64 IndexNumber;
  905. } __packed; /* level 6 Query */
  906. struct smb2_file_rename_info { /* encoding of request for level 10 */
  907. __u8 ReplaceIfExists; /* 1 = replace existing target with new */
  908. /* 0 = fail if target already exists */
  909. __u8 Reserved[7];
  910. __u64 RootDirectory; /* MBZ for network operations (why says spec?) */
  911. __le32 FileNameLength;
  912. char FileName[0]; /* New name to be assigned */
  913. } __packed; /* level 10 Set */
  914. struct smb2_file_link_info { /* encoding of request for level 11 */
  915. __u8 ReplaceIfExists; /* 1 = replace existing link with new */
  916. /* 0 = fail if link already exists */
  917. __u8 Reserved[7];
  918. __u64 RootDirectory; /* MBZ for network operations (why says spec?) */
  919. __le32 FileNameLength;
  920. char FileName[0]; /* Name to be assigned to new link */
  921. } __packed; /* level 11 Set */
  922. /*
  923. * This level 18, although with struct with same name is different from cifs
  924. * level 0x107. Level 0x107 has an extra u64 between AccessFlags and
  925. * CurrentByteOffset.
  926. */
  927. struct smb2_file_all_info { /* data block encoding of response to level 18 */
  928. __le64 CreationTime; /* Beginning of FILE_BASIC_INFO equivalent */
  929. __le64 LastAccessTime;
  930. __le64 LastWriteTime;
  931. __le64 ChangeTime;
  932. __le32 Attributes;
  933. __u32 Pad1; /* End of FILE_BASIC_INFO_INFO equivalent */
  934. __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */
  935. __le64 EndOfFile; /* size ie offset to first free byte in file */
  936. __le32 NumberOfLinks; /* hard links */
  937. __u8 DeletePending;
  938. __u8 Directory;
  939. __u16 Pad2; /* End of FILE_STANDARD_INFO equivalent */
  940. __le64 IndexNumber;
  941. __le32 EASize;
  942. __le32 AccessFlags;
  943. __le64 CurrentByteOffset;
  944. __le32 Mode;
  945. __le32 AlignmentRequirement;
  946. __le32 FileNameLength;
  947. char FileName[1];
  948. } __packed; /* level 18 Query */
  949. struct smb2_file_eof_info { /* encoding of request for level 10 */
  950. __le64 EndOfFile; /* new end of file value */
  951. } __packed; /* level 20 Set */
  952. #endif /* _SMB2PDU_H */