cifs_debug.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785
  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(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 Cbdata: %p Mid %d",
  76. mid_entry->midState,
  77. (int)mid_entry->command,
  78. mid_entry->pid,
  79. mid_entry->callback_data,
  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 *tmp1, *tmp2, *tmp3;
  103. struct mid_q_entry *mid_entry;
  104. struct TCP_Server_Info *server;
  105. struct cifs_ses *ses;
  106. struct cifs_tcon *tcon;
  107. int i, j;
  108. __u32 dev_type;
  109. seq_puts(m,
  110. "Display Internal CIFS Data Structures for Debugging\n"
  111. "---------------------------------------------------\n");
  112. seq_printf(m, "CIFS Version %s\n", CIFS_VERSION);
  113. seq_printf(m, "Features:");
  114. #ifdef CONFIG_CIFS_DFS_UPCALL
  115. seq_printf(m, " dfs");
  116. #endif
  117. #ifdef CONFIG_CIFS_FSCACHE
  118. seq_printf(m, " fscache");
  119. #endif
  120. #ifdef CONFIG_CIFS_WEAK_PW_HASH
  121. seq_printf(m, " lanman");
  122. #endif
  123. #ifdef CONFIG_CIFS_POSIX
  124. seq_printf(m, " posix");
  125. #endif
  126. #ifdef CONFIG_CIFS_UPCALL
  127. seq_printf(m, " spnego");
  128. #endif
  129. #ifdef CONFIG_CIFS_XATTR
  130. seq_printf(m, " xattr");
  131. #endif
  132. #ifdef CONFIG_CIFS_ACL
  133. seq_printf(m, " acl");
  134. #endif
  135. seq_putc(m, '\n');
  136. seq_printf(m, "Active VFS Requests: %d\n", GlobalTotalActiveXid);
  137. seq_printf(m, "Servers:");
  138. i = 0;
  139. spin_lock(&cifs_tcp_ses_lock);
  140. list_for_each(tmp1, &cifs_tcp_ses_list) {
  141. server = list_entry(tmp1, struct TCP_Server_Info,
  142. tcp_ses_list);
  143. i++;
  144. list_for_each(tmp2, &server->smb_ses_list) {
  145. ses = list_entry(tmp2, struct cifs_ses,
  146. smb_ses_list);
  147. if ((ses->serverDomain == NULL) ||
  148. (ses->serverOS == NULL) ||
  149. (ses->serverNOS == NULL)) {
  150. seq_printf(m, "\n%d) entry for %s not fully "
  151. "displayed\n\t", i, ses->serverName);
  152. } else {
  153. seq_printf(m,
  154. "\n%d) Name: %s Domain: %s Uses: %d OS:"
  155. " %s\n\tNOS: %s\tCapability: 0x%x\n\tSMB"
  156. " session status: %d\t",
  157. i, ses->serverName, ses->serverDomain,
  158. ses->ses_count, ses->serverOS, ses->serverNOS,
  159. ses->capabilities, ses->status);
  160. }
  161. seq_printf(m, "TCP status: %d\n\tLocal Users To "
  162. "Server: %d SecMode: 0x%x Req On Wire: %d",
  163. server->tcpStatus, server->srv_count,
  164. server->sec_mode,
  165. atomic_read(&server->inFlight));
  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 %d\n",
  207. mid_entry->midState,
  208. (int)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_oplock_proc_fops;
  391. static const struct file_operations cifs_lookup_cache_proc_fops;
  392. static const struct file_operations traceSMB_proc_fops;
  393. static const struct file_operations cifs_multiuser_mount_proc_fops;
  394. static const struct file_operations cifs_security_flags_proc_fops;
  395. static const struct file_operations cifs_linux_ext_proc_fops;
  396. void
  397. cifs_proc_init(void)
  398. {
  399. proc_fs_cifs = proc_mkdir("fs/cifs", NULL);
  400. if (proc_fs_cifs == NULL)
  401. return;
  402. proc_create("DebugData", 0, proc_fs_cifs, &cifs_debug_data_proc_fops);
  403. #ifdef CONFIG_CIFS_STATS
  404. proc_create("Stats", 0, proc_fs_cifs, &cifs_stats_proc_fops);
  405. #endif /* STATS */
  406. proc_create("cifsFYI", 0, proc_fs_cifs, &cifsFYI_proc_fops);
  407. proc_create("traceSMB", 0, proc_fs_cifs, &traceSMB_proc_fops);
  408. proc_create("OplockEnabled", 0, proc_fs_cifs, &cifs_oplock_proc_fops);
  409. proc_create("LinuxExtensionsEnabled", 0, proc_fs_cifs,
  410. &cifs_linux_ext_proc_fops);
  411. proc_create("MultiuserMount", 0, proc_fs_cifs,
  412. &cifs_multiuser_mount_proc_fops);
  413. proc_create("SecurityFlags", 0, proc_fs_cifs,
  414. &cifs_security_flags_proc_fops);
  415. proc_create("LookupCacheEnabled", 0, proc_fs_cifs,
  416. &cifs_lookup_cache_proc_fops);
  417. }
  418. void
  419. cifs_proc_clean(void)
  420. {
  421. if (proc_fs_cifs == NULL)
  422. return;
  423. remove_proc_entry("DebugData", proc_fs_cifs);
  424. remove_proc_entry("cifsFYI", proc_fs_cifs);
  425. remove_proc_entry("traceSMB", proc_fs_cifs);
  426. #ifdef CONFIG_CIFS_STATS
  427. remove_proc_entry("Stats", proc_fs_cifs);
  428. #endif
  429. remove_proc_entry("MultiuserMount", proc_fs_cifs);
  430. remove_proc_entry("OplockEnabled", proc_fs_cifs);
  431. remove_proc_entry("SecurityFlags", proc_fs_cifs);
  432. remove_proc_entry("LinuxExtensionsEnabled", proc_fs_cifs);
  433. remove_proc_entry("LookupCacheEnabled", proc_fs_cifs);
  434. remove_proc_entry("fs/cifs", NULL);
  435. }
  436. static int cifsFYI_proc_show(struct seq_file *m, void *v)
  437. {
  438. seq_printf(m, "%d\n", cifsFYI);
  439. return 0;
  440. }
  441. static int cifsFYI_proc_open(struct inode *inode, struct file *file)
  442. {
  443. return single_open(file, cifsFYI_proc_show, NULL);
  444. }
  445. static ssize_t cifsFYI_proc_write(struct file *file, const char __user *buffer,
  446. size_t count, loff_t *ppos)
  447. {
  448. char c;
  449. int rc;
  450. rc = get_user(c, buffer);
  451. if (rc)
  452. return rc;
  453. if (c == '0' || c == 'n' || c == 'N')
  454. cifsFYI = 0;
  455. else if (c == '1' || c == 'y' || c == 'Y')
  456. cifsFYI = 1;
  457. else if ((c > '1') && (c <= '9'))
  458. cifsFYI = (int) (c - '0'); /* see cifs_debug.h for meanings */
  459. return count;
  460. }
  461. static const struct file_operations cifsFYI_proc_fops = {
  462. .owner = THIS_MODULE,
  463. .open = cifsFYI_proc_open,
  464. .read = seq_read,
  465. .llseek = seq_lseek,
  466. .release = single_release,
  467. .write = cifsFYI_proc_write,
  468. };
  469. static int cifs_oplock_proc_show(struct seq_file *m, void *v)
  470. {
  471. seq_printf(m, "%d\n", enable_oplocks);
  472. return 0;
  473. }
  474. static int cifs_oplock_proc_open(struct inode *inode, struct file *file)
  475. {
  476. return single_open(file, cifs_oplock_proc_show, NULL);
  477. }
  478. static ssize_t cifs_oplock_proc_write(struct file *file,
  479. const char __user *buffer, size_t count, loff_t *ppos)
  480. {
  481. char c;
  482. int rc;
  483. printk(KERN_WARNING "CIFS: The /proc/fs/cifs/OplockEnabled interface "
  484. "will be removed in kernel version 3.4. Please migrate to "
  485. "using the 'enable_oplocks' module parameter in cifs.ko.\n");
  486. rc = get_user(c, buffer);
  487. if (rc)
  488. return rc;
  489. if (c == '0' || c == 'n' || c == 'N')
  490. enable_oplocks = false;
  491. else if (c == '1' || c == 'y' || c == 'Y')
  492. enable_oplocks = true;
  493. return count;
  494. }
  495. static const struct file_operations cifs_oplock_proc_fops = {
  496. .owner = THIS_MODULE,
  497. .open = cifs_oplock_proc_open,
  498. .read = seq_read,
  499. .llseek = seq_lseek,
  500. .release = single_release,
  501. .write = cifs_oplock_proc_write,
  502. };
  503. static int cifs_linux_ext_proc_show(struct seq_file *m, void *v)
  504. {
  505. seq_printf(m, "%d\n", linuxExtEnabled);
  506. return 0;
  507. }
  508. static int cifs_linux_ext_proc_open(struct inode *inode, struct file *file)
  509. {
  510. return single_open(file, cifs_linux_ext_proc_show, NULL);
  511. }
  512. static ssize_t cifs_linux_ext_proc_write(struct file *file,
  513. const char __user *buffer, size_t count, loff_t *ppos)
  514. {
  515. char c;
  516. int rc;
  517. rc = get_user(c, buffer);
  518. if (rc)
  519. return rc;
  520. if (c == '0' || c == 'n' || c == 'N')
  521. linuxExtEnabled = 0;
  522. else if (c == '1' || c == 'y' || c == 'Y')
  523. linuxExtEnabled = 1;
  524. return count;
  525. }
  526. static const struct file_operations cifs_linux_ext_proc_fops = {
  527. .owner = THIS_MODULE,
  528. .open = cifs_linux_ext_proc_open,
  529. .read = seq_read,
  530. .llseek = seq_lseek,
  531. .release = single_release,
  532. .write = cifs_linux_ext_proc_write,
  533. };
  534. static int cifs_lookup_cache_proc_show(struct seq_file *m, void *v)
  535. {
  536. seq_printf(m, "%d\n", lookupCacheEnabled);
  537. return 0;
  538. }
  539. static int cifs_lookup_cache_proc_open(struct inode *inode, struct file *file)
  540. {
  541. return single_open(file, cifs_lookup_cache_proc_show, NULL);
  542. }
  543. static ssize_t cifs_lookup_cache_proc_write(struct file *file,
  544. const char __user *buffer, size_t count, loff_t *ppos)
  545. {
  546. char c;
  547. int rc;
  548. rc = get_user(c, buffer);
  549. if (rc)
  550. return rc;
  551. if (c == '0' || c == 'n' || c == 'N')
  552. lookupCacheEnabled = 0;
  553. else if (c == '1' || c == 'y' || c == 'Y')
  554. lookupCacheEnabled = 1;
  555. return count;
  556. }
  557. static const struct file_operations cifs_lookup_cache_proc_fops = {
  558. .owner = THIS_MODULE,
  559. .open = cifs_lookup_cache_proc_open,
  560. .read = seq_read,
  561. .llseek = seq_lseek,
  562. .release = single_release,
  563. .write = cifs_lookup_cache_proc_write,
  564. };
  565. static int traceSMB_proc_show(struct seq_file *m, void *v)
  566. {
  567. seq_printf(m, "%d\n", traceSMB);
  568. return 0;
  569. }
  570. static int traceSMB_proc_open(struct inode *inode, struct file *file)
  571. {
  572. return single_open(file, traceSMB_proc_show, NULL);
  573. }
  574. static ssize_t traceSMB_proc_write(struct file *file, const char __user *buffer,
  575. size_t count, loff_t *ppos)
  576. {
  577. char c;
  578. int rc;
  579. rc = get_user(c, buffer);
  580. if (rc)
  581. return rc;
  582. if (c == '0' || c == 'n' || c == 'N')
  583. traceSMB = 0;
  584. else if (c == '1' || c == 'y' || c == 'Y')
  585. traceSMB = 1;
  586. return count;
  587. }
  588. static const struct file_operations traceSMB_proc_fops = {
  589. .owner = THIS_MODULE,
  590. .open = traceSMB_proc_open,
  591. .read = seq_read,
  592. .llseek = seq_lseek,
  593. .release = single_release,
  594. .write = traceSMB_proc_write,
  595. };
  596. static int cifs_multiuser_mount_proc_show(struct seq_file *m, void *v)
  597. {
  598. seq_printf(m, "%d\n", multiuser_mount);
  599. return 0;
  600. }
  601. static int cifs_multiuser_mount_proc_open(struct inode *inode, struct file *fh)
  602. {
  603. return single_open(fh, cifs_multiuser_mount_proc_show, NULL);
  604. }
  605. static ssize_t cifs_multiuser_mount_proc_write(struct file *file,
  606. const char __user *buffer, size_t count, loff_t *ppos)
  607. {
  608. char c;
  609. int rc;
  610. rc = get_user(c, buffer);
  611. if (rc)
  612. return rc;
  613. if (c == '0' || c == 'n' || c == 'N')
  614. multiuser_mount = 0;
  615. else if (c == '1' || c == 'y' || c == 'Y')
  616. multiuser_mount = 1;
  617. return count;
  618. }
  619. static const struct file_operations cifs_multiuser_mount_proc_fops = {
  620. .owner = THIS_MODULE,
  621. .open = cifs_multiuser_mount_proc_open,
  622. .read = seq_read,
  623. .llseek = seq_lseek,
  624. .release = single_release,
  625. .write = cifs_multiuser_mount_proc_write,
  626. };
  627. static int cifs_security_flags_proc_show(struct seq_file *m, void *v)
  628. {
  629. seq_printf(m, "0x%x\n", global_secflags);
  630. return 0;
  631. }
  632. static int cifs_security_flags_proc_open(struct inode *inode, struct file *file)
  633. {
  634. return single_open(file, cifs_security_flags_proc_show, NULL);
  635. }
  636. static ssize_t cifs_security_flags_proc_write(struct file *file,
  637. const char __user *buffer, size_t count, loff_t *ppos)
  638. {
  639. unsigned int flags;
  640. char flags_string[12];
  641. char c;
  642. if ((count < 1) || (count > 11))
  643. return -EINVAL;
  644. memset(flags_string, 0, 12);
  645. if (copy_from_user(flags_string, buffer, count))
  646. return -EFAULT;
  647. if (count < 3) {
  648. /* single char or single char followed by null */
  649. c = flags_string[0];
  650. if (c == '0' || c == 'n' || c == 'N') {
  651. global_secflags = CIFSSEC_DEF; /* default */
  652. return count;
  653. } else if (c == '1' || c == 'y' || c == 'Y') {
  654. global_secflags = CIFSSEC_MAX;
  655. return count;
  656. } else if (!isdigit(c)) {
  657. cERROR(1, "invalid flag %c", c);
  658. return -EINVAL;
  659. }
  660. }
  661. /* else we have a number */
  662. flags = simple_strtoul(flags_string, NULL, 0);
  663. cFYI(1, "sec flags 0x%x", flags);
  664. if (flags <= 0) {
  665. cERROR(1, "invalid security flags %s", flags_string);
  666. return -EINVAL;
  667. }
  668. if (flags & ~CIFSSEC_MASK) {
  669. cERROR(1, "attempt to set unsupported security flags 0x%x",
  670. flags & ~CIFSSEC_MASK);
  671. return -EINVAL;
  672. }
  673. /* flags look ok - update the global security flags for cifs module */
  674. global_secflags = flags;
  675. if (global_secflags & CIFSSEC_MUST_SIGN) {
  676. /* requiring signing implies signing is allowed */
  677. global_secflags |= CIFSSEC_MAY_SIGN;
  678. cFYI(1, "packet signing now required");
  679. } else if ((global_secflags & CIFSSEC_MAY_SIGN) == 0) {
  680. cFYI(1, "packet signing disabled");
  681. }
  682. /* BB should we turn on MAY flags for other MUST options? */
  683. return count;
  684. }
  685. static const struct file_operations cifs_security_flags_proc_fops = {
  686. .owner = THIS_MODULE,
  687. .open = cifs_security_flags_proc_open,
  688. .read = seq_read,
  689. .llseek = seq_lseek,
  690. .release = single_release,
  691. .write = cifs_security_flags_proc_write,
  692. };
  693. #else
  694. inline void cifs_proc_init(void)
  695. {
  696. }
  697. inline void cifs_proc_clean(void)
  698. {
  699. }
  700. #endif /* PROC_FS */