cifs_debug.c 21 KB

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