cifspdu.h 84 KB

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