cifs_debug.c 19 KB

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