cifs_debug.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828
  1. /*
  2. * fs/cifs_debug.c
  3. *
  4. * Copyright (C) International Business Machines Corp., 2000,2005
  5. *
  6. * Modified by Steve French (sfrench@us.ibm.com)
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
  16. * the GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. */
  22. #include <linux/fs.h>
  23. #include <linux/string.h>
  24. #include <linux/ctype.h>
  25. #include <linux/module.h>
  26. #include <linux/proc_fs.h>
  27. #include <asm/uaccess.h>
  28. #include "cifspdu.h"
  29. #include "cifsglob.h"
  30. #include "cifsproto.h"
  31. #include "cifs_debug.h"
  32. #include "cifsfs.h"
  33. void
  34. cifs_dump_mem(char *label, void *data, int length)
  35. {
  36. int i, j;
  37. int *intptr = data;
  38. char *charptr = data;
  39. char buf[10], line[80];
  40. printk(KERN_DEBUG "%s: dump of %d bytes of data at 0x%p\n\n",
  41. label, length, data);
  42. for (i = 0; i < length; i += 16) {
  43. line[0] = 0;
  44. for (j = 0; (j < 4) && (i + j * 4 < length); j++) {
  45. sprintf(buf, " %08x", intptr[i / 4 + j]);
  46. strcat(line, buf);
  47. }
  48. buf[0] = ' ';
  49. buf[2] = 0;
  50. for (j = 0; (j < 16) && (i + j < length); j++) {
  51. buf[1] = isprint(charptr[i + j]) ? charptr[i + j] : '.';
  52. strcat(line, buf);
  53. }
  54. printk(KERN_DEBUG "%s\n", line);
  55. }
  56. }
  57. #ifdef CONFIG_PROC_FS
  58. static int
  59. cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
  60. int count, int *eof, void *data)
  61. {
  62. struct list_head *tmp;
  63. struct list_head *tmp1;
  64. struct mid_q_entry * mid_entry;
  65. struct cifsSesInfo *ses;
  66. struct cifsTconInfo *tcon;
  67. int i;
  68. int length = 0;
  69. char * original_buf = buf;
  70. *beginBuffer = buf + offset;
  71. length =
  72. sprintf(buf,
  73. "Display Internal CIFS Data Structures for Debugging\n"
  74. "---------------------------------------------------\n");
  75. buf += length;
  76. length = sprintf(buf,"CIFS Version %s\n",CIFS_VERSION);
  77. buf += length;
  78. length = sprintf(buf, "Servers:");
  79. buf += length;
  80. i = 0;
  81. read_lock(&GlobalSMBSeslock);
  82. list_for_each(tmp, &GlobalSMBSessionList) {
  83. i++;
  84. ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList);
  85. if((ses->serverDomain == NULL) || (ses->serverOS == NULL) ||
  86. (ses->serverNOS == NULL)) {
  87. buf += sprintf("\nentry for %s not fully displayed\n\t",
  88. ses->serverName);
  89. } else {
  90. length =
  91. sprintf(buf,
  92. "\n%d) Name: %s Domain: %s Mounts: %d ServerOS: %s \n\tServerNOS: %s\tCapabilities: 0x%x\n\tSMB session status: %d\t",
  93. i, ses->serverName, ses->serverDomain,
  94. atomic_read(&ses->inUse),
  95. ses->serverOS, ses->serverNOS,
  96. ses->capabilities,ses->status);
  97. buf += length;
  98. }
  99. if(ses->server) {
  100. buf += sprintf(buf, "TCP status: %d\n\tLocal Users To Server: %d SecMode: 0x%x Req Active: %d",
  101. ses->server->tcpStatus,
  102. atomic_read(&ses->server->socketUseCount),
  103. ses->server->secMode,
  104. atomic_read(&ses->server->inFlight));
  105. length = sprintf(buf, "\nMIDs:\n");
  106. buf += length;
  107. spin_lock(&GlobalMid_Lock);
  108. list_for_each(tmp1, &ses->server->pending_mid_q) {
  109. mid_entry = list_entry(tmp1, struct
  110. mid_q_entry,
  111. qhead);
  112. if(mid_entry) {
  113. length = sprintf(buf,"State: %d com: %d pid: %d tsk: %p mid %d\n",
  114. mid_entry->midState,
  115. (int)mid_entry->command,
  116. mid_entry->pid,
  117. mid_entry->tsk,
  118. mid_entry->mid);
  119. buf += length;
  120. }
  121. }
  122. spin_unlock(&GlobalMid_Lock);
  123. }
  124. }
  125. read_unlock(&GlobalSMBSeslock);
  126. sprintf(buf, "\n");
  127. buf++;
  128. length = sprintf(buf, "Shares:");
  129. buf += length;
  130. i = 0;
  131. read_lock(&GlobalSMBSeslock);
  132. list_for_each(tmp, &GlobalTreeConnectionList) {
  133. __u32 dev_type;
  134. i++;
  135. tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList);
  136. dev_type = le32_to_cpu(tcon->fsDevInfo.DeviceType);
  137. length =
  138. sprintf(buf,
  139. "\n%d) %s Uses: %d Type: %s Characteristics: 0x%x Attributes: 0x%x\nPathComponentMax: %d Status: %d",
  140. i, tcon->treeName,
  141. atomic_read(&tcon->useCount),
  142. tcon->nativeFileSystem,
  143. le32_to_cpu(tcon->fsDevInfo.DeviceCharacteristics),
  144. le32_to_cpu(tcon->fsAttrInfo.Attributes),
  145. le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength),
  146. tcon->tidStatus);
  147. buf += length;
  148. if (dev_type == FILE_DEVICE_DISK)
  149. length = sprintf(buf, " type: DISK ");
  150. else if (dev_type == FILE_DEVICE_CD_ROM)
  151. length = sprintf(buf, " type: CDROM ");
  152. else
  153. length =
  154. sprintf(buf, " type: %d ", dev_type);
  155. buf += length;
  156. if(tcon->tidStatus == CifsNeedReconnect) {
  157. buf += sprintf(buf, "\tDISCONNECTED ");
  158. length += 14;
  159. }
  160. }
  161. read_unlock(&GlobalSMBSeslock);
  162. length = sprintf(buf, "\n");
  163. buf += length;
  164. /* BB add code to dump additional info such as TCP session info now */
  165. /* Now calculate total size of returned data */
  166. length = buf - original_buf;
  167. if(offset + count >= length)
  168. *eof = 1;
  169. if(length < offset) {
  170. *eof = 1;
  171. return 0;
  172. } else {
  173. length = length - offset;
  174. }
  175. if (length > count)
  176. length = count;
  177. return length;
  178. }
  179. #ifdef CONFIG_CIFS_STATS
  180. static int
  181. cifs_stats_read(char *buf, char **beginBuffer, off_t offset,
  182. int count, int *eof, void *data)
  183. {
  184. int item_length,i,length;
  185. struct list_head *tmp;
  186. struct cifsTconInfo *tcon;
  187. *beginBuffer = buf + offset;
  188. length = sprintf(buf,
  189. "Resources in use\nCIFS Session: %d\n",
  190. sesInfoAllocCount.counter);
  191. buf += length;
  192. item_length =
  193. sprintf(buf,"Share (unique mount targets): %d\n",
  194. tconInfoAllocCount.counter);
  195. length += item_length;
  196. buf += item_length;
  197. item_length =
  198. sprintf(buf,"SMB Request/Response Buffer: %d Pool size: %d\n",
  199. bufAllocCount.counter,
  200. cifs_min_rcv + tcpSesAllocCount.counter);
  201. length += item_length;
  202. buf += item_length;
  203. item_length =
  204. sprintf(buf,"SMB Small Req/Resp Buffer: %d Pool size: %d\n",
  205. smBufAllocCount.counter,cifs_min_small);
  206. length += item_length;
  207. buf += item_length;
  208. item_length =
  209. sprintf(buf,"Operations (MIDs): %d\n",
  210. midCount.counter);
  211. length += item_length;
  212. buf += item_length;
  213. item_length = sprintf(buf,
  214. "\n%d session %d share reconnects\n",
  215. tcpSesReconnectCount.counter,tconInfoReconnectCount.counter);
  216. length += item_length;
  217. buf += item_length;
  218. item_length = sprintf(buf,
  219. "Total vfs operations: %d maximum at one time: %d\n",
  220. GlobalCurrentXid,GlobalMaxActiveXid);
  221. length += item_length;
  222. buf += item_length;
  223. i = 0;
  224. read_lock(&GlobalSMBSeslock);
  225. list_for_each(tmp, &GlobalTreeConnectionList) {
  226. i++;
  227. tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList);
  228. item_length = sprintf(buf,"\n%d) %s",i, tcon->treeName);
  229. buf += item_length;
  230. length += item_length;
  231. if(tcon->tidStatus == CifsNeedReconnect) {
  232. buf += sprintf(buf, "\tDISCONNECTED ");
  233. length += 14;
  234. }
  235. item_length = sprintf(buf,"\nSMBs: %d Oplock Breaks: %d",
  236. atomic_read(&tcon->num_smbs_sent),
  237. atomic_read(&tcon->num_oplock_brks));
  238. buf += item_length;
  239. length += item_length;
  240. item_length = sprintf(buf,"\nReads: %d Bytes %lld",
  241. atomic_read(&tcon->num_reads),
  242. (long long)(tcon->bytes_read));
  243. buf += item_length;
  244. length += item_length;
  245. item_length = sprintf(buf,"\nWrites: %d Bytes: %lld",
  246. atomic_read(&tcon->num_writes),
  247. (long long)(tcon->bytes_written));
  248. buf += item_length;
  249. length += item_length;
  250. item_length = sprintf(buf,
  251. "\nOpens: %d Deletes: %d\nMkdirs: %d Rmdirs: %d",
  252. atomic_read(&tcon->num_opens),
  253. atomic_read(&tcon->num_deletes),
  254. atomic_read(&tcon->num_mkdirs),
  255. atomic_read(&tcon->num_rmdirs));
  256. buf += item_length;
  257. length += item_length;
  258. item_length = sprintf(buf,
  259. "\nRenames: %d T2 Renames %d",
  260. atomic_read(&tcon->num_renames),
  261. atomic_read(&tcon->num_t2renames));
  262. buf += item_length;
  263. length += item_length;
  264. item_length = sprintf(buf,"\nFindFirst: %d FNext %d FClose %d",
  265. atomic_read(&tcon->num_ffirst),
  266. atomic_read(&tcon->num_fnext),
  267. atomic_read(&tcon->num_fclose));
  268. buf += item_length;
  269. length += item_length;
  270. }
  271. read_unlock(&GlobalSMBSeslock);
  272. buf += sprintf(buf,"\n");
  273. length++;
  274. if(offset + count >= length)
  275. *eof = 1;
  276. if(length < offset) {
  277. *eof = 1;
  278. return 0;
  279. } else {
  280. length = length - offset;
  281. }
  282. if (length > count)
  283. length = count;
  284. return length;
  285. }
  286. #endif
  287. static struct proc_dir_entry *proc_fs_cifs;
  288. read_proc_t cifs_txanchor_read;
  289. static read_proc_t cifsFYI_read;
  290. static write_proc_t cifsFYI_write;
  291. static read_proc_t oplockEnabled_read;
  292. static write_proc_t oplockEnabled_write;
  293. static read_proc_t lookupFlag_read;
  294. static write_proc_t lookupFlag_write;
  295. static read_proc_t traceSMB_read;
  296. static write_proc_t traceSMB_write;
  297. static read_proc_t multiuser_mount_read;
  298. static write_proc_t multiuser_mount_write;
  299. static read_proc_t extended_security_read;
  300. static write_proc_t extended_security_write;
  301. static read_proc_t ntlmv2_enabled_read;
  302. static write_proc_t ntlmv2_enabled_write;
  303. static read_proc_t packet_signing_enabled_read;
  304. static write_proc_t packet_signing_enabled_write;
  305. static read_proc_t quotaEnabled_read;
  306. static write_proc_t quotaEnabled_write;
  307. static read_proc_t linuxExtensionsEnabled_read;
  308. static write_proc_t linuxExtensionsEnabled_write;
  309. void
  310. cifs_proc_init(void)
  311. {
  312. struct proc_dir_entry *pde;
  313. proc_fs_cifs = proc_mkdir("cifs", proc_root_fs);
  314. if (proc_fs_cifs == NULL)
  315. return;
  316. proc_fs_cifs->owner = THIS_MODULE;
  317. create_proc_read_entry("DebugData", 0, proc_fs_cifs,
  318. cifs_debug_data_read, NULL);
  319. #ifdef CONFIG_CIFS_STATS
  320. create_proc_read_entry("Stats", 0, proc_fs_cifs,
  321. cifs_stats_read, NULL);
  322. #endif
  323. pde = create_proc_read_entry("cifsFYI", 0, proc_fs_cifs,
  324. cifsFYI_read, NULL);
  325. if (pde)
  326. pde->write_proc = cifsFYI_write;
  327. pde =
  328. create_proc_read_entry("traceSMB", 0, proc_fs_cifs,
  329. traceSMB_read, NULL);
  330. if (pde)
  331. pde->write_proc = traceSMB_write;
  332. pde = create_proc_read_entry("OplockEnabled", 0, proc_fs_cifs,
  333. oplockEnabled_read, NULL);
  334. if (pde)
  335. pde->write_proc = oplockEnabled_write;
  336. pde = create_proc_read_entry("Experimental", 0, proc_fs_cifs,
  337. quotaEnabled_read, NULL);
  338. if (pde)
  339. pde->write_proc = quotaEnabled_write;
  340. pde = create_proc_read_entry("LinuxExtensionsEnabled", 0, proc_fs_cifs,
  341. linuxExtensionsEnabled_read, NULL);
  342. if (pde)
  343. pde->write_proc = linuxExtensionsEnabled_write;
  344. pde =
  345. create_proc_read_entry("MultiuserMount", 0, proc_fs_cifs,
  346. multiuser_mount_read, NULL);
  347. if (pde)
  348. pde->write_proc = multiuser_mount_write;
  349. pde =
  350. create_proc_read_entry("ExtendedSecurity", 0, proc_fs_cifs,
  351. extended_security_read, NULL);
  352. if (pde)
  353. pde->write_proc = extended_security_write;
  354. pde =
  355. create_proc_read_entry("LookupCacheEnabled", 0, proc_fs_cifs,
  356. lookupFlag_read, NULL);
  357. if (pde)
  358. pde->write_proc = lookupFlag_write;
  359. pde =
  360. create_proc_read_entry("NTLMV2Enabled", 0, proc_fs_cifs,
  361. ntlmv2_enabled_read, NULL);
  362. if (pde)
  363. pde->write_proc = ntlmv2_enabled_write;
  364. pde =
  365. create_proc_read_entry("PacketSigningEnabled", 0, proc_fs_cifs,
  366. packet_signing_enabled_read, NULL);
  367. if (pde)
  368. pde->write_proc = packet_signing_enabled_write;
  369. }
  370. void
  371. cifs_proc_clean(void)
  372. {
  373. if (proc_fs_cifs == NULL)
  374. return;
  375. remove_proc_entry("DebugData", proc_fs_cifs);
  376. remove_proc_entry("cifsFYI", proc_fs_cifs);
  377. remove_proc_entry("traceSMB", proc_fs_cifs);
  378. #ifdef CONFIG_CIFS_STATS
  379. remove_proc_entry("Stats", proc_fs_cifs);
  380. #endif
  381. remove_proc_entry("MultiuserMount", proc_fs_cifs);
  382. remove_proc_entry("OplockEnabled", proc_fs_cifs);
  383. remove_proc_entry("NTLMV2Enabled",proc_fs_cifs);
  384. remove_proc_entry("ExtendedSecurity",proc_fs_cifs);
  385. remove_proc_entry("PacketSigningEnabled",proc_fs_cifs);
  386. remove_proc_entry("LinuxExtensionsEnabled",proc_fs_cifs);
  387. remove_proc_entry("Experimental",proc_fs_cifs);
  388. remove_proc_entry("LookupCacheEnabled",proc_fs_cifs);
  389. remove_proc_entry("cifs", proc_root_fs);
  390. }
  391. static int
  392. cifsFYI_read(char *page, char **start, off_t off, int count,
  393. int *eof, void *data)
  394. {
  395. int len;
  396. len = sprintf(page, "%d\n", cifsFYI);
  397. len -= off;
  398. *start = page + off;
  399. if (len > count)
  400. len = count;
  401. else
  402. *eof = 1;
  403. if (len < 0)
  404. len = 0;
  405. return len;
  406. }
  407. static int
  408. cifsFYI_write(struct file *file, const char __user *buffer,
  409. unsigned long count, void *data)
  410. {
  411. char c;
  412. int rc;
  413. rc = get_user(c, buffer);
  414. if (rc)
  415. return rc;
  416. if (c == '0' || c == 'n' || c == 'N')
  417. cifsFYI = 0;
  418. else if (c == '1' || c == 'y' || c == 'Y')
  419. cifsFYI = 1;
  420. return count;
  421. }
  422. static int
  423. oplockEnabled_read(char *page, char **start, off_t off,
  424. int count, int *eof, void *data)
  425. {
  426. int len;
  427. len = sprintf(page, "%d\n", oplockEnabled);
  428. len -= off;
  429. *start = page + off;
  430. if (len > count)
  431. len = count;
  432. else
  433. *eof = 1;
  434. if (len < 0)
  435. len = 0;
  436. return len;
  437. }
  438. static int
  439. oplockEnabled_write(struct file *file, const char __user *buffer,
  440. unsigned long count, void *data)
  441. {
  442. char c;
  443. int rc;
  444. rc = get_user(c, buffer);
  445. if (rc)
  446. return rc;
  447. if (c == '0' || c == 'n' || c == 'N')
  448. oplockEnabled = 0;
  449. else if (c == '1' || c == 'y' || c == 'Y')
  450. oplockEnabled = 1;
  451. return count;
  452. }
  453. static int
  454. quotaEnabled_read(char *page, char **start, off_t off,
  455. int count, int *eof, void *data)
  456. {
  457. int len;
  458. len = sprintf(page, "%d\n", experimEnabled);
  459. /* could also check if quotas are enabled in kernel
  460. as a whole first */
  461. len -= off;
  462. *start = page + off;
  463. if (len > count)
  464. len = count;
  465. else
  466. *eof = 1;
  467. if (len < 0)
  468. len = 0;
  469. return len;
  470. }
  471. static int
  472. quotaEnabled_write(struct file *file, const char __user *buffer,
  473. unsigned long count, void *data)
  474. {
  475. char c;
  476. int rc;
  477. rc = get_user(c, buffer);
  478. if (rc)
  479. return rc;
  480. if (c == '0' || c == 'n' || c == 'N')
  481. experimEnabled = 0;
  482. else if (c == '1' || c == 'y' || c == 'Y')
  483. experimEnabled = 1;
  484. return count;
  485. }
  486. static int
  487. linuxExtensionsEnabled_read(char *page, char **start, off_t off,
  488. int count, int *eof, void *data)
  489. {
  490. int len;
  491. len = sprintf(page, "%d\n", linuxExtEnabled);
  492. /* could also check if quotas are enabled in kernel
  493. as a whole first */
  494. len -= off;
  495. *start = page + off;
  496. if (len > count)
  497. len = count;
  498. else
  499. *eof = 1;
  500. if (len < 0)
  501. len = 0;
  502. return len;
  503. }
  504. static int
  505. linuxExtensionsEnabled_write(struct file *file, const char __user *buffer,
  506. unsigned long count, void *data)
  507. {
  508. char c;
  509. int rc;
  510. rc = get_user(c, buffer);
  511. if (rc)
  512. return rc;
  513. if (c == '0' || c == 'n' || c == 'N')
  514. linuxExtEnabled = 0;
  515. else if (c == '1' || c == 'y' || c == 'Y')
  516. linuxExtEnabled = 1;
  517. return count;
  518. }
  519. static int
  520. lookupFlag_read(char *page, char **start, off_t off,
  521. int count, int *eof, void *data)
  522. {
  523. int len;
  524. len = sprintf(page, "%d\n", lookupCacheEnabled);
  525. len -= off;
  526. *start = page + off;
  527. if (len > count)
  528. len = count;
  529. else
  530. *eof = 1;
  531. if (len < 0)
  532. len = 0;
  533. return len;
  534. }
  535. static int
  536. lookupFlag_write(struct file *file, const char __user *buffer,
  537. unsigned long count, void *data)
  538. {
  539. char c;
  540. int rc;
  541. rc = get_user(c, buffer);
  542. if (rc)
  543. return rc;
  544. if (c == '0' || c == 'n' || c == 'N')
  545. lookupCacheEnabled = 0;
  546. else if (c == '1' || c == 'y' || c == 'Y')
  547. lookupCacheEnabled = 1;
  548. return count;
  549. }
  550. static int
  551. traceSMB_read(char *page, char **start, off_t off, int count,
  552. int *eof, void *data)
  553. {
  554. int len;
  555. len = sprintf(page, "%d\n", traceSMB);
  556. len -= off;
  557. *start = page + off;
  558. if (len > count)
  559. len = count;
  560. else
  561. *eof = 1;
  562. if (len < 0)
  563. len = 0;
  564. return len;
  565. }
  566. static int
  567. traceSMB_write(struct file *file, const char __user *buffer,
  568. unsigned long count, void *data)
  569. {
  570. char c;
  571. int rc;
  572. rc = get_user(c, buffer);
  573. if (rc)
  574. return rc;
  575. if (c == '0' || c == 'n' || c == 'N')
  576. traceSMB = 0;
  577. else if (c == '1' || c == 'y' || c == 'Y')
  578. traceSMB = 1;
  579. return count;
  580. }
  581. static int
  582. multiuser_mount_read(char *page, char **start, off_t off,
  583. int count, int *eof, void *data)
  584. {
  585. int len;
  586. len = sprintf(page, "%d\n", multiuser_mount);
  587. len -= off;
  588. *start = page + off;
  589. if (len > count)
  590. len = count;
  591. else
  592. *eof = 1;
  593. if (len < 0)
  594. len = 0;
  595. return len;
  596. }
  597. static int
  598. multiuser_mount_write(struct file *file, const char __user *buffer,
  599. unsigned long count, void *data)
  600. {
  601. char c;
  602. int rc;
  603. rc = get_user(c, buffer);
  604. if (rc)
  605. return rc;
  606. if (c == '0' || c == 'n' || c == 'N')
  607. multiuser_mount = 0;
  608. else if (c == '1' || c == 'y' || c == 'Y')
  609. multiuser_mount = 1;
  610. return count;
  611. }
  612. static int
  613. extended_security_read(char *page, char **start, off_t off,
  614. int count, int *eof, void *data)
  615. {
  616. int len;
  617. len = sprintf(page, "%d\n", extended_security);
  618. len -= off;
  619. *start = page + off;
  620. if (len > count)
  621. len = count;
  622. else
  623. *eof = 1;
  624. if (len < 0)
  625. len = 0;
  626. return len;
  627. }
  628. static int
  629. extended_security_write(struct file *file, const char __user *buffer,
  630. unsigned long count, void *data)
  631. {
  632. char c;
  633. int rc;
  634. rc = get_user(c, buffer);
  635. if (rc)
  636. return rc;
  637. if (c == '0' || c == 'n' || c == 'N')
  638. extended_security = 0;
  639. else if (c == '1' || c == 'y' || c == 'Y')
  640. extended_security = 1;
  641. return count;
  642. }
  643. static int
  644. ntlmv2_enabled_read(char *page, char **start, off_t off,
  645. int count, int *eof, void *data)
  646. {
  647. int len;
  648. len = sprintf(page, "%d\n", ntlmv2_support);
  649. len -= off;
  650. *start = page + off;
  651. if (len > count)
  652. len = count;
  653. else
  654. *eof = 1;
  655. if (len < 0)
  656. len = 0;
  657. return len;
  658. }
  659. static int
  660. ntlmv2_enabled_write(struct file *file, const char __user *buffer,
  661. unsigned long count, void *data)
  662. {
  663. char c;
  664. int rc;
  665. rc = get_user(c, buffer);
  666. if (rc)
  667. return rc;
  668. if (c == '0' || c == 'n' || c == 'N')
  669. ntlmv2_support = 0;
  670. else if (c == '1' || c == 'y' || c == 'Y')
  671. ntlmv2_support = 1;
  672. return count;
  673. }
  674. static int
  675. packet_signing_enabled_read(char *page, char **start, off_t off,
  676. int count, int *eof, void *data)
  677. {
  678. int len;
  679. len = sprintf(page, "%d\n", sign_CIFS_PDUs);
  680. len -= off;
  681. *start = page + off;
  682. if (len > count)
  683. len = count;
  684. else
  685. *eof = 1;
  686. if (len < 0)
  687. len = 0;
  688. return len;
  689. }
  690. static int
  691. packet_signing_enabled_write(struct file *file, const char __user *buffer,
  692. unsigned long count, void *data)
  693. {
  694. char c;
  695. int rc;
  696. rc = get_user(c, buffer);
  697. if (rc)
  698. return rc;
  699. if (c == '0' || c == 'n' || c == 'N')
  700. sign_CIFS_PDUs = 0;
  701. else if (c == '1' || c == 'y' || c == 'Y')
  702. sign_CIFS_PDUs = 1;
  703. else if (c == '2')
  704. sign_CIFS_PDUs = 2;
  705. return count;
  706. }
  707. #endif