cifs_debug.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822
  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. }
  265. read_unlock(&GlobalSMBSeslock);
  266. buf += sprintf(buf,"\n");
  267. length++;
  268. if(offset + count >= length)
  269. *eof = 1;
  270. if(length < offset) {
  271. *eof = 1;
  272. return 0;
  273. } else {
  274. length = length - offset;
  275. }
  276. if (length > count)
  277. length = count;
  278. return length;
  279. }
  280. #endif
  281. static struct proc_dir_entry *proc_fs_cifs;
  282. read_proc_t cifs_txanchor_read;
  283. static read_proc_t cifsFYI_read;
  284. static write_proc_t cifsFYI_write;
  285. static read_proc_t oplockEnabled_read;
  286. static write_proc_t oplockEnabled_write;
  287. static read_proc_t lookupFlag_read;
  288. static write_proc_t lookupFlag_write;
  289. static read_proc_t traceSMB_read;
  290. static write_proc_t traceSMB_write;
  291. static read_proc_t multiuser_mount_read;
  292. static write_proc_t multiuser_mount_write;
  293. static read_proc_t extended_security_read;
  294. static write_proc_t extended_security_write;
  295. static read_proc_t ntlmv2_enabled_read;
  296. static write_proc_t ntlmv2_enabled_write;
  297. static read_proc_t packet_signing_enabled_read;
  298. static write_proc_t packet_signing_enabled_write;
  299. static read_proc_t quotaEnabled_read;
  300. static write_proc_t quotaEnabled_write;
  301. static read_proc_t linuxExtensionsEnabled_read;
  302. static write_proc_t linuxExtensionsEnabled_write;
  303. void
  304. cifs_proc_init(void)
  305. {
  306. struct proc_dir_entry *pde;
  307. proc_fs_cifs = proc_mkdir("cifs", proc_root_fs);
  308. if (proc_fs_cifs == NULL)
  309. return;
  310. proc_fs_cifs->owner = THIS_MODULE;
  311. create_proc_read_entry("DebugData", 0, proc_fs_cifs,
  312. cifs_debug_data_read, NULL);
  313. #ifdef CONFIG_CIFS_STATS
  314. create_proc_read_entry("Stats", 0, proc_fs_cifs,
  315. cifs_stats_read, NULL);
  316. #endif
  317. pde = create_proc_read_entry("cifsFYI", 0, proc_fs_cifs,
  318. cifsFYI_read, NULL);
  319. if (pde)
  320. pde->write_proc = cifsFYI_write;
  321. pde =
  322. create_proc_read_entry("traceSMB", 0, proc_fs_cifs,
  323. traceSMB_read, NULL);
  324. if (pde)
  325. pde->write_proc = traceSMB_write;
  326. pde = create_proc_read_entry("OplockEnabled", 0, proc_fs_cifs,
  327. oplockEnabled_read, NULL);
  328. if (pde)
  329. pde->write_proc = oplockEnabled_write;
  330. pde = create_proc_read_entry("ReenableOldCifsReaddirCode", 0, proc_fs_cifs,
  331. quotaEnabled_read, NULL);
  332. if (pde)
  333. pde->write_proc = quotaEnabled_write;
  334. pde = create_proc_read_entry("LinuxExtensionsEnabled", 0, proc_fs_cifs,
  335. linuxExtensionsEnabled_read, NULL);
  336. if (pde)
  337. pde->write_proc = linuxExtensionsEnabled_write;
  338. pde =
  339. create_proc_read_entry("MultiuserMount", 0, proc_fs_cifs,
  340. multiuser_mount_read, NULL);
  341. if (pde)
  342. pde->write_proc = multiuser_mount_write;
  343. pde =
  344. create_proc_read_entry("ExtendedSecurity", 0, proc_fs_cifs,
  345. extended_security_read, NULL);
  346. if (pde)
  347. pde->write_proc = extended_security_write;
  348. pde =
  349. create_proc_read_entry("LookupCacheEnabled", 0, proc_fs_cifs,
  350. lookupFlag_read, NULL);
  351. if (pde)
  352. pde->write_proc = lookupFlag_write;
  353. pde =
  354. create_proc_read_entry("NTLMV2Enabled", 0, proc_fs_cifs,
  355. ntlmv2_enabled_read, NULL);
  356. if (pde)
  357. pde->write_proc = ntlmv2_enabled_write;
  358. pde =
  359. create_proc_read_entry("PacketSigningEnabled", 0, proc_fs_cifs,
  360. packet_signing_enabled_read, NULL);
  361. if (pde)
  362. pde->write_proc = packet_signing_enabled_write;
  363. }
  364. void
  365. cifs_proc_clean(void)
  366. {
  367. if (proc_fs_cifs == NULL)
  368. return;
  369. remove_proc_entry("DebugData", proc_fs_cifs);
  370. remove_proc_entry("cifsFYI", proc_fs_cifs);
  371. remove_proc_entry("traceSMB", proc_fs_cifs);
  372. #ifdef CONFIG_CIFS_STATS
  373. remove_proc_entry("Stats", proc_fs_cifs);
  374. #endif
  375. remove_proc_entry("MultiuserMount", proc_fs_cifs);
  376. remove_proc_entry("OplockEnabled", proc_fs_cifs);
  377. remove_proc_entry("NTLMV2Enabled",proc_fs_cifs);
  378. remove_proc_entry("ExtendedSecurity",proc_fs_cifs);
  379. remove_proc_entry("PacketSigningEnabled",proc_fs_cifs);
  380. remove_proc_entry("LinuxExtensionsEnabled",proc_fs_cifs);
  381. remove_proc_entry("ReenableOldCifsReaddirCode",proc_fs_cifs);
  382. remove_proc_entry("LookupCacheEnabled",proc_fs_cifs);
  383. remove_proc_entry("cifs", proc_root_fs);
  384. }
  385. static int
  386. cifsFYI_read(char *page, char **start, off_t off, int count,
  387. int *eof, void *data)
  388. {
  389. int len;
  390. len = sprintf(page, "%d\n", cifsFYI);
  391. len -= off;
  392. *start = page + off;
  393. if (len > count)
  394. len = count;
  395. else
  396. *eof = 1;
  397. if (len < 0)
  398. len = 0;
  399. return len;
  400. }
  401. static int
  402. cifsFYI_write(struct file *file, const char __user *buffer,
  403. unsigned long count, void *data)
  404. {
  405. char c;
  406. int rc;
  407. rc = get_user(c, buffer);
  408. if (rc)
  409. return rc;
  410. if (c == '0' || c == 'n' || c == 'N')
  411. cifsFYI = 0;
  412. else if (c == '1' || c == 'y' || c == 'Y')
  413. cifsFYI = 1;
  414. return count;
  415. }
  416. static int
  417. oplockEnabled_read(char *page, char **start, off_t off,
  418. int count, int *eof, void *data)
  419. {
  420. int len;
  421. len = sprintf(page, "%d\n", oplockEnabled);
  422. len -= off;
  423. *start = page + off;
  424. if (len > count)
  425. len = count;
  426. else
  427. *eof = 1;
  428. if (len < 0)
  429. len = 0;
  430. return len;
  431. }
  432. static int
  433. oplockEnabled_write(struct file *file, const char __user *buffer,
  434. unsigned long count, void *data)
  435. {
  436. char c;
  437. int rc;
  438. rc = get_user(c, buffer);
  439. if (rc)
  440. return rc;
  441. if (c == '0' || c == 'n' || c == 'N')
  442. oplockEnabled = 0;
  443. else if (c == '1' || c == 'y' || c == 'Y')
  444. oplockEnabled = 1;
  445. return count;
  446. }
  447. static int
  448. quotaEnabled_read(char *page, char **start, off_t off,
  449. int count, int *eof, void *data)
  450. {
  451. int len;
  452. len = sprintf(page, "%d\n", experimEnabled);
  453. /* could also check if quotas are enabled in kernel
  454. as a whole first */
  455. len -= off;
  456. *start = page + off;
  457. if (len > count)
  458. len = count;
  459. else
  460. *eof = 1;
  461. if (len < 0)
  462. len = 0;
  463. return len;
  464. }
  465. static int
  466. quotaEnabled_write(struct file *file, const char __user *buffer,
  467. unsigned long count, void *data)
  468. {
  469. char c;
  470. int rc;
  471. rc = get_user(c, buffer);
  472. if (rc)
  473. return rc;
  474. if (c == '0' || c == 'n' || c == 'N')
  475. experimEnabled = 0;
  476. else if (c == '1' || c == 'y' || c == 'Y')
  477. experimEnabled = 1;
  478. return count;
  479. }
  480. static int
  481. linuxExtensionsEnabled_read(char *page, char **start, off_t off,
  482. int count, int *eof, void *data)
  483. {
  484. int len;
  485. len = sprintf(page, "%d\n", linuxExtEnabled);
  486. /* could also check if quotas are enabled in kernel
  487. as a whole first */
  488. len -= off;
  489. *start = page + off;
  490. if (len > count)
  491. len = count;
  492. else
  493. *eof = 1;
  494. if (len < 0)
  495. len = 0;
  496. return len;
  497. }
  498. static int
  499. linuxExtensionsEnabled_write(struct file *file, const char __user *buffer,
  500. unsigned long count, void *data)
  501. {
  502. char c;
  503. int rc;
  504. rc = get_user(c, buffer);
  505. if (rc)
  506. return rc;
  507. if (c == '0' || c == 'n' || c == 'N')
  508. linuxExtEnabled = 0;
  509. else if (c == '1' || c == 'y' || c == 'Y')
  510. linuxExtEnabled = 1;
  511. return count;
  512. }
  513. static int
  514. lookupFlag_read(char *page, char **start, off_t off,
  515. int count, int *eof, void *data)
  516. {
  517. int len;
  518. len = sprintf(page, "%d\n", lookupCacheEnabled);
  519. len -= off;
  520. *start = page + off;
  521. if (len > count)
  522. len = count;
  523. else
  524. *eof = 1;
  525. if (len < 0)
  526. len = 0;
  527. return len;
  528. }
  529. static int
  530. lookupFlag_write(struct file *file, const char __user *buffer,
  531. unsigned long count, void *data)
  532. {
  533. char c;
  534. int rc;
  535. rc = get_user(c, buffer);
  536. if (rc)
  537. return rc;
  538. if (c == '0' || c == 'n' || c == 'N')
  539. lookupCacheEnabled = 0;
  540. else if (c == '1' || c == 'y' || c == 'Y')
  541. lookupCacheEnabled = 1;
  542. return count;
  543. }
  544. static int
  545. traceSMB_read(char *page, char **start, off_t off, int count,
  546. int *eof, void *data)
  547. {
  548. int len;
  549. len = sprintf(page, "%d\n", traceSMB);
  550. len -= off;
  551. *start = page + off;
  552. if (len > count)
  553. len = count;
  554. else
  555. *eof = 1;
  556. if (len < 0)
  557. len = 0;
  558. return len;
  559. }
  560. static int
  561. traceSMB_write(struct file *file, const char __user *buffer,
  562. unsigned long count, void *data)
  563. {
  564. char c;
  565. int rc;
  566. rc = get_user(c, buffer);
  567. if (rc)
  568. return rc;
  569. if (c == '0' || c == 'n' || c == 'N')
  570. traceSMB = 0;
  571. else if (c == '1' || c == 'y' || c == 'Y')
  572. traceSMB = 1;
  573. return count;
  574. }
  575. static int
  576. multiuser_mount_read(char *page, char **start, off_t off,
  577. int count, int *eof, void *data)
  578. {
  579. int len;
  580. len = sprintf(page, "%d\n", multiuser_mount);
  581. len -= off;
  582. *start = page + off;
  583. if (len > count)
  584. len = count;
  585. else
  586. *eof = 1;
  587. if (len < 0)
  588. len = 0;
  589. return len;
  590. }
  591. static int
  592. multiuser_mount_write(struct file *file, const char __user *buffer,
  593. unsigned long count, void *data)
  594. {
  595. char c;
  596. int rc;
  597. rc = get_user(c, buffer);
  598. if (rc)
  599. return rc;
  600. if (c == '0' || c == 'n' || c == 'N')
  601. multiuser_mount = 0;
  602. else if (c == '1' || c == 'y' || c == 'Y')
  603. multiuser_mount = 1;
  604. return count;
  605. }
  606. static int
  607. extended_security_read(char *page, char **start, off_t off,
  608. int count, int *eof, void *data)
  609. {
  610. int len;
  611. len = sprintf(page, "%d\n", extended_security);
  612. len -= off;
  613. *start = page + off;
  614. if (len > count)
  615. len = count;
  616. else
  617. *eof = 1;
  618. if (len < 0)
  619. len = 0;
  620. return len;
  621. }
  622. static int
  623. extended_security_write(struct file *file, const char __user *buffer,
  624. unsigned long count, void *data)
  625. {
  626. char c;
  627. int rc;
  628. rc = get_user(c, buffer);
  629. if (rc)
  630. return rc;
  631. if (c == '0' || c == 'n' || c == 'N')
  632. extended_security = 0;
  633. else if (c == '1' || c == 'y' || c == 'Y')
  634. extended_security = 1;
  635. return count;
  636. }
  637. static int
  638. ntlmv2_enabled_read(char *page, char **start, off_t off,
  639. int count, int *eof, void *data)
  640. {
  641. int len;
  642. len = sprintf(page, "%d\n", ntlmv2_support);
  643. len -= off;
  644. *start = page + off;
  645. if (len > count)
  646. len = count;
  647. else
  648. *eof = 1;
  649. if (len < 0)
  650. len = 0;
  651. return len;
  652. }
  653. static int
  654. ntlmv2_enabled_write(struct file *file, const char __user *buffer,
  655. unsigned long count, void *data)
  656. {
  657. char c;
  658. int rc;
  659. rc = get_user(c, buffer);
  660. if (rc)
  661. return rc;
  662. if (c == '0' || c == 'n' || c == 'N')
  663. ntlmv2_support = 0;
  664. else if (c == '1' || c == 'y' || c == 'Y')
  665. ntlmv2_support = 1;
  666. return count;
  667. }
  668. static int
  669. packet_signing_enabled_read(char *page, char **start, off_t off,
  670. int count, int *eof, void *data)
  671. {
  672. int len;
  673. len = sprintf(page, "%d\n", sign_CIFS_PDUs);
  674. len -= off;
  675. *start = page + off;
  676. if (len > count)
  677. len = count;
  678. else
  679. *eof = 1;
  680. if (len < 0)
  681. len = 0;
  682. return len;
  683. }
  684. static int
  685. packet_signing_enabled_write(struct file *file, const char __user *buffer,
  686. unsigned long count, void *data)
  687. {
  688. char c;
  689. int rc;
  690. rc = get_user(c, buffer);
  691. if (rc)
  692. return rc;
  693. if (c == '0' || c == 'n' || c == 'N')
  694. sign_CIFS_PDUs = 0;
  695. else if (c == '1' || c == 'y' || c == 'Y')
  696. sign_CIFS_PDUs = 1;
  697. else if (c == '2')
  698. sign_CIFS_PDUs = 2;
  699. return count;
  700. }
  701. #endif