smb2ops.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041
  1. /*
  2. * SMB2 version specific operations
  3. *
  4. * Copyright (c) 2012, Jeff Layton <jlayton@redhat.com>
  5. *
  6. * This library is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License v2 as published
  8. * by the Free Software Foundation.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
  13. * the GNU Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public License
  16. * along with this library; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. #include <linux/pagemap.h>
  20. #include <linux/vfs.h>
  21. #include "cifsglob.h"
  22. #include "smb2pdu.h"
  23. #include "smb2proto.h"
  24. #include "cifsproto.h"
  25. #include "cifs_debug.h"
  26. #include "cifs_unicode.h"
  27. #include "smb2status.h"
  28. #include "smb2glob.h"
  29. static int
  30. change_conf(struct TCP_Server_Info *server)
  31. {
  32. server->credits += server->echo_credits + server->oplock_credits;
  33. server->oplock_credits = server->echo_credits = 0;
  34. switch (server->credits) {
  35. case 0:
  36. return -1;
  37. case 1:
  38. server->echoes = false;
  39. server->oplocks = false;
  40. cifs_dbg(VFS, "disabling echoes and oplocks\n");
  41. break;
  42. case 2:
  43. server->echoes = true;
  44. server->oplocks = false;
  45. server->echo_credits = 1;
  46. cifs_dbg(FYI, "disabling oplocks\n");
  47. break;
  48. default:
  49. server->echoes = true;
  50. server->oplocks = true;
  51. server->echo_credits = 1;
  52. server->oplock_credits = 1;
  53. }
  54. server->credits -= server->echo_credits + server->oplock_credits;
  55. return 0;
  56. }
  57. static void
  58. smb2_add_credits(struct TCP_Server_Info *server, const unsigned int add,
  59. const int optype)
  60. {
  61. int *val, rc = 0;
  62. spin_lock(&server->req_lock);
  63. val = server->ops->get_credits_field(server, optype);
  64. *val += add;
  65. server->in_flight--;
  66. if (server->in_flight == 0 && (optype & CIFS_OP_MASK) != CIFS_NEG_OP)
  67. rc = change_conf(server);
  68. /*
  69. * Sometimes server returns 0 credits on oplock break ack - we need to
  70. * rebalance credits in this case.
  71. */
  72. else if (server->in_flight > 0 && server->oplock_credits == 0 &&
  73. server->oplocks) {
  74. if (server->credits > 1) {
  75. server->credits--;
  76. server->oplock_credits++;
  77. }
  78. }
  79. spin_unlock(&server->req_lock);
  80. wake_up(&server->request_q);
  81. if (rc)
  82. cifs_reconnect(server);
  83. }
  84. static void
  85. smb2_set_credits(struct TCP_Server_Info *server, const int val)
  86. {
  87. spin_lock(&server->req_lock);
  88. server->credits = val;
  89. spin_unlock(&server->req_lock);
  90. }
  91. static int *
  92. smb2_get_credits_field(struct TCP_Server_Info *server, const int optype)
  93. {
  94. switch (optype) {
  95. case CIFS_ECHO_OP:
  96. return &server->echo_credits;
  97. case CIFS_OBREAK_OP:
  98. return &server->oplock_credits;
  99. default:
  100. return &server->credits;
  101. }
  102. }
  103. static unsigned int
  104. smb2_get_credits(struct mid_q_entry *mid)
  105. {
  106. return le16_to_cpu(((struct smb2_hdr *)mid->resp_buf)->CreditRequest);
  107. }
  108. static __u64
  109. smb2_get_next_mid(struct TCP_Server_Info *server)
  110. {
  111. __u64 mid;
  112. /* for SMB2 we need the current value */
  113. spin_lock(&GlobalMid_Lock);
  114. mid = server->CurrentMid++;
  115. spin_unlock(&GlobalMid_Lock);
  116. return mid;
  117. }
  118. static struct mid_q_entry *
  119. smb2_find_mid(struct TCP_Server_Info *server, char *buf)
  120. {
  121. struct mid_q_entry *mid;
  122. struct smb2_hdr *hdr = (struct smb2_hdr *)buf;
  123. spin_lock(&GlobalMid_Lock);
  124. list_for_each_entry(mid, &server->pending_mid_q, qhead) {
  125. if ((mid->mid == hdr->MessageId) &&
  126. (mid->mid_state == MID_REQUEST_SUBMITTED) &&
  127. (mid->command == hdr->Command)) {
  128. spin_unlock(&GlobalMid_Lock);
  129. return mid;
  130. }
  131. }
  132. spin_unlock(&GlobalMid_Lock);
  133. return NULL;
  134. }
  135. static void
  136. smb2_dump_detail(void *buf)
  137. {
  138. #ifdef CONFIG_CIFS_DEBUG2
  139. struct smb2_hdr *smb = (struct smb2_hdr *)buf;
  140. cifs_dbg(VFS, "Cmd: %d Err: 0x%x Flags: 0x%x Mid: %llu Pid: %d\n",
  141. smb->Command, smb->Status, smb->Flags, smb->MessageId,
  142. smb->ProcessId);
  143. cifs_dbg(VFS, "smb buf %p len %u\n", smb, smb2_calc_size(smb));
  144. #endif
  145. }
  146. static bool
  147. smb2_need_neg(struct TCP_Server_Info *server)
  148. {
  149. return server->max_read == 0;
  150. }
  151. static int
  152. smb2_negotiate(const unsigned int xid, struct cifs_ses *ses)
  153. {
  154. int rc;
  155. ses->server->CurrentMid = 0;
  156. rc = SMB2_negotiate(xid, ses);
  157. /* BB we probably don't need to retry with modern servers */
  158. if (rc == -EAGAIN)
  159. rc = -EHOSTDOWN;
  160. return rc;
  161. }
  162. static unsigned int
  163. smb2_negotiate_wsize(struct cifs_tcon *tcon, struct smb_vol *volume_info)
  164. {
  165. struct TCP_Server_Info *server = tcon->ses->server;
  166. unsigned int wsize;
  167. /* start with specified wsize, or default */
  168. wsize = volume_info->wsize ? volume_info->wsize : CIFS_DEFAULT_IOSIZE;
  169. wsize = min_t(unsigned int, wsize, server->max_write);
  170. /*
  171. * limit write size to 2 ** 16, because we don't support multicredit
  172. * requests now.
  173. */
  174. wsize = min_t(unsigned int, wsize, 2 << 15);
  175. return wsize;
  176. }
  177. static unsigned int
  178. smb2_negotiate_rsize(struct cifs_tcon *tcon, struct smb_vol *volume_info)
  179. {
  180. struct TCP_Server_Info *server = tcon->ses->server;
  181. unsigned int rsize;
  182. /* start with specified rsize, or default */
  183. rsize = volume_info->rsize ? volume_info->rsize : CIFS_DEFAULT_IOSIZE;
  184. rsize = min_t(unsigned int, rsize, server->max_read);
  185. /*
  186. * limit write size to 2 ** 16, because we don't support multicredit
  187. * requests now.
  188. */
  189. rsize = min_t(unsigned int, rsize, 2 << 15);
  190. return rsize;
  191. }
  192. static int
  193. smb2_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon,
  194. struct cifs_sb_info *cifs_sb, const char *full_path)
  195. {
  196. int rc;
  197. __le16 *utf16_path;
  198. __u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
  199. struct cifs_open_parms oparms;
  200. struct cifs_fid fid;
  201. utf16_path = cifs_convert_path_to_utf16(full_path, cifs_sb);
  202. if (!utf16_path)
  203. return -ENOMEM;
  204. oparms.tcon = tcon;
  205. oparms.desired_access = FILE_READ_ATTRIBUTES;
  206. oparms.disposition = FILE_OPEN;
  207. oparms.create_options = 0;
  208. oparms.fid = &fid;
  209. oparms.reconnect = false;
  210. rc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL, NULL);
  211. if (rc) {
  212. kfree(utf16_path);
  213. return rc;
  214. }
  215. rc = SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
  216. kfree(utf16_path);
  217. return rc;
  218. }
  219. static int
  220. smb2_get_srv_inum(const unsigned int xid, struct cifs_tcon *tcon,
  221. struct cifs_sb_info *cifs_sb, const char *full_path,
  222. u64 *uniqueid, FILE_ALL_INFO *data)
  223. {
  224. *uniqueid = le64_to_cpu(data->IndexNumber);
  225. return 0;
  226. }
  227. static int
  228. smb2_query_file_info(const unsigned int xid, struct cifs_tcon *tcon,
  229. struct cifs_fid *fid, FILE_ALL_INFO *data)
  230. {
  231. int rc;
  232. struct smb2_file_all_info *smb2_data;
  233. smb2_data = kzalloc(sizeof(struct smb2_file_all_info) + MAX_NAME * 2,
  234. GFP_KERNEL);
  235. if (smb2_data == NULL)
  236. return -ENOMEM;
  237. rc = SMB2_query_info(xid, tcon, fid->persistent_fid, fid->volatile_fid,
  238. smb2_data);
  239. if (!rc)
  240. move_smb2_info_to_cifs(data, smb2_data);
  241. kfree(smb2_data);
  242. return rc;
  243. }
  244. static bool
  245. smb2_can_echo(struct TCP_Server_Info *server)
  246. {
  247. return server->echoes;
  248. }
  249. static void
  250. smb2_clear_stats(struct cifs_tcon *tcon)
  251. {
  252. #ifdef CONFIG_CIFS_STATS
  253. int i;
  254. for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
  255. atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
  256. atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
  257. }
  258. #endif
  259. }
  260. static void
  261. smb2_dump_share_caps(struct seq_file *m, struct cifs_tcon *tcon)
  262. {
  263. seq_puts(m, "\n\tShare Capabilities:");
  264. if (tcon->capabilities & SMB2_SHARE_CAP_DFS)
  265. seq_puts(m, " DFS,");
  266. if (tcon->capabilities & SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY)
  267. seq_puts(m, " CONTINUOUS AVAILABILITY,");
  268. if (tcon->capabilities & SMB2_SHARE_CAP_SCALEOUT)
  269. seq_puts(m, " SCALEOUT,");
  270. if (tcon->capabilities & SMB2_SHARE_CAP_CLUSTER)
  271. seq_puts(m, " CLUSTER,");
  272. if (tcon->capabilities & SMB2_SHARE_CAP_ASYMMETRIC)
  273. seq_puts(m, " ASYMMETRIC,");
  274. if (tcon->capabilities == 0)
  275. seq_puts(m, " None");
  276. seq_printf(m, "\tShare Flags: 0x%x", tcon->share_flags);
  277. }
  278. static void
  279. smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
  280. {
  281. #ifdef CONFIG_CIFS_STATS
  282. atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
  283. atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
  284. seq_printf(m, "\nNegotiates: %d sent %d failed",
  285. atomic_read(&sent[SMB2_NEGOTIATE_HE]),
  286. atomic_read(&failed[SMB2_NEGOTIATE_HE]));
  287. seq_printf(m, "\nSessionSetups: %d sent %d failed",
  288. atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
  289. atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
  290. seq_printf(m, "\nLogoffs: %d sent %d failed",
  291. atomic_read(&sent[SMB2_LOGOFF_HE]),
  292. atomic_read(&failed[SMB2_LOGOFF_HE]));
  293. seq_printf(m, "\nTreeConnects: %d sent %d failed",
  294. atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
  295. atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
  296. seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
  297. atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
  298. atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
  299. seq_printf(m, "\nCreates: %d sent %d failed",
  300. atomic_read(&sent[SMB2_CREATE_HE]),
  301. atomic_read(&failed[SMB2_CREATE_HE]));
  302. seq_printf(m, "\nCloses: %d sent %d failed",
  303. atomic_read(&sent[SMB2_CLOSE_HE]),
  304. atomic_read(&failed[SMB2_CLOSE_HE]));
  305. seq_printf(m, "\nFlushes: %d sent %d failed",
  306. atomic_read(&sent[SMB2_FLUSH_HE]),
  307. atomic_read(&failed[SMB2_FLUSH_HE]));
  308. seq_printf(m, "\nReads: %d sent %d failed",
  309. atomic_read(&sent[SMB2_READ_HE]),
  310. atomic_read(&failed[SMB2_READ_HE]));
  311. seq_printf(m, "\nWrites: %d sent %d failed",
  312. atomic_read(&sent[SMB2_WRITE_HE]),
  313. atomic_read(&failed[SMB2_WRITE_HE]));
  314. seq_printf(m, "\nLocks: %d sent %d failed",
  315. atomic_read(&sent[SMB2_LOCK_HE]),
  316. atomic_read(&failed[SMB2_LOCK_HE]));
  317. seq_printf(m, "\nIOCTLs: %d sent %d failed",
  318. atomic_read(&sent[SMB2_IOCTL_HE]),
  319. atomic_read(&failed[SMB2_IOCTL_HE]));
  320. seq_printf(m, "\nCancels: %d sent %d failed",
  321. atomic_read(&sent[SMB2_CANCEL_HE]),
  322. atomic_read(&failed[SMB2_CANCEL_HE]));
  323. seq_printf(m, "\nEchos: %d sent %d failed",
  324. atomic_read(&sent[SMB2_ECHO_HE]),
  325. atomic_read(&failed[SMB2_ECHO_HE]));
  326. seq_printf(m, "\nQueryDirectories: %d sent %d failed",
  327. atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
  328. atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
  329. seq_printf(m, "\nChangeNotifies: %d sent %d failed",
  330. atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
  331. atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
  332. seq_printf(m, "\nQueryInfos: %d sent %d failed",
  333. atomic_read(&sent[SMB2_QUERY_INFO_HE]),
  334. atomic_read(&failed[SMB2_QUERY_INFO_HE]));
  335. seq_printf(m, "\nSetInfos: %d sent %d failed",
  336. atomic_read(&sent[SMB2_SET_INFO_HE]),
  337. atomic_read(&failed[SMB2_SET_INFO_HE]));
  338. seq_printf(m, "\nOplockBreaks: %d sent %d failed",
  339. atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
  340. atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
  341. #endif
  342. }
  343. static void
  344. smb2_set_fid(struct cifsFileInfo *cfile, struct cifs_fid *fid, __u32 oplock)
  345. {
  346. struct cifsInodeInfo *cinode = CIFS_I(cfile->dentry->d_inode);
  347. struct TCP_Server_Info *server = tlink_tcon(cfile->tlink)->ses->server;
  348. cfile->fid.persistent_fid = fid->persistent_fid;
  349. cfile->fid.volatile_fid = fid->volatile_fid;
  350. server->ops->set_oplock_level(cinode, oplock);
  351. cinode->can_cache_brlcks = CIFS_CACHE_WRITE(cinode);
  352. }
  353. static void
  354. smb2_close_file(const unsigned int xid, struct cifs_tcon *tcon,
  355. struct cifs_fid *fid)
  356. {
  357. SMB2_close(xid, tcon, fid->persistent_fid, fid->volatile_fid);
  358. }
  359. static int
  360. smb2_flush_file(const unsigned int xid, struct cifs_tcon *tcon,
  361. struct cifs_fid *fid)
  362. {
  363. return SMB2_flush(xid, tcon, fid->persistent_fid, fid->volatile_fid);
  364. }
  365. static unsigned int
  366. smb2_read_data_offset(char *buf)
  367. {
  368. struct smb2_read_rsp *rsp = (struct smb2_read_rsp *)buf;
  369. return rsp->DataOffset;
  370. }
  371. static unsigned int
  372. smb2_read_data_length(char *buf)
  373. {
  374. struct smb2_read_rsp *rsp = (struct smb2_read_rsp *)buf;
  375. return le32_to_cpu(rsp->DataLength);
  376. }
  377. static int
  378. smb2_sync_read(const unsigned int xid, struct cifsFileInfo *cfile,
  379. struct cifs_io_parms *parms, unsigned int *bytes_read,
  380. char **buf, int *buf_type)
  381. {
  382. parms->persistent_fid = cfile->fid.persistent_fid;
  383. parms->volatile_fid = cfile->fid.volatile_fid;
  384. return SMB2_read(xid, parms, bytes_read, buf, buf_type);
  385. }
  386. static int
  387. smb2_sync_write(const unsigned int xid, struct cifsFileInfo *cfile,
  388. struct cifs_io_parms *parms, unsigned int *written,
  389. struct kvec *iov, unsigned long nr_segs)
  390. {
  391. parms->persistent_fid = cfile->fid.persistent_fid;
  392. parms->volatile_fid = cfile->fid.volatile_fid;
  393. return SMB2_write(xid, parms, written, iov, nr_segs);
  394. }
  395. static int
  396. smb2_set_file_size(const unsigned int xid, struct cifs_tcon *tcon,
  397. struct cifsFileInfo *cfile, __u64 size, bool set_alloc)
  398. {
  399. __le64 eof = cpu_to_le64(size);
  400. return SMB2_set_eof(xid, tcon, cfile->fid.persistent_fid,
  401. cfile->fid.volatile_fid, cfile->pid, &eof);
  402. }
  403. static int
  404. smb2_query_dir_first(const unsigned int xid, struct cifs_tcon *tcon,
  405. const char *path, struct cifs_sb_info *cifs_sb,
  406. struct cifs_fid *fid, __u16 search_flags,
  407. struct cifs_search_info *srch_inf)
  408. {
  409. __le16 *utf16_path;
  410. int rc;
  411. __u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
  412. struct cifs_open_parms oparms;
  413. utf16_path = cifs_convert_path_to_utf16(path, cifs_sb);
  414. if (!utf16_path)
  415. return -ENOMEM;
  416. oparms.tcon = tcon;
  417. oparms.desired_access = FILE_READ_ATTRIBUTES | FILE_READ_DATA;
  418. oparms.disposition = FILE_OPEN;
  419. oparms.create_options = 0;
  420. oparms.fid = fid;
  421. oparms.reconnect = false;
  422. rc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL, NULL);
  423. kfree(utf16_path);
  424. if (rc) {
  425. cifs_dbg(VFS, "open dir failed\n");
  426. return rc;
  427. }
  428. srch_inf->entries_in_buffer = 0;
  429. srch_inf->index_of_last_entry = 0;
  430. rc = SMB2_query_directory(xid, tcon, fid->persistent_fid,
  431. fid->volatile_fid, 0, srch_inf);
  432. if (rc) {
  433. cifs_dbg(VFS, "query directory failed\n");
  434. SMB2_close(xid, tcon, fid->persistent_fid, fid->volatile_fid);
  435. }
  436. return rc;
  437. }
  438. static int
  439. smb2_query_dir_next(const unsigned int xid, struct cifs_tcon *tcon,
  440. struct cifs_fid *fid, __u16 search_flags,
  441. struct cifs_search_info *srch_inf)
  442. {
  443. return SMB2_query_directory(xid, tcon, fid->persistent_fid,
  444. fid->volatile_fid, 0, srch_inf);
  445. }
  446. static int
  447. smb2_close_dir(const unsigned int xid, struct cifs_tcon *tcon,
  448. struct cifs_fid *fid)
  449. {
  450. return SMB2_close(xid, tcon, fid->persistent_fid, fid->volatile_fid);
  451. }
  452. /*
  453. * If we negotiate SMB2 protocol and get STATUS_PENDING - update
  454. * the number of credits and return true. Otherwise - return false.
  455. */
  456. static bool
  457. smb2_is_status_pending(char *buf, struct TCP_Server_Info *server, int length)
  458. {
  459. struct smb2_hdr *hdr = (struct smb2_hdr *)buf;
  460. if (hdr->Status != STATUS_PENDING)
  461. return false;
  462. if (!length) {
  463. spin_lock(&server->req_lock);
  464. server->credits += le16_to_cpu(hdr->CreditRequest);
  465. spin_unlock(&server->req_lock);
  466. wake_up(&server->request_q);
  467. }
  468. return true;
  469. }
  470. static int
  471. smb2_oplock_response(struct cifs_tcon *tcon, struct cifs_fid *fid,
  472. struct cifsInodeInfo *cinode)
  473. {
  474. if (tcon->ses->server->capabilities & SMB2_GLOBAL_CAP_LEASING)
  475. return SMB2_lease_break(0, tcon, cinode->lease_key,
  476. smb2_get_lease_state(cinode));
  477. return SMB2_oplock_break(0, tcon, fid->persistent_fid,
  478. fid->volatile_fid,
  479. CIFS_CACHE_READ(cinode) ? 1 : 0);
  480. }
  481. static int
  482. smb2_queryfs(const unsigned int xid, struct cifs_tcon *tcon,
  483. struct kstatfs *buf)
  484. {
  485. int rc;
  486. __le16 srch_path = 0; /* Null - open root of share */
  487. u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
  488. struct cifs_open_parms oparms;
  489. struct cifs_fid fid;
  490. oparms.tcon = tcon;
  491. oparms.desired_access = FILE_READ_ATTRIBUTES;
  492. oparms.disposition = FILE_OPEN;
  493. oparms.create_options = 0;
  494. oparms.fid = &fid;
  495. oparms.reconnect = false;
  496. rc = SMB2_open(xid, &oparms, &srch_path, &oplock, NULL, NULL);
  497. if (rc)
  498. return rc;
  499. buf->f_type = SMB2_MAGIC_NUMBER;
  500. rc = SMB2_QFS_info(xid, tcon, fid.persistent_fid, fid.volatile_fid,
  501. buf);
  502. SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
  503. return rc;
  504. }
  505. static bool
  506. smb2_compare_fids(struct cifsFileInfo *ob1, struct cifsFileInfo *ob2)
  507. {
  508. return ob1->fid.persistent_fid == ob2->fid.persistent_fid &&
  509. ob1->fid.volatile_fid == ob2->fid.volatile_fid;
  510. }
  511. static int
  512. smb2_mand_lock(const unsigned int xid, struct cifsFileInfo *cfile, __u64 offset,
  513. __u64 length, __u32 type, int lock, int unlock, bool wait)
  514. {
  515. if (unlock && !lock)
  516. type = SMB2_LOCKFLAG_UNLOCK;
  517. return SMB2_lock(xid, tlink_tcon(cfile->tlink),
  518. cfile->fid.persistent_fid, cfile->fid.volatile_fid,
  519. current->tgid, length, offset, type, wait);
  520. }
  521. static void
  522. smb2_get_lease_key(struct inode *inode, struct cifs_fid *fid)
  523. {
  524. memcpy(fid->lease_key, CIFS_I(inode)->lease_key, SMB2_LEASE_KEY_SIZE);
  525. }
  526. static void
  527. smb2_set_lease_key(struct inode *inode, struct cifs_fid *fid)
  528. {
  529. memcpy(CIFS_I(inode)->lease_key, fid->lease_key, SMB2_LEASE_KEY_SIZE);
  530. }
  531. static void
  532. smb2_new_lease_key(struct cifs_fid *fid)
  533. {
  534. get_random_bytes(fid->lease_key, SMB2_LEASE_KEY_SIZE);
  535. }
  536. static int
  537. smb2_query_symlink(const unsigned int xid, struct cifs_tcon *tcon,
  538. const char *full_path, char **target_path,
  539. struct cifs_sb_info *cifs_sb)
  540. {
  541. int rc;
  542. __le16 *utf16_path;
  543. __u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
  544. struct cifs_open_parms oparms;
  545. struct cifs_fid fid;
  546. struct smb2_err_rsp *err_buf = NULL;
  547. struct smb2_symlink_err_rsp *symlink;
  548. unsigned int sub_len, sub_offset;
  549. cifs_dbg(FYI, "%s: path: %s\n", __func__, full_path);
  550. utf16_path = cifs_convert_path_to_utf16(full_path, cifs_sb);
  551. if (!utf16_path)
  552. return -ENOMEM;
  553. oparms.tcon = tcon;
  554. oparms.desired_access = FILE_READ_ATTRIBUTES;
  555. oparms.disposition = FILE_OPEN;
  556. oparms.create_options = 0;
  557. oparms.fid = &fid;
  558. oparms.reconnect = false;
  559. rc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL, &err_buf);
  560. if (!rc || !err_buf) {
  561. kfree(utf16_path);
  562. return -ENOENT;
  563. }
  564. /* open must fail on symlink - reset rc */
  565. rc = 0;
  566. symlink = (struct smb2_symlink_err_rsp *)err_buf->ErrorData;
  567. sub_len = le16_to_cpu(symlink->SubstituteNameLength);
  568. sub_offset = le16_to_cpu(symlink->SubstituteNameOffset);
  569. *target_path = cifs_strndup_from_utf16(
  570. (char *)symlink->PathBuffer + sub_offset,
  571. sub_len, true, cifs_sb->local_nls);
  572. if (!(*target_path)) {
  573. kfree(utf16_path);
  574. return -ENOMEM;
  575. }
  576. convert_delimiter(*target_path, '/');
  577. cifs_dbg(FYI, "%s: target path: %s\n", __func__, *target_path);
  578. kfree(utf16_path);
  579. return rc;
  580. }
  581. static void
  582. smb2_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock)
  583. {
  584. oplock &= 0xFF;
  585. if (oplock == SMB2_OPLOCK_LEVEL_NOCHANGE)
  586. return;
  587. if (oplock == SMB2_OPLOCK_LEVEL_BATCH) {
  588. cinode->oplock = CIFS_CACHE_READ_FLG | CIFS_CACHE_WRITE_FLG |
  589. CIFS_CACHE_HANDLE_FLG;
  590. cifs_dbg(FYI, "Batch Oplock granted on inode %p\n",
  591. &cinode->vfs_inode);
  592. } else if (oplock == SMB2_OPLOCK_LEVEL_EXCLUSIVE) {
  593. cinode->oplock = CIFS_CACHE_READ_FLG | CIFS_CACHE_WRITE_FLG;
  594. cifs_dbg(FYI, "Exclusive Oplock granted on inode %p\n",
  595. &cinode->vfs_inode);
  596. } else if (oplock == SMB2_OPLOCK_LEVEL_II) {
  597. cinode->oplock = CIFS_CACHE_READ_FLG;
  598. cifs_dbg(FYI, "Level II Oplock granted on inode %p\n",
  599. &cinode->vfs_inode);
  600. } else
  601. cinode->oplock = 0;
  602. }
  603. static void
  604. smb21_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock)
  605. {
  606. char message[5] = {0};
  607. oplock &= 0xFF;
  608. if (oplock == SMB2_OPLOCK_LEVEL_NOCHANGE)
  609. return;
  610. cinode->oplock = 0;
  611. if (oplock & SMB2_LEASE_READ_CACHING_HE) {
  612. cinode->oplock |= CIFS_CACHE_READ_FLG;
  613. strcat(message, "R");
  614. }
  615. if (oplock & SMB2_LEASE_HANDLE_CACHING_HE) {
  616. cinode->oplock |= CIFS_CACHE_HANDLE_FLG;
  617. strcat(message, "H");
  618. }
  619. if (oplock & SMB2_LEASE_WRITE_CACHING_HE) {
  620. cinode->oplock |= CIFS_CACHE_WRITE_FLG;
  621. strcat(message, "W");
  622. }
  623. if (!cinode->oplock)
  624. strcat(message, "None");
  625. cifs_dbg(FYI, "%s Lease granted on inode %p\n", message,
  626. &cinode->vfs_inode);
  627. }
  628. static bool
  629. smb2_is_read_op(__u32 oplock)
  630. {
  631. return oplock == SMB2_OPLOCK_LEVEL_II;
  632. }
  633. static bool
  634. smb21_is_read_op(__u32 oplock)
  635. {
  636. return (oplock & SMB2_LEASE_READ_CACHING_HE) &&
  637. !(oplock & SMB2_LEASE_WRITE_CACHING_HE);
  638. }
  639. static char *
  640. smb2_create_lease_buf(u8 *lease_key, u8 oplock)
  641. {
  642. struct create_lease *buf;
  643. buf = kzalloc(sizeof(struct create_lease), GFP_KERNEL);
  644. if (!buf)
  645. return NULL;
  646. buf->lcontext.LeaseKeyLow = cpu_to_le64(*((u64 *)lease_key));
  647. buf->lcontext.LeaseKeyHigh = cpu_to_le64(*((u64 *)(lease_key + 8)));
  648. if (oplock == SMB2_OPLOCK_LEVEL_EXCLUSIVE)
  649. buf->lcontext.LeaseState = SMB2_LEASE_WRITE_CACHING |
  650. SMB2_LEASE_READ_CACHING;
  651. else if (oplock == SMB2_OPLOCK_LEVEL_II)
  652. buf->lcontext.LeaseState = SMB2_LEASE_READ_CACHING;
  653. else if (oplock == SMB2_OPLOCK_LEVEL_BATCH)
  654. buf->lcontext.LeaseState = SMB2_LEASE_HANDLE_CACHING |
  655. SMB2_LEASE_READ_CACHING |
  656. SMB2_LEASE_WRITE_CACHING;
  657. buf->ccontext.DataOffset = cpu_to_le16(offsetof
  658. (struct create_lease, lcontext));
  659. buf->ccontext.DataLength = cpu_to_le32(sizeof(struct lease_context));
  660. buf->ccontext.NameOffset = cpu_to_le16(offsetof
  661. (struct create_lease, Name));
  662. buf->ccontext.NameLength = cpu_to_le16(4);
  663. buf->Name[0] = 'R';
  664. buf->Name[1] = 'q';
  665. buf->Name[2] = 'L';
  666. buf->Name[3] = 's';
  667. return (char *)buf;
  668. }
  669. struct smb_version_operations smb20_operations = {
  670. .compare_fids = smb2_compare_fids,
  671. .setup_request = smb2_setup_request,
  672. .setup_async_request = smb2_setup_async_request,
  673. .check_receive = smb2_check_receive,
  674. .add_credits = smb2_add_credits,
  675. .set_credits = smb2_set_credits,
  676. .get_credits_field = smb2_get_credits_field,
  677. .get_credits = smb2_get_credits,
  678. .get_next_mid = smb2_get_next_mid,
  679. .read_data_offset = smb2_read_data_offset,
  680. .read_data_length = smb2_read_data_length,
  681. .map_error = map_smb2_to_linux_error,
  682. .find_mid = smb2_find_mid,
  683. .check_message = smb2_check_message,
  684. .dump_detail = smb2_dump_detail,
  685. .clear_stats = smb2_clear_stats,
  686. .print_stats = smb2_print_stats,
  687. .is_oplock_break = smb2_is_valid_oplock_break,
  688. .need_neg = smb2_need_neg,
  689. .negotiate = smb2_negotiate,
  690. .negotiate_wsize = smb2_negotiate_wsize,
  691. .negotiate_rsize = smb2_negotiate_rsize,
  692. .sess_setup = SMB2_sess_setup,
  693. .logoff = SMB2_logoff,
  694. .tree_connect = SMB2_tcon,
  695. .tree_disconnect = SMB2_tdis,
  696. .is_path_accessible = smb2_is_path_accessible,
  697. .can_echo = smb2_can_echo,
  698. .echo = SMB2_echo,
  699. .query_path_info = smb2_query_path_info,
  700. .get_srv_inum = smb2_get_srv_inum,
  701. .query_file_info = smb2_query_file_info,
  702. .set_path_size = smb2_set_path_size,
  703. .set_file_size = smb2_set_file_size,
  704. .set_file_info = smb2_set_file_info,
  705. .mkdir = smb2_mkdir,
  706. .mkdir_setinfo = smb2_mkdir_setinfo,
  707. .rmdir = smb2_rmdir,
  708. .unlink = smb2_unlink,
  709. .rename = smb2_rename_path,
  710. .create_hardlink = smb2_create_hardlink,
  711. .query_symlink = smb2_query_symlink,
  712. .open = smb2_open_file,
  713. .set_fid = smb2_set_fid,
  714. .close = smb2_close_file,
  715. .flush = smb2_flush_file,
  716. .async_readv = smb2_async_readv,
  717. .async_writev = smb2_async_writev,
  718. .sync_read = smb2_sync_read,
  719. .sync_write = smb2_sync_write,
  720. .query_dir_first = smb2_query_dir_first,
  721. .query_dir_next = smb2_query_dir_next,
  722. .close_dir = smb2_close_dir,
  723. .calc_smb_size = smb2_calc_size,
  724. .is_status_pending = smb2_is_status_pending,
  725. .oplock_response = smb2_oplock_response,
  726. .queryfs = smb2_queryfs,
  727. .mand_lock = smb2_mand_lock,
  728. .mand_unlock_range = smb2_unlock_range,
  729. .push_mand_locks = smb2_push_mandatory_locks,
  730. .get_lease_key = smb2_get_lease_key,
  731. .set_lease_key = smb2_set_lease_key,
  732. .new_lease_key = smb2_new_lease_key,
  733. .calc_signature = smb2_calc_signature,
  734. .is_read_op = smb2_is_read_op,
  735. .set_oplock_level = smb2_set_oplock_level,
  736. .create_lease_buf = smb2_create_lease_buf,
  737. };
  738. struct smb_version_operations smb21_operations = {
  739. .compare_fids = smb2_compare_fids,
  740. .setup_request = smb2_setup_request,
  741. .setup_async_request = smb2_setup_async_request,
  742. .check_receive = smb2_check_receive,
  743. .add_credits = smb2_add_credits,
  744. .set_credits = smb2_set_credits,
  745. .get_credits_field = smb2_get_credits_field,
  746. .get_credits = smb2_get_credits,
  747. .get_next_mid = smb2_get_next_mid,
  748. .read_data_offset = smb2_read_data_offset,
  749. .read_data_length = smb2_read_data_length,
  750. .map_error = map_smb2_to_linux_error,
  751. .find_mid = smb2_find_mid,
  752. .check_message = smb2_check_message,
  753. .dump_detail = smb2_dump_detail,
  754. .clear_stats = smb2_clear_stats,
  755. .print_stats = smb2_print_stats,
  756. .is_oplock_break = smb2_is_valid_oplock_break,
  757. .need_neg = smb2_need_neg,
  758. .negotiate = smb2_negotiate,
  759. .negotiate_wsize = smb2_negotiate_wsize,
  760. .negotiate_rsize = smb2_negotiate_rsize,
  761. .sess_setup = SMB2_sess_setup,
  762. .logoff = SMB2_logoff,
  763. .tree_connect = SMB2_tcon,
  764. .tree_disconnect = SMB2_tdis,
  765. .is_path_accessible = smb2_is_path_accessible,
  766. .can_echo = smb2_can_echo,
  767. .echo = SMB2_echo,
  768. .query_path_info = smb2_query_path_info,
  769. .get_srv_inum = smb2_get_srv_inum,
  770. .query_file_info = smb2_query_file_info,
  771. .set_path_size = smb2_set_path_size,
  772. .set_file_size = smb2_set_file_size,
  773. .set_file_info = smb2_set_file_info,
  774. .mkdir = smb2_mkdir,
  775. .mkdir_setinfo = smb2_mkdir_setinfo,
  776. .rmdir = smb2_rmdir,
  777. .unlink = smb2_unlink,
  778. .rename = smb2_rename_path,
  779. .create_hardlink = smb2_create_hardlink,
  780. .query_symlink = smb2_query_symlink,
  781. .open = smb2_open_file,
  782. .set_fid = smb2_set_fid,
  783. .close = smb2_close_file,
  784. .flush = smb2_flush_file,
  785. .async_readv = smb2_async_readv,
  786. .async_writev = smb2_async_writev,
  787. .sync_read = smb2_sync_read,
  788. .sync_write = smb2_sync_write,
  789. .query_dir_first = smb2_query_dir_first,
  790. .query_dir_next = smb2_query_dir_next,
  791. .close_dir = smb2_close_dir,
  792. .calc_smb_size = smb2_calc_size,
  793. .is_status_pending = smb2_is_status_pending,
  794. .oplock_response = smb2_oplock_response,
  795. .queryfs = smb2_queryfs,
  796. .mand_lock = smb2_mand_lock,
  797. .mand_unlock_range = smb2_unlock_range,
  798. .push_mand_locks = smb2_push_mandatory_locks,
  799. .get_lease_key = smb2_get_lease_key,
  800. .set_lease_key = smb2_set_lease_key,
  801. .new_lease_key = smb2_new_lease_key,
  802. .calc_signature = smb2_calc_signature,
  803. .is_read_op = smb21_is_read_op,
  804. .set_oplock_level = smb21_set_oplock_level,
  805. .create_lease_buf = smb2_create_lease_buf,
  806. };
  807. struct smb_version_operations smb30_operations = {
  808. .compare_fids = smb2_compare_fids,
  809. .setup_request = smb2_setup_request,
  810. .setup_async_request = smb2_setup_async_request,
  811. .check_receive = smb2_check_receive,
  812. .add_credits = smb2_add_credits,
  813. .set_credits = smb2_set_credits,
  814. .get_credits_field = smb2_get_credits_field,
  815. .get_credits = smb2_get_credits,
  816. .get_next_mid = smb2_get_next_mid,
  817. .read_data_offset = smb2_read_data_offset,
  818. .read_data_length = smb2_read_data_length,
  819. .map_error = map_smb2_to_linux_error,
  820. .find_mid = smb2_find_mid,
  821. .check_message = smb2_check_message,
  822. .dump_detail = smb2_dump_detail,
  823. .clear_stats = smb2_clear_stats,
  824. .print_stats = smb2_print_stats,
  825. .dump_share_caps = smb2_dump_share_caps,
  826. .is_oplock_break = smb2_is_valid_oplock_break,
  827. .need_neg = smb2_need_neg,
  828. .negotiate = smb2_negotiate,
  829. .negotiate_wsize = smb2_negotiate_wsize,
  830. .negotiate_rsize = smb2_negotiate_rsize,
  831. .sess_setup = SMB2_sess_setup,
  832. .logoff = SMB2_logoff,
  833. .tree_connect = SMB2_tcon,
  834. .tree_disconnect = SMB2_tdis,
  835. .is_path_accessible = smb2_is_path_accessible,
  836. .can_echo = smb2_can_echo,
  837. .echo = SMB2_echo,
  838. .query_path_info = smb2_query_path_info,
  839. .get_srv_inum = smb2_get_srv_inum,
  840. .query_file_info = smb2_query_file_info,
  841. .set_path_size = smb2_set_path_size,
  842. .set_file_size = smb2_set_file_size,
  843. .set_file_info = smb2_set_file_info,
  844. .mkdir = smb2_mkdir,
  845. .mkdir_setinfo = smb2_mkdir_setinfo,
  846. .rmdir = smb2_rmdir,
  847. .unlink = smb2_unlink,
  848. .rename = smb2_rename_path,
  849. .create_hardlink = smb2_create_hardlink,
  850. .query_symlink = smb2_query_symlink,
  851. .open = smb2_open_file,
  852. .set_fid = smb2_set_fid,
  853. .close = smb2_close_file,
  854. .flush = smb2_flush_file,
  855. .async_readv = smb2_async_readv,
  856. .async_writev = smb2_async_writev,
  857. .sync_read = smb2_sync_read,
  858. .sync_write = smb2_sync_write,
  859. .query_dir_first = smb2_query_dir_first,
  860. .query_dir_next = smb2_query_dir_next,
  861. .close_dir = smb2_close_dir,
  862. .calc_smb_size = smb2_calc_size,
  863. .is_status_pending = smb2_is_status_pending,
  864. .oplock_response = smb2_oplock_response,
  865. .queryfs = smb2_queryfs,
  866. .mand_lock = smb2_mand_lock,
  867. .mand_unlock_range = smb2_unlock_range,
  868. .push_mand_locks = smb2_push_mandatory_locks,
  869. .get_lease_key = smb2_get_lease_key,
  870. .set_lease_key = smb2_set_lease_key,
  871. .new_lease_key = smb2_new_lease_key,
  872. .generate_signingkey = generate_smb3signingkey,
  873. .calc_signature = smb3_calc_signature,
  874. .is_read_op = smb21_is_read_op,
  875. .set_oplock_level = smb21_set_oplock_level,
  876. .create_lease_buf = smb2_create_lease_buf,
  877. };
  878. struct smb_version_values smb20_values = {
  879. .version_string = SMB20_VERSION_STRING,
  880. .protocol_id = SMB20_PROT_ID,
  881. .req_capabilities = 0, /* MBZ */
  882. .large_lock_type = 0,
  883. .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK,
  884. .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK,
  885. .unlock_lock_type = SMB2_LOCKFLAG_UNLOCK,
  886. .header_size = sizeof(struct smb2_hdr),
  887. .max_header_size = MAX_SMB2_HDR_SIZE,
  888. .read_rsp_size = sizeof(struct smb2_read_rsp) - 1,
  889. .lock_cmd = SMB2_LOCK,
  890. .cap_unix = 0,
  891. .cap_nt_find = SMB2_NT_FIND,
  892. .cap_large_files = SMB2_LARGE_FILES,
  893. .signing_enabled = SMB2_NEGOTIATE_SIGNING_ENABLED | SMB2_NEGOTIATE_SIGNING_REQUIRED,
  894. .signing_required = SMB2_NEGOTIATE_SIGNING_REQUIRED,
  895. .create_lease_size = sizeof(struct create_lease),
  896. };
  897. struct smb_version_values smb21_values = {
  898. .version_string = SMB21_VERSION_STRING,
  899. .protocol_id = SMB21_PROT_ID,
  900. .req_capabilities = 0, /* MBZ on negotiate req until SMB3 dialect */
  901. .large_lock_type = 0,
  902. .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK,
  903. .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK,
  904. .unlock_lock_type = SMB2_LOCKFLAG_UNLOCK,
  905. .header_size = sizeof(struct smb2_hdr),
  906. .max_header_size = MAX_SMB2_HDR_SIZE,
  907. .read_rsp_size = sizeof(struct smb2_read_rsp) - 1,
  908. .lock_cmd = SMB2_LOCK,
  909. .cap_unix = 0,
  910. .cap_nt_find = SMB2_NT_FIND,
  911. .cap_large_files = SMB2_LARGE_FILES,
  912. .signing_enabled = SMB2_NEGOTIATE_SIGNING_ENABLED | SMB2_NEGOTIATE_SIGNING_REQUIRED,
  913. .signing_required = SMB2_NEGOTIATE_SIGNING_REQUIRED,
  914. .create_lease_size = sizeof(struct create_lease),
  915. };
  916. struct smb_version_values smb30_values = {
  917. .version_string = SMB30_VERSION_STRING,
  918. .protocol_id = SMB30_PROT_ID,
  919. .req_capabilities = SMB2_GLOBAL_CAP_DFS | SMB2_GLOBAL_CAP_LEASING | SMB2_GLOBAL_CAP_LARGE_MTU,
  920. .large_lock_type = 0,
  921. .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK,
  922. .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK,
  923. .unlock_lock_type = SMB2_LOCKFLAG_UNLOCK,
  924. .header_size = sizeof(struct smb2_hdr),
  925. .max_header_size = MAX_SMB2_HDR_SIZE,
  926. .read_rsp_size = sizeof(struct smb2_read_rsp) - 1,
  927. .lock_cmd = SMB2_LOCK,
  928. .cap_unix = 0,
  929. .cap_nt_find = SMB2_NT_FIND,
  930. .cap_large_files = SMB2_LARGE_FILES,
  931. .signing_enabled = SMB2_NEGOTIATE_SIGNING_ENABLED | SMB2_NEGOTIATE_SIGNING_REQUIRED,
  932. .signing_required = SMB2_NEGOTIATE_SIGNING_REQUIRED,
  933. .create_lease_size = sizeof(struct create_lease),
  934. };
  935. struct smb_version_values smb302_values = {
  936. .version_string = SMB302_VERSION_STRING,
  937. .protocol_id = SMB302_PROT_ID,
  938. .req_capabilities = SMB2_GLOBAL_CAP_DFS | SMB2_GLOBAL_CAP_LEASING | SMB2_GLOBAL_CAP_LARGE_MTU,
  939. .large_lock_type = 0,
  940. .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK,
  941. .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK,
  942. .unlock_lock_type = SMB2_LOCKFLAG_UNLOCK,
  943. .header_size = sizeof(struct smb2_hdr),
  944. .max_header_size = MAX_SMB2_HDR_SIZE,
  945. .read_rsp_size = sizeof(struct smb2_read_rsp) - 1,
  946. .lock_cmd = SMB2_LOCK,
  947. .cap_unix = 0,
  948. .cap_nt_find = SMB2_NT_FIND,
  949. .cap_large_files = SMB2_LARGE_FILES,
  950. .signing_enabled = SMB2_NEGOTIATE_SIGNING_ENABLED | SMB2_NEGOTIATE_SIGNING_REQUIRED,
  951. .signing_required = SMB2_NEGOTIATE_SIGNING_REQUIRED,
  952. .create_lease_size = sizeof(struct create_lease),
  953. };