cifs_debug.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928
  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. if (mid_entry) {
  76. cERROR(1, ("State: %d Cmd: %d Pid: %d Tsk: %p Mid %d",
  77. mid_entry->midState,
  78. (int)mid_entry->command,
  79. mid_entry->pid,
  80. mid_entry->tsk,
  81. mid_entry->mid));
  82. #ifdef CONFIG_CIFS_STATS2
  83. cERROR(1, ("IsLarge: %d buf: %p time rcv: %ld now: %ld",
  84. mid_entry->largeBuf,
  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. }
  98. spin_unlock(&GlobalMid_Lock);
  99. }
  100. #endif /* CONFIG_CIFS_DEBUG2 */
  101. #ifdef CONFIG_PROC_FS
  102. static int
  103. cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
  104. int count, int *eof, void *data)
  105. {
  106. struct list_head *tmp;
  107. struct list_head *tmp1;
  108. struct mid_q_entry *mid_entry;
  109. struct cifsSesInfo *ses;
  110. struct cifsTconInfo *tcon;
  111. int i;
  112. int length = 0;
  113. char *original_buf = buf;
  114. *beginBuffer = buf + offset;
  115. length =
  116. sprintf(buf,
  117. "Display Internal CIFS Data Structures for Debugging\n"
  118. "---------------------------------------------------\n");
  119. buf += length;
  120. length = sprintf(buf, "CIFS Version %s\n", CIFS_VERSION);
  121. buf += length;
  122. length = sprintf(buf,
  123. "Active VFS Requests: %d\n", GlobalTotalActiveXid);
  124. buf += length;
  125. length = sprintf(buf, "Servers:");
  126. buf += length;
  127. i = 0;
  128. read_lock(&GlobalSMBSeslock);
  129. list_for_each(tmp, &GlobalSMBSessionList) {
  130. i++;
  131. ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList);
  132. if ((ses->serverDomain == NULL) || (ses->serverOS == NULL) ||
  133. (ses->serverNOS == NULL)) {
  134. buf += sprintf(buf, "\nentry for %s not fully "
  135. "displayed\n\t", ses->serverName);
  136. } else {
  137. length =
  138. sprintf(buf,
  139. "\n%d) Name: %s Domain: %s Mounts: %d OS:"
  140. " %s \n\tNOS: %s\tCapability: 0x%x\n\tSMB"
  141. " session status: %d\t",
  142. i, ses->serverName, ses->serverDomain,
  143. atomic_read(&ses->inUse),
  144. ses->serverOS, ses->serverNOS,
  145. ses->capabilities, ses->status);
  146. buf += length;
  147. }
  148. if (ses->server) {
  149. buf += sprintf(buf, "TCP status: %d\n\tLocal Users To "
  150. "Server: %d SecMode: 0x%x Req On Wire: %d",
  151. ses->server->tcpStatus,
  152. atomic_read(&ses->server->socketUseCount),
  153. ses->server->secMode,
  154. atomic_read(&ses->server->inFlight));
  155. #ifdef CONFIG_CIFS_STATS2
  156. buf += sprintf(buf, " In Send: %d In MaxReq Wait: %d",
  157. atomic_read(&ses->server->inSend),
  158. atomic_read(&ses->server->num_waiters));
  159. #endif
  160. length = sprintf(buf, "\nMIDs:\n");
  161. buf += length;
  162. spin_lock(&GlobalMid_Lock);
  163. list_for_each(tmp1, &ses->server->pending_mid_q) {
  164. mid_entry = list_entry(tmp1, struct
  165. mid_q_entry,
  166. qhead);
  167. if (mid_entry) {
  168. length = sprintf(buf,
  169. "State: %d com: %d pid:"
  170. " %d tsk: %p mid %d\n",
  171. mid_entry->midState,
  172. (int)mid_entry->command,
  173. mid_entry->pid,
  174. mid_entry->tsk,
  175. mid_entry->mid);
  176. buf += length;
  177. }
  178. }
  179. spin_unlock(&GlobalMid_Lock);
  180. }
  181. }
  182. read_unlock(&GlobalSMBSeslock);
  183. sprintf(buf, "\n");
  184. buf++;
  185. length = sprintf(buf, "Shares:");
  186. buf += length;
  187. i = 0;
  188. read_lock(&GlobalSMBSeslock);
  189. list_for_each(tmp, &GlobalTreeConnectionList) {
  190. __u32 dev_type;
  191. i++;
  192. tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList);
  193. dev_type = le32_to_cpu(tcon->fsDevInfo.DeviceType);
  194. length = sprintf(buf, "\n%d) %s Uses: %d ", i,
  195. tcon->treeName, atomic_read(&tcon->useCount));
  196. buf += length;
  197. if (tcon->nativeFileSystem) {
  198. length = sprintf(buf, "Type: %s ",
  199. tcon->nativeFileSystem);
  200. buf += length;
  201. }
  202. length = sprintf(buf, "DevInfo: 0x%x Attributes: 0x%x"
  203. "\nPathComponentMax: %d Status: %d",
  204. le32_to_cpu(tcon->fsDevInfo.DeviceCharacteristics),
  205. le32_to_cpu(tcon->fsAttrInfo.Attributes),
  206. le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength),
  207. tcon->tidStatus);
  208. buf += length;
  209. if (dev_type == FILE_DEVICE_DISK)
  210. length = sprintf(buf, " type: DISK ");
  211. else if (dev_type == FILE_DEVICE_CD_ROM)
  212. length = sprintf(buf, " type: CDROM ");
  213. else
  214. length =
  215. sprintf(buf, " type: %d ", dev_type);
  216. buf += length;
  217. if (tcon->tidStatus == CifsNeedReconnect) {
  218. buf += sprintf(buf, "\tDISCONNECTED ");
  219. length += 14;
  220. }
  221. }
  222. read_unlock(&GlobalSMBSeslock);
  223. length = sprintf(buf, "\n");
  224. buf += length;
  225. /* BB add code to dump additional info such as TCP session info now */
  226. /* Now calculate total size of returned data */
  227. length = buf - original_buf;
  228. if (offset + count >= length)
  229. *eof = 1;
  230. if (length < offset) {
  231. *eof = 1;
  232. return 0;
  233. } else {
  234. length = length - offset;
  235. }
  236. if (length > count)
  237. length = count;
  238. return length;
  239. }
  240. #ifdef CONFIG_CIFS_STATS
  241. static int
  242. cifs_stats_write(struct file *file, const char __user *buffer,
  243. unsigned long count, void *data)
  244. {
  245. char c;
  246. int rc;
  247. struct list_head *tmp;
  248. struct cifsTconInfo *tcon;
  249. rc = get_user(c, buffer);
  250. if (rc)
  251. return rc;
  252. if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
  253. read_lock(&GlobalSMBSeslock);
  254. #ifdef CONFIG_CIFS_STATS2
  255. atomic_set(&totBufAllocCount, 0);
  256. atomic_set(&totSmBufAllocCount, 0);
  257. #endif /* CONFIG_CIFS_STATS2 */
  258. list_for_each(tmp, &GlobalTreeConnectionList) {
  259. tcon = list_entry(tmp, struct cifsTconInfo,
  260. cifsConnectionList);
  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_closes, 0);
  267. atomic_set(&tcon->num_deletes, 0);
  268. atomic_set(&tcon->num_mkdirs, 0);
  269. atomic_set(&tcon->num_rmdirs, 0);
  270. atomic_set(&tcon->num_renames, 0);
  271. atomic_set(&tcon->num_t2renames, 0);
  272. atomic_set(&tcon->num_ffirst, 0);
  273. atomic_set(&tcon->num_fnext, 0);
  274. atomic_set(&tcon->num_fclose, 0);
  275. atomic_set(&tcon->num_hardlinks, 0);
  276. atomic_set(&tcon->num_symlinks, 0);
  277. atomic_set(&tcon->num_locks, 0);
  278. }
  279. read_unlock(&GlobalSMBSeslock);
  280. }
  281. return count;
  282. }
  283. static int
  284. cifs_stats_read(char *buf, char **beginBuffer, off_t offset,
  285. int count, int *eof, void *data)
  286. {
  287. int item_length, i, length;
  288. struct list_head *tmp;
  289. struct cifsTconInfo *tcon;
  290. *beginBuffer = buf + offset;
  291. length = sprintf(buf,
  292. "Resources in use\nCIFS Session: %d\n",
  293. sesInfoAllocCount.counter);
  294. buf += length;
  295. item_length =
  296. sprintf(buf, "Share (unique mount targets): %d\n",
  297. tconInfoAllocCount.counter);
  298. length += item_length;
  299. buf += item_length;
  300. item_length =
  301. sprintf(buf, "SMB Request/Response Buffer: %d Pool size: %d\n",
  302. bufAllocCount.counter,
  303. cifs_min_rcv + tcpSesAllocCount.counter);
  304. length += item_length;
  305. buf += item_length;
  306. item_length =
  307. sprintf(buf, "SMB Small Req/Resp Buffer: %d Pool size: %d\n",
  308. smBufAllocCount.counter, cifs_min_small);
  309. length += item_length;
  310. buf += item_length;
  311. #ifdef CONFIG_CIFS_STATS2
  312. item_length = sprintf(buf, "Total Large %d Small %d Allocations\n",
  313. atomic_read(&totBufAllocCount),
  314. atomic_read(&totSmBufAllocCount));
  315. length += item_length;
  316. buf += item_length;
  317. #endif /* CONFIG_CIFS_STATS2 */
  318. item_length =
  319. sprintf(buf, "Operations (MIDs): %d\n",
  320. midCount.counter);
  321. length += item_length;
  322. buf += item_length;
  323. item_length = sprintf(buf,
  324. "\n%d session %d share reconnects\n",
  325. tcpSesReconnectCount.counter, tconInfoReconnectCount.counter);
  326. length += item_length;
  327. buf += item_length;
  328. item_length = sprintf(buf,
  329. "Total vfs operations: %d maximum at one time: %d\n",
  330. GlobalCurrentXid, GlobalMaxActiveXid);
  331. length += item_length;
  332. buf += item_length;
  333. i = 0;
  334. read_lock(&GlobalSMBSeslock);
  335. list_for_each(tmp, &GlobalTreeConnectionList) {
  336. i++;
  337. tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList);
  338. item_length = sprintf(buf, "\n%d) %s", i, tcon->treeName);
  339. buf += item_length;
  340. length += item_length;
  341. if (tcon->tidStatus == CifsNeedReconnect) {
  342. buf += sprintf(buf, "\tDISCONNECTED ");
  343. length += 14;
  344. }
  345. item_length = sprintf(buf, "\nSMBs: %d Oplock Breaks: %d",
  346. atomic_read(&tcon->num_smbs_sent),
  347. atomic_read(&tcon->num_oplock_brks));
  348. buf += item_length;
  349. length += item_length;
  350. item_length = sprintf(buf, "\nReads: %d Bytes: %lld",
  351. atomic_read(&tcon->num_reads),
  352. (long long)(tcon->bytes_read));
  353. buf += item_length;
  354. length += item_length;
  355. item_length = sprintf(buf, "\nWrites: %d Bytes: %lld",
  356. atomic_read(&tcon->num_writes),
  357. (long long)(tcon->bytes_written));
  358. buf += item_length;
  359. length += item_length;
  360. item_length = sprintf(buf,
  361. "\nLocks: %d HardLinks: %d Symlinks: %d",
  362. atomic_read(&tcon->num_locks),
  363. atomic_read(&tcon->num_hardlinks),
  364. atomic_read(&tcon->num_symlinks));
  365. buf += item_length;
  366. length += item_length;
  367. item_length = sprintf(buf, "\nOpens: %d Closes: %d Deletes: %d",
  368. atomic_read(&tcon->num_opens),
  369. atomic_read(&tcon->num_closes),
  370. atomic_read(&tcon->num_deletes));
  371. buf += item_length;
  372. length += item_length;
  373. item_length = sprintf(buf, "\nMkdirs: %d Rmdirs: %d",
  374. atomic_read(&tcon->num_mkdirs),
  375. atomic_read(&tcon->num_rmdirs));
  376. buf += item_length;
  377. length += item_length;
  378. item_length = sprintf(buf, "\nRenames: %d T2 Renames %d",
  379. atomic_read(&tcon->num_renames),
  380. atomic_read(&tcon->num_t2renames));
  381. buf += item_length;
  382. length += item_length;
  383. item_length = sprintf(buf, "\nFindFirst: %d FNext %d FClose %d",
  384. atomic_read(&tcon->num_ffirst),
  385. atomic_read(&tcon->num_fnext),
  386. atomic_read(&tcon->num_fclose));
  387. buf += item_length;
  388. length += item_length;
  389. }
  390. read_unlock(&GlobalSMBSeslock);
  391. buf += sprintf(buf, "\n");
  392. length++;
  393. if (offset + count >= length)
  394. *eof = 1;
  395. if (length < offset) {
  396. *eof = 1;
  397. return 0;
  398. } else {
  399. length = length - offset;
  400. }
  401. if (length > count)
  402. length = count;
  403. return length;
  404. }
  405. #endif /* STATS */
  406. static struct proc_dir_entry *proc_fs_cifs;
  407. read_proc_t cifs_txanchor_read;
  408. static read_proc_t cifsFYI_read;
  409. static write_proc_t cifsFYI_write;
  410. static read_proc_t oplockEnabled_read;
  411. static write_proc_t oplockEnabled_write;
  412. static read_proc_t lookupFlag_read;
  413. static write_proc_t lookupFlag_write;
  414. static read_proc_t traceSMB_read;
  415. static write_proc_t traceSMB_write;
  416. static read_proc_t multiuser_mount_read;
  417. static write_proc_t multiuser_mount_write;
  418. static read_proc_t security_flags_read;
  419. static write_proc_t security_flags_write;
  420. /* static read_proc_t ntlmv2_enabled_read;
  421. static write_proc_t ntlmv2_enabled_write;
  422. static read_proc_t packet_signing_enabled_read;
  423. static write_proc_t packet_signing_enabled_write;*/
  424. static read_proc_t experimEnabled_read;
  425. static write_proc_t experimEnabled_write;
  426. static read_proc_t linuxExtensionsEnabled_read;
  427. static write_proc_t linuxExtensionsEnabled_write;
  428. void
  429. cifs_proc_init(void)
  430. {
  431. struct proc_dir_entry *pde;
  432. proc_fs_cifs = proc_mkdir("fs/cifs", NULL);
  433. if (proc_fs_cifs == NULL)
  434. return;
  435. proc_fs_cifs->owner = THIS_MODULE;
  436. create_proc_read_entry("DebugData", 0, proc_fs_cifs,
  437. cifs_debug_data_read, NULL);
  438. #ifdef CONFIG_CIFS_STATS
  439. pde = create_proc_read_entry("Stats", 0, proc_fs_cifs,
  440. cifs_stats_read, NULL);
  441. if (pde)
  442. pde->write_proc = cifs_stats_write;
  443. #endif /* STATS */
  444. pde = create_proc_read_entry("cifsFYI", 0, proc_fs_cifs,
  445. cifsFYI_read, NULL);
  446. if (pde)
  447. pde->write_proc = cifsFYI_write;
  448. pde =
  449. create_proc_read_entry("traceSMB", 0, proc_fs_cifs,
  450. traceSMB_read, NULL);
  451. if (pde)
  452. pde->write_proc = traceSMB_write;
  453. pde = create_proc_read_entry("OplockEnabled", 0, proc_fs_cifs,
  454. oplockEnabled_read, NULL);
  455. if (pde)
  456. pde->write_proc = oplockEnabled_write;
  457. pde = create_proc_read_entry("Experimental", 0, proc_fs_cifs,
  458. experimEnabled_read, NULL);
  459. if (pde)
  460. pde->write_proc = experimEnabled_write;
  461. pde = create_proc_read_entry("LinuxExtensionsEnabled", 0, proc_fs_cifs,
  462. linuxExtensionsEnabled_read, NULL);
  463. if (pde)
  464. pde->write_proc = linuxExtensionsEnabled_write;
  465. pde =
  466. create_proc_read_entry("MultiuserMount", 0, proc_fs_cifs,
  467. multiuser_mount_read, NULL);
  468. if (pde)
  469. pde->write_proc = multiuser_mount_write;
  470. pde =
  471. create_proc_read_entry("SecurityFlags", 0, proc_fs_cifs,
  472. security_flags_read, NULL);
  473. if (pde)
  474. pde->write_proc = security_flags_write;
  475. pde =
  476. create_proc_read_entry("LookupCacheEnabled", 0, proc_fs_cifs,
  477. lookupFlag_read, NULL);
  478. if (pde)
  479. pde->write_proc = lookupFlag_write;
  480. /* pde =
  481. create_proc_read_entry("NTLMV2Enabled", 0, proc_fs_cifs,
  482. ntlmv2_enabled_read, NULL);
  483. if (pde)
  484. pde->write_proc = ntlmv2_enabled_write;
  485. pde =
  486. create_proc_read_entry("PacketSigningEnabled", 0, proc_fs_cifs,
  487. packet_signing_enabled_read, NULL);
  488. if (pde)
  489. pde->write_proc = packet_signing_enabled_write;*/
  490. }
  491. void
  492. cifs_proc_clean(void)
  493. {
  494. if (proc_fs_cifs == NULL)
  495. return;
  496. remove_proc_entry("DebugData", proc_fs_cifs);
  497. remove_proc_entry("cifsFYI", proc_fs_cifs);
  498. remove_proc_entry("traceSMB", proc_fs_cifs);
  499. #ifdef CONFIG_CIFS_STATS
  500. remove_proc_entry("Stats", proc_fs_cifs);
  501. #endif
  502. remove_proc_entry("MultiuserMount", proc_fs_cifs);
  503. remove_proc_entry("OplockEnabled", proc_fs_cifs);
  504. /* remove_proc_entry("NTLMV2Enabled",proc_fs_cifs); */
  505. remove_proc_entry("SecurityFlags", proc_fs_cifs);
  506. /* remove_proc_entry("PacketSigningEnabled", proc_fs_cifs); */
  507. remove_proc_entry("LinuxExtensionsEnabled", proc_fs_cifs);
  508. remove_proc_entry("Experimental", proc_fs_cifs);
  509. remove_proc_entry("LookupCacheEnabled", proc_fs_cifs);
  510. remove_proc_entry("fs/cifs", NULL);
  511. }
  512. static int
  513. cifsFYI_read(char *page, char **start, off_t off, int count,
  514. int *eof, void *data)
  515. {
  516. int len;
  517. len = sprintf(page, "%d\n", cifsFYI);
  518. len -= off;
  519. *start = page + off;
  520. if (len > count)
  521. len = count;
  522. else
  523. *eof = 1;
  524. if (len < 0)
  525. len = 0;
  526. return len;
  527. }
  528. static int
  529. cifsFYI_write(struct file *file, const char __user *buffer,
  530. unsigned long count, void *data)
  531. {
  532. char c;
  533. int rc;
  534. rc = get_user(c, buffer);
  535. if (rc)
  536. return rc;
  537. if (c == '0' || c == 'n' || c == 'N')
  538. cifsFYI = 0;
  539. else if (c == '1' || c == 'y' || c == 'Y')
  540. cifsFYI = 1;
  541. else if ((c > '1') && (c <= '9'))
  542. cifsFYI = (int) (c - '0'); /* see cifs_debug.h for meanings */
  543. return count;
  544. }
  545. static int
  546. oplockEnabled_read(char *page, char **start, off_t off,
  547. int count, int *eof, void *data)
  548. {
  549. int len;
  550. len = sprintf(page, "%d\n", oplockEnabled);
  551. len -= off;
  552. *start = page + off;
  553. if (len > count)
  554. len = count;
  555. else
  556. *eof = 1;
  557. if (len < 0)
  558. len = 0;
  559. return len;
  560. }
  561. static int
  562. oplockEnabled_write(struct file *file, const char __user *buffer,
  563. unsigned long count, void *data)
  564. {
  565. char c;
  566. int rc;
  567. rc = get_user(c, buffer);
  568. if (rc)
  569. return rc;
  570. if (c == '0' || c == 'n' || c == 'N')
  571. oplockEnabled = 0;
  572. else if (c == '1' || c == 'y' || c == 'Y')
  573. oplockEnabled = 1;
  574. return count;
  575. }
  576. static int
  577. experimEnabled_read(char *page, char **start, off_t off,
  578. int count, int *eof, void *data)
  579. {
  580. int len;
  581. len = sprintf(page, "%d\n", experimEnabled);
  582. len -= off;
  583. *start = page + off;
  584. if (len > count)
  585. len = count;
  586. else
  587. *eof = 1;
  588. if (len < 0)
  589. len = 0;
  590. return len;
  591. }
  592. static int
  593. experimEnabled_write(struct file *file, const char __user *buffer,
  594. unsigned long count, void *data)
  595. {
  596. char c;
  597. int rc;
  598. rc = get_user(c, buffer);
  599. if (rc)
  600. return rc;
  601. if (c == '0' || c == 'n' || c == 'N')
  602. experimEnabled = 0;
  603. else if (c == '1' || c == 'y' || c == 'Y')
  604. experimEnabled = 1;
  605. else if (c == '2')
  606. experimEnabled = 2;
  607. return count;
  608. }
  609. static int
  610. linuxExtensionsEnabled_read(char *page, char **start, off_t off,
  611. int count, int *eof, void *data)
  612. {
  613. int len;
  614. len = sprintf(page, "%d\n", linuxExtEnabled);
  615. len -= off;
  616. *start = page + off;
  617. if (len > count)
  618. len = count;
  619. else
  620. *eof = 1;
  621. if (len < 0)
  622. len = 0;
  623. return len;
  624. }
  625. static int
  626. linuxExtensionsEnabled_write(struct file *file, const char __user *buffer,
  627. unsigned long count, void *data)
  628. {
  629. char c;
  630. int rc;
  631. rc = get_user(c, buffer);
  632. if (rc)
  633. return rc;
  634. if (c == '0' || c == 'n' || c == 'N')
  635. linuxExtEnabled = 0;
  636. else if (c == '1' || c == 'y' || c == 'Y')
  637. linuxExtEnabled = 1;
  638. return count;
  639. }
  640. static int
  641. lookupFlag_read(char *page, char **start, off_t off,
  642. int count, int *eof, void *data)
  643. {
  644. int len;
  645. len = sprintf(page, "%d\n", lookupCacheEnabled);
  646. len -= off;
  647. *start = page + off;
  648. if (len > count)
  649. len = count;
  650. else
  651. *eof = 1;
  652. if (len < 0)
  653. len = 0;
  654. return len;
  655. }
  656. static int
  657. lookupFlag_write(struct file *file, const char __user *buffer,
  658. unsigned long count, void *data)
  659. {
  660. char c;
  661. int rc;
  662. rc = get_user(c, buffer);
  663. if (rc)
  664. return rc;
  665. if (c == '0' || c == 'n' || c == 'N')
  666. lookupCacheEnabled = 0;
  667. else if (c == '1' || c == 'y' || c == 'Y')
  668. lookupCacheEnabled = 1;
  669. return count;
  670. }
  671. static int
  672. traceSMB_read(char *page, char **start, off_t off, int count,
  673. int *eof, void *data)
  674. {
  675. int len;
  676. len = sprintf(page, "%d\n", traceSMB);
  677. len -= off;
  678. *start = page + off;
  679. if (len > count)
  680. len = count;
  681. else
  682. *eof = 1;
  683. if (len < 0)
  684. len = 0;
  685. return len;
  686. }
  687. static int
  688. traceSMB_write(struct file *file, const char __user *buffer,
  689. unsigned long count, void *data)
  690. {
  691. char c;
  692. int rc;
  693. rc = get_user(c, buffer);
  694. if (rc)
  695. return rc;
  696. if (c == '0' || c == 'n' || c == 'N')
  697. traceSMB = 0;
  698. else if (c == '1' || c == 'y' || c == 'Y')
  699. traceSMB = 1;
  700. return count;
  701. }
  702. static int
  703. multiuser_mount_read(char *page, char **start, off_t off,
  704. int count, int *eof, void *data)
  705. {
  706. int len;
  707. len = sprintf(page, "%d\n", multiuser_mount);
  708. len -= off;
  709. *start = page + off;
  710. if (len > count)
  711. len = count;
  712. else
  713. *eof = 1;
  714. if (len < 0)
  715. len = 0;
  716. return len;
  717. }
  718. static int
  719. multiuser_mount_write(struct file *file, const char __user *buffer,
  720. unsigned long count, void *data)
  721. {
  722. char c;
  723. int rc;
  724. rc = get_user(c, buffer);
  725. if (rc)
  726. return rc;
  727. if (c == '0' || c == 'n' || c == 'N')
  728. multiuser_mount = 0;
  729. else if (c == '1' || c == 'y' || c == 'Y')
  730. multiuser_mount = 1;
  731. return count;
  732. }
  733. static int
  734. security_flags_read(char *page, char **start, off_t off,
  735. int count, int *eof, void *data)
  736. {
  737. int len;
  738. len = sprintf(page, "0x%x\n", extended_security);
  739. len -= off;
  740. *start = page + off;
  741. if (len > count)
  742. len = count;
  743. else
  744. *eof = 1;
  745. if (len < 0)
  746. len = 0;
  747. return len;
  748. }
  749. static int
  750. security_flags_write(struct file *file, const char __user *buffer,
  751. unsigned long count, void *data)
  752. {
  753. unsigned int flags;
  754. char flags_string[12];
  755. char c;
  756. if ((count < 1) || (count > 11))
  757. return -EINVAL;
  758. memset(flags_string, 0, 12);
  759. if (copy_from_user(flags_string, buffer, count))
  760. return -EFAULT;
  761. if (count < 3) {
  762. /* single char or single char followed by null */
  763. c = flags_string[0];
  764. if (c == '0' || c == 'n' || c == 'N') {
  765. extended_security = CIFSSEC_DEF; /* default */
  766. return count;
  767. } else if (c == '1' || c == 'y' || c == 'Y') {
  768. extended_security = CIFSSEC_MAX;
  769. return count;
  770. } else if (!isdigit(c)) {
  771. cERROR(1, ("invalid flag %c", c));
  772. return -EINVAL;
  773. }
  774. }
  775. /* else we have a number */
  776. flags = simple_strtoul(flags_string, NULL, 0);
  777. cFYI(1, ("sec flags 0x%x", flags));
  778. if (flags <= 0) {
  779. cERROR(1, ("invalid security flags %s", flags_string));
  780. return -EINVAL;
  781. }
  782. if (flags & ~CIFSSEC_MASK) {
  783. cERROR(1, ("attempt to set unsupported security flags 0x%x",
  784. flags & ~CIFSSEC_MASK));
  785. return -EINVAL;
  786. }
  787. /* flags look ok - update the global security flags for cifs module */
  788. extended_security = flags;
  789. if (extended_security & CIFSSEC_MUST_SIGN) {
  790. /* requiring signing implies signing is allowed */
  791. extended_security |= CIFSSEC_MAY_SIGN;
  792. cFYI(1, ("packet signing now required"));
  793. } else if ((extended_security & CIFSSEC_MAY_SIGN) == 0) {
  794. cFYI(1, ("packet signing disabled"));
  795. }
  796. /* BB should we turn on MAY flags for other MUST options? */
  797. return count;
  798. }
  799. #else
  800. inline void cifs_proc_init(void)
  801. {
  802. }
  803. inline void cifs_proc_clean(void)
  804. {
  805. }
  806. #endif /* PROC_FS */