smb1ops.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  1. /*
  2. * SMB1 (CIFS) 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 "cifsglob.h"
  20. #include "cifsproto.h"
  21. #include "cifs_debug.h"
  22. #include "cifspdu.h"
  23. /*
  24. * An NT cancel request header looks just like the original request except:
  25. *
  26. * The Command is SMB_COM_NT_CANCEL
  27. * The WordCount is zeroed out
  28. * The ByteCount is zeroed out
  29. *
  30. * This function mangles an existing request buffer into a
  31. * SMB_COM_NT_CANCEL request and then sends it.
  32. */
  33. static int
  34. send_nt_cancel(struct TCP_Server_Info *server, void *buf,
  35. struct mid_q_entry *mid)
  36. {
  37. int rc = 0;
  38. struct smb_hdr *in_buf = (struct smb_hdr *)buf;
  39. /* -4 for RFC1001 length and +2 for BCC field */
  40. in_buf->smb_buf_length = cpu_to_be32(sizeof(struct smb_hdr) - 4 + 2);
  41. in_buf->Command = SMB_COM_NT_CANCEL;
  42. in_buf->WordCount = 0;
  43. put_bcc(0, in_buf);
  44. mutex_lock(&server->srv_mutex);
  45. rc = cifs_sign_smb(in_buf, server, &mid->sequence_number);
  46. if (rc) {
  47. mutex_unlock(&server->srv_mutex);
  48. return rc;
  49. }
  50. rc = smb_send(server, in_buf, be32_to_cpu(in_buf->smb_buf_length));
  51. mutex_unlock(&server->srv_mutex);
  52. cFYI(1, "issued NT_CANCEL for mid %u, rc = %d",
  53. in_buf->Mid, rc);
  54. return rc;
  55. }
  56. static bool
  57. cifs_compare_fids(struct cifsFileInfo *ob1, struct cifsFileInfo *ob2)
  58. {
  59. return ob1->netfid == ob2->netfid;
  60. }
  61. static unsigned int
  62. cifs_read_data_offset(char *buf)
  63. {
  64. READ_RSP *rsp = (READ_RSP *)buf;
  65. return le16_to_cpu(rsp->DataOffset);
  66. }
  67. static unsigned int
  68. cifs_read_data_length(char *buf)
  69. {
  70. READ_RSP *rsp = (READ_RSP *)buf;
  71. return (le16_to_cpu(rsp->DataLengthHigh) << 16) +
  72. le16_to_cpu(rsp->DataLength);
  73. }
  74. static struct mid_q_entry *
  75. cifs_find_mid(struct TCP_Server_Info *server, char *buffer)
  76. {
  77. struct smb_hdr *buf = (struct smb_hdr *)buffer;
  78. struct mid_q_entry *mid;
  79. spin_lock(&GlobalMid_Lock);
  80. list_for_each_entry(mid, &server->pending_mid_q, qhead) {
  81. if (mid->mid == buf->Mid &&
  82. mid->mid_state == MID_REQUEST_SUBMITTED &&
  83. le16_to_cpu(mid->command) == buf->Command) {
  84. spin_unlock(&GlobalMid_Lock);
  85. return mid;
  86. }
  87. }
  88. spin_unlock(&GlobalMid_Lock);
  89. return NULL;
  90. }
  91. static void
  92. cifs_add_credits(struct TCP_Server_Info *server, const unsigned int add,
  93. const int optype)
  94. {
  95. spin_lock(&server->req_lock);
  96. server->credits += add;
  97. server->in_flight--;
  98. spin_unlock(&server->req_lock);
  99. wake_up(&server->request_q);
  100. }
  101. static void
  102. cifs_set_credits(struct TCP_Server_Info *server, const int val)
  103. {
  104. spin_lock(&server->req_lock);
  105. server->credits = val;
  106. server->oplocks = val > 1 ? enable_oplocks : false;
  107. spin_unlock(&server->req_lock);
  108. }
  109. static int *
  110. cifs_get_credits_field(struct TCP_Server_Info *server, const int optype)
  111. {
  112. return &server->credits;
  113. }
  114. static unsigned int
  115. cifs_get_credits(struct mid_q_entry *mid)
  116. {
  117. return 1;
  118. }
  119. /*
  120. * Find a free multiplex id (SMB mid). Otherwise there could be
  121. * mid collisions which might cause problems, demultiplexing the
  122. * wrong response to this request. Multiplex ids could collide if
  123. * one of a series requests takes much longer than the others, or
  124. * if a very large number of long lived requests (byte range
  125. * locks or FindNotify requests) are pending. No more than
  126. * 64K-1 requests can be outstanding at one time. If no
  127. * mids are available, return zero. A future optimization
  128. * could make the combination of mids and uid the key we use
  129. * to demultiplex on (rather than mid alone).
  130. * In addition to the above check, the cifs demultiplex
  131. * code already used the command code as a secondary
  132. * check of the frame and if signing is negotiated the
  133. * response would be discarded if the mid were the same
  134. * but the signature was wrong. Since the mid is not put in the
  135. * pending queue until later (when it is about to be dispatched)
  136. * we do have to limit the number of outstanding requests
  137. * to somewhat less than 64K-1 although it is hard to imagine
  138. * so many threads being in the vfs at one time.
  139. */
  140. static __u64
  141. cifs_get_next_mid(struct TCP_Server_Info *server)
  142. {
  143. __u64 mid = 0;
  144. __u16 last_mid, cur_mid;
  145. bool collision;
  146. spin_lock(&GlobalMid_Lock);
  147. /* mid is 16 bit only for CIFS/SMB */
  148. cur_mid = (__u16)((server->CurrentMid) & 0xffff);
  149. /* we do not want to loop forever */
  150. last_mid = cur_mid;
  151. cur_mid++;
  152. /*
  153. * This nested loop looks more expensive than it is.
  154. * In practice the list of pending requests is short,
  155. * fewer than 50, and the mids are likely to be unique
  156. * on the first pass through the loop unless some request
  157. * takes longer than the 64 thousand requests before it
  158. * (and it would also have to have been a request that
  159. * did not time out).
  160. */
  161. while (cur_mid != last_mid) {
  162. struct mid_q_entry *mid_entry;
  163. unsigned int num_mids;
  164. collision = false;
  165. if (cur_mid == 0)
  166. cur_mid++;
  167. num_mids = 0;
  168. list_for_each_entry(mid_entry, &server->pending_mid_q, qhead) {
  169. ++num_mids;
  170. if (mid_entry->mid == cur_mid &&
  171. mid_entry->mid_state == MID_REQUEST_SUBMITTED) {
  172. /* This mid is in use, try a different one */
  173. collision = true;
  174. break;
  175. }
  176. }
  177. /*
  178. * if we have more than 32k mids in the list, then something
  179. * is very wrong. Possibly a local user is trying to DoS the
  180. * box by issuing long-running calls and SIGKILL'ing them. If
  181. * we get to 2^16 mids then we're in big trouble as this
  182. * function could loop forever.
  183. *
  184. * Go ahead and assign out the mid in this situation, but force
  185. * an eventual reconnect to clean out the pending_mid_q.
  186. */
  187. if (num_mids > 32768)
  188. server->tcpStatus = CifsNeedReconnect;
  189. if (!collision) {
  190. mid = (__u64)cur_mid;
  191. server->CurrentMid = mid;
  192. break;
  193. }
  194. cur_mid++;
  195. }
  196. spin_unlock(&GlobalMid_Lock);
  197. return mid;
  198. }
  199. /*
  200. return codes:
  201. 0 not a transact2, or all data present
  202. >0 transact2 with that much data missing
  203. -EINVAL invalid transact2
  204. */
  205. static int
  206. check2ndT2(char *buf)
  207. {
  208. struct smb_hdr *pSMB = (struct smb_hdr *)buf;
  209. struct smb_t2_rsp *pSMBt;
  210. int remaining;
  211. __u16 total_data_size, data_in_this_rsp;
  212. if (pSMB->Command != SMB_COM_TRANSACTION2)
  213. return 0;
  214. /* check for plausible wct, bcc and t2 data and parm sizes */
  215. /* check for parm and data offset going beyond end of smb */
  216. if (pSMB->WordCount != 10) { /* coalesce_t2 depends on this */
  217. cFYI(1, "invalid transact2 word count");
  218. return -EINVAL;
  219. }
  220. pSMBt = (struct smb_t2_rsp *)pSMB;
  221. total_data_size = get_unaligned_le16(&pSMBt->t2_rsp.TotalDataCount);
  222. data_in_this_rsp = get_unaligned_le16(&pSMBt->t2_rsp.DataCount);
  223. if (total_data_size == data_in_this_rsp)
  224. return 0;
  225. else if (total_data_size < data_in_this_rsp) {
  226. cFYI(1, "total data %d smaller than data in frame %d",
  227. total_data_size, data_in_this_rsp);
  228. return -EINVAL;
  229. }
  230. remaining = total_data_size - data_in_this_rsp;
  231. cFYI(1, "missing %d bytes from transact2, check next response",
  232. remaining);
  233. if (total_data_size > CIFSMaxBufSize) {
  234. cERROR(1, "TotalDataSize %d is over maximum buffer %d",
  235. total_data_size, CIFSMaxBufSize);
  236. return -EINVAL;
  237. }
  238. return remaining;
  239. }
  240. static int
  241. coalesce_t2(char *second_buf, struct smb_hdr *target_hdr)
  242. {
  243. struct smb_t2_rsp *pSMBs = (struct smb_t2_rsp *)second_buf;
  244. struct smb_t2_rsp *pSMBt = (struct smb_t2_rsp *)target_hdr;
  245. char *data_area_of_tgt;
  246. char *data_area_of_src;
  247. int remaining;
  248. unsigned int byte_count, total_in_tgt;
  249. __u16 tgt_total_cnt, src_total_cnt, total_in_src;
  250. src_total_cnt = get_unaligned_le16(&pSMBs->t2_rsp.TotalDataCount);
  251. tgt_total_cnt = get_unaligned_le16(&pSMBt->t2_rsp.TotalDataCount);
  252. if (tgt_total_cnt != src_total_cnt)
  253. cFYI(1, "total data count of primary and secondary t2 differ "
  254. "source=%hu target=%hu", src_total_cnt, tgt_total_cnt);
  255. total_in_tgt = get_unaligned_le16(&pSMBt->t2_rsp.DataCount);
  256. remaining = tgt_total_cnt - total_in_tgt;
  257. if (remaining < 0) {
  258. cFYI(1, "Server sent too much data. tgt_total_cnt=%hu "
  259. "total_in_tgt=%hu", tgt_total_cnt, total_in_tgt);
  260. return -EPROTO;
  261. }
  262. if (remaining == 0) {
  263. /* nothing to do, ignore */
  264. cFYI(1, "no more data remains");
  265. return 0;
  266. }
  267. total_in_src = get_unaligned_le16(&pSMBs->t2_rsp.DataCount);
  268. if (remaining < total_in_src)
  269. cFYI(1, "transact2 2nd response contains too much data");
  270. /* find end of first SMB data area */
  271. data_area_of_tgt = (char *)&pSMBt->hdr.Protocol +
  272. get_unaligned_le16(&pSMBt->t2_rsp.DataOffset);
  273. /* validate target area */
  274. data_area_of_src = (char *)&pSMBs->hdr.Protocol +
  275. get_unaligned_le16(&pSMBs->t2_rsp.DataOffset);
  276. data_area_of_tgt += total_in_tgt;
  277. total_in_tgt += total_in_src;
  278. /* is the result too big for the field? */
  279. if (total_in_tgt > USHRT_MAX) {
  280. cFYI(1, "coalesced DataCount too large (%u)", total_in_tgt);
  281. return -EPROTO;
  282. }
  283. put_unaligned_le16(total_in_tgt, &pSMBt->t2_rsp.DataCount);
  284. /* fix up the BCC */
  285. byte_count = get_bcc(target_hdr);
  286. byte_count += total_in_src;
  287. /* is the result too big for the field? */
  288. if (byte_count > USHRT_MAX) {
  289. cFYI(1, "coalesced BCC too large (%u)", byte_count);
  290. return -EPROTO;
  291. }
  292. put_bcc(byte_count, target_hdr);
  293. byte_count = be32_to_cpu(target_hdr->smb_buf_length);
  294. byte_count += total_in_src;
  295. /* don't allow buffer to overflow */
  296. if (byte_count > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) {
  297. cFYI(1, "coalesced BCC exceeds buffer size (%u)", byte_count);
  298. return -ENOBUFS;
  299. }
  300. target_hdr->smb_buf_length = cpu_to_be32(byte_count);
  301. /* copy second buffer into end of first buffer */
  302. memcpy(data_area_of_tgt, data_area_of_src, total_in_src);
  303. if (remaining != total_in_src) {
  304. /* more responses to go */
  305. cFYI(1, "waiting for more secondary responses");
  306. return 1;
  307. }
  308. /* we are done */
  309. cFYI(1, "found the last secondary response");
  310. return 0;
  311. }
  312. static bool
  313. cifs_check_trans2(struct mid_q_entry *mid, struct TCP_Server_Info *server,
  314. char *buf, int malformed)
  315. {
  316. if (malformed)
  317. return false;
  318. if (check2ndT2(buf) <= 0)
  319. return false;
  320. mid->multiRsp = true;
  321. if (mid->resp_buf) {
  322. /* merge response - fix up 1st*/
  323. malformed = coalesce_t2(buf, mid->resp_buf);
  324. if (malformed > 0)
  325. return true;
  326. /* All parts received or packet is malformed. */
  327. mid->multiEnd = true;
  328. dequeue_mid(mid, malformed);
  329. return true;
  330. }
  331. if (!server->large_buf) {
  332. /*FIXME: switch to already allocated largebuf?*/
  333. cERROR(1, "1st trans2 resp needs bigbuf");
  334. } else {
  335. /* Have first buffer */
  336. mid->resp_buf = buf;
  337. mid->large_buf = true;
  338. server->bigbuf = NULL;
  339. }
  340. return true;
  341. }
  342. static bool
  343. cifs_need_neg(struct TCP_Server_Info *server)
  344. {
  345. return server->maxBuf == 0;
  346. }
  347. static int
  348. cifs_negotiate(const unsigned int xid, struct cifs_ses *ses)
  349. {
  350. int rc;
  351. rc = CIFSSMBNegotiate(xid, ses);
  352. if (rc == -EAGAIN) {
  353. /* retry only once on 1st time connection */
  354. set_credits(ses->server, 1);
  355. rc = CIFSSMBNegotiate(xid, ses);
  356. if (rc == -EAGAIN)
  357. rc = -EHOSTDOWN;
  358. }
  359. return rc;
  360. }
  361. static void
  362. cifs_qfs_tcon(const unsigned int xid, struct cifs_tcon *tcon)
  363. {
  364. CIFSSMBQFSDeviceInfo(xid, tcon);
  365. CIFSSMBQFSAttributeInfo(xid, tcon);
  366. }
  367. static int
  368. cifs_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon,
  369. struct cifs_sb_info *cifs_sb, const char *full_path)
  370. {
  371. int rc;
  372. FILE_ALL_INFO *file_info;
  373. file_info = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL);
  374. if (file_info == NULL)
  375. return -ENOMEM;
  376. rc = CIFSSMBQPathInfo(xid, tcon, full_path, file_info,
  377. 0 /* not legacy */, cifs_sb->local_nls,
  378. cifs_sb->mnt_cifs_flags &
  379. CIFS_MOUNT_MAP_SPECIAL_CHR);
  380. if (rc == -EOPNOTSUPP || rc == -EINVAL)
  381. rc = SMBQueryInformation(xid, tcon, full_path, file_info,
  382. cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
  383. CIFS_MOUNT_MAP_SPECIAL_CHR);
  384. kfree(file_info);
  385. return rc;
  386. }
  387. static int
  388. cifs_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
  389. struct cifs_sb_info *cifs_sb, const char *full_path,
  390. FILE_ALL_INFO *data, bool *adjustTZ)
  391. {
  392. int rc;
  393. /* could do find first instead but this returns more info */
  394. rc = CIFSSMBQPathInfo(xid, tcon, full_path, data, 0 /* not legacy */,
  395. cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
  396. CIFS_MOUNT_MAP_SPECIAL_CHR);
  397. /*
  398. * BB optimize code so we do not make the above call when server claims
  399. * no NT SMB support and the above call failed at least once - set flag
  400. * in tcon or mount.
  401. */
  402. if ((rc == -EOPNOTSUPP) || (rc == -EINVAL)) {
  403. rc = SMBQueryInformation(xid, tcon, full_path, data,
  404. cifs_sb->local_nls,
  405. cifs_sb->mnt_cifs_flags &
  406. CIFS_MOUNT_MAP_SPECIAL_CHR);
  407. *adjustTZ = true;
  408. }
  409. return rc;
  410. }
  411. static int
  412. cifs_get_srv_inum(const unsigned int xid, struct cifs_tcon *tcon,
  413. struct cifs_sb_info *cifs_sb, const char *full_path,
  414. u64 *uniqueid, FILE_ALL_INFO *data)
  415. {
  416. /*
  417. * We can not use the IndexNumber field by default from Windows or
  418. * Samba (in ALL_INFO buf) but we can request it explicitly. The SNIA
  419. * CIFS spec claims that this value is unique within the scope of a
  420. * share, and the windows docs hint that it's actually unique
  421. * per-machine.
  422. *
  423. * There may be higher info levels that work but are there Windows
  424. * server or network appliances for which IndexNumber field is not
  425. * guaranteed unique?
  426. */
  427. return CIFSGetSrvInodeNumber(xid, tcon, full_path, uniqueid,
  428. cifs_sb->local_nls,
  429. cifs_sb->mnt_cifs_flags &
  430. CIFS_MOUNT_MAP_SPECIAL_CHR);
  431. }
  432. static char *
  433. cifs_build_path_to_root(struct smb_vol *vol, struct cifs_sb_info *cifs_sb,
  434. struct cifs_tcon *tcon)
  435. {
  436. int pplen = vol->prepath ? strlen(vol->prepath) : 0;
  437. int dfsplen;
  438. char *full_path = NULL;
  439. /* if no prefix path, simply set path to the root of share to "" */
  440. if (pplen == 0) {
  441. full_path = kzalloc(1, GFP_KERNEL);
  442. return full_path;
  443. }
  444. if (tcon->Flags & SMB_SHARE_IS_IN_DFS)
  445. dfsplen = strnlen(tcon->treeName, MAX_TREE_SIZE + 1);
  446. else
  447. dfsplen = 0;
  448. full_path = kmalloc(dfsplen + pplen + 1, GFP_KERNEL);
  449. if (full_path == NULL)
  450. return full_path;
  451. if (dfsplen)
  452. strncpy(full_path, tcon->treeName, dfsplen);
  453. strncpy(full_path + dfsplen, vol->prepath, pplen);
  454. convert_delimiter(full_path, CIFS_DIR_SEP(cifs_sb));
  455. full_path[dfsplen + pplen] = 0; /* add trailing null */
  456. return full_path;
  457. }
  458. static void
  459. cifs_clear_stats(struct cifs_tcon *tcon)
  460. {
  461. #ifdef CONFIG_CIFS_STATS
  462. atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
  463. atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
  464. atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
  465. atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
  466. atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
  467. atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
  468. atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
  469. atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
  470. atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
  471. atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
  472. atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
  473. atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
  474. atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
  475. atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
  476. atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
  477. atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
  478. atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
  479. atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
  480. atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
  481. atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
  482. atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
  483. #endif
  484. }
  485. static void
  486. cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
  487. {
  488. #ifdef CONFIG_CIFS_STATS
  489. seq_printf(m, " Oplocks breaks: %d",
  490. atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
  491. seq_printf(m, "\nReads: %d Bytes: %llu",
  492. atomic_read(&tcon->stats.cifs_stats.num_reads),
  493. (long long)(tcon->bytes_read));
  494. seq_printf(m, "\nWrites: %d Bytes: %llu",
  495. atomic_read(&tcon->stats.cifs_stats.num_writes),
  496. (long long)(tcon->bytes_written));
  497. seq_printf(m, "\nFlushes: %d",
  498. atomic_read(&tcon->stats.cifs_stats.num_flushes));
  499. seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
  500. atomic_read(&tcon->stats.cifs_stats.num_locks),
  501. atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
  502. atomic_read(&tcon->stats.cifs_stats.num_symlinks));
  503. seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
  504. atomic_read(&tcon->stats.cifs_stats.num_opens),
  505. atomic_read(&tcon->stats.cifs_stats.num_closes),
  506. atomic_read(&tcon->stats.cifs_stats.num_deletes));
  507. seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
  508. atomic_read(&tcon->stats.cifs_stats.num_posixopens),
  509. atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
  510. seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
  511. atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
  512. atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
  513. seq_printf(m, "\nRenames: %d T2 Renames %d",
  514. atomic_read(&tcon->stats.cifs_stats.num_renames),
  515. atomic_read(&tcon->stats.cifs_stats.num_t2renames));
  516. seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
  517. atomic_read(&tcon->stats.cifs_stats.num_ffirst),
  518. atomic_read(&tcon->stats.cifs_stats.num_fnext),
  519. atomic_read(&tcon->stats.cifs_stats.num_fclose));
  520. #endif
  521. }
  522. static void
  523. cifs_mkdir_setinfo(struct inode *inode, const char *full_path,
  524. struct cifs_sb_info *cifs_sb, struct cifs_tcon *tcon,
  525. const unsigned int xid)
  526. {
  527. FILE_BASIC_INFO info;
  528. struct cifsInodeInfo *cifsInode;
  529. u32 dosattrs;
  530. int rc;
  531. memset(&info, 0, sizeof(info));
  532. cifsInode = CIFS_I(inode);
  533. dosattrs = cifsInode->cifsAttrs|ATTR_READONLY;
  534. info.Attributes = cpu_to_le32(dosattrs);
  535. rc = CIFSSMBSetPathInfo(xid, tcon, full_path, &info, cifs_sb->local_nls,
  536. cifs_sb->mnt_cifs_flags &
  537. CIFS_MOUNT_MAP_SPECIAL_CHR);
  538. if (rc == 0)
  539. cifsInode->cifsAttrs = dosattrs;
  540. }
  541. struct smb_version_operations smb1_operations = {
  542. .send_cancel = send_nt_cancel,
  543. .compare_fids = cifs_compare_fids,
  544. .setup_request = cifs_setup_request,
  545. .setup_async_request = cifs_setup_async_request,
  546. .check_receive = cifs_check_receive,
  547. .add_credits = cifs_add_credits,
  548. .set_credits = cifs_set_credits,
  549. .get_credits_field = cifs_get_credits_field,
  550. .get_credits = cifs_get_credits,
  551. .get_next_mid = cifs_get_next_mid,
  552. .read_data_offset = cifs_read_data_offset,
  553. .read_data_length = cifs_read_data_length,
  554. .map_error = map_smb_to_linux_error,
  555. .find_mid = cifs_find_mid,
  556. .check_message = checkSMB,
  557. .dump_detail = cifs_dump_detail,
  558. .clear_stats = cifs_clear_stats,
  559. .print_stats = cifs_print_stats,
  560. .is_oplock_break = is_valid_oplock_break,
  561. .check_trans2 = cifs_check_trans2,
  562. .need_neg = cifs_need_neg,
  563. .negotiate = cifs_negotiate,
  564. .sess_setup = CIFS_SessSetup,
  565. .logoff = CIFSSMBLogoff,
  566. .tree_connect = CIFSTCon,
  567. .tree_disconnect = CIFSSMBTDis,
  568. .get_dfs_refer = CIFSGetDFSRefer,
  569. .qfs_tcon = cifs_qfs_tcon,
  570. .is_path_accessible = cifs_is_path_accessible,
  571. .query_path_info = cifs_query_path_info,
  572. .get_srv_inum = cifs_get_srv_inum,
  573. .build_path_to_root = cifs_build_path_to_root,
  574. .echo = CIFSSMBEcho,
  575. .mkdir = CIFSSMBMkDir,
  576. .mkdir_setinfo = cifs_mkdir_setinfo,
  577. .rmdir = CIFSSMBRmDir,
  578. };
  579. struct smb_version_values smb1_values = {
  580. .version_string = SMB1_VERSION_STRING,
  581. .large_lock_type = LOCKING_ANDX_LARGE_FILES,
  582. .exclusive_lock_type = 0,
  583. .shared_lock_type = LOCKING_ANDX_SHARED_LOCK,
  584. .unlock_lock_type = 0,
  585. .header_size = sizeof(struct smb_hdr),
  586. .max_header_size = MAX_CIFS_HDR_SIZE,
  587. .read_rsp_size = sizeof(READ_RSP),
  588. .lock_cmd = cpu_to_le16(SMB_COM_LOCKING_ANDX),
  589. .cap_unix = CAP_UNIX,
  590. .cap_nt_find = CAP_NT_SMBS | CAP_NT_FIND,
  591. .cap_large_files = CAP_LARGE_FILES,
  592. };