cifs_debug.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904
  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_write(struct file *file, const char __user *buffer,
  189. unsigned long count, void *data)
  190. {
  191. char c;
  192. int rc;
  193. struct list_head *tmp;
  194. struct cifsTconInfo *tcon;
  195. rc = get_user(c, buffer);
  196. if (rc)
  197. return rc;
  198. if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
  199. read_lock(&GlobalSMBSeslock);
  200. #ifdef CONFIG_CIFS_STATS2
  201. atomic_set(&totBufAllocCount, 0);
  202. atomic_set(&totSmBufAllocCount, 0);
  203. #endif /* CONFIG_CIFS_STATS2 */
  204. list_for_each(tmp, &GlobalTreeConnectionList) {
  205. tcon = list_entry(tmp, struct cifsTconInfo,
  206. cifsConnectionList);
  207. atomic_set(&tcon->num_smbs_sent, 0);
  208. atomic_set(&tcon->num_writes, 0);
  209. atomic_set(&tcon->num_reads, 0);
  210. atomic_set(&tcon->num_oplock_brks, 0);
  211. atomic_set(&tcon->num_opens, 0);
  212. atomic_set(&tcon->num_closes, 0);
  213. atomic_set(&tcon->num_deletes, 0);
  214. atomic_set(&tcon->num_mkdirs, 0);
  215. atomic_set(&tcon->num_rmdirs, 0);
  216. atomic_set(&tcon->num_renames, 0);
  217. atomic_set(&tcon->num_t2renames, 0);
  218. atomic_set(&tcon->num_ffirst, 0);
  219. atomic_set(&tcon->num_fnext, 0);
  220. atomic_set(&tcon->num_fclose, 0);
  221. atomic_set(&tcon->num_hardlinks, 0);
  222. atomic_set(&tcon->num_symlinks, 0);
  223. atomic_set(&tcon->num_locks, 0);
  224. }
  225. read_unlock(&GlobalSMBSeslock);
  226. }
  227. return count;
  228. }
  229. static int
  230. cifs_stats_read(char *buf, char **beginBuffer, off_t offset,
  231. int count, int *eof, void *data)
  232. {
  233. int item_length,i,length;
  234. struct list_head *tmp;
  235. struct cifsTconInfo *tcon;
  236. *beginBuffer = buf + offset;
  237. length = sprintf(buf,
  238. "Resources in use\nCIFS Session: %d\n",
  239. sesInfoAllocCount.counter);
  240. buf += length;
  241. item_length =
  242. sprintf(buf,"Share (unique mount targets): %d\n",
  243. tconInfoAllocCount.counter);
  244. length += item_length;
  245. buf += item_length;
  246. item_length =
  247. sprintf(buf,"SMB Request/Response Buffer: %d Pool size: %d\n",
  248. bufAllocCount.counter,
  249. cifs_min_rcv + tcpSesAllocCount.counter);
  250. length += item_length;
  251. buf += item_length;
  252. item_length =
  253. sprintf(buf,"SMB Small Req/Resp Buffer: %d Pool size: %d\n",
  254. smBufAllocCount.counter,cifs_min_small);
  255. length += item_length;
  256. buf += item_length;
  257. #ifdef CONFIG_CIFS_STATS2
  258. item_length = sprintf(buf, "Total Large %d Small %d Allocations\n",
  259. atomic_read(&totBufAllocCount),
  260. atomic_read(&totSmBufAllocCount));
  261. length += item_length;
  262. buf += item_length;
  263. #endif /* CONFIG_CIFS_STATS2 */
  264. item_length =
  265. sprintf(buf,"Operations (MIDs): %d\n",
  266. midCount.counter);
  267. length += item_length;
  268. buf += item_length;
  269. item_length = sprintf(buf,
  270. "\n%d session %d share reconnects\n",
  271. tcpSesReconnectCount.counter,tconInfoReconnectCount.counter);
  272. length += item_length;
  273. buf += item_length;
  274. item_length = sprintf(buf,
  275. "Total vfs operations: %d maximum at one time: %d\n",
  276. GlobalCurrentXid,GlobalMaxActiveXid);
  277. length += item_length;
  278. buf += item_length;
  279. i = 0;
  280. read_lock(&GlobalSMBSeslock);
  281. list_for_each(tmp, &GlobalTreeConnectionList) {
  282. i++;
  283. tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList);
  284. item_length = sprintf(buf,"\n%d) %s",i, tcon->treeName);
  285. buf += item_length;
  286. length += item_length;
  287. if(tcon->tidStatus == CifsNeedReconnect) {
  288. buf += sprintf(buf, "\tDISCONNECTED ");
  289. length += 14;
  290. }
  291. item_length = sprintf(buf, "\nSMBs: %d Oplock Breaks: %d",
  292. atomic_read(&tcon->num_smbs_sent),
  293. atomic_read(&tcon->num_oplock_brks));
  294. buf += item_length;
  295. length += item_length;
  296. item_length = sprintf(buf, "\nReads: %d Bytes: %lld",
  297. atomic_read(&tcon->num_reads),
  298. (long long)(tcon->bytes_read));
  299. buf += item_length;
  300. length += item_length;
  301. item_length = sprintf(buf, "\nWrites: %d Bytes: %lld",
  302. atomic_read(&tcon->num_writes),
  303. (long long)(tcon->bytes_written));
  304. buf += item_length;
  305. length += item_length;
  306. item_length = sprintf(buf,
  307. "\nLocks: %d HardLinks: %d Symlinks: %d",
  308. atomic_read(&tcon->num_locks),
  309. atomic_read(&tcon->num_hardlinks),
  310. atomic_read(&tcon->num_symlinks));
  311. buf += item_length;
  312. length += item_length;
  313. item_length = sprintf(buf, "\nOpens: %d Closes: %d Deletes: %d",
  314. atomic_read(&tcon->num_opens),
  315. atomic_read(&tcon->num_closes),
  316. atomic_read(&tcon->num_deletes));
  317. buf += item_length;
  318. length += item_length;
  319. item_length = sprintf(buf, "\nMkdirs: %d Rmdirs: %d",
  320. atomic_read(&tcon->num_mkdirs),
  321. atomic_read(&tcon->num_rmdirs));
  322. buf += item_length;
  323. length += item_length;
  324. item_length = sprintf(buf, "\nRenames: %d T2 Renames %d",
  325. atomic_read(&tcon->num_renames),
  326. atomic_read(&tcon->num_t2renames));
  327. buf += item_length;
  328. length += item_length;
  329. item_length = sprintf(buf, "\nFindFirst: %d FNext %d FClose %d",
  330. atomic_read(&tcon->num_ffirst),
  331. atomic_read(&tcon->num_fnext),
  332. atomic_read(&tcon->num_fclose));
  333. buf += item_length;
  334. length += item_length;
  335. }
  336. read_unlock(&GlobalSMBSeslock);
  337. buf += sprintf(buf,"\n");
  338. length++;
  339. if(offset + count >= length)
  340. *eof = 1;
  341. if(length < offset) {
  342. *eof = 1;
  343. return 0;
  344. } else {
  345. length = length - offset;
  346. }
  347. if (length > count)
  348. length = count;
  349. return length;
  350. }
  351. #endif
  352. static struct proc_dir_entry *proc_fs_cifs;
  353. read_proc_t cifs_txanchor_read;
  354. static read_proc_t cifsFYI_read;
  355. static write_proc_t cifsFYI_write;
  356. static read_proc_t oplockEnabled_read;
  357. static write_proc_t oplockEnabled_write;
  358. static read_proc_t lookupFlag_read;
  359. static write_proc_t lookupFlag_write;
  360. static read_proc_t traceSMB_read;
  361. static write_proc_t traceSMB_write;
  362. static read_proc_t multiuser_mount_read;
  363. static write_proc_t multiuser_mount_write;
  364. static read_proc_t extended_security_read;
  365. static write_proc_t extended_security_write;
  366. static read_proc_t ntlmv2_enabled_read;
  367. static write_proc_t ntlmv2_enabled_write;
  368. static read_proc_t packet_signing_enabled_read;
  369. static write_proc_t packet_signing_enabled_write;
  370. static read_proc_t experimEnabled_read;
  371. static write_proc_t experimEnabled_write;
  372. static read_proc_t linuxExtensionsEnabled_read;
  373. static write_proc_t linuxExtensionsEnabled_write;
  374. void
  375. cifs_proc_init(void)
  376. {
  377. struct proc_dir_entry *pde;
  378. proc_fs_cifs = proc_mkdir("cifs", proc_root_fs);
  379. if (proc_fs_cifs == NULL)
  380. return;
  381. proc_fs_cifs->owner = THIS_MODULE;
  382. create_proc_read_entry("DebugData", 0, proc_fs_cifs,
  383. cifs_debug_data_read, NULL);
  384. #ifdef CONFIG_CIFS_STATS
  385. pde = create_proc_read_entry("Stats", 0, proc_fs_cifs,
  386. cifs_stats_read, NULL);
  387. if (pde)
  388. pde->write_proc = cifs_stats_write;
  389. #endif
  390. pde = create_proc_read_entry("cifsFYI", 0, proc_fs_cifs,
  391. cifsFYI_read, NULL);
  392. if (pde)
  393. pde->write_proc = cifsFYI_write;
  394. pde =
  395. create_proc_read_entry("traceSMB", 0, proc_fs_cifs,
  396. traceSMB_read, NULL);
  397. if (pde)
  398. pde->write_proc = traceSMB_write;
  399. pde = create_proc_read_entry("OplockEnabled", 0, proc_fs_cifs,
  400. oplockEnabled_read, NULL);
  401. if (pde)
  402. pde->write_proc = oplockEnabled_write;
  403. pde = create_proc_read_entry("Experimental", 0, proc_fs_cifs,
  404. experimEnabled_read, NULL);
  405. if (pde)
  406. pde->write_proc = experimEnabled_write;
  407. pde = create_proc_read_entry("LinuxExtensionsEnabled", 0, proc_fs_cifs,
  408. linuxExtensionsEnabled_read, NULL);
  409. if (pde)
  410. pde->write_proc = linuxExtensionsEnabled_write;
  411. pde =
  412. create_proc_read_entry("MultiuserMount", 0, proc_fs_cifs,
  413. multiuser_mount_read, NULL);
  414. if (pde)
  415. pde->write_proc = multiuser_mount_write;
  416. pde =
  417. create_proc_read_entry("ExtendedSecurity", 0, proc_fs_cifs,
  418. extended_security_read, NULL);
  419. if (pde)
  420. pde->write_proc = extended_security_write;
  421. pde =
  422. create_proc_read_entry("LookupCacheEnabled", 0, proc_fs_cifs,
  423. lookupFlag_read, NULL);
  424. if (pde)
  425. pde->write_proc = lookupFlag_write;
  426. pde =
  427. create_proc_read_entry("NTLMV2Enabled", 0, proc_fs_cifs,
  428. ntlmv2_enabled_read, NULL);
  429. if (pde)
  430. pde->write_proc = ntlmv2_enabled_write;
  431. pde =
  432. create_proc_read_entry("PacketSigningEnabled", 0, proc_fs_cifs,
  433. packet_signing_enabled_read, NULL);
  434. if (pde)
  435. pde->write_proc = packet_signing_enabled_write;
  436. }
  437. void
  438. cifs_proc_clean(void)
  439. {
  440. if (proc_fs_cifs == NULL)
  441. return;
  442. remove_proc_entry("DebugData", proc_fs_cifs);
  443. remove_proc_entry("cifsFYI", proc_fs_cifs);
  444. remove_proc_entry("traceSMB", proc_fs_cifs);
  445. #ifdef CONFIG_CIFS_STATS
  446. remove_proc_entry("Stats", proc_fs_cifs);
  447. #endif
  448. remove_proc_entry("MultiuserMount", proc_fs_cifs);
  449. remove_proc_entry("OplockEnabled", proc_fs_cifs);
  450. remove_proc_entry("NTLMV2Enabled",proc_fs_cifs);
  451. remove_proc_entry("ExtendedSecurity",proc_fs_cifs);
  452. remove_proc_entry("PacketSigningEnabled",proc_fs_cifs);
  453. remove_proc_entry("LinuxExtensionsEnabled",proc_fs_cifs);
  454. remove_proc_entry("Experimental",proc_fs_cifs);
  455. remove_proc_entry("LookupCacheEnabled",proc_fs_cifs);
  456. remove_proc_entry("cifs", proc_root_fs);
  457. }
  458. static int
  459. cifsFYI_read(char *page, char **start, off_t off, int count,
  460. int *eof, void *data)
  461. {
  462. int len;
  463. len = sprintf(page, "%d\n", cifsFYI);
  464. len -= off;
  465. *start = page + off;
  466. if (len > count)
  467. len = count;
  468. else
  469. *eof = 1;
  470. if (len < 0)
  471. len = 0;
  472. return len;
  473. }
  474. static int
  475. cifsFYI_write(struct file *file, const char __user *buffer,
  476. unsigned long count, void *data)
  477. {
  478. char c;
  479. int rc;
  480. rc = get_user(c, buffer);
  481. if (rc)
  482. return rc;
  483. if (c == '0' || c == 'n' || c == 'N')
  484. cifsFYI = 0;
  485. else if (c == '1' || c == 'y' || c == 'Y')
  486. cifsFYI = 1;
  487. else if((c > '1') && (c <= '9'))
  488. cifsFYI = (int) (c - '0'); /* see cifs_debug.h for meanings */
  489. return count;
  490. }
  491. static int
  492. oplockEnabled_read(char *page, char **start, off_t off,
  493. int count, int *eof, void *data)
  494. {
  495. int len;
  496. len = sprintf(page, "%d\n", oplockEnabled);
  497. len -= off;
  498. *start = page + off;
  499. if (len > count)
  500. len = count;
  501. else
  502. *eof = 1;
  503. if (len < 0)
  504. len = 0;
  505. return len;
  506. }
  507. static int
  508. oplockEnabled_write(struct file *file, const char __user *buffer,
  509. unsigned long count, void *data)
  510. {
  511. char c;
  512. int rc;
  513. rc = get_user(c, buffer);
  514. if (rc)
  515. return rc;
  516. if (c == '0' || c == 'n' || c == 'N')
  517. oplockEnabled = 0;
  518. else if (c == '1' || c == 'y' || c == 'Y')
  519. oplockEnabled = 1;
  520. return count;
  521. }
  522. static int
  523. experimEnabled_read(char *page, char **start, off_t off,
  524. int count, int *eof, void *data)
  525. {
  526. int len;
  527. len = sprintf(page, "%d\n", experimEnabled);
  528. len -= off;
  529. *start = page + off;
  530. if (len > count)
  531. len = count;
  532. else
  533. *eof = 1;
  534. if (len < 0)
  535. len = 0;
  536. return len;
  537. }
  538. static int
  539. experimEnabled_write(struct file *file, const char __user *buffer,
  540. unsigned long count, void *data)
  541. {
  542. char c;
  543. int rc;
  544. rc = get_user(c, buffer);
  545. if (rc)
  546. return rc;
  547. if (c == '0' || c == 'n' || c == 'N')
  548. experimEnabled = 0;
  549. else if (c == '1' || c == 'y' || c == 'Y')
  550. experimEnabled = 1;
  551. else if (c == '2')
  552. experimEnabled = 2;
  553. return count;
  554. }
  555. static int
  556. linuxExtensionsEnabled_read(char *page, char **start, off_t off,
  557. int count, int *eof, void *data)
  558. {
  559. int len;
  560. len = sprintf(page, "%d\n", linuxExtEnabled);
  561. len -= off;
  562. *start = page + off;
  563. if (len > count)
  564. len = count;
  565. else
  566. *eof = 1;
  567. if (len < 0)
  568. len = 0;
  569. return len;
  570. }
  571. static int
  572. linuxExtensionsEnabled_write(struct file *file, const char __user *buffer,
  573. unsigned long count, void *data)
  574. {
  575. char c;
  576. int rc;
  577. rc = get_user(c, buffer);
  578. if (rc)
  579. return rc;
  580. if (c == '0' || c == 'n' || c == 'N')
  581. linuxExtEnabled = 0;
  582. else if (c == '1' || c == 'y' || c == 'Y')
  583. linuxExtEnabled = 1;
  584. return count;
  585. }
  586. static int
  587. lookupFlag_read(char *page, char **start, off_t off,
  588. int count, int *eof, void *data)
  589. {
  590. int len;
  591. len = sprintf(page, "%d\n", lookupCacheEnabled);
  592. len -= off;
  593. *start = page + off;
  594. if (len > count)
  595. len = count;
  596. else
  597. *eof = 1;
  598. if (len < 0)
  599. len = 0;
  600. return len;
  601. }
  602. static int
  603. lookupFlag_write(struct file *file, const char __user *buffer,
  604. unsigned long count, void *data)
  605. {
  606. char c;
  607. int rc;
  608. rc = get_user(c, buffer);
  609. if (rc)
  610. return rc;
  611. if (c == '0' || c == 'n' || c == 'N')
  612. lookupCacheEnabled = 0;
  613. else if (c == '1' || c == 'y' || c == 'Y')
  614. lookupCacheEnabled = 1;
  615. return count;
  616. }
  617. static int
  618. traceSMB_read(char *page, char **start, off_t off, int count,
  619. int *eof, void *data)
  620. {
  621. int len;
  622. len = sprintf(page, "%d\n", traceSMB);
  623. len -= off;
  624. *start = page + off;
  625. if (len > count)
  626. len = count;
  627. else
  628. *eof = 1;
  629. if (len < 0)
  630. len = 0;
  631. return len;
  632. }
  633. static int
  634. traceSMB_write(struct file *file, const char __user *buffer,
  635. unsigned long count, void *data)
  636. {
  637. char c;
  638. int rc;
  639. rc = get_user(c, buffer);
  640. if (rc)
  641. return rc;
  642. if (c == '0' || c == 'n' || c == 'N')
  643. traceSMB = 0;
  644. else if (c == '1' || c == 'y' || c == 'Y')
  645. traceSMB = 1;
  646. return count;
  647. }
  648. static int
  649. multiuser_mount_read(char *page, char **start, off_t off,
  650. int count, int *eof, void *data)
  651. {
  652. int len;
  653. len = sprintf(page, "%d\n", multiuser_mount);
  654. len -= off;
  655. *start = page + off;
  656. if (len > count)
  657. len = count;
  658. else
  659. *eof = 1;
  660. if (len < 0)
  661. len = 0;
  662. return len;
  663. }
  664. static int
  665. multiuser_mount_write(struct file *file, const char __user *buffer,
  666. unsigned long count, void *data)
  667. {
  668. char c;
  669. int rc;
  670. rc = get_user(c, buffer);
  671. if (rc)
  672. return rc;
  673. if (c == '0' || c == 'n' || c == 'N')
  674. multiuser_mount = 0;
  675. else if (c == '1' || c == 'y' || c == 'Y')
  676. multiuser_mount = 1;
  677. return count;
  678. }
  679. static int
  680. extended_security_read(char *page, char **start, off_t off,
  681. int count, int *eof, void *data)
  682. {
  683. int len;
  684. len = sprintf(page, "%d\n", extended_security);
  685. len -= off;
  686. *start = page + off;
  687. if (len > count)
  688. len = count;
  689. else
  690. *eof = 1;
  691. if (len < 0)
  692. len = 0;
  693. return len;
  694. }
  695. static int
  696. extended_security_write(struct file *file, const char __user *buffer,
  697. unsigned long count, void *data)
  698. {
  699. char c;
  700. int rc;
  701. rc = get_user(c, buffer);
  702. if (rc)
  703. return rc;
  704. if (c == '0' || c == 'n' || c == 'N')
  705. extended_security = 0;
  706. else if (c == '1' || c == 'y' || c == 'Y')
  707. extended_security = 1;
  708. return count;
  709. }
  710. static int
  711. ntlmv2_enabled_read(char *page, char **start, off_t off,
  712. int count, int *eof, void *data)
  713. {
  714. int len;
  715. len = sprintf(page, "%d\n", ntlmv2_support);
  716. len -= off;
  717. *start = page + off;
  718. if (len > count)
  719. len = count;
  720. else
  721. *eof = 1;
  722. if (len < 0)
  723. len = 0;
  724. return len;
  725. }
  726. static int
  727. ntlmv2_enabled_write(struct file *file, const char __user *buffer,
  728. unsigned long count, void *data)
  729. {
  730. char c;
  731. int rc;
  732. rc = get_user(c, buffer);
  733. if (rc)
  734. return rc;
  735. if (c == '0' || c == 'n' || c == 'N')
  736. ntlmv2_support = 0;
  737. else if (c == '1' || c == 'y' || c == 'Y')
  738. ntlmv2_support = 1;
  739. return count;
  740. }
  741. static int
  742. packet_signing_enabled_read(char *page, char **start, off_t off,
  743. int count, int *eof, void *data)
  744. {
  745. int len;
  746. len = sprintf(page, "%d\n", sign_CIFS_PDUs);
  747. len -= off;
  748. *start = page + off;
  749. if (len > count)
  750. len = count;
  751. else
  752. *eof = 1;
  753. if (len < 0)
  754. len = 0;
  755. return len;
  756. }
  757. static int
  758. packet_signing_enabled_write(struct file *file, const char __user *buffer,
  759. unsigned long count, void *data)
  760. {
  761. char c;
  762. int rc;
  763. rc = get_user(c, buffer);
  764. if (rc)
  765. return rc;
  766. if (c == '0' || c == 'n' || c == 'N')
  767. sign_CIFS_PDUs = 0;
  768. else if (c == '1' || c == 'y' || c == 'Y')
  769. sign_CIFS_PDUs = 1;
  770. else if (c == '2')
  771. sign_CIFS_PDUs = 2;
  772. return count;
  773. }
  774. #endif