cifs_debug.c 18 KB

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