cifs_debug.c 22 KB

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