Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[wrt350n-kernel.git] / fs / cifs / cifs_debug.c
blobaf368989905a151d09094c4f058d1a91b3a8d8cb
1 /*
2 * fs/cifs_debug.c
4 * Copyright (C) International Business Machines Corp., 2000,2005
6 * Modified by Steve French (sfrench@us.ibm.com)
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.
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.
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
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"
34 void
35 cifs_dump_mem(char *label, void *data, int length)
37 int i, j;
38 int *intptr = data;
39 char *charptr = data;
40 char buf[10], line[80];
42 printk(KERN_DEBUG "%s: dump of %d bytes of data at 0x%p\n",
43 label, length, data);
44 for (i = 0; i < length; i += 16) {
45 line[0] = 0;
46 for (j = 0; (j < 4) && (i + j * 4 < length); j++) {
47 sprintf(buf, " %08x", intptr[i / 4 + j]);
48 strcat(line, buf);
50 buf[0] = ' ';
51 buf[2] = 0;
52 for (j = 0; (j < 16) && (i + j < length); j++) {
53 buf[1] = isprint(charptr[i + j]) ? charptr[i + j] : '.';
54 strcat(line, buf);
56 printk(KERN_DEBUG "%s\n", line);
60 #ifdef CONFIG_CIFS_DEBUG2
61 void cifs_dump_detail(struct smb_hdr *smb)
63 cERROR(1, ("Cmd: %d Err: 0x%x Flags: 0x%x Flgs2: 0x%x Mid: %d Pid: %d",
64 smb->Command, smb->Status.CifsError,
65 smb->Flags, smb->Flags2, smb->Mid, smb->Pid));
66 cERROR(1, ("smb buf %p len %d", smb, smbCalcSize_LE(smb)));
70 void cifs_dump_mids(struct TCP_Server_Info *server)
72 struct list_head *tmp;
73 struct mid_q_entry *mid_entry;
75 if (server == NULL)
76 return;
78 cERROR(1, ("Dump pending requests:"));
79 spin_lock(&GlobalMid_Lock);
80 list_for_each(tmp, &server->pending_mid_q) {
81 mid_entry = list_entry(tmp, struct mid_q_entry, qhead);
82 if (mid_entry) {
83 cERROR(1, ("State: %d Cmd: %d Pid: %d Tsk: %p Mid %d",
84 mid_entry->midState,
85 (int)mid_entry->command,
86 mid_entry->pid,
87 mid_entry->tsk,
88 mid_entry->mid));
89 #ifdef CONFIG_CIFS_STATS2
90 cERROR(1, ("IsLarge: %d buf: %p time rcv: %ld now: %ld",
91 mid_entry->largeBuf,
92 mid_entry->resp_buf,
93 mid_entry->when_received,
94 jiffies));
95 #endif /* STATS2 */
96 cERROR(1, ("IsMult: %d IsEnd: %d", mid_entry->multiRsp,
97 mid_entry->multiEnd));
98 if (mid_entry->resp_buf) {
99 cifs_dump_detail(mid_entry->resp_buf);
100 cifs_dump_mem("existing buf: ",
101 <<<<<<< HEAD:fs/cifs/cifs_debug.c
102 mid_entry->resp_buf,
103 62 /* fixme */);
104 =======
105 mid_entry->resp_buf, 62);
106 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:fs/cifs/cifs_debug.c
110 spin_unlock(&GlobalMid_Lock);
112 #endif /* CONFIG_CIFS_DEBUG2 */
114 #ifdef CONFIG_PROC_FS
115 static int
116 cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
117 int count, int *eof, void *data)
119 struct list_head *tmp;
120 struct list_head *tmp1;
121 struct mid_q_entry *mid_entry;
122 struct cifsSesInfo *ses;
123 struct cifsTconInfo *tcon;
124 int i;
125 int length = 0;
126 char *original_buf = buf;
128 *beginBuffer = buf + offset;
130 length =
131 sprintf(buf,
132 "Display Internal CIFS Data Structures for Debugging\n"
133 "---------------------------------------------------\n");
134 buf += length;
135 length = sprintf(buf, "CIFS Version %s\n", CIFS_VERSION);
136 buf += length;
137 length = sprintf(buf,
138 "Active VFS Requests: %d\n", GlobalTotalActiveXid);
139 buf += length;
140 length = sprintf(buf, "Servers:");
141 buf += length;
143 i = 0;
144 read_lock(&GlobalSMBSeslock);
145 list_for_each(tmp, &GlobalSMBSessionList) {
146 i++;
147 ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList);
148 if ((ses->serverDomain == NULL) || (ses->serverOS == NULL) ||
149 (ses->serverNOS == NULL)) {
150 buf += sprintf(buf, "\nentry for %s not fully "
151 "displayed\n\t", ses->serverName);
152 } else {
153 length =
154 sprintf(buf,
155 "\n%d) Name: %s Domain: %s Mounts: %d OS:"
156 " %s \n\tNOS: %s\tCapability: 0x%x\n\tSMB"
157 " session status: %d\t",
158 i, ses->serverName, ses->serverDomain,
159 atomic_read(&ses->inUse),
160 ses->serverOS, ses->serverNOS,
161 ses->capabilities, ses->status);
162 buf += length;
164 if (ses->server) {
165 buf += sprintf(buf, "TCP status: %d\n\tLocal Users To "
166 "Server: %d SecMode: 0x%x Req On Wire: %d",
167 ses->server->tcpStatus,
168 atomic_read(&ses->server->socketUseCount),
169 ses->server->secMode,
170 atomic_read(&ses->server->inFlight));
172 #ifdef CONFIG_CIFS_STATS2
173 buf += sprintf(buf, " In Send: %d In MaxReq Wait: %d",
174 atomic_read(&ses->server->inSend),
175 atomic_read(&ses->server->num_waiters));
176 #endif
178 length = sprintf(buf, "\nMIDs:\n");
179 buf += length;
181 spin_lock(&GlobalMid_Lock);
182 list_for_each(tmp1, &ses->server->pending_mid_q) {
183 mid_entry = list_entry(tmp1, struct
184 mid_q_entry,
185 qhead);
186 if (mid_entry) {
187 length = sprintf(buf,
188 "State: %d com: %d pid:"
189 " %d tsk: %p mid %d\n",
190 mid_entry->midState,
191 (int)mid_entry->command,
192 mid_entry->pid,
193 mid_entry->tsk,
194 mid_entry->mid);
195 buf += length;
198 spin_unlock(&GlobalMid_Lock);
202 read_unlock(&GlobalSMBSeslock);
203 sprintf(buf, "\n");
204 buf++;
206 length = sprintf(buf, "Shares:");
207 buf += length;
209 i = 0;
210 read_lock(&GlobalSMBSeslock);
211 list_for_each(tmp, &GlobalTreeConnectionList) {
212 __u32 dev_type;
213 i++;
214 tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList);
215 dev_type = le32_to_cpu(tcon->fsDevInfo.DeviceType);
216 length = sprintf(buf, "\n%d) %s Uses: %d ", i,
217 tcon->treeName, atomic_read(&tcon->useCount));
218 buf += length;
219 if (tcon->nativeFileSystem) {
220 length = sprintf(buf, "Type: %s ",
221 tcon->nativeFileSystem);
222 buf += length;
224 length = sprintf(buf, "DevInfo: 0x%x Attributes: 0x%x"
225 "\nPathComponentMax: %d Status: %d",
226 le32_to_cpu(tcon->fsDevInfo.DeviceCharacteristics),
227 le32_to_cpu(tcon->fsAttrInfo.Attributes),
228 le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength),
229 tcon->tidStatus);
230 buf += length;
231 if (dev_type == FILE_DEVICE_DISK)
232 length = sprintf(buf, " type: DISK ");
233 else if (dev_type == FILE_DEVICE_CD_ROM)
234 length = sprintf(buf, " type: CDROM ");
235 else
236 length =
237 sprintf(buf, " type: %d ", dev_type);
238 buf += length;
239 if (tcon->tidStatus == CifsNeedReconnect) {
240 buf += sprintf(buf, "\tDISCONNECTED ");
241 length += 14;
244 read_unlock(&GlobalSMBSeslock);
246 length = sprintf(buf, "\n");
247 buf += length;
249 /* BB add code to dump additional info such as TCP session info now */
250 /* Now calculate total size of returned data */
251 length = buf - original_buf;
253 if (offset + count >= length)
254 *eof = 1;
255 if (length < offset) {
256 *eof = 1;
257 return 0;
258 } else {
259 length = length - offset;
261 if (length > count)
262 length = count;
264 return length;
267 #ifdef CONFIG_CIFS_STATS
269 static int
270 cifs_stats_write(struct file *file, const char __user *buffer,
271 unsigned long count, void *data)
273 char c;
274 int rc;
275 struct list_head *tmp;
276 struct cifsTconInfo *tcon;
278 rc = get_user(c, buffer);
279 if (rc)
280 return rc;
282 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
283 read_lock(&GlobalSMBSeslock);
284 #ifdef CONFIG_CIFS_STATS2
285 atomic_set(&totBufAllocCount, 0);
286 atomic_set(&totSmBufAllocCount, 0);
287 #endif /* CONFIG_CIFS_STATS2 */
288 list_for_each(tmp, &GlobalTreeConnectionList) {
289 tcon = list_entry(tmp, struct cifsTconInfo,
290 cifsConnectionList);
291 atomic_set(&tcon->num_smbs_sent, 0);
292 atomic_set(&tcon->num_writes, 0);
293 atomic_set(&tcon->num_reads, 0);
294 atomic_set(&tcon->num_oplock_brks, 0);
295 atomic_set(&tcon->num_opens, 0);
296 atomic_set(&tcon->num_closes, 0);
297 atomic_set(&tcon->num_deletes, 0);
298 atomic_set(&tcon->num_mkdirs, 0);
299 atomic_set(&tcon->num_rmdirs, 0);
300 atomic_set(&tcon->num_renames, 0);
301 atomic_set(&tcon->num_t2renames, 0);
302 atomic_set(&tcon->num_ffirst, 0);
303 atomic_set(&tcon->num_fnext, 0);
304 atomic_set(&tcon->num_fclose, 0);
305 atomic_set(&tcon->num_hardlinks, 0);
306 atomic_set(&tcon->num_symlinks, 0);
307 atomic_set(&tcon->num_locks, 0);
309 read_unlock(&GlobalSMBSeslock);
312 return count;
315 static int
316 cifs_stats_read(char *buf, char **beginBuffer, off_t offset,
317 int count, int *eof, void *data)
319 int item_length, i, length;
320 struct list_head *tmp;
321 struct cifsTconInfo *tcon;
323 *beginBuffer = buf + offset;
325 length = sprintf(buf,
326 "Resources in use\nCIFS Session: %d\n",
327 sesInfoAllocCount.counter);
328 buf += length;
329 item_length =
330 sprintf(buf, "Share (unique mount targets): %d\n",
331 tconInfoAllocCount.counter);
332 length += item_length;
333 buf += item_length;
334 item_length =
335 sprintf(buf, "SMB Request/Response Buffer: %d Pool size: %d\n",
336 bufAllocCount.counter,
337 cifs_min_rcv + tcpSesAllocCount.counter);
338 length += item_length;
339 buf += item_length;
340 item_length =
341 sprintf(buf, "SMB Small Req/Resp Buffer: %d Pool size: %d\n",
342 smBufAllocCount.counter, cifs_min_small);
343 length += item_length;
344 buf += item_length;
345 #ifdef CONFIG_CIFS_STATS2
346 item_length = sprintf(buf, "Total Large %d Small %d Allocations\n",
347 atomic_read(&totBufAllocCount),
348 atomic_read(&totSmBufAllocCount));
349 length += item_length;
350 buf += item_length;
351 #endif /* CONFIG_CIFS_STATS2 */
353 item_length =
354 sprintf(buf, "Operations (MIDs): %d\n",
355 midCount.counter);
356 length += item_length;
357 buf += item_length;
358 item_length = sprintf(buf,
359 "\n%d session %d share reconnects\n",
360 tcpSesReconnectCount.counter, tconInfoReconnectCount.counter);
361 length += item_length;
362 buf += item_length;
364 item_length = sprintf(buf,
365 "Total vfs operations: %d maximum at one time: %d\n",
366 GlobalCurrentXid, GlobalMaxActiveXid);
367 length += item_length;
368 buf += item_length;
370 i = 0;
371 read_lock(&GlobalSMBSeslock);
372 list_for_each(tmp, &GlobalTreeConnectionList) {
373 i++;
374 tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList);
375 item_length = sprintf(buf, "\n%d) %s", i, tcon->treeName);
376 buf += item_length;
377 length += item_length;
378 if (tcon->tidStatus == CifsNeedReconnect) {
379 buf += sprintf(buf, "\tDISCONNECTED ");
380 length += 14;
382 item_length = sprintf(buf, "\nSMBs: %d Oplock Breaks: %d",
383 atomic_read(&tcon->num_smbs_sent),
384 atomic_read(&tcon->num_oplock_brks));
385 buf += item_length;
386 length += item_length;
387 item_length = sprintf(buf, "\nReads: %d Bytes: %lld",
388 atomic_read(&tcon->num_reads),
389 (long long)(tcon->bytes_read));
390 buf += item_length;
391 length += item_length;
392 item_length = sprintf(buf, "\nWrites: %d Bytes: %lld",
393 atomic_read(&tcon->num_writes),
394 (long long)(tcon->bytes_written));
395 buf += item_length;
396 length += item_length;
397 item_length = sprintf(buf,
398 "\nLocks: %d HardLinks: %d Symlinks: %d",
399 atomic_read(&tcon->num_locks),
400 atomic_read(&tcon->num_hardlinks),
401 atomic_read(&tcon->num_symlinks));
402 buf += item_length;
403 length += item_length;
405 item_length = sprintf(buf, "\nOpens: %d Closes: %d Deletes: %d",
406 atomic_read(&tcon->num_opens),
407 atomic_read(&tcon->num_closes),
408 atomic_read(&tcon->num_deletes));
409 buf += item_length;
410 length += item_length;
411 item_length = sprintf(buf, "\nMkdirs: %d Rmdirs: %d",
412 atomic_read(&tcon->num_mkdirs),
413 atomic_read(&tcon->num_rmdirs));
414 buf += item_length;
415 length += item_length;
416 item_length = sprintf(buf, "\nRenames: %d T2 Renames %d",
417 atomic_read(&tcon->num_renames),
418 atomic_read(&tcon->num_t2renames));
419 buf += item_length;
420 length += item_length;
421 item_length = sprintf(buf, "\nFindFirst: %d FNext %d FClose %d",
422 atomic_read(&tcon->num_ffirst),
423 atomic_read(&tcon->num_fnext),
424 atomic_read(&tcon->num_fclose));
425 buf += item_length;
426 length += item_length;
428 read_unlock(&GlobalSMBSeslock);
430 buf += sprintf(buf, "\n");
431 length++;
433 if (offset + count >= length)
434 *eof = 1;
435 if (length < offset) {
436 *eof = 1;
437 return 0;
438 } else {
439 length = length - offset;
441 if (length > count)
442 length = count;
444 return length;
446 <<<<<<< HEAD:fs/cifs/cifs_debug.c
447 #endif
448 =======
449 #endif /* STATS */
450 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:fs/cifs/cifs_debug.c
452 static struct proc_dir_entry *proc_fs_cifs;
453 read_proc_t cifs_txanchor_read;
454 static read_proc_t cifsFYI_read;
455 static write_proc_t cifsFYI_write;
456 static read_proc_t oplockEnabled_read;
457 static write_proc_t oplockEnabled_write;
458 static read_proc_t lookupFlag_read;
459 static write_proc_t lookupFlag_write;
460 static read_proc_t traceSMB_read;
461 static write_proc_t traceSMB_write;
462 static read_proc_t multiuser_mount_read;
463 static write_proc_t multiuser_mount_write;
464 static read_proc_t security_flags_read;
465 static write_proc_t security_flags_write;
466 /* static read_proc_t ntlmv2_enabled_read;
467 static write_proc_t ntlmv2_enabled_write;
468 static read_proc_t packet_signing_enabled_read;
469 static write_proc_t packet_signing_enabled_write;*/
470 static read_proc_t experimEnabled_read;
471 static write_proc_t experimEnabled_write;
472 static read_proc_t linuxExtensionsEnabled_read;
473 static write_proc_t linuxExtensionsEnabled_write;
475 void
476 cifs_proc_init(void)
478 struct proc_dir_entry *pde;
480 proc_fs_cifs = proc_mkdir("cifs", proc_root_fs);
481 if (proc_fs_cifs == NULL)
482 return;
484 proc_fs_cifs->owner = THIS_MODULE;
485 create_proc_read_entry("DebugData", 0, proc_fs_cifs,
486 cifs_debug_data_read, NULL);
488 #ifdef CONFIG_CIFS_STATS
489 pde = create_proc_read_entry("Stats", 0, proc_fs_cifs,
490 cifs_stats_read, NULL);
491 if (pde)
492 pde->write_proc = cifs_stats_write;
493 <<<<<<< HEAD:fs/cifs/cifs_debug.c
494 #endif
495 =======
496 #endif /* STATS */
497 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:fs/cifs/cifs_debug.c
498 pde = create_proc_read_entry("cifsFYI", 0, proc_fs_cifs,
499 cifsFYI_read, NULL);
500 if (pde)
501 pde->write_proc = cifsFYI_write;
503 pde =
504 create_proc_read_entry("traceSMB", 0, proc_fs_cifs,
505 traceSMB_read, NULL);
506 if (pde)
507 pde->write_proc = traceSMB_write;
509 pde = create_proc_read_entry("OplockEnabled", 0, proc_fs_cifs,
510 oplockEnabled_read, NULL);
511 if (pde)
512 pde->write_proc = oplockEnabled_write;
514 pde = create_proc_read_entry("Experimental", 0, proc_fs_cifs,
515 experimEnabled_read, NULL);
516 if (pde)
517 pde->write_proc = experimEnabled_write;
519 pde = create_proc_read_entry("LinuxExtensionsEnabled", 0, proc_fs_cifs,
520 linuxExtensionsEnabled_read, NULL);
521 if (pde)
522 pde->write_proc = linuxExtensionsEnabled_write;
524 pde =
525 create_proc_read_entry("MultiuserMount", 0, proc_fs_cifs,
526 multiuser_mount_read, NULL);
527 if (pde)
528 pde->write_proc = multiuser_mount_write;
530 pde =
531 create_proc_read_entry("SecurityFlags", 0, proc_fs_cifs,
532 security_flags_read, NULL);
533 if (pde)
534 pde->write_proc = security_flags_write;
536 pde =
537 create_proc_read_entry("LookupCacheEnabled", 0, proc_fs_cifs,
538 lookupFlag_read, NULL);
539 if (pde)
540 pde->write_proc = lookupFlag_write;
542 /* pde =
543 create_proc_read_entry("NTLMV2Enabled", 0, proc_fs_cifs,
544 ntlmv2_enabled_read, NULL);
545 if (pde)
546 pde->write_proc = ntlmv2_enabled_write;
548 pde =
549 create_proc_read_entry("PacketSigningEnabled", 0, proc_fs_cifs,
550 packet_signing_enabled_read, NULL);
551 if (pde)
552 pde->write_proc = packet_signing_enabled_write;*/
555 void
556 cifs_proc_clean(void)
558 if (proc_fs_cifs == NULL)
559 return;
561 remove_proc_entry("DebugData", proc_fs_cifs);
562 remove_proc_entry("cifsFYI", proc_fs_cifs);
563 remove_proc_entry("traceSMB", proc_fs_cifs);
564 #ifdef CONFIG_CIFS_STATS
565 remove_proc_entry("Stats", proc_fs_cifs);
566 #endif
567 remove_proc_entry("MultiuserMount", proc_fs_cifs);
568 remove_proc_entry("OplockEnabled", proc_fs_cifs);
569 /* remove_proc_entry("NTLMV2Enabled",proc_fs_cifs); */
570 remove_proc_entry("SecurityFlags", proc_fs_cifs);
571 /* remove_proc_entry("PacketSigningEnabled", proc_fs_cifs); */
572 remove_proc_entry("LinuxExtensionsEnabled", proc_fs_cifs);
573 remove_proc_entry("Experimental", proc_fs_cifs);
574 remove_proc_entry("LookupCacheEnabled", proc_fs_cifs);
575 remove_proc_entry("cifs", proc_root_fs);
578 static int
579 cifsFYI_read(char *page, char **start, off_t off, int count,
580 int *eof, void *data)
582 int len;
584 len = sprintf(page, "%d\n", cifsFYI);
586 len -= off;
587 *start = page + off;
589 if (len > count)
590 len = count;
591 else
592 *eof = 1;
594 if (len < 0)
595 len = 0;
597 return len;
599 static int
600 cifsFYI_write(struct file *file, const char __user *buffer,
601 unsigned long count, void *data)
603 char c;
604 int rc;
606 rc = get_user(c, buffer);
607 if (rc)
608 return rc;
609 if (c == '0' || c == 'n' || c == 'N')
610 cifsFYI = 0;
611 else if (c == '1' || c == 'y' || c == 'Y')
612 cifsFYI = 1;
613 else if ((c > '1') && (c <= '9'))
614 cifsFYI = (int) (c - '0'); /* see cifs_debug.h for meanings */
616 return count;
619 static int
620 oplockEnabled_read(char *page, char **start, off_t off,
621 int count, int *eof, void *data)
623 int len;
625 len = sprintf(page, "%d\n", oplockEnabled);
627 len -= off;
628 *start = page + off;
630 if (len > count)
631 len = count;
632 else
633 *eof = 1;
635 if (len < 0)
636 len = 0;
638 return len;
640 static int
641 oplockEnabled_write(struct file *file, const char __user *buffer,
642 unsigned long count, void *data)
644 char c;
645 int rc;
647 rc = get_user(c, buffer);
648 if (rc)
649 return rc;
650 if (c == '0' || c == 'n' || c == 'N')
651 oplockEnabled = 0;
652 else if (c == '1' || c == 'y' || c == 'Y')
653 oplockEnabled = 1;
655 return count;
658 static int
659 experimEnabled_read(char *page, char **start, off_t off,
660 int count, int *eof, void *data)
662 int len;
664 len = sprintf(page, "%d\n", experimEnabled);
666 len -= off;
667 *start = page + off;
669 if (len > count)
670 len = count;
671 else
672 *eof = 1;
674 if (len < 0)
675 len = 0;
677 return len;
679 static int
680 experimEnabled_write(struct file *file, const char __user *buffer,
681 unsigned long count, void *data)
683 char c;
684 int rc;
686 rc = get_user(c, buffer);
687 if (rc)
688 return rc;
689 if (c == '0' || c == 'n' || c == 'N')
690 experimEnabled = 0;
691 else if (c == '1' || c == 'y' || c == 'Y')
692 experimEnabled = 1;
693 else if (c == '2')
694 experimEnabled = 2;
696 return count;
699 static int
700 linuxExtensionsEnabled_read(char *page, char **start, off_t off,
701 int count, int *eof, void *data)
703 int len;
705 len = sprintf(page, "%d\n", linuxExtEnabled);
706 len -= off;
707 *start = page + off;
709 if (len > count)
710 len = count;
711 else
712 *eof = 1;
714 if (len < 0)
715 len = 0;
717 return len;
719 static int
720 linuxExtensionsEnabled_write(struct file *file, const char __user *buffer,
721 unsigned long count, void *data)
723 char c;
724 int rc;
726 rc = get_user(c, buffer);
727 if (rc)
728 return rc;
729 if (c == '0' || c == 'n' || c == 'N')
730 linuxExtEnabled = 0;
731 else if (c == '1' || c == 'y' || c == 'Y')
732 linuxExtEnabled = 1;
734 return count;
738 static int
739 lookupFlag_read(char *page, char **start, off_t off,
740 int count, int *eof, void *data)
742 int len;
744 len = sprintf(page, "%d\n", lookupCacheEnabled);
746 len -= off;
747 *start = page + off;
749 if (len > count)
750 len = count;
751 else
752 *eof = 1;
754 if (len < 0)
755 len = 0;
757 return len;
759 static int
760 lookupFlag_write(struct file *file, const char __user *buffer,
761 unsigned long count, void *data)
763 char c;
764 int rc;
766 rc = get_user(c, buffer);
767 if (rc)
768 return rc;
769 if (c == '0' || c == 'n' || c == 'N')
770 lookupCacheEnabled = 0;
771 else if (c == '1' || c == 'y' || c == 'Y')
772 lookupCacheEnabled = 1;
774 return count;
776 static int
777 traceSMB_read(char *page, char **start, off_t off, int count,
778 int *eof, void *data)
780 int len;
782 len = sprintf(page, "%d\n", traceSMB);
784 len -= off;
785 *start = page + off;
787 if (len > count)
788 len = count;
789 else
790 *eof = 1;
792 if (len < 0)
793 len = 0;
795 return len;
797 static int
798 traceSMB_write(struct file *file, const char __user *buffer,
799 unsigned long count, void *data)
801 char c;
802 int rc;
804 rc = get_user(c, buffer);
805 if (rc)
806 return rc;
807 if (c == '0' || c == 'n' || c == 'N')
808 traceSMB = 0;
809 else if (c == '1' || c == 'y' || c == 'Y')
810 traceSMB = 1;
812 return count;
815 static int
816 multiuser_mount_read(char *page, char **start, off_t off,
817 int count, int *eof, void *data)
819 int len;
821 len = sprintf(page, "%d\n", multiuser_mount);
823 len -= off;
824 *start = page + off;
826 if (len > count)
827 len = count;
828 else
829 *eof = 1;
831 if (len < 0)
832 len = 0;
834 return len;
836 static int
837 multiuser_mount_write(struct file *file, const char __user *buffer,
838 unsigned long count, void *data)
840 char c;
841 int rc;
843 rc = get_user(c, buffer);
844 if (rc)
845 return rc;
846 if (c == '0' || c == 'n' || c == 'N')
847 multiuser_mount = 0;
848 else if (c == '1' || c == 'y' || c == 'Y')
849 multiuser_mount = 1;
851 return count;
854 static int
855 security_flags_read(char *page, char **start, off_t off,
856 int count, int *eof, void *data)
858 int len;
860 len = sprintf(page, "0x%x\n", extended_security);
862 len -= off;
863 *start = page + off;
865 if (len > count)
866 len = count;
867 else
868 *eof = 1;
870 if (len < 0)
871 len = 0;
873 return len;
875 static int
876 security_flags_write(struct file *file, const char __user *buffer,
877 unsigned long count, void *data)
879 unsigned int flags;
880 char flags_string[12];
881 char c;
883 if ((count < 1) || (count > 11))
884 return -EINVAL;
886 memset(flags_string, 0, 12);
888 if (copy_from_user(flags_string, buffer, count))
889 return -EFAULT;
891 if (count < 3) {
892 /* single char or single char followed by null */
893 c = flags_string[0];
894 if (c == '0' || c == 'n' || c == 'N') {
895 extended_security = CIFSSEC_DEF; /* default */
896 return count;
897 } else if (c == '1' || c == 'y' || c == 'Y') {
898 extended_security = CIFSSEC_MAX;
899 return count;
900 } else if (!isdigit(c)) {
901 cERROR(1, ("invalid flag %c", c));
902 return -EINVAL;
905 /* else we have a number */
907 flags = simple_strtoul(flags_string, NULL, 0);
909 cFYI(1, ("sec flags 0x%x", flags));
911 if (flags <= 0) {
912 cERROR(1, ("invalid security flags %s", flags_string));
913 return -EINVAL;
916 if (flags & ~CIFSSEC_MASK) {
917 cERROR(1, ("attempt to set unsupported security flags 0x%x",
918 flags & ~CIFSSEC_MASK));
919 return -EINVAL;
921 /* flags look ok - update the global security flags for cifs module */
922 extended_security = flags;
923 if (extended_security & CIFSSEC_MUST_SIGN) {
924 /* requiring signing implies signing is allowed */
925 extended_security |= CIFSSEC_MAY_SIGN;
926 cFYI(1, ("packet signing now required"));
927 } else if ((extended_security & CIFSSEC_MAY_SIGN) == 0) {
928 cFYI(1, ("packet signing disabled"));
930 /* BB should we turn on MAY flags for other MUST options? */
931 return count;
933 <<<<<<< HEAD:fs/cifs/cifs_debug.c
934 #endif
935 =======
936 #else
937 inline void cifs_proc_init(void)
941 inline void cifs_proc_clean(void)
944 #endif /* PROC_FS */
945 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:fs/cifs/cifs_debug.c