cifspdu.h 70 KB

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