cifs_debug.c 20 KB

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