cifs_debug.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807
  1. /*
  2. * fs/cifs_debug.c
  3. *
  4. * Copyright (C) International Business Machines Corp., 2000,2003
  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. length =
  86. sprintf(buf,
  87. "\n%d) Name: %s Domain: %s Mounts: %d ServerOS: %s \n\tServerNOS: %s\tCapabilities: 0x%x\n\tSMB session status: %d\t",
  88. i, ses->serverName, ses->serverDomain, atomic_read(&ses->inUse),
  89. ses->serverOS, ses->serverNOS, ses->capabilities,ses->status);
  90. buf += length;
  91. if(ses->server) {
  92. buf += sprintf(buf, "TCP status: %d\n\tLocal Users To Server: %d SecMode: 0x%x Req Active: %d",
  93. ses->server->tcpStatus,
  94. atomic_read(&ses->server->socketUseCount),
  95. ses->server->secMode,
  96. atomic_read(&ses->server->inFlight));
  97. length = sprintf(buf, "\nMIDs:\n");
  98. buf += length;
  99. spin_lock(&GlobalMid_Lock);
  100. list_for_each(tmp1, &ses->server->pending_mid_q) {
  101. mid_entry = list_entry(tmp1, struct
  102. mid_q_entry,
  103. qhead);
  104. if(mid_entry) {
  105. length = sprintf(buf,"State: %d com: %d pid: %d tsk: %p mid %d\n",mid_entry->midState,mid_entry->command,mid_entry->pid,mid_entry->tsk,mid_entry->mid);
  106. buf += length;
  107. }
  108. }
  109. spin_unlock(&GlobalMid_Lock);
  110. }
  111. }
  112. read_unlock(&GlobalSMBSeslock);
  113. sprintf(buf, "\n");
  114. buf++;
  115. length = sprintf(buf, "Shares:");
  116. buf += length;
  117. i = 0;
  118. read_lock(&GlobalSMBSeslock);
  119. list_for_each(tmp, &GlobalTreeConnectionList) {
  120. __u32 dev_type;
  121. i++;
  122. tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList);
  123. dev_type = le32_to_cpu(tcon->fsDevInfo.DeviceType);
  124. length =
  125. sprintf(buf,
  126. "\n%d) %s Uses: %d Type: %s Characteristics: 0x%x Attributes: 0x%x\nPathComponentMax: %d Status: %d",
  127. i, tcon->treeName,
  128. atomic_read(&tcon->useCount),
  129. tcon->nativeFileSystem,
  130. le32_to_cpu(tcon->fsDevInfo.DeviceCharacteristics),
  131. le32_to_cpu(tcon->fsAttrInfo.Attributes),
  132. le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength),
  133. tcon->tidStatus);
  134. buf += length;
  135. if (dev_type == FILE_DEVICE_DISK)
  136. length = sprintf(buf, " type: DISK ");
  137. else if (dev_type == FILE_DEVICE_CD_ROM)
  138. length = sprintf(buf, " type: CDROM ");
  139. else
  140. length =
  141. sprintf(buf, " type: %d ", dev_type);
  142. buf += length;
  143. if(tcon->tidStatus == CifsNeedReconnect) {
  144. buf += sprintf(buf, "\tDISCONNECTED ");
  145. length += 14;
  146. }
  147. }
  148. read_unlock(&GlobalSMBSeslock);
  149. length = sprintf(buf, "\n");
  150. buf += length;
  151. /* BB add code to dump additional info such as TCP session info now */
  152. /* Now calculate total size of returned data */
  153. length = buf - original_buf;
  154. if(offset + count >= length)
  155. *eof = 1;
  156. if(length < offset) {
  157. *eof = 1;
  158. return 0;
  159. } else {
  160. length = length - offset;
  161. }
  162. if (length > count)
  163. length = count;
  164. return length;
  165. }
  166. #ifdef CONFIG_CIFS_STATS
  167. static int
  168. cifs_stats_read(char *buf, char **beginBuffer, off_t offset,
  169. int count, int *eof, void *data)
  170. {
  171. int item_length,i,length;
  172. struct list_head *tmp;
  173. struct cifsTconInfo *tcon;
  174. *beginBuffer = buf + offset;
  175. length = sprintf(buf,
  176. "Resources in use\nCIFS Session: %d\n",
  177. sesInfoAllocCount.counter);
  178. buf += length;
  179. item_length =
  180. sprintf(buf,"Share (unique mount targets): %d\n",
  181. tconInfoAllocCount.counter);
  182. length += item_length;
  183. buf += item_length;
  184. item_length =
  185. sprintf(buf,"SMB Request/Response Buffer: %d Pool size: %d\n",
  186. bufAllocCount.counter,cifs_min_rcv + tcpSesAllocCount.counter);
  187. length += item_length;
  188. buf += item_length;
  189. item_length =
  190. sprintf(buf,"SMB Small Req/Resp Buffer: %d Pool size: %d\n",
  191. smBufAllocCount.counter,cifs_min_small);
  192. length += item_length;
  193. buf += item_length;
  194. item_length =
  195. sprintf(buf,"Operations (MIDs): %d\n",
  196. midCount.counter);
  197. length += item_length;
  198. buf += item_length;
  199. item_length = sprintf(buf,
  200. "\n%d session %d share reconnects\n",
  201. tcpSesReconnectCount.counter,tconInfoReconnectCount.counter);
  202. length += item_length;
  203. buf += item_length;
  204. item_length = sprintf(buf,
  205. "Total vfs operations: %d maximum at one time: %d\n",
  206. GlobalCurrentXid,GlobalMaxActiveXid);
  207. length += item_length;
  208. buf += item_length;
  209. i = 0;
  210. read_lock(&GlobalSMBSeslock);
  211. list_for_each(tmp, &GlobalTreeConnectionList) {
  212. i++;
  213. tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList);
  214. item_length = sprintf(buf,"\n%d) %s",i, tcon->treeName);
  215. buf += item_length;
  216. length += item_length;
  217. if(tcon->tidStatus == CifsNeedReconnect) {
  218. buf += sprintf(buf, "\tDISCONNECTED ");
  219. length += 14;
  220. }
  221. item_length = sprintf(buf,"\nSMBs: %d Oplock Breaks: %d",
  222. atomic_read(&tcon->num_smbs_sent),
  223. atomic_read(&tcon->num_oplock_brks));
  224. buf += item_length;
  225. length += item_length;
  226. item_length = sprintf(buf,"\nReads: %d Bytes %lld",
  227. atomic_read(&tcon->num_reads),
  228. (long long)(tcon->bytes_read));
  229. buf += item_length;
  230. length += item_length;
  231. item_length = sprintf(buf,"\nWrites: %d Bytes: %lld",
  232. atomic_read(&tcon->num_writes),
  233. (long long)(tcon->bytes_written));
  234. buf += item_length;
  235. length += item_length;
  236. item_length = sprintf(buf,
  237. "\nOpens: %d Deletes: %d\nMkdirs: %d Rmdirs: %d",
  238. atomic_read(&tcon->num_opens),
  239. atomic_read(&tcon->num_deletes),
  240. atomic_read(&tcon->num_mkdirs),
  241. atomic_read(&tcon->num_rmdirs));
  242. buf += item_length;
  243. length += item_length;
  244. item_length = sprintf(buf,
  245. "\nRenames: %d T2 Renames %d",
  246. atomic_read(&tcon->num_renames),
  247. atomic_read(&tcon->num_t2renames));
  248. buf += item_length;
  249. length += item_length;
  250. }
  251. read_unlock(&GlobalSMBSeslock);
  252. buf += sprintf(buf,"\n");
  253. length++;
  254. if(offset + count >= length)
  255. *eof = 1;
  256. if(length < offset) {
  257. *eof = 1;
  258. return 0;
  259. } else {
  260. length = length - offset;
  261. }
  262. if (length > count)
  263. length = count;
  264. return length;
  265. }
  266. #endif
  267. static struct proc_dir_entry *proc_fs_cifs;
  268. read_proc_t cifs_txanchor_read;
  269. static read_proc_t cifsFYI_read;
  270. static write_proc_t cifsFYI_write;
  271. static read_proc_t oplockEnabled_read;
  272. static write_proc_t oplockEnabled_write;
  273. static read_proc_t lookupFlag_read;
  274. static write_proc_t lookupFlag_write;
  275. static read_proc_t traceSMB_read;
  276. static write_proc_t traceSMB_write;
  277. static read_proc_t multiuser_mount_read;
  278. static write_proc_t multiuser_mount_write;
  279. static read_proc_t extended_security_read;
  280. static write_proc_t extended_security_write;
  281. static read_proc_t ntlmv2_enabled_read;
  282. static write_proc_t ntlmv2_enabled_write;
  283. static read_proc_t packet_signing_enabled_read;
  284. static write_proc_t packet_signing_enabled_write;
  285. static read_proc_t quotaEnabled_read;
  286. static write_proc_t quotaEnabled_write;
  287. static read_proc_t linuxExtensionsEnabled_read;
  288. static write_proc_t linuxExtensionsEnabled_write;
  289. void
  290. cifs_proc_init(void)
  291. {
  292. struct proc_dir_entry *pde;
  293. proc_fs_cifs = proc_mkdir("cifs", proc_root_fs);
  294. if (proc_fs_cifs == NULL)
  295. return;
  296. proc_fs_cifs->owner = THIS_MODULE;
  297. create_proc_read_entry("DebugData", 0, proc_fs_cifs,
  298. cifs_debug_data_read, NULL);
  299. #ifdef CONFIG_CIFS_STATS
  300. create_proc_read_entry("Stats", 0, proc_fs_cifs,
  301. cifs_stats_read, NULL);
  302. #endif
  303. pde = create_proc_read_entry("cifsFYI", 0, proc_fs_cifs,
  304. cifsFYI_read, NULL);
  305. if (pde)
  306. pde->write_proc = cifsFYI_write;
  307. pde =
  308. create_proc_read_entry("traceSMB", 0, proc_fs_cifs,
  309. traceSMB_read, NULL);
  310. if (pde)
  311. pde->write_proc = traceSMB_write;
  312. pde = create_proc_read_entry("OplockEnabled", 0, proc_fs_cifs,
  313. oplockEnabled_read, NULL);
  314. if (pde)
  315. pde->write_proc = oplockEnabled_write;
  316. pde = create_proc_read_entry("ReenableOldCifsReaddirCode", 0, proc_fs_cifs,
  317. quotaEnabled_read, NULL);
  318. if (pde)
  319. pde->write_proc = quotaEnabled_write;
  320. pde = create_proc_read_entry("LinuxExtensionsEnabled", 0, proc_fs_cifs,
  321. linuxExtensionsEnabled_read, NULL);
  322. if (pde)
  323. pde->write_proc = linuxExtensionsEnabled_write;
  324. pde =
  325. create_proc_read_entry("MultiuserMount", 0, proc_fs_cifs,
  326. multiuser_mount_read, NULL);
  327. if (pde)
  328. pde->write_proc = multiuser_mount_write;
  329. pde =
  330. create_proc_read_entry("ExtendedSecurity", 0, proc_fs_cifs,
  331. extended_security_read, NULL);
  332. if (pde)
  333. pde->write_proc = extended_security_write;
  334. pde =
  335. create_proc_read_entry("LookupCacheEnabled", 0, proc_fs_cifs,
  336. lookupFlag_read, NULL);
  337. if (pde)
  338. pde->write_proc = lookupFlag_write;
  339. pde =
  340. create_proc_read_entry("NTLMV2Enabled", 0, proc_fs_cifs,
  341. ntlmv2_enabled_read, NULL);
  342. if (pde)
  343. pde->write_proc = ntlmv2_enabled_write;
  344. pde =
  345. create_proc_read_entry("PacketSigningEnabled", 0, proc_fs_cifs,
  346. packet_signing_enabled_read, NULL);
  347. if (pde)
  348. pde->write_proc = packet_signing_enabled_write;
  349. }
  350. void
  351. cifs_proc_clean(void)
  352. {
  353. if (proc_fs_cifs == NULL)
  354. return;
  355. remove_proc_entry("DebugData", proc_fs_cifs);
  356. remove_proc_entry("cifsFYI", proc_fs_cifs);
  357. remove_proc_entry("traceSMB", proc_fs_cifs);
  358. #ifdef CONFIG_CIFS_STATS
  359. remove_proc_entry("Stats", proc_fs_cifs);
  360. #endif
  361. remove_proc_entry("MultiuserMount", proc_fs_cifs);
  362. remove_proc_entry("OplockEnabled", proc_fs_cifs);
  363. remove_proc_entry("NTLMV2Enabled",proc_fs_cifs);
  364. remove_proc_entry("ExtendedSecurity",proc_fs_cifs);
  365. remove_proc_entry("PacketSigningEnabled",proc_fs_cifs);
  366. remove_proc_entry("LinuxExtensionsEnabled",proc_fs_cifs);
  367. remove_proc_entry("ReenableOldCifsReaddirCode",proc_fs_cifs);
  368. remove_proc_entry("LookupCacheEnabled",proc_fs_cifs);
  369. remove_proc_entry("cifs", proc_root_fs);
  370. }
  371. static int
  372. cifsFYI_read(char *page, char **start, off_t off, int count,
  373. int *eof, void *data)
  374. {
  375. int len;
  376. len = sprintf(page, "%d\n", cifsFYI);
  377. len -= off;
  378. *start = page + off;
  379. if (len > count)
  380. len = count;
  381. else
  382. *eof = 1;
  383. if (len < 0)
  384. len = 0;
  385. return len;
  386. }
  387. static int
  388. cifsFYI_write(struct file *file, const char __user *buffer,
  389. unsigned long count, void *data)
  390. {
  391. char c;
  392. int rc;
  393. rc = get_user(c, buffer);
  394. if (rc)
  395. return rc;
  396. if (c == '0' || c == 'n' || c == 'N')
  397. cifsFYI = 0;
  398. else if (c == '1' || c == 'y' || c == 'Y')
  399. cifsFYI = 1;
  400. return count;
  401. }
  402. static int
  403. oplockEnabled_read(char *page, char **start, off_t off,
  404. int count, int *eof, void *data)
  405. {
  406. int len;
  407. len = sprintf(page, "%d\n", oplockEnabled);
  408. len -= off;
  409. *start = page + off;
  410. if (len > count)
  411. len = count;
  412. else
  413. *eof = 1;
  414. if (len < 0)
  415. len = 0;
  416. return len;
  417. }
  418. static int
  419. oplockEnabled_write(struct file *file, const char __user *buffer,
  420. unsigned long count, void *data)
  421. {
  422. char c;
  423. int rc;
  424. rc = get_user(c, buffer);
  425. if (rc)
  426. return rc;
  427. if (c == '0' || c == 'n' || c == 'N')
  428. oplockEnabled = 0;
  429. else if (c == '1' || c == 'y' || c == 'Y')
  430. oplockEnabled = 1;
  431. return count;
  432. }
  433. static int
  434. quotaEnabled_read(char *page, char **start, off_t off,
  435. int count, int *eof, void *data)
  436. {
  437. int len;
  438. len = sprintf(page, "%d\n", experimEnabled);
  439. /* could also check if quotas are enabled in kernel
  440. as a whole first */
  441. len -= off;
  442. *start = page + off;
  443. if (len > count)
  444. len = count;
  445. else
  446. *eof = 1;
  447. if (len < 0)
  448. len = 0;
  449. return len;
  450. }
  451. static int
  452. quotaEnabled_write(struct file *file, const char __user *buffer,
  453. unsigned long count, void *data)
  454. {
  455. char c;
  456. int rc;
  457. rc = get_user(c, buffer);
  458. if (rc)
  459. return rc;
  460. if (c == '0' || c == 'n' || c == 'N')
  461. experimEnabled = 0;
  462. else if (c == '1' || c == 'y' || c == 'Y')
  463. experimEnabled = 1;
  464. return count;
  465. }
  466. static int
  467. linuxExtensionsEnabled_read(char *page, char **start, off_t off,
  468. int count, int *eof, void *data)
  469. {
  470. int len;
  471. len = sprintf(page, "%d\n", linuxExtEnabled);
  472. /* could also check if quotas are enabled in kernel
  473. as a whole first */
  474. len -= off;
  475. *start = page + off;
  476. if (len > count)
  477. len = count;
  478. else
  479. *eof = 1;
  480. if (len < 0)
  481. len = 0;
  482. return len;
  483. }
  484. static int
  485. linuxExtensionsEnabled_write(struct file *file, const char __user *buffer,
  486. unsigned long count, void *data)
  487. {
  488. char c;
  489. int rc;
  490. rc = get_user(c, buffer);
  491. if (rc)
  492. return rc;
  493. if (c == '0' || c == 'n' || c == 'N')
  494. linuxExtEnabled = 0;
  495. else if (c == '1' || c == 'y' || c == 'Y')
  496. linuxExtEnabled = 1;
  497. return count;
  498. }
  499. static int
  500. lookupFlag_read(char *page, char **start, off_t off,
  501. int count, int *eof, void *data)
  502. {
  503. int len;
  504. len = sprintf(page, "%d\n", lookupCacheEnabled);
  505. len -= off;
  506. *start = page + off;
  507. if (len > count)
  508. len = count;
  509. else
  510. *eof = 1;
  511. if (len < 0)
  512. len = 0;
  513. return len;
  514. }
  515. static int
  516. lookupFlag_write(struct file *file, const char __user *buffer,
  517. unsigned long count, void *data)
  518. {
  519. char c;
  520. int rc;
  521. rc = get_user(c, buffer);
  522. if (rc)
  523. return rc;
  524. if (c == '0' || c == 'n' || c == 'N')
  525. lookupCacheEnabled = 0;
  526. else if (c == '1' || c == 'y' || c == 'Y')
  527. lookupCacheEnabled = 1;
  528. return count;
  529. }
  530. static int
  531. traceSMB_read(char *page, char **start, off_t off, int count,
  532. int *eof, void *data)
  533. {
  534. int len;
  535. len = sprintf(page, "%d\n", traceSMB);
  536. len -= off;
  537. *start = page + off;
  538. if (len > count)
  539. len = count;
  540. else
  541. *eof = 1;
  542. if (len < 0)
  543. len = 0;
  544. return len;
  545. }
  546. static int
  547. traceSMB_write(struct file *file, const char __user *buffer,
  548. unsigned long count, void *data)
  549. {
  550. char c;
  551. int rc;
  552. rc = get_user(c, buffer);
  553. if (rc)
  554. return rc;
  555. if (c == '0' || c == 'n' || c == 'N')
  556. traceSMB = 0;
  557. else if (c == '1' || c == 'y' || c == 'Y')
  558. traceSMB = 1;
  559. return count;
  560. }
  561. static int
  562. multiuser_mount_read(char *page, char **start, off_t off,
  563. int count, int *eof, void *data)
  564. {
  565. int len;
  566. len = sprintf(page, "%d\n", multiuser_mount);
  567. len -= off;
  568. *start = page + off;
  569. if (len > count)
  570. len = count;
  571. else
  572. *eof = 1;
  573. if (len < 0)
  574. len = 0;
  575. return len;
  576. }
  577. static int
  578. multiuser_mount_write(struct file *file, const char __user *buffer,
  579. unsigned long count, void *data)
  580. {
  581. char c;
  582. int rc;
  583. rc = get_user(c, buffer);
  584. if (rc)
  585. return rc;
  586. if (c == '0' || c == 'n' || c == 'N')
  587. multiuser_mount = 0;
  588. else if (c == '1' || c == 'y' || c == 'Y')
  589. multiuser_mount = 1;
  590. return count;
  591. }
  592. static int
  593. extended_security_read(char *page, char **start, off_t off,
  594. int count, int *eof, void *data)
  595. {
  596. int len;
  597. len = sprintf(page, "%d\n", extended_security);
  598. len -= off;
  599. *start = page + off;
  600. if (len > count)
  601. len = count;
  602. else
  603. *eof = 1;
  604. if (len < 0)
  605. len = 0;
  606. return len;
  607. }
  608. static int
  609. extended_security_write(struct file *file, const char __user *buffer,
  610. unsigned long count, void *data)
  611. {
  612. char c;
  613. int rc;
  614. rc = get_user(c, buffer);
  615. if (rc)
  616. return rc;
  617. if (c == '0' || c == 'n' || c == 'N')
  618. extended_security = 0;
  619. else if (c == '1' || c == 'y' || c == 'Y')
  620. extended_security = 1;
  621. return count;
  622. }
  623. static int
  624. ntlmv2_enabled_read(char *page, char **start, off_t off,
  625. int count, int *eof, void *data)
  626. {
  627. int len;
  628. len = sprintf(page, "%d\n", ntlmv2_support);
  629. len -= off;
  630. *start = page + off;
  631. if (len > count)
  632. len = count;
  633. else
  634. *eof = 1;
  635. if (len < 0)
  636. len = 0;
  637. return len;
  638. }
  639. static int
  640. ntlmv2_enabled_write(struct file *file, const char __user *buffer,
  641. unsigned long count, void *data)
  642. {
  643. char c;
  644. int rc;
  645. rc = get_user(c, buffer);
  646. if (rc)
  647. return rc;
  648. if (c == '0' || c == 'n' || c == 'N')
  649. ntlmv2_support = 0;
  650. else if (c == '1' || c == 'y' || c == 'Y')
  651. ntlmv2_support = 1;
  652. return count;
  653. }
  654. static int
  655. packet_signing_enabled_read(char *page, char **start, off_t off,
  656. int count, int *eof, void *data)
  657. {
  658. int len;
  659. len = sprintf(page, "%d\n", sign_CIFS_PDUs);
  660. len -= off;
  661. *start = page + off;
  662. if (len > count)
  663. len = count;
  664. else
  665. *eof = 1;
  666. if (len < 0)
  667. len = 0;
  668. return len;
  669. }
  670. static int
  671. packet_signing_enabled_write(struct file *file, const char __user *buffer,
  672. unsigned long count, void *data)
  673. {
  674. char c;
  675. int rc;
  676. rc = get_user(c, buffer);
  677. if (rc)
  678. return rc;
  679. if (c == '0' || c == 'n' || c == 'N')
  680. sign_CIFS_PDUs = 0;
  681. else if (c == '1' || c == 'y' || c == 'Y')
  682. sign_CIFS_PDUs = 1;
  683. else if (c == '2')
  684. sign_CIFS_PDUs = 2;
  685. return count;
  686. }
  687. #endif