cifs_debug.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775
  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",
  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_CIFS_DEBUG2
  58. void cifs_dump_detail(struct smb_hdr *smb)
  59. {
  60. cERROR(1, ("Cmd: %d Err: 0x%x Flags: 0x%x Flgs2: 0x%x Mid: %d Pid: %d",
  61. smb->Command, smb->Status.CifsError,
  62. smb->Flags, smb->Flags2, smb->Mid, smb->Pid));
  63. cERROR(1, ("smb buf %p len %d", smb, smbCalcSize_LE(smb)));
  64. }
  65. void cifs_dump_mids(struct TCP_Server_Info *server)
  66. {
  67. struct list_head *tmp;
  68. struct mid_q_entry *mid_entry;
  69. if (server == NULL)
  70. return;
  71. cERROR(1, ("Dump pending requests:"));
  72. spin_lock(&GlobalMid_Lock);
  73. list_for_each(tmp, &server->pending_mid_q) {
  74. mid_entry = list_entry(tmp, struct mid_q_entry, qhead);
  75. cERROR(1, ("State: %d Cmd: %d Pid: %d Tsk: %p Mid %d",
  76. mid_entry->midState,
  77. (int)mid_entry->command,
  78. mid_entry->pid,
  79. mid_entry->tsk,
  80. mid_entry->mid));
  81. #ifdef CONFIG_CIFS_STATS2
  82. cERROR(1, ("IsLarge: %d buf: %p time rcv: %ld now: %ld",
  83. mid_entry->largeBuf,
  84. mid_entry->resp_buf,
  85. mid_entry->when_received,
  86. jiffies));
  87. #endif /* STATS2 */
  88. cERROR(1, ("IsMult: %d IsEnd: %d", mid_entry->multiRsp,
  89. mid_entry->multiEnd));
  90. if (mid_entry->resp_buf) {
  91. cifs_dump_detail(mid_entry->resp_buf);
  92. cifs_dump_mem("existing buf: ",
  93. mid_entry->resp_buf, 62);
  94. }
  95. }
  96. spin_unlock(&GlobalMid_Lock);
  97. }
  98. #endif /* CONFIG_CIFS_DEBUG2 */
  99. #ifdef CONFIG_PROC_FS
  100. static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
  101. {
  102. struct list_head *tmp, *tmp2, *tmp3;
  103. struct mid_q_entry *mid_entry;
  104. struct TCP_Server_Info *server;
  105. struct cifsSesInfo *ses;
  106. struct cifsTconInfo *tcon;
  107. int i;
  108. seq_puts(m,
  109. "Display Internal CIFS Data Structures for Debugging\n"
  110. "---------------------------------------------------\n");
  111. seq_printf(m, "CIFS Version %s\n", CIFS_VERSION);
  112. seq_printf(m, "Active VFS Requests: %d\n", GlobalTotalActiveXid);
  113. seq_printf(m, "Servers:");
  114. i = 0;
  115. read_lock(&cifs_tcp_ses_lock);
  116. list_for_each(tmp, &cifs_tcp_ses_list) {
  117. server = list_entry(tmp, struct TCP_Server_Info,
  118. tcp_ses_list);
  119. i++;
  120. list_for_each(tmp2, &server->smb_ses_list) {
  121. ses = list_entry(tmp2, struct cifsSesInfo,
  122. smb_ses_list);
  123. if ((ses->serverDomain == NULL) ||
  124. (ses->serverOS == NULL) ||
  125. (ses->serverNOS == NULL)) {
  126. seq_printf(m, "\nentry for %s not fully "
  127. "displayed\n\t", ses->serverName);
  128. } else {
  129. seq_printf(m,
  130. "\n%d) Name: %s Domain: %s Mounts: %d OS:"
  131. " %s \n\tNOS: %s\tCapability: 0x%x\n\tSMB"
  132. " session status: %d\t",
  133. i, ses->serverName, ses->serverDomain,
  134. ses->ses_count, ses->serverOS, ses->serverNOS,
  135. ses->capabilities, ses->status);
  136. }
  137. seq_printf(m, "TCP status: %d\n\tLocal Users To "
  138. "Server: %d SecMode: 0x%x Req On Wire: %d",
  139. server->tcpStatus, server->srv_count,
  140. server->secMode,
  141. atomic_read(&server->inFlight));
  142. #ifdef CONFIG_CIFS_STATS2
  143. seq_printf(m, " In Send: %d In MaxReq Wait: %d",
  144. atomic_read(&server->inSend),
  145. atomic_read(&server->num_waiters));
  146. #endif
  147. seq_puts(m, "\nMIDs:\n");
  148. spin_lock(&GlobalMid_Lock);
  149. list_for_each(tmp3, &server->pending_mid_q) {
  150. mid_entry = list_entry(tmp3, struct
  151. mid_q_entry,
  152. qhead);
  153. seq_printf(m, "State: %d com: %d pid:"
  154. " %d tsk: %p mid %d\n",
  155. mid_entry->midState,
  156. (int)mid_entry->command,
  157. mid_entry->pid,
  158. mid_entry->tsk,
  159. mid_entry->mid);
  160. }
  161. spin_unlock(&GlobalMid_Lock);
  162. }
  163. }
  164. read_unlock(&cifs_tcp_ses_lock);
  165. seq_putc(m, '\n');
  166. seq_puts(m, "Shares:");
  167. i = 0;
  168. read_lock(&GlobalSMBSeslock);
  169. list_for_each(tmp, &GlobalTreeConnectionList) {
  170. __u32 dev_type;
  171. i++;
  172. tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList);
  173. dev_type = le32_to_cpu(tcon->fsDevInfo.DeviceType);
  174. seq_printf(m, "\n%d) %s Uses: %d ", i,
  175. tcon->treeName, atomic_read(&tcon->useCount));
  176. if (tcon->nativeFileSystem) {
  177. seq_printf(m, "Type: %s ",
  178. tcon->nativeFileSystem);
  179. }
  180. seq_printf(m, "DevInfo: 0x%x Attributes: 0x%x"
  181. "\nPathComponentMax: %d Status: %d",
  182. le32_to_cpu(tcon->fsDevInfo.DeviceCharacteristics),
  183. le32_to_cpu(tcon->fsAttrInfo.Attributes),
  184. le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength),
  185. tcon->tidStatus);
  186. if (dev_type == FILE_DEVICE_DISK)
  187. seq_puts(m, " type: DISK ");
  188. else if (dev_type == FILE_DEVICE_CD_ROM)
  189. seq_puts(m, " type: CDROM ");
  190. else
  191. seq_printf(m, " type: %d ", dev_type);
  192. if (tcon->need_reconnect)
  193. seq_puts(m, "\tDISCONNECTED ");
  194. }
  195. read_unlock(&GlobalSMBSeslock);
  196. seq_putc(m, '\n');
  197. /* BB add code to dump additional info such as TCP session info now */
  198. return 0;
  199. }
  200. static int cifs_debug_data_proc_open(struct inode *inode, struct file *file)
  201. {
  202. return single_open(file, cifs_debug_data_proc_show, NULL);
  203. }
  204. static const struct file_operations cifs_debug_data_proc_fops = {
  205. .owner = THIS_MODULE,
  206. .open = cifs_debug_data_proc_open,
  207. .read = seq_read,
  208. .llseek = seq_lseek,
  209. .release = single_release,
  210. };
  211. #ifdef CONFIG_CIFS_STATS
  212. static ssize_t cifs_stats_proc_write(struct file *file,
  213. const char __user *buffer, size_t count, loff_t *ppos)
  214. {
  215. char c;
  216. int rc;
  217. struct list_head *tmp;
  218. struct cifsTconInfo *tcon;
  219. rc = get_user(c, buffer);
  220. if (rc)
  221. return rc;
  222. if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
  223. read_lock(&GlobalSMBSeslock);
  224. #ifdef CONFIG_CIFS_STATS2
  225. atomic_set(&totBufAllocCount, 0);
  226. atomic_set(&totSmBufAllocCount, 0);
  227. #endif /* CONFIG_CIFS_STATS2 */
  228. list_for_each(tmp, &GlobalTreeConnectionList) {
  229. tcon = list_entry(tmp, struct cifsTconInfo,
  230. cifsConnectionList);
  231. atomic_set(&tcon->num_smbs_sent, 0);
  232. atomic_set(&tcon->num_writes, 0);
  233. atomic_set(&tcon->num_reads, 0);
  234. atomic_set(&tcon->num_oplock_brks, 0);
  235. atomic_set(&tcon->num_opens, 0);
  236. atomic_set(&tcon->num_closes, 0);
  237. atomic_set(&tcon->num_deletes, 0);
  238. atomic_set(&tcon->num_mkdirs, 0);
  239. atomic_set(&tcon->num_rmdirs, 0);
  240. atomic_set(&tcon->num_renames, 0);
  241. atomic_set(&tcon->num_t2renames, 0);
  242. atomic_set(&tcon->num_ffirst, 0);
  243. atomic_set(&tcon->num_fnext, 0);
  244. atomic_set(&tcon->num_fclose, 0);
  245. atomic_set(&tcon->num_hardlinks, 0);
  246. atomic_set(&tcon->num_symlinks, 0);
  247. atomic_set(&tcon->num_locks, 0);
  248. }
  249. read_unlock(&GlobalSMBSeslock);
  250. }
  251. return count;
  252. }
  253. static int cifs_stats_proc_show(struct seq_file *m, void *v)
  254. {
  255. int i;
  256. struct list_head *tmp;
  257. struct cifsTconInfo *tcon;
  258. seq_printf(m,
  259. "Resources in use\nCIFS Session: %d\n",
  260. sesInfoAllocCount.counter);
  261. seq_printf(m, "Share (unique mount targets): %d\n",
  262. tconInfoAllocCount.counter);
  263. seq_printf(m, "SMB Request/Response Buffer: %d Pool size: %d\n",
  264. bufAllocCount.counter,
  265. cifs_min_rcv + tcpSesAllocCount.counter);
  266. seq_printf(m, "SMB Small Req/Resp Buffer: %d Pool size: %d\n",
  267. smBufAllocCount.counter, cifs_min_small);
  268. #ifdef CONFIG_CIFS_STATS2
  269. seq_printf(m, "Total Large %d Small %d Allocations\n",
  270. atomic_read(&totBufAllocCount),
  271. atomic_read(&totSmBufAllocCount));
  272. #endif /* CONFIG_CIFS_STATS2 */
  273. seq_printf(m, "Operations (MIDs): %d\n", midCount.counter);
  274. seq_printf(m,
  275. "\n%d session %d share reconnects\n",
  276. tcpSesReconnectCount.counter, tconInfoReconnectCount.counter);
  277. seq_printf(m,
  278. "Total vfs operations: %d maximum at one time: %d\n",
  279. GlobalCurrentXid, GlobalMaxActiveXid);
  280. i = 0;
  281. read_lock(&GlobalSMBSeslock);
  282. list_for_each(tmp, &GlobalTreeConnectionList) {
  283. i++;
  284. tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList);
  285. seq_printf(m, "\n%d) %s", i, tcon->treeName);
  286. if (tcon->need_reconnect)
  287. seq_puts(m, "\tDISCONNECTED ");
  288. seq_printf(m, "\nSMBs: %d Oplock Breaks: %d",
  289. atomic_read(&tcon->num_smbs_sent),
  290. atomic_read(&tcon->num_oplock_brks));
  291. seq_printf(m, "\nReads: %d Bytes: %lld",
  292. atomic_read(&tcon->num_reads),
  293. (long long)(tcon->bytes_read));
  294. seq_printf(m, "\nWrites: %d Bytes: %lld",
  295. atomic_read(&tcon->num_writes),
  296. (long long)(tcon->bytes_written));
  297. seq_printf(m,
  298. "\nLocks: %d HardLinks: %d Symlinks: %d",
  299. atomic_read(&tcon->num_locks),
  300. atomic_read(&tcon->num_hardlinks),
  301. atomic_read(&tcon->num_symlinks));
  302. seq_printf(m, "\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. seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
  307. atomic_read(&tcon->num_mkdirs),
  308. atomic_read(&tcon->num_rmdirs));
  309. seq_printf(m, "\nRenames: %d T2 Renames %d",
  310. atomic_read(&tcon->num_renames),
  311. atomic_read(&tcon->num_t2renames));
  312. seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
  313. atomic_read(&tcon->num_ffirst),
  314. atomic_read(&tcon->num_fnext),
  315. atomic_read(&tcon->num_fclose));
  316. }
  317. read_unlock(&GlobalSMBSeslock);
  318. seq_putc(m, '\n');
  319. return 0;
  320. }
  321. static int cifs_stats_proc_open(struct inode *inode, struct file *file)
  322. {
  323. return single_open(file, cifs_stats_proc_show, NULL);
  324. }
  325. static const struct file_operations cifs_stats_proc_fops = {
  326. .owner = THIS_MODULE,
  327. .open = cifs_stats_proc_open,
  328. .read = seq_read,
  329. .llseek = seq_lseek,
  330. .release = single_release,
  331. .write = cifs_stats_proc_write,
  332. };
  333. #endif /* STATS */
  334. static struct proc_dir_entry *proc_fs_cifs;
  335. static const struct file_operations cifsFYI_proc_fops;
  336. static const struct file_operations cifs_oplock_proc_fops;
  337. static const struct file_operations cifs_lookup_cache_proc_fops;
  338. static const struct file_operations traceSMB_proc_fops;
  339. static const struct file_operations cifs_multiuser_mount_proc_fops;
  340. static const struct file_operations cifs_security_flags_proc_fops;
  341. static const struct file_operations cifs_experimental_proc_fops;
  342. static const struct file_operations cifs_linux_ext_proc_fops;
  343. void
  344. cifs_proc_init(void)
  345. {
  346. proc_fs_cifs = proc_mkdir("fs/cifs", NULL);
  347. if (proc_fs_cifs == NULL)
  348. return;
  349. proc_fs_cifs->owner = THIS_MODULE;
  350. proc_create("DebugData", 0, proc_fs_cifs, &cifs_debug_data_proc_fops);
  351. #ifdef CONFIG_CIFS_STATS
  352. proc_create("Stats", 0, proc_fs_cifs, &cifs_stats_proc_fops);
  353. #endif /* STATS */
  354. proc_create("cifsFYI", 0, proc_fs_cifs, &cifsFYI_proc_fops);
  355. proc_create("traceSMB", 0, proc_fs_cifs, &traceSMB_proc_fops);
  356. proc_create("OplockEnabled", 0, proc_fs_cifs, &cifs_oplock_proc_fops);
  357. proc_create("Experimental", 0, proc_fs_cifs,
  358. &cifs_experimental_proc_fops);
  359. proc_create("LinuxExtensionsEnabled", 0, proc_fs_cifs,
  360. &cifs_linux_ext_proc_fops);
  361. proc_create("MultiuserMount", 0, proc_fs_cifs,
  362. &cifs_multiuser_mount_proc_fops);
  363. proc_create("SecurityFlags", 0, proc_fs_cifs,
  364. &cifs_security_flags_proc_fops);
  365. proc_create("LookupCacheEnabled", 0, proc_fs_cifs,
  366. &cifs_lookup_cache_proc_fops);
  367. }
  368. void
  369. cifs_proc_clean(void)
  370. {
  371. if (proc_fs_cifs == NULL)
  372. return;
  373. remove_proc_entry("DebugData", proc_fs_cifs);
  374. remove_proc_entry("cifsFYI", proc_fs_cifs);
  375. remove_proc_entry("traceSMB", proc_fs_cifs);
  376. #ifdef CONFIG_CIFS_STATS
  377. remove_proc_entry("Stats", proc_fs_cifs);
  378. #endif
  379. remove_proc_entry("MultiuserMount", proc_fs_cifs);
  380. remove_proc_entry("OplockEnabled", proc_fs_cifs);
  381. remove_proc_entry("SecurityFlags", proc_fs_cifs);
  382. remove_proc_entry("LinuxExtensionsEnabled", proc_fs_cifs);
  383. remove_proc_entry("Experimental", proc_fs_cifs);
  384. remove_proc_entry("LookupCacheEnabled", proc_fs_cifs);
  385. remove_proc_entry("fs/cifs", NULL);
  386. }
  387. static int cifsFYI_proc_show(struct seq_file *m, void *v)
  388. {
  389. seq_printf(m, "%d\n", cifsFYI);
  390. return 0;
  391. }
  392. static int cifsFYI_proc_open(struct inode *inode, struct file *file)
  393. {
  394. return single_open(file, cifsFYI_proc_show, NULL);
  395. }
  396. static ssize_t cifsFYI_proc_write(struct file *file, const char __user *buffer,
  397. size_t count, loff_t *ppos)
  398. {
  399. char c;
  400. int rc;
  401. rc = get_user(c, buffer);
  402. if (rc)
  403. return rc;
  404. if (c == '0' || c == 'n' || c == 'N')
  405. cifsFYI = 0;
  406. else if (c == '1' || c == 'y' || c == 'Y')
  407. cifsFYI = 1;
  408. else if ((c > '1') && (c <= '9'))
  409. cifsFYI = (int) (c - '0'); /* see cifs_debug.h for meanings */
  410. return count;
  411. }
  412. static const struct file_operations cifsFYI_proc_fops = {
  413. .owner = THIS_MODULE,
  414. .open = cifsFYI_proc_open,
  415. .read = seq_read,
  416. .llseek = seq_lseek,
  417. .release = single_release,
  418. .write = cifsFYI_proc_write,
  419. };
  420. static int cifs_oplock_proc_show(struct seq_file *m, void *v)
  421. {
  422. seq_printf(m, "%d\n", oplockEnabled);
  423. return 0;
  424. }
  425. static int cifs_oplock_proc_open(struct inode *inode, struct file *file)
  426. {
  427. return single_open(file, cifs_oplock_proc_show, NULL);
  428. }
  429. static ssize_t cifs_oplock_proc_write(struct file *file,
  430. const char __user *buffer, size_t count, loff_t *ppos)
  431. {
  432. char c;
  433. int rc;
  434. rc = get_user(c, buffer);
  435. if (rc)
  436. return rc;
  437. if (c == '0' || c == 'n' || c == 'N')
  438. oplockEnabled = 0;
  439. else if (c == '1' || c == 'y' || c == 'Y')
  440. oplockEnabled = 1;
  441. return count;
  442. }
  443. static const struct file_operations cifs_oplock_proc_fops = {
  444. .owner = THIS_MODULE,
  445. .open = cifs_oplock_proc_open,
  446. .read = seq_read,
  447. .llseek = seq_lseek,
  448. .release = single_release,
  449. .write = cifs_oplock_proc_write,
  450. };
  451. static int cifs_experimental_proc_show(struct seq_file *m, void *v)
  452. {
  453. seq_printf(m, "%d\n", experimEnabled);
  454. return 0;
  455. }
  456. static int cifs_experimental_proc_open(struct inode *inode, struct file *file)
  457. {
  458. return single_open(file, cifs_experimental_proc_show, NULL);
  459. }
  460. static ssize_t cifs_experimental_proc_write(struct file *file,
  461. const char __user *buffer, size_t count, loff_t *ppos)
  462. {
  463. char c;
  464. int rc;
  465. rc = get_user(c, buffer);
  466. if (rc)
  467. return rc;
  468. if (c == '0' || c == 'n' || c == 'N')
  469. experimEnabled = 0;
  470. else if (c == '1' || c == 'y' || c == 'Y')
  471. experimEnabled = 1;
  472. else if (c == '2')
  473. experimEnabled = 2;
  474. return count;
  475. }
  476. static const struct file_operations cifs_experimental_proc_fops = {
  477. .owner = THIS_MODULE,
  478. .open = cifs_experimental_proc_open,
  479. .read = seq_read,
  480. .llseek = seq_lseek,
  481. .release = single_release,
  482. .write = cifs_experimental_proc_write,
  483. };
  484. static int cifs_linux_ext_proc_show(struct seq_file *m, void *v)
  485. {
  486. seq_printf(m, "%d\n", linuxExtEnabled);
  487. return 0;
  488. }
  489. static int cifs_linux_ext_proc_open(struct inode *inode, struct file *file)
  490. {
  491. return single_open(file, cifs_linux_ext_proc_show, NULL);
  492. }
  493. static ssize_t cifs_linux_ext_proc_write(struct file *file,
  494. const char __user *buffer, size_t count, loff_t *ppos)
  495. {
  496. char c;
  497. int rc;
  498. rc = get_user(c, buffer);
  499. if (rc)
  500. return rc;
  501. if (c == '0' || c == 'n' || c == 'N')
  502. linuxExtEnabled = 0;
  503. else if (c == '1' || c == 'y' || c == 'Y')
  504. linuxExtEnabled = 1;
  505. return count;
  506. }
  507. static const struct file_operations cifs_linux_ext_proc_fops = {
  508. .owner = THIS_MODULE,
  509. .open = cifs_linux_ext_proc_open,
  510. .read = seq_read,
  511. .llseek = seq_lseek,
  512. .release = single_release,
  513. .write = cifs_linux_ext_proc_write,
  514. };
  515. static int cifs_lookup_cache_proc_show(struct seq_file *m, void *v)
  516. {
  517. seq_printf(m, "%d\n", lookupCacheEnabled);
  518. return 0;
  519. }
  520. static int cifs_lookup_cache_proc_open(struct inode *inode, struct file *file)
  521. {
  522. return single_open(file, cifs_lookup_cache_proc_show, NULL);
  523. }
  524. static ssize_t cifs_lookup_cache_proc_write(struct file *file,
  525. const char __user *buffer, size_t count, loff_t *ppos)
  526. {
  527. char c;
  528. int rc;
  529. rc = get_user(c, buffer);
  530. if (rc)
  531. return rc;
  532. if (c == '0' || c == 'n' || c == 'N')
  533. lookupCacheEnabled = 0;
  534. else if (c == '1' || c == 'y' || c == 'Y')
  535. lookupCacheEnabled = 1;
  536. return count;
  537. }
  538. static const struct file_operations cifs_lookup_cache_proc_fops = {
  539. .owner = THIS_MODULE,
  540. .open = cifs_lookup_cache_proc_open,
  541. .read = seq_read,
  542. .llseek = seq_lseek,
  543. .release = single_release,
  544. .write = cifs_lookup_cache_proc_write,
  545. };
  546. static int traceSMB_proc_show(struct seq_file *m, void *v)
  547. {
  548. seq_printf(m, "%d\n", traceSMB);
  549. return 0;
  550. }
  551. static int traceSMB_proc_open(struct inode *inode, struct file *file)
  552. {
  553. return single_open(file, traceSMB_proc_show, NULL);
  554. }
  555. static ssize_t traceSMB_proc_write(struct file *file, const char __user *buffer,
  556. size_t count, loff_t *ppos)
  557. {
  558. char c;
  559. int rc;
  560. rc = get_user(c, buffer);
  561. if (rc)
  562. return rc;
  563. if (c == '0' || c == 'n' || c == 'N')
  564. traceSMB = 0;
  565. else if (c == '1' || c == 'y' || c == 'Y')
  566. traceSMB = 1;
  567. return count;
  568. }
  569. static const struct file_operations traceSMB_proc_fops = {
  570. .owner = THIS_MODULE,
  571. .open = traceSMB_proc_open,
  572. .read = seq_read,
  573. .llseek = seq_lseek,
  574. .release = single_release,
  575. .write = traceSMB_proc_write,
  576. };
  577. static int cifs_multiuser_mount_proc_show(struct seq_file *m, void *v)
  578. {
  579. seq_printf(m, "%d\n", multiuser_mount);
  580. return 0;
  581. }
  582. static int cifs_multiuser_mount_proc_open(struct inode *inode, struct file *fh)
  583. {
  584. return single_open(fh, cifs_multiuser_mount_proc_show, NULL);
  585. }
  586. static ssize_t cifs_multiuser_mount_proc_write(struct file *file,
  587. const char __user *buffer, size_t count, loff_t *ppos)
  588. {
  589. char c;
  590. int rc;
  591. rc = get_user(c, buffer);
  592. if (rc)
  593. return rc;
  594. if (c == '0' || c == 'n' || c == 'N')
  595. multiuser_mount = 0;
  596. else if (c == '1' || c == 'y' || c == 'Y')
  597. multiuser_mount = 1;
  598. return count;
  599. }
  600. static const struct file_operations cifs_multiuser_mount_proc_fops = {
  601. .owner = THIS_MODULE,
  602. .open = cifs_multiuser_mount_proc_open,
  603. .read = seq_read,
  604. .llseek = seq_lseek,
  605. .release = single_release,
  606. .write = cifs_multiuser_mount_proc_write,
  607. };
  608. static int cifs_security_flags_proc_show(struct seq_file *m, void *v)
  609. {
  610. seq_printf(m, "0x%x\n", extended_security);
  611. return 0;
  612. }
  613. static int cifs_security_flags_proc_open(struct inode *inode, struct file *file)
  614. {
  615. return single_open(file, cifs_security_flags_proc_show, NULL);
  616. }
  617. static ssize_t cifs_security_flags_proc_write(struct file *file,
  618. const char __user *buffer, size_t count, loff_t *ppos)
  619. {
  620. unsigned int flags;
  621. char flags_string[12];
  622. char c;
  623. if ((count < 1) || (count > 11))
  624. return -EINVAL;
  625. memset(flags_string, 0, 12);
  626. if (copy_from_user(flags_string, buffer, count))
  627. return -EFAULT;
  628. if (count < 3) {
  629. /* single char or single char followed by null */
  630. c = flags_string[0];
  631. if (c == '0' || c == 'n' || c == 'N') {
  632. extended_security = CIFSSEC_DEF; /* default */
  633. return count;
  634. } else if (c == '1' || c == 'y' || c == 'Y') {
  635. extended_security = CIFSSEC_MAX;
  636. return count;
  637. } else if (!isdigit(c)) {
  638. cERROR(1, ("invalid flag %c", c));
  639. return -EINVAL;
  640. }
  641. }
  642. /* else we have a number */
  643. flags = simple_strtoul(flags_string, NULL, 0);
  644. cFYI(1, ("sec flags 0x%x", flags));
  645. if (flags <= 0) {
  646. cERROR(1, ("invalid security flags %s", flags_string));
  647. return -EINVAL;
  648. }
  649. if (flags & ~CIFSSEC_MASK) {
  650. cERROR(1, ("attempt to set unsupported security flags 0x%x",
  651. flags & ~CIFSSEC_MASK));
  652. return -EINVAL;
  653. }
  654. /* flags look ok - update the global security flags for cifs module */
  655. extended_security = flags;
  656. if (extended_security & CIFSSEC_MUST_SIGN) {
  657. /* requiring signing implies signing is allowed */
  658. extended_security |= CIFSSEC_MAY_SIGN;
  659. cFYI(1, ("packet signing now required"));
  660. } else if ((extended_security & CIFSSEC_MAY_SIGN) == 0) {
  661. cFYI(1, ("packet signing disabled"));
  662. }
  663. /* BB should we turn on MAY flags for other MUST options? */
  664. return count;
  665. }
  666. static const struct file_operations cifs_security_flags_proc_fops = {
  667. .owner = THIS_MODULE,
  668. .open = cifs_security_flags_proc_open,
  669. .read = seq_read,
  670. .llseek = seq_lseek,
  671. .release = single_release,
  672. .write = cifs_security_flags_proc_write,
  673. };
  674. #else
  675. inline void cifs_proc_init(void)
  676. {
  677. }
  678. inline void cifs_proc_clean(void)
  679. {
  680. }
  681. #endif /* PROC_FS */