cifspdu.h 84 KB

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