cifs_debug.c 23 KB

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