cifspdu.h 83 KB

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