cifspdu.h 80 KB

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