cifspdu.h 74 KB

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