smb2pdu.h 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045
  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. extern __u8 cifs_client_guid[SMB2_CLIENT_GUID_SIZE];
  166. struct smb2_negotiate_req {
  167. struct smb2_hdr hdr;
  168. __le16 StructureSize; /* Must be 36 */
  169. __le16 DialectCount;
  170. __le16 SecurityMode;
  171. __le16 Reserved; /* MBZ */
  172. __le32 Capabilities;
  173. __u8 ClientGUID[SMB2_CLIENT_GUID_SIZE];
  174. __le64 ClientStartTime; /* MBZ */
  175. __le16 Dialects[1]; /* One dialect (vers=) at a time for now */
  176. } __packed;
  177. /* Dialects */
  178. #define SMB20_PROT_ID 0x0202
  179. #define SMB21_PROT_ID 0x0210
  180. #define SMB30_PROT_ID 0x0300
  181. #define SMB302_PROT_ID 0x0302
  182. #define BAD_PROT_ID 0xFFFF
  183. /* SecurityMode flags */
  184. #define SMB2_NEGOTIATE_SIGNING_ENABLED 0x0001
  185. #define SMB2_NEGOTIATE_SIGNING_REQUIRED 0x0002
  186. /* Capabilities flags */
  187. #define SMB2_GLOBAL_CAP_DFS 0x00000001
  188. #define SMB2_GLOBAL_CAP_LEASING 0x00000002 /* Resp only New to SMB2.1 */
  189. #define SMB2_GLOBAL_CAP_LARGE_MTU 0X00000004 /* Resp only New to SMB2.1 */
  190. #define SMB2_GLOBAL_CAP_MULTI_CHANNEL 0x00000008 /* New to SMB3 */
  191. #define SMB2_GLOBAL_CAP_PERSISTENT_HANDLES 0x00000010 /* New to SMB3 */
  192. #define SMB2_GLOBAL_CAP_DIRECTORY_LEASING 0x00000020 /* New to SMB3 */
  193. #define SMB2_GLOBAL_CAP_ENCRYPTION 0x00000040 /* New to SMB3 */
  194. /* Internal types */
  195. #define SMB2_NT_FIND 0x00100000
  196. #define SMB2_LARGE_FILES 0x00200000
  197. struct smb2_negotiate_rsp {
  198. struct smb2_hdr hdr;
  199. __le16 StructureSize; /* Must be 65 */
  200. __le16 SecurityMode;
  201. __le16 DialectRevision;
  202. __le16 Reserved; /* MBZ */
  203. __u8 ServerGUID[16];
  204. __le32 Capabilities;
  205. __le32 MaxTransactSize;
  206. __le32 MaxReadSize;
  207. __le32 MaxWriteSize;
  208. __le64 SystemTime; /* MBZ */
  209. __le64 ServerStartTime;
  210. __le16 SecurityBufferOffset;
  211. __le16 SecurityBufferLength;
  212. __le32 Reserved2; /* may be any value, ignore */
  213. __u8 Buffer[1]; /* variable length GSS security buffer */
  214. } __packed;
  215. struct smb2_sess_setup_req {
  216. struct smb2_hdr hdr;
  217. __le16 StructureSize; /* Must be 25 */
  218. __u8 VcNumber;
  219. __u8 SecurityMode;
  220. __le32 Capabilities;
  221. __le32 Channel;
  222. __le16 SecurityBufferOffset;
  223. __le16 SecurityBufferLength;
  224. __le64 PreviousSessionId;
  225. __u8 Buffer[1]; /* variable length GSS security buffer */
  226. } __packed;
  227. /* Currently defined SessionFlags */
  228. #define SMB2_SESSION_FLAG_IS_GUEST 0x0001
  229. #define SMB2_SESSION_FLAG_IS_NULL 0x0002
  230. #define SMB2_SESSION_FLAG_ENCRYPT_DATA 0x0004
  231. struct smb2_sess_setup_rsp {
  232. struct smb2_hdr hdr;
  233. __le16 StructureSize; /* Must be 9 */
  234. __le16 SessionFlags;
  235. __le16 SecurityBufferOffset;
  236. __le16 SecurityBufferLength;
  237. __u8 Buffer[1]; /* variable length GSS security buffer */
  238. } __packed;
  239. struct smb2_logoff_req {
  240. struct smb2_hdr hdr;
  241. __le16 StructureSize; /* Must be 4 */
  242. __le16 Reserved;
  243. } __packed;
  244. struct smb2_logoff_rsp {
  245. struct smb2_hdr hdr;
  246. __le16 StructureSize; /* Must be 4 */
  247. __le16 Reserved;
  248. } __packed;
  249. struct smb2_tree_connect_req {
  250. struct smb2_hdr hdr;
  251. __le16 StructureSize; /* Must be 9 */
  252. __le16 Reserved;
  253. __le16 PathOffset;
  254. __le16 PathLength;
  255. __u8 Buffer[1]; /* variable length */
  256. } __packed;
  257. struct smb2_tree_connect_rsp {
  258. struct smb2_hdr hdr;
  259. __le16 StructureSize; /* Must be 16 */
  260. __u8 ShareType; /* see below */
  261. __u8 Reserved;
  262. __le32 ShareFlags; /* see below */
  263. __le32 Capabilities; /* see below */
  264. __le32 MaximalAccess;
  265. } __packed;
  266. /* Possible ShareType values */
  267. #define SMB2_SHARE_TYPE_DISK 0x01
  268. #define SMB2_SHARE_TYPE_PIPE 0x02
  269. #define SMB2_SHARE_TYPE_PRINT 0x03
  270. /*
  271. * Possible ShareFlags - exactly one and only one of the first 4 caching flags
  272. * must be set (any of the remaining, SHI1005, flags may be set individually
  273. * or in combination.
  274. */
  275. #define SMB2_SHAREFLAG_MANUAL_CACHING 0x00000000
  276. #define SMB2_SHAREFLAG_AUTO_CACHING 0x00000010
  277. #define SMB2_SHAREFLAG_VDO_CACHING 0x00000020
  278. #define SMB2_SHAREFLAG_NO_CACHING 0x00000030
  279. #define SHI1005_FLAGS_DFS 0x00000001
  280. #define SHI1005_FLAGS_DFS_ROOT 0x00000002
  281. #define SHI1005_FLAGS_RESTRICT_EXCLUSIVE_OPENS 0x00000100
  282. #define SHI1005_FLAGS_FORCE_SHARED_DELETE 0x00000200
  283. #define SHI1005_FLAGS_ALLOW_NAMESPACE_CACHING 0x00000400
  284. #define SHI1005_FLAGS_ACCESS_BASED_DIRECTORY_ENUM 0x00000800
  285. #define SHI1005_FLAGS_FORCE_LEVELII_OPLOCK 0x00001000
  286. #define SHI1005_FLAGS_ENABLE_HASH_V1 0x00002000
  287. #define SHI1005_FLAGS_ENABLE_HASH_V2 0x00004000
  288. #define SHI1005_FLAGS_ENCRYPT_DATA 0x00008000
  289. #define SHI1005_FLAGS_ALL 0x0000FF33
  290. /* Possible share capabilities */
  291. #define SMB2_SHARE_CAP_DFS cpu_to_le32(0x00000008) /* all dialects */
  292. #define SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY cpu_to_le32(0x00000010) /* 3.0 */
  293. #define SMB2_SHARE_CAP_SCALEOUT cpu_to_le32(0x00000020) /* 3.0 */
  294. #define SMB2_SHARE_CAP_CLUSTER cpu_to_le32(0x00000040) /* 3.0 */
  295. #define SMB2_SHARE_CAP_ASYMMETRIC cpu_to_le32(0x00000080) /* 3.02 */
  296. struct smb2_tree_disconnect_req {
  297. struct smb2_hdr hdr;
  298. __le16 StructureSize; /* Must be 4 */
  299. __le16 Reserved;
  300. } __packed;
  301. struct smb2_tree_disconnect_rsp {
  302. struct smb2_hdr hdr;
  303. __le16 StructureSize; /* Must be 4 */
  304. __le16 Reserved;
  305. } __packed;
  306. /* File Attrubutes */
  307. #define FILE_ATTRIBUTE_READONLY 0x00000001
  308. #define FILE_ATTRIBUTE_HIDDEN 0x00000002
  309. #define FILE_ATTRIBUTE_SYSTEM 0x00000004
  310. #define FILE_ATTRIBUTE_DIRECTORY 0x00000010
  311. #define FILE_ATTRIBUTE_ARCHIVE 0x00000020
  312. #define FILE_ATTRIBUTE_NORMAL 0x00000080
  313. #define FILE_ATTRIBUTE_TEMPORARY 0x00000100
  314. #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
  315. #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
  316. #define FILE_ATTRIBUTE_COMPRESSED 0x00000800
  317. #define FILE_ATTRIBUTE_OFFLINE 0x00001000
  318. #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
  319. #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
  320. /* Oplock levels */
  321. #define SMB2_OPLOCK_LEVEL_NONE 0x00
  322. #define SMB2_OPLOCK_LEVEL_II 0x01
  323. #define SMB2_OPLOCK_LEVEL_EXCLUSIVE 0x08
  324. #define SMB2_OPLOCK_LEVEL_BATCH 0x09
  325. #define SMB2_OPLOCK_LEVEL_LEASE 0xFF
  326. /* Non-spec internal type */
  327. #define SMB2_OPLOCK_LEVEL_NOCHANGE 0x99
  328. /* Desired Access Flags */
  329. #define FILE_READ_DATA_LE cpu_to_le32(0x00000001)
  330. #define FILE_WRITE_DATA_LE cpu_to_le32(0x00000002)
  331. #define FILE_APPEND_DATA_LE cpu_to_le32(0x00000004)
  332. #define FILE_READ_EA_LE cpu_to_le32(0x00000008)
  333. #define FILE_WRITE_EA_LE cpu_to_le32(0x00000010)
  334. #define FILE_EXECUTE_LE cpu_to_le32(0x00000020)
  335. #define FILE_READ_ATTRIBUTES_LE cpu_to_le32(0x00000080)
  336. #define FILE_WRITE_ATTRIBUTES_LE cpu_to_le32(0x00000100)
  337. #define FILE_DELETE_LE cpu_to_le32(0x00010000)
  338. #define FILE_READ_CONTROL_LE cpu_to_le32(0x00020000)
  339. #define FILE_WRITE_DAC_LE cpu_to_le32(0x00040000)
  340. #define FILE_WRITE_OWNER_LE cpu_to_le32(0x00080000)
  341. #define FILE_SYNCHRONIZE_LE cpu_to_le32(0x00100000)
  342. #define FILE_ACCESS_SYSTEM_SECURITY_LE cpu_to_le32(0x01000000)
  343. #define FILE_MAXIMAL_ACCESS_LE cpu_to_le32(0x02000000)
  344. #define FILE_GENERIC_ALL_LE cpu_to_le32(0x10000000)
  345. #define FILE_GENERIC_EXECUTE_LE cpu_to_le32(0x20000000)
  346. #define FILE_GENERIC_WRITE_LE cpu_to_le32(0x40000000)
  347. #define FILE_GENERIC_READ_LE cpu_to_le32(0x80000000)
  348. /* ShareAccess Flags */
  349. #define FILE_SHARE_READ_LE cpu_to_le32(0x00000001)
  350. #define FILE_SHARE_WRITE_LE cpu_to_le32(0x00000002)
  351. #define FILE_SHARE_DELETE_LE cpu_to_le32(0x00000004)
  352. #define FILE_SHARE_ALL_LE cpu_to_le32(0x00000007)
  353. /* CreateDisposition Flags */
  354. #define FILE_SUPERSEDE_LE cpu_to_le32(0x00000000)
  355. #define FILE_OPEN_LE cpu_to_le32(0x00000001)
  356. #define FILE_CREATE_LE cpu_to_le32(0x00000002)
  357. #define FILE_OPEN_IF_LE cpu_to_le32(0x00000003)
  358. #define FILE_OVERWRITE_LE cpu_to_le32(0x00000004)
  359. #define FILE_OVERWRITE_IF_LE cpu_to_le32(0x00000005)
  360. /* CreateOptions Flags */
  361. #define FILE_DIRECTORY_FILE_LE cpu_to_le32(0x00000001)
  362. /* same as #define CREATE_NOT_FILE_LE cpu_to_le32(0x00000001) */
  363. #define FILE_WRITE_THROUGH_LE cpu_to_le32(0x00000002)
  364. #define FILE_SEQUENTIAL_ONLY_LE cpu_to_le32(0x00000004)
  365. #define FILE_NO_INTERMEDIATE_BUFFERRING_LE cpu_to_le32(0x00000008)
  366. #define FILE_SYNCHRONOUS_IO_ALERT_LE cpu_to_le32(0x00000010)
  367. #define FILE_SYNCHRONOUS_IO_NON_ALERT_LE cpu_to_le32(0x00000020)
  368. #define FILE_NON_DIRECTORY_FILE_LE cpu_to_le32(0x00000040)
  369. #define FILE_COMPLETE_IF_OPLOCKED_LE cpu_to_le32(0x00000100)
  370. #define FILE_NO_EA_KNOWLEDGE_LE cpu_to_le32(0x00000200)
  371. #define FILE_RANDOM_ACCESS_LE cpu_to_le32(0x00000800)
  372. #define FILE_DELETE_ON_CLOSE_LE cpu_to_le32(0x00001000)
  373. #define FILE_OPEN_BY_FILE_ID_LE cpu_to_le32(0x00002000)
  374. #define FILE_OPEN_FOR_BACKUP_INTENT_LE cpu_to_le32(0x00004000)
  375. #define FILE_NO_COMPRESSION_LE cpu_to_le32(0x00008000)
  376. #define FILE_RESERVE_OPFILTER_LE cpu_to_le32(0x00100000)
  377. #define FILE_OPEN_REPARSE_POINT_LE cpu_to_le32(0x00200000)
  378. #define FILE_OPEN_NO_RECALL_LE cpu_to_le32(0x00400000)
  379. #define FILE_OPEN_FOR_FREE_SPACE_QUERY_LE cpu_to_le32(0x00800000)
  380. #define FILE_READ_RIGHTS_LE (FILE_READ_DATA_LE | FILE_READ_EA_LE \
  381. | FILE_READ_ATTRIBUTES_LE)
  382. #define FILE_WRITE_RIGHTS_LE (FILE_WRITE_DATA_LE | FILE_APPEND_DATA_LE \
  383. | FILE_WRITE_EA_LE | FILE_WRITE_ATTRIBUTES_LE)
  384. #define FILE_EXEC_RIGHTS_LE (FILE_EXECUTE_LE)
  385. /* Impersonation Levels */
  386. #define IL_ANONYMOUS cpu_to_le32(0x00000000)
  387. #define IL_IDENTIFICATION cpu_to_le32(0x00000001)
  388. #define IL_IMPERSONATION cpu_to_le32(0x00000002)
  389. #define IL_DELEGATE cpu_to_le32(0x00000003)
  390. /* Create Context Values */
  391. #define SMB2_CREATE_EA_BUFFER "ExtA" /* extended attributes */
  392. #define SMB2_CREATE_SD_BUFFER "SecD" /* security descriptor */
  393. #define SMB2_CREATE_DURABLE_HANDLE_REQUEST "DHnQ"
  394. #define SMB2_CREATE_DURABLE_HANDLE_RECONNECT "DHnC"
  395. #define SMB2_CREATE_ALLOCATION_SIZE "AlSi"
  396. #define SMB2_CREATE_QUERY_MAXIMAL_ACCESS_REQUEST "MxAc"
  397. #define SMB2_CREATE_TIMEWARP_REQUEST "TWrp"
  398. #define SMB2_CREATE_QUERY_ON_DISK_ID "QFid"
  399. #define SMB2_CREATE_REQUEST_LEASE "RqLs"
  400. struct smb2_create_req {
  401. struct smb2_hdr hdr;
  402. __le16 StructureSize; /* Must be 57 */
  403. __u8 SecurityFlags;
  404. __u8 RequestedOplockLevel;
  405. __le32 ImpersonationLevel;
  406. __le64 SmbCreateFlags;
  407. __le64 Reserved;
  408. __le32 DesiredAccess;
  409. __le32 FileAttributes;
  410. __le32 ShareAccess;
  411. __le32 CreateDisposition;
  412. __le32 CreateOptions;
  413. __le16 NameOffset;
  414. __le16 NameLength;
  415. __le32 CreateContextsOffset;
  416. __le32 CreateContextsLength;
  417. __u8 Buffer[0];
  418. } __packed;
  419. struct smb2_create_rsp {
  420. struct smb2_hdr hdr;
  421. __le16 StructureSize; /* Must be 89 */
  422. __u8 OplockLevel;
  423. __u8 Reserved;
  424. __le32 CreateAction;
  425. __le64 CreationTime;
  426. __le64 LastAccessTime;
  427. __le64 LastWriteTime;
  428. __le64 ChangeTime;
  429. __le64 AllocationSize;
  430. __le64 EndofFile;
  431. __le32 FileAttributes;
  432. __le32 Reserved2;
  433. __u64 PersistentFileId; /* opaque endianness */
  434. __u64 VolatileFileId; /* opaque endianness */
  435. __le32 CreateContextsOffset;
  436. __le32 CreateContextsLength;
  437. __u8 Buffer[1];
  438. } __packed;
  439. struct create_context {
  440. __le32 Next;
  441. __le16 NameOffset;
  442. __le16 NameLength;
  443. __le16 Reserved;
  444. __le16 DataOffset;
  445. __le32 DataLength;
  446. __u8 Buffer[0];
  447. } __packed;
  448. #define SMB2_LEASE_READ_CACHING_HE 0x01
  449. #define SMB2_LEASE_HANDLE_CACHING_HE 0x02
  450. #define SMB2_LEASE_WRITE_CACHING_HE 0x04
  451. #define SMB2_LEASE_NONE __constant_cpu_to_le32(0x00)
  452. #define SMB2_LEASE_READ_CACHING __constant_cpu_to_le32(0x01)
  453. #define SMB2_LEASE_HANDLE_CACHING __constant_cpu_to_le32(0x02)
  454. #define SMB2_LEASE_WRITE_CACHING __constant_cpu_to_le32(0x04)
  455. #define SMB2_LEASE_FLAG_BREAK_IN_PROGRESS __constant_cpu_to_le32(0x02)
  456. #define SMB2_LEASE_KEY_SIZE 16
  457. struct lease_context {
  458. __le64 LeaseKeyLow;
  459. __le64 LeaseKeyHigh;
  460. __le32 LeaseState;
  461. __le32 LeaseFlags;
  462. __le64 LeaseDuration;
  463. } __packed;
  464. struct lease_context_v2 {
  465. __le64 LeaseKeyLow;
  466. __le64 LeaseKeyHigh;
  467. __le32 LeaseState;
  468. __le32 LeaseFlags;
  469. __le64 LeaseDuration;
  470. __le64 ParentLeaseKeyLow;
  471. __le64 ParentLeaseKeyHigh;
  472. __le16 Epoch;
  473. __le16 Reserved;
  474. } __packed;
  475. struct create_lease {
  476. struct create_context ccontext;
  477. __u8 Name[8];
  478. struct lease_context lcontext;
  479. } __packed;
  480. struct create_lease_v2 {
  481. struct create_context ccontext;
  482. __u8 Name[8];
  483. struct lease_context_v2 lcontext;
  484. __u8 Pad[4];
  485. } __packed;
  486. struct create_durable {
  487. struct create_context ccontext;
  488. __u8 Name[8];
  489. union {
  490. __u8 Reserved[16];
  491. struct {
  492. __u64 PersistentFileId;
  493. __u64 VolatileFileId;
  494. } Fid;
  495. } Data;
  496. } __packed;
  497. #define COPY_CHUNK_RES_KEY_SIZE 24
  498. struct resume_key_req {
  499. char ResumeKey[COPY_CHUNK_RES_KEY_SIZE];
  500. __le32 ContextLength; /* MBZ */
  501. char Context[0]; /* ignored, Windows sets to 4 bytes of zero */
  502. } __packed;
  503. /* this goes in the ioctl buffer when doing a copychunk request */
  504. struct copychunk_ioctl {
  505. char SourceKey[COPY_CHUNK_RES_KEY_SIZE];
  506. __le32 ChunkCount; /* we are only sending 1 */
  507. __le32 Reserved;
  508. /* array will only be one chunk long for us */
  509. __le64 SourceOffset;
  510. __le64 TargetOffset;
  511. __le32 Length; /* how many bytes to copy */
  512. __u32 Reserved2;
  513. } __packed;
  514. struct copychunk_ioctl_rsp {
  515. __le32 ChunksWritten;
  516. __le32 ChunkBytesWritten;
  517. __le32 TotalBytesWritten;
  518. } __packed;
  519. /* Response and Request are the same format */
  520. struct validate_negotiate_info {
  521. __le32 Capabilities;
  522. __u8 Guid[SMB2_CLIENT_GUID_SIZE];
  523. __le16 SecurityMode;
  524. __le16 DialectCount;
  525. __le16 Dialect[1];
  526. } __packed;
  527. #define RSS_CAPABLE 0x00000001
  528. #define RDMA_CAPABLE 0x00000002
  529. struct network_interface_info_ioctl_rsp {
  530. __le32 Next; /* next interface. zero if this is last one */
  531. __le32 IfIndex;
  532. __le32 Capability; /* RSS or RDMA Capable */
  533. __le32 Reserved;
  534. __le64 LinkSpeed;
  535. char SockAddr_Storage[128];
  536. } __packed;
  537. #define NO_FILE_ID 0xFFFFFFFFFFFFFFFFULL /* general ioctls to srv not to file */
  538. struct compress_ioctl {
  539. __le16 CompressionState; /* See cifspdu.h for possible flag values */
  540. } __packed;
  541. struct smb2_ioctl_req {
  542. struct smb2_hdr hdr;
  543. __le16 StructureSize; /* Must be 57 */
  544. __u16 Reserved;
  545. __le32 CtlCode;
  546. __u64 PersistentFileId; /* opaque endianness */
  547. __u64 VolatileFileId; /* opaque endianness */
  548. __le32 InputOffset;
  549. __le32 InputCount;
  550. __le32 MaxInputResponse;
  551. __le32 OutputOffset;
  552. __le32 OutputCount;
  553. __le32 MaxOutputResponse;
  554. __le32 Flags;
  555. __u32 Reserved2;
  556. __u8 Buffer[0];
  557. } __packed;
  558. struct smb2_ioctl_rsp {
  559. struct smb2_hdr hdr;
  560. __le16 StructureSize; /* Must be 57 */
  561. __u16 Reserved;
  562. __le32 CtlCode;
  563. __u64 PersistentFileId; /* opaque endianness */
  564. __u64 VolatileFileId; /* opaque endianness */
  565. __le32 InputOffset;
  566. __le32 InputCount;
  567. __le32 OutputOffset;
  568. __le32 OutputCount;
  569. __le32 Flags;
  570. __u32 Reserved2;
  571. /* char * buffer[] */
  572. } __packed;
  573. /* Currently defined values for close flags */
  574. #define SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB cpu_to_le16(0x0001)
  575. struct smb2_close_req {
  576. struct smb2_hdr hdr;
  577. __le16 StructureSize; /* Must be 24 */
  578. __le16 Flags;
  579. __le32 Reserved;
  580. __u64 PersistentFileId; /* opaque endianness */
  581. __u64 VolatileFileId; /* opaque endianness */
  582. } __packed;
  583. struct smb2_close_rsp {
  584. struct smb2_hdr hdr;
  585. __le16 StructureSize; /* 60 */
  586. __le16 Flags;
  587. __le32 Reserved;
  588. __le64 CreationTime;
  589. __le64 LastAccessTime;
  590. __le64 LastWriteTime;
  591. __le64 ChangeTime;
  592. __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */
  593. __le64 EndOfFile;
  594. __le32 Attributes;
  595. } __packed;
  596. struct smb2_flush_req {
  597. struct smb2_hdr hdr;
  598. __le16 StructureSize; /* Must be 24 */
  599. __le16 Reserved1;
  600. __le32 Reserved2;
  601. __u64 PersistentFileId; /* opaque endianness */
  602. __u64 VolatileFileId; /* opaque endianness */
  603. } __packed;
  604. struct smb2_flush_rsp {
  605. struct smb2_hdr hdr;
  606. __le16 StructureSize;
  607. __le16 Reserved;
  608. } __packed;
  609. /* For read request Flags field below, following flag is defined for SMB3.02 */
  610. #define SMB2_READFLAG_READ_UNBUFFERED 0x01
  611. /* Channel field for read and write: exactly one of following flags can be set*/
  612. #define SMB2_CHANNEL_NONE 0x00000000
  613. #define SMB2_CHANNEL_RDMA_V1 0x00000001 /* SMB3 or later */
  614. #define SMB2_CHANNEL_RDMA_V1_INVALIDATE 0x00000001 /* SMB3.02 or later */
  615. struct smb2_read_req {
  616. struct smb2_hdr hdr;
  617. __le16 StructureSize; /* Must be 49 */
  618. __u8 Padding; /* offset from start of SMB2 header to place read */
  619. __u8 Flags; /* MBZ unless SMB3.02 or later */
  620. __le32 Length;
  621. __le64 Offset;
  622. __u64 PersistentFileId; /* opaque endianness */
  623. __u64 VolatileFileId; /* opaque endianness */
  624. __le32 MinimumCount;
  625. __le32 Channel; /* MBZ except for SMB3 or later */
  626. __le32 RemainingBytes;
  627. __le16 ReadChannelInfoOffset; /* Reserved MBZ */
  628. __le16 ReadChannelInfoLength; /* Reserved MBZ */
  629. __u8 Buffer[1];
  630. } __packed;
  631. struct smb2_read_rsp {
  632. struct smb2_hdr hdr;
  633. __le16 StructureSize; /* Must be 17 */
  634. __u8 DataOffset;
  635. __u8 Reserved;
  636. __le32 DataLength;
  637. __le32 DataRemaining;
  638. __u32 Reserved2;
  639. __u8 Buffer[1];
  640. } __packed;
  641. /* For write request Flags field below the following flags are defined: */
  642. #define SMB2_WRITEFLAG_WRITE_THROUGH 0x00000001 /* SMB2.1 or later */
  643. #define SMB2_WRITEFLAG_WRITE_UNBUFFERED 0x00000002 /* SMB3.02 or later */
  644. struct smb2_write_req {
  645. struct smb2_hdr hdr;
  646. __le16 StructureSize; /* Must be 49 */
  647. __le16 DataOffset; /* offset from start of SMB2 header to write data */
  648. __le32 Length;
  649. __le64 Offset;
  650. __u64 PersistentFileId; /* opaque endianness */
  651. __u64 VolatileFileId; /* opaque endianness */
  652. __le32 Channel; /* Reserved MBZ */
  653. __le32 RemainingBytes;
  654. __le16 WriteChannelInfoOffset; /* Reserved MBZ */
  655. __le16 WriteChannelInfoLength; /* Reserved MBZ */
  656. __le32 Flags;
  657. __u8 Buffer[1];
  658. } __packed;
  659. struct smb2_write_rsp {
  660. struct smb2_hdr hdr;
  661. __le16 StructureSize; /* Must be 17 */
  662. __u8 DataOffset;
  663. __u8 Reserved;
  664. __le32 DataLength;
  665. __le32 DataRemaining;
  666. __u32 Reserved2;
  667. __u8 Buffer[1];
  668. } __packed;
  669. #define SMB2_LOCKFLAG_SHARED_LOCK 0x0001
  670. #define SMB2_LOCKFLAG_EXCLUSIVE_LOCK 0x0002
  671. #define SMB2_LOCKFLAG_UNLOCK 0x0004
  672. #define SMB2_LOCKFLAG_FAIL_IMMEDIATELY 0x0010
  673. struct smb2_lock_element {
  674. __le64 Offset;
  675. __le64 Length;
  676. __le32 Flags;
  677. __le32 Reserved;
  678. } __packed;
  679. struct smb2_lock_req {
  680. struct smb2_hdr hdr;
  681. __le16 StructureSize; /* Must be 48 */
  682. __le16 LockCount;
  683. __le32 Reserved;
  684. __u64 PersistentFileId; /* opaque endianness */
  685. __u64 VolatileFileId; /* opaque endianness */
  686. /* Followed by at least one */
  687. struct smb2_lock_element locks[1];
  688. } __packed;
  689. struct smb2_lock_rsp {
  690. struct smb2_hdr hdr;
  691. __le16 StructureSize; /* Must be 4 */
  692. __le16 Reserved;
  693. } __packed;
  694. struct smb2_echo_req {
  695. struct smb2_hdr hdr;
  696. __le16 StructureSize; /* Must be 4 */
  697. __u16 Reserved;
  698. } __packed;
  699. struct smb2_echo_rsp {
  700. struct smb2_hdr hdr;
  701. __le16 StructureSize; /* Must be 4 */
  702. __u16 Reserved;
  703. } __packed;
  704. /* search (query_directory) Flags field */
  705. #define SMB2_RESTART_SCANS 0x01
  706. #define SMB2_RETURN_SINGLE_ENTRY 0x02
  707. #define SMB2_INDEX_SPECIFIED 0x04
  708. #define SMB2_REOPEN 0x10
  709. struct smb2_query_directory_req {
  710. struct smb2_hdr hdr;
  711. __le16 StructureSize; /* Must be 33 */
  712. __u8 FileInformationClass;
  713. __u8 Flags;
  714. __le32 FileIndex;
  715. __u64 PersistentFileId; /* opaque endianness */
  716. __u64 VolatileFileId; /* opaque endianness */
  717. __le16 FileNameOffset;
  718. __le16 FileNameLength;
  719. __le32 OutputBufferLength;
  720. __u8 Buffer[1];
  721. } __packed;
  722. struct smb2_query_directory_rsp {
  723. struct smb2_hdr hdr;
  724. __le16 StructureSize; /* Must be 9 */
  725. __le16 OutputBufferOffset;
  726. __le32 OutputBufferLength;
  727. __u8 Buffer[1];
  728. } __packed;
  729. /* Possible InfoType values */
  730. #define SMB2_O_INFO_FILE 0x01
  731. #define SMB2_O_INFO_FILESYSTEM 0x02
  732. #define SMB2_O_INFO_SECURITY 0x03
  733. #define SMB2_O_INFO_QUOTA 0x04
  734. struct smb2_query_info_req {
  735. struct smb2_hdr hdr;
  736. __le16 StructureSize; /* Must be 41 */
  737. __u8 InfoType;
  738. __u8 FileInfoClass;
  739. __le32 OutputBufferLength;
  740. __le16 InputBufferOffset;
  741. __u16 Reserved;
  742. __le32 InputBufferLength;
  743. __le32 AdditionalInformation;
  744. __le32 Flags;
  745. __u64 PersistentFileId; /* opaque endianness */
  746. __u64 VolatileFileId; /* opaque endianness */
  747. __u8 Buffer[1];
  748. } __packed;
  749. struct smb2_query_info_rsp {
  750. struct smb2_hdr hdr;
  751. __le16 StructureSize; /* Must be 9 */
  752. __le16 OutputBufferOffset;
  753. __le32 OutputBufferLength;
  754. __u8 Buffer[1];
  755. } __packed;
  756. struct smb2_set_info_req {
  757. struct smb2_hdr hdr;
  758. __le16 StructureSize; /* Must be 33 */
  759. __u8 InfoType;
  760. __u8 FileInfoClass;
  761. __le32 BufferLength;
  762. __le16 BufferOffset;
  763. __u16 Reserved;
  764. __le32 AdditionalInformation;
  765. __u64 PersistentFileId; /* opaque endianness */
  766. __u64 VolatileFileId; /* opaque endianness */
  767. __u8 Buffer[1];
  768. } __packed;
  769. struct smb2_set_info_rsp {
  770. struct smb2_hdr hdr;
  771. __le16 StructureSize; /* Must be 2 */
  772. } __packed;
  773. struct smb2_oplock_break {
  774. struct smb2_hdr hdr;
  775. __le16 StructureSize; /* Must be 24 */
  776. __u8 OplockLevel;
  777. __u8 Reserved;
  778. __le32 Reserved2;
  779. __u64 PersistentFid;
  780. __u64 VolatileFid;
  781. } __packed;
  782. #define SMB2_NOTIFY_BREAK_LEASE_FLAG_ACK_REQUIRED cpu_to_le32(0x01)
  783. struct smb2_lease_break {
  784. struct smb2_hdr hdr;
  785. __le16 StructureSize; /* Must be 44 */
  786. __le16 Reserved;
  787. __le32 Flags;
  788. __u8 LeaseKey[16];
  789. __le32 CurrentLeaseState;
  790. __le32 NewLeaseState;
  791. __le32 BreakReason;
  792. __le32 AccessMaskHint;
  793. __le32 ShareMaskHint;
  794. } __packed;
  795. struct smb2_lease_ack {
  796. struct smb2_hdr hdr;
  797. __le16 StructureSize; /* Must be 36 */
  798. __le16 Reserved;
  799. __le32 Flags;
  800. __u8 LeaseKey[16];
  801. __le32 LeaseState;
  802. __le64 LeaseDuration;
  803. } __packed;
  804. /*
  805. * PDU infolevel structure definitions
  806. * BB consider moving to a different header
  807. */
  808. /* File System Information Classes */
  809. #define FS_VOLUME_INFORMATION 1 /* Query */
  810. #define FS_LABEL_INFORMATION 2 /* Local only */
  811. #define FS_SIZE_INFORMATION 3 /* Query */
  812. #define FS_DEVICE_INFORMATION 4 /* Query */
  813. #define FS_ATTRIBUTE_INFORMATION 5 /* Query */
  814. #define FS_CONTROL_INFORMATION 6 /* Query, Set */
  815. #define FS_FULL_SIZE_INFORMATION 7 /* Query */
  816. #define FS_OBJECT_ID_INFORMATION 8 /* Query, Set */
  817. #define FS_DRIVER_PATH_INFORMATION 9 /* Local only */
  818. #define FS_VOLUME_FLAGS_INFORMATION 10 /* Local only */
  819. #define FS_SECTOR_SIZE_INFORMATION 11 /* SMB3 or later. Query */
  820. struct smb2_fs_full_size_info {
  821. __le64 TotalAllocationUnits;
  822. __le64 CallerAvailableAllocationUnits;
  823. __le64 ActualAvailableAllocationUnits;
  824. __le32 SectorsPerAllocationUnit;
  825. __le32 BytesPerSector;
  826. } __packed;
  827. #define SSINFO_FLAGS_ALIGNED_DEVICE 0x00000001
  828. #define SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE 0x00000002
  829. #define SSINFO_FLAGS_NO_SEEK_PENALTY 0x00000004
  830. #define SSINFO_FLAGS_TRIM_ENABLED 0x00000008
  831. /* sector size info struct */
  832. struct smb3_fs_ss_info {
  833. __le32 LogicalBytesPerSector;
  834. __le32 PhysicalBytesPerSectorForAtomicity;
  835. __le32 PhysicalBytesPerSectorForPerf;
  836. __le32 FileSystemEffectivePhysicalBytesPerSectorForAtomicity;
  837. __le32 Flags;
  838. __le32 ByteOffsetForSectorAlignment;
  839. __le32 ByteOffsetForPartitionAlignment;
  840. } __packed;
  841. /* partial list of QUERY INFO levels */
  842. #define FILE_DIRECTORY_INFORMATION 1
  843. #define FILE_FULL_DIRECTORY_INFORMATION 2
  844. #define FILE_BOTH_DIRECTORY_INFORMATION 3
  845. #define FILE_BASIC_INFORMATION 4
  846. #define FILE_STANDARD_INFORMATION 5
  847. #define FILE_INTERNAL_INFORMATION 6
  848. #define FILE_EA_INFORMATION 7
  849. #define FILE_ACCESS_INFORMATION 8
  850. #define FILE_NAME_INFORMATION 9
  851. #define FILE_RENAME_INFORMATION 10
  852. #define FILE_LINK_INFORMATION 11
  853. #define FILE_NAMES_INFORMATION 12
  854. #define FILE_DISPOSITION_INFORMATION 13
  855. #define FILE_POSITION_INFORMATION 14
  856. #define FILE_FULL_EA_INFORMATION 15
  857. #define FILE_MODE_INFORMATION 16
  858. #define FILE_ALIGNMENT_INFORMATION 17
  859. #define FILE_ALL_INFORMATION 18
  860. #define FILE_ALLOCATION_INFORMATION 19
  861. #define FILE_END_OF_FILE_INFORMATION 20
  862. #define FILE_ALTERNATE_NAME_INFORMATION 21
  863. #define FILE_STREAM_INFORMATION 22
  864. #define FILE_PIPE_INFORMATION 23
  865. #define FILE_PIPE_LOCAL_INFORMATION 24
  866. #define FILE_PIPE_REMOTE_INFORMATION 25
  867. #define FILE_MAILSLOT_QUERY_INFORMATION 26
  868. #define FILE_MAILSLOT_SET_INFORMATION 27
  869. #define FILE_COMPRESSION_INFORMATION 28
  870. #define FILE_OBJECT_ID_INFORMATION 29
  871. /* Number 30 not defined in documents */
  872. #define FILE_MOVE_CLUSTER_INFORMATION 31
  873. #define FILE_QUOTA_INFORMATION 32
  874. #define FILE_REPARSE_POINT_INFORMATION 33
  875. #define FILE_NETWORK_OPEN_INFORMATION 34
  876. #define FILE_ATTRIBUTE_TAG_INFORMATION 35
  877. #define FILE_TRACKING_INFORMATION 36
  878. #define FILEID_BOTH_DIRECTORY_INFORMATION 37
  879. #define FILEID_FULL_DIRECTORY_INFORMATION 38
  880. #define FILE_VALID_DATA_LENGTH_INFORMATION 39
  881. #define FILE_SHORT_NAME_INFORMATION 40
  882. #define FILE_SFIO_RESERVE_INFORMATION 44
  883. #define FILE_SFIO_VOLUME_INFORMATION 45
  884. #define FILE_HARD_LINK_INFORMATION 46
  885. #define FILE_NORMALIZED_NAME_INFORMATION 48
  886. #define FILEID_GLOBAL_TX_DIRECTORY_INFORMATION 50
  887. #define FILE_STANDARD_LINK_INFORMATION 54
  888. struct smb2_file_internal_info {
  889. __le64 IndexNumber;
  890. } __packed; /* level 6 Query */
  891. struct smb2_file_rename_info { /* encoding of request for level 10 */
  892. __u8 ReplaceIfExists; /* 1 = replace existing target with new */
  893. /* 0 = fail if target already exists */
  894. __u8 Reserved[7];
  895. __u64 RootDirectory; /* MBZ for network operations (why says spec?) */
  896. __le32 FileNameLength;
  897. char FileName[0]; /* New name to be assigned */
  898. } __packed; /* level 10 Set */
  899. struct smb2_file_link_info { /* encoding of request for level 11 */
  900. __u8 ReplaceIfExists; /* 1 = replace existing link with new */
  901. /* 0 = fail if link already exists */
  902. __u8 Reserved[7];
  903. __u64 RootDirectory; /* MBZ for network operations (why says spec?) */
  904. __le32 FileNameLength;
  905. char FileName[0]; /* Name to be assigned to new link */
  906. } __packed; /* level 11 Set */
  907. /*
  908. * This level 18, although with struct with same name is different from cifs
  909. * level 0x107. Level 0x107 has an extra u64 between AccessFlags and
  910. * CurrentByteOffset.
  911. */
  912. struct smb2_file_all_info { /* data block encoding of response to level 18 */
  913. __le64 CreationTime; /* Beginning of FILE_BASIC_INFO equivalent */
  914. __le64 LastAccessTime;
  915. __le64 LastWriteTime;
  916. __le64 ChangeTime;
  917. __le32 Attributes;
  918. __u32 Pad1; /* End of FILE_BASIC_INFO_INFO equivalent */
  919. __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */
  920. __le64 EndOfFile; /* size ie offset to first free byte in file */
  921. __le32 NumberOfLinks; /* hard links */
  922. __u8 DeletePending;
  923. __u8 Directory;
  924. __u16 Pad2; /* End of FILE_STANDARD_INFO equivalent */
  925. __le64 IndexNumber;
  926. __le32 EASize;
  927. __le32 AccessFlags;
  928. __le64 CurrentByteOffset;
  929. __le32 Mode;
  930. __le32 AlignmentRequirement;
  931. __le32 FileNameLength;
  932. char FileName[1];
  933. } __packed; /* level 18 Query */
  934. struct smb2_file_eof_info { /* encoding of request for level 10 */
  935. __le64 EndOfFile; /* new end of file value */
  936. } __packed; /* level 20 Set */
  937. #endif /* _SMB2PDU_H */