[CIFS] Add extended stats (STATS2) for total buffer allocations for
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / fs / cifs / cifs_debug.c
CommitLineData
1da177e4
LT
1/*
2 * fs/cifs_debug.c
3 *
b8643e1b 4 * Copyright (C) International Business Machines Corp., 2000,2005
1da177e4
LT
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"
6c91d362 32#include "cifsfs.h"
1da177e4
LT
33
34void
35cifs_dump_mem(char *label, void *data, int length)
36{
37 int i, j;
38 int *intptr = data;
39 char *charptr = data;
40 char buf[10], line[80];
41
42 printk(KERN_DEBUG "%s: dump of %d bytes of data at 0x%p\n\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);
49 }
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);
55 }
56 printk(KERN_DEBUG "%s\n", line);
57 }
58}
59
60#ifdef CONFIG_PROC_FS
61static int
62cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
63 int count, int *eof, void *data)
64{
65 struct list_head *tmp;
66 struct list_head *tmp1;
67 struct mid_q_entry * mid_entry;
68 struct cifsSesInfo *ses;
69 struct cifsTconInfo *tcon;
70 int i;
71 int length = 0;
72 char * original_buf = buf;
73
74 *beginBuffer = buf + offset;
75
76
77 length =
78 sprintf(buf,
79 "Display Internal CIFS Data Structures for Debugging\n"
80 "---------------------------------------------------\n");
81 buf += length;
6c91d362
SF
82 length = sprintf(buf,"CIFS Version %s\n",CIFS_VERSION);
83 buf += length;
131afd0b
SF
84 length = sprintf(buf,"Active VFS Requests: %d\n", GlobalTotalActiveXid);
85 buf += length;
6c91d362 86 length = sprintf(buf, "Servers:");
1da177e4
LT
87 buf += length;
88
89 i = 0;
90 read_lock(&GlobalSMBSeslock);
91 list_for_each(tmp, &GlobalSMBSessionList) {
92 i++;
93 ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList);
433dc24f
SF
94 if((ses->serverDomain == NULL) || (ses->serverOS == NULL) ||
95 (ses->serverNOS == NULL)) {
96 buf += sprintf("\nentry for %s not fully displayed\n\t",
97 ses->serverName);
98
99 } else {
100 length =
101 sprintf(buf,
131afd0b 102 "\n%d) Name: %s Domain: %s Mounts: %d OS: %s \n\tNOS: %s\tCapability: 0x%x\n\tSMB session status: %d\t",
b8643e1b
SF
103 i, ses->serverName, ses->serverDomain,
104 atomic_read(&ses->inUse),
105 ses->serverOS, ses->serverNOS,
106 ses->capabilities,ses->status);
433dc24f
SF
107 buf += length;
108 }
1da177e4 109 if(ses->server) {
131afd0b 110 buf += sprintf(buf, "TCP status: %d\n\tLocal Users To Server: %d SecMode: 0x%x Req On Wire: %d",
1da177e4
LT
111 ses->server->tcpStatus,
112 atomic_read(&ses->server->socketUseCount),
113 ses->server->secMode,
114 atomic_read(&ses->server->inFlight));
131afd0b
SF
115
116#ifdef CONFIG_CIFS_STATS2
68058e75 117 buf += sprintf(buf, " In Send: %d In MaxReq Wait: %d",
131afd0b
SF
118 atomic_read(&ses->server->inSend),
119 atomic_read(&ses->server->num_waiters));
120#endif
121
6c91d362 122 length = sprintf(buf, "\nMIDs:\n");
1da177e4
LT
123 buf += length;
124
125 spin_lock(&GlobalMid_Lock);
126 list_for_each(tmp1, &ses->server->pending_mid_q) {
127 mid_entry = list_entry(tmp1, struct
128 mid_q_entry,
129 qhead);
130 if(mid_entry) {
848f3fce
SF
131 length = sprintf(buf,"State: %d com: %d pid: %d tsk: %p mid %d\n",
132 mid_entry->midState,
133 (int)mid_entry->command,
134 mid_entry->pid,
135 mid_entry->tsk,
136 mid_entry->mid);
1da177e4
LT
137 buf += length;
138 }
139 }
140 spin_unlock(&GlobalMid_Lock);
141 }
142
143 }
144 read_unlock(&GlobalSMBSeslock);
145 sprintf(buf, "\n");
146 buf++;
147
6c91d362 148 length = sprintf(buf, "Shares:");
1da177e4
LT
149 buf += length;
150
151 i = 0;
152 read_lock(&GlobalSMBSeslock);
153 list_for_each(tmp, &GlobalTreeConnectionList) {
154 __u32 dev_type;
155 i++;
156 tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList);
157 dev_type = le32_to_cpu(tcon->fsDevInfo.DeviceType);
158 length =
159 sprintf(buf,
131afd0b 160 "\n%d) %s Uses: %d Type: %s DevInfo: 0x%x Attributes: 0x%x\nPathComponentMax: %d Status: %d",
1da177e4
LT
161 i, tcon->treeName,
162 atomic_read(&tcon->useCount),
163 tcon->nativeFileSystem,
164 le32_to_cpu(tcon->fsDevInfo.DeviceCharacteristics),
165 le32_to_cpu(tcon->fsAttrInfo.Attributes),
166 le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength),
167 tcon->tidStatus);
168 buf += length;
169 if (dev_type == FILE_DEVICE_DISK)
170 length = sprintf(buf, " type: DISK ");
171 else if (dev_type == FILE_DEVICE_CD_ROM)
172 length = sprintf(buf, " type: CDROM ");
173 else
174 length =
175 sprintf(buf, " type: %d ", dev_type);
176 buf += length;
177 if(tcon->tidStatus == CifsNeedReconnect) {
178 buf += sprintf(buf, "\tDISCONNECTED ");
179 length += 14;
180 }
181 }
182 read_unlock(&GlobalSMBSeslock);
183
184 length = sprintf(buf, "\n");
185 buf += length;
186
187 /* BB add code to dump additional info such as TCP session info now */
188 /* Now calculate total size of returned data */
189 length = buf - original_buf;
190
191 if(offset + count >= length)
192 *eof = 1;
193 if(length < offset) {
194 *eof = 1;
195 return 0;
196 } else {
197 length = length - offset;
198 }
199 if (length > count)
200 length = count;
201
202 return length;
203}
204
205#ifdef CONFIG_CIFS_STATS
1047abc1
SF
206
207static int
208cifs_stats_write(struct file *file, const char __user *buffer,
209 unsigned long count, void *data)
210{
211 char c;
212 int rc;
213 struct list_head *tmp;
214 struct cifsTconInfo *tcon;
215
216 rc = get_user(c, buffer);
217 if (rc)
218 return rc;
219
47c786e7 220 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
1047abc1 221 read_lock(&GlobalSMBSeslock);
4498eed5
SF
222#ifdef CONFIG_CIFS_STATS2
223 atomic_set(&totBufAllocCount, 0);
224 atomic_set(&totSmBufAllocCount, 0);
225#endif /* CONFIG_CIFS_STATS2 */
1047abc1
SF
226 list_for_each(tmp, &GlobalTreeConnectionList) {
227 tcon = list_entry(tmp, struct cifsTconInfo,
228 cifsConnectionList);
229 atomic_set(&tcon->num_smbs_sent, 0);
230 atomic_set(&tcon->num_writes, 0);
231 atomic_set(&tcon->num_reads, 0);
232 atomic_set(&tcon->num_oplock_brks, 0);
233 atomic_set(&tcon->num_opens, 0);
234 atomic_set(&tcon->num_closes, 0);
235 atomic_set(&tcon->num_deletes, 0);
236 atomic_set(&tcon->num_mkdirs, 0);
237 atomic_set(&tcon->num_rmdirs, 0);
238 atomic_set(&tcon->num_renames, 0);
239 atomic_set(&tcon->num_t2renames, 0);
240 atomic_set(&tcon->num_ffirst, 0);
241 atomic_set(&tcon->num_fnext, 0);
242 atomic_set(&tcon->num_fclose, 0);
243 atomic_set(&tcon->num_hardlinks, 0);
244 atomic_set(&tcon->num_symlinks, 0);
245 atomic_set(&tcon->num_locks, 0);
246 }
247 read_unlock(&GlobalSMBSeslock);
248 }
249
250 return count;
251}
252
1da177e4
LT
253static int
254cifs_stats_read(char *buf, char **beginBuffer, off_t offset,
255 int count, int *eof, void *data)
256{
257 int item_length,i,length;
258 struct list_head *tmp;
259 struct cifsTconInfo *tcon;
260
261 *beginBuffer = buf + offset;
262
263 length = sprintf(buf,
264 "Resources in use\nCIFS Session: %d\n",
265 sesInfoAllocCount.counter);
266 buf += length;
267 item_length =
268 sprintf(buf,"Share (unique mount targets): %d\n",
269 tconInfoAllocCount.counter);
270 length += item_length;
271 buf += item_length;
272 item_length =
273 sprintf(buf,"SMB Request/Response Buffer: %d Pool size: %d\n",
b8643e1b
SF
274 bufAllocCount.counter,
275 cifs_min_rcv + tcpSesAllocCount.counter);
1da177e4
LT
276 length += item_length;
277 buf += item_length;
278 item_length =
279 sprintf(buf,"SMB Small Req/Resp Buffer: %d Pool size: %d\n",
280 smBufAllocCount.counter,cifs_min_small);
281 length += item_length;
282 buf += item_length;
283 item_length =
284 sprintf(buf,"Operations (MIDs): %d\n",
285 midCount.counter);
286 length += item_length;
287 buf += item_length;
288 item_length = sprintf(buf,
289 "\n%d session %d share reconnects\n",
290 tcpSesReconnectCount.counter,tconInfoReconnectCount.counter);
291 length += item_length;
292 buf += item_length;
293
294 item_length = sprintf(buf,
295 "Total vfs operations: %d maximum at one time: %d\n",
296 GlobalCurrentXid,GlobalMaxActiveXid);
297 length += item_length;
298 buf += item_length;
299
300 i = 0;
301 read_lock(&GlobalSMBSeslock);
302 list_for_each(tmp, &GlobalTreeConnectionList) {
303 i++;
304 tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList);
305 item_length = sprintf(buf,"\n%d) %s",i, tcon->treeName);
306 buf += item_length;
307 length += item_length;
308 if(tcon->tidStatus == CifsNeedReconnect) {
309 buf += sprintf(buf, "\tDISCONNECTED ");
310 length += 14;
311 }
a5a2b489 312 item_length = sprintf(buf, "\nSMBs: %d Oplock Breaks: %d",
1da177e4
LT
313 atomic_read(&tcon->num_smbs_sent),
314 atomic_read(&tcon->num_oplock_brks));
315 buf += item_length;
316 length += item_length;
0ae0efad 317 item_length = sprintf(buf, "\nReads: %d Bytes: %lld",
1da177e4
LT
318 atomic_read(&tcon->num_reads),
319 (long long)(tcon->bytes_read));
320 buf += item_length;
321 length += item_length;
a5a2b489 322 item_length = sprintf(buf, "\nWrites: %d Bytes: %lld",
1da177e4
LT
323 atomic_read(&tcon->num_writes),
324 (long long)(tcon->bytes_written));
a5a2b489
SF
325 buf += item_length;
326 length += item_length;
327 item_length = sprintf(buf,
328 "\nLocks: %d HardLinks: %d Symlinks: %d",
329 atomic_read(&tcon->num_locks),
330 atomic_read(&tcon->num_hardlinks),
331 atomic_read(&tcon->num_symlinks));
332 buf += item_length;
333 length += item_length;
334
335 item_length = sprintf(buf, "\nOpens: %d Closes: %d Deletes: %d",
336 atomic_read(&tcon->num_opens),
337 atomic_read(&tcon->num_closes),
338 atomic_read(&tcon->num_deletes));
1da177e4
LT
339 buf += item_length;
340 length += item_length;
a5a2b489 341 item_length = sprintf(buf, "\nMkdirs: %d Rmdirs: %d",
1da177e4
LT
342 atomic_read(&tcon->num_mkdirs),
343 atomic_read(&tcon->num_rmdirs));
344 buf += item_length;
345 length += item_length;
a5a2b489 346 item_length = sprintf(buf, "\nRenames: %d T2 Renames %d",
1da177e4
LT
347 atomic_read(&tcon->num_renames),
348 atomic_read(&tcon->num_t2renames));
349 buf += item_length;
350 length += item_length;
a5a2b489 351 item_length = sprintf(buf, "\nFindFirst: %d FNext %d FClose %d",
0c0ff093
SF
352 atomic_read(&tcon->num_ffirst),
353 atomic_read(&tcon->num_fnext),
354 atomic_read(&tcon->num_fclose));
355 buf += item_length;
356 length += item_length;
1da177e4
LT
357 }
358 read_unlock(&GlobalSMBSeslock);
359
360 buf += sprintf(buf,"\n");
361 length++;
362
363 if(offset + count >= length)
364 *eof = 1;
365 if(length < offset) {
366 *eof = 1;
367 return 0;
368 } else {
369 length = length - offset;
370 }
371 if (length > count)
372 length = count;
373
374 return length;
375}
376#endif
377
378static struct proc_dir_entry *proc_fs_cifs;
379read_proc_t cifs_txanchor_read;
380static read_proc_t cifsFYI_read;
381static write_proc_t cifsFYI_write;
382static read_proc_t oplockEnabled_read;
383static write_proc_t oplockEnabled_write;
384static read_proc_t lookupFlag_read;
385static write_proc_t lookupFlag_write;
386static read_proc_t traceSMB_read;
387static write_proc_t traceSMB_write;
388static read_proc_t multiuser_mount_read;
389static write_proc_t multiuser_mount_write;
390static read_proc_t extended_security_read;
391static write_proc_t extended_security_write;
392static read_proc_t ntlmv2_enabled_read;
393static write_proc_t ntlmv2_enabled_write;
394static read_proc_t packet_signing_enabled_read;
395static write_proc_t packet_signing_enabled_write;
396static read_proc_t quotaEnabled_read;
397static write_proc_t quotaEnabled_write;
398static read_proc_t linuxExtensionsEnabled_read;
399static write_proc_t linuxExtensionsEnabled_write;
400
401void
402cifs_proc_init(void)
403{
404 struct proc_dir_entry *pde;
405
406 proc_fs_cifs = proc_mkdir("cifs", proc_root_fs);
407 if (proc_fs_cifs == NULL)
408 return;
409
410 proc_fs_cifs->owner = THIS_MODULE;
411 create_proc_read_entry("DebugData", 0, proc_fs_cifs,
412 cifs_debug_data_read, NULL);
413
414#ifdef CONFIG_CIFS_STATS
1047abc1 415 pde = create_proc_read_entry("Stats", 0, proc_fs_cifs,
1da177e4 416 cifs_stats_read, NULL);
1047abc1
SF
417 if (pde)
418 pde->write_proc = cifs_stats_write;
1da177e4
LT
419#endif
420 pde = create_proc_read_entry("cifsFYI", 0, proc_fs_cifs,
421 cifsFYI_read, NULL);
422 if (pde)
423 pde->write_proc = cifsFYI_write;
424
425 pde =
426 create_proc_read_entry("traceSMB", 0, proc_fs_cifs,
427 traceSMB_read, NULL);
428 if (pde)
429 pde->write_proc = traceSMB_write;
430
431 pde = create_proc_read_entry("OplockEnabled", 0, proc_fs_cifs,
432 oplockEnabled_read, NULL);
433 if (pde)
434 pde->write_proc = oplockEnabled_write;
435
0c0ff093 436 pde = create_proc_read_entry("Experimental", 0, proc_fs_cifs,
1da177e4
LT
437 quotaEnabled_read, NULL);
438 if (pde)
439 pde->write_proc = quotaEnabled_write;
440
441 pde = create_proc_read_entry("LinuxExtensionsEnabled", 0, proc_fs_cifs,
442 linuxExtensionsEnabled_read, NULL);
443 if (pde)
444 pde->write_proc = linuxExtensionsEnabled_write;
445
446 pde =
447 create_proc_read_entry("MultiuserMount", 0, proc_fs_cifs,
448 multiuser_mount_read, NULL);
449 if (pde)
450 pde->write_proc = multiuser_mount_write;
451
452 pde =
453 create_proc_read_entry("ExtendedSecurity", 0, proc_fs_cifs,
454 extended_security_read, NULL);
455 if (pde)
456 pde->write_proc = extended_security_write;
457
458 pde =
459 create_proc_read_entry("LookupCacheEnabled", 0, proc_fs_cifs,
460 lookupFlag_read, NULL);
461 if (pde)
462 pde->write_proc = lookupFlag_write;
463
464 pde =
465 create_proc_read_entry("NTLMV2Enabled", 0, proc_fs_cifs,
466 ntlmv2_enabled_read, NULL);
467 if (pde)
468 pde->write_proc = ntlmv2_enabled_write;
469
470 pde =
471 create_proc_read_entry("PacketSigningEnabled", 0, proc_fs_cifs,
472 packet_signing_enabled_read, NULL);
473 if (pde)
474 pde->write_proc = packet_signing_enabled_write;
475}
476
477void
478cifs_proc_clean(void)
479{
480 if (proc_fs_cifs == NULL)
481 return;
482
483 remove_proc_entry("DebugData", proc_fs_cifs);
484 remove_proc_entry("cifsFYI", proc_fs_cifs);
485 remove_proc_entry("traceSMB", proc_fs_cifs);
486#ifdef CONFIG_CIFS_STATS
487 remove_proc_entry("Stats", proc_fs_cifs);
488#endif
489 remove_proc_entry("MultiuserMount", proc_fs_cifs);
490 remove_proc_entry("OplockEnabled", proc_fs_cifs);
491 remove_proc_entry("NTLMV2Enabled",proc_fs_cifs);
492 remove_proc_entry("ExtendedSecurity",proc_fs_cifs);
493 remove_proc_entry("PacketSigningEnabled",proc_fs_cifs);
494 remove_proc_entry("LinuxExtensionsEnabled",proc_fs_cifs);
0c0ff093 495 remove_proc_entry("Experimental",proc_fs_cifs);
1da177e4
LT
496 remove_proc_entry("LookupCacheEnabled",proc_fs_cifs);
497 remove_proc_entry("cifs", proc_root_fs);
498}
499
500static int
501cifsFYI_read(char *page, char **start, off_t off, int count,
502 int *eof, void *data)
503{
504 int len;
505
506 len = sprintf(page, "%d\n", cifsFYI);
507
508 len -= off;
509 *start = page + off;
510
511 if (len > count)
512 len = count;
513 else
514 *eof = 1;
515
516 if (len < 0)
517 len = 0;
518
519 return len;
520}
521static int
522cifsFYI_write(struct file *file, const char __user *buffer,
523 unsigned long count, void *data)
524{
525 char c;
526 int rc;
527
528 rc = get_user(c, buffer);
529 if (rc)
530 return rc;
531 if (c == '0' || c == 'n' || c == 'N')
532 cifsFYI = 0;
533 else if (c == '1' || c == 'y' || c == 'Y')
534 cifsFYI = 1;
1047abc1
SF
535 else if((c > '1') && (c <= '9'))
536 cifsFYI = (int) (c - '0'); /* see cifs_debug.h for meanings */
1da177e4
LT
537
538 return count;
539}
540
541static int
542oplockEnabled_read(char *page, char **start, off_t off,
543 int count, int *eof, void *data)
544{
545 int len;
546
547 len = sprintf(page, "%d\n", oplockEnabled);
548
549 len -= off;
550 *start = page + off;
551
552 if (len > count)
553 len = count;
554 else
555 *eof = 1;
556
557 if (len < 0)
558 len = 0;
559
560 return len;
561}
562static int
563oplockEnabled_write(struct file *file, const char __user *buffer,
564 unsigned long count, void *data)
565{
566 char c;
567 int rc;
568
569 rc = get_user(c, buffer);
570 if (rc)
571 return rc;
572 if (c == '0' || c == 'n' || c == 'N')
573 oplockEnabled = 0;
574 else if (c == '1' || c == 'y' || c == 'Y')
575 oplockEnabled = 1;
576
577 return count;
578}
579
580static int
581quotaEnabled_read(char *page, char **start, off_t off,
582 int count, int *eof, void *data)
583{
584 int len;
585
586 len = sprintf(page, "%d\n", experimEnabled);
587/* could also check if quotas are enabled in kernel
588 as a whole first */
589 len -= off;
590 *start = page + off;
591
592 if (len > count)
593 len = count;
594 else
595 *eof = 1;
596
597 if (len < 0)
598 len = 0;
599
600 return len;
601}
602static int
603quotaEnabled_write(struct file *file, const char __user *buffer,
604 unsigned long count, void *data)
605{
606 char c;
607 int rc;
608
609 rc = get_user(c, buffer);
610 if (rc)
611 return rc;
612 if (c == '0' || c == 'n' || c == 'N')
613 experimEnabled = 0;
614 else if (c == '1' || c == 'y' || c == 'Y')
615 experimEnabled = 1;
616
617 return count;
618}
619
620static int
621linuxExtensionsEnabled_read(char *page, char **start, off_t off,
622 int count, int *eof, void *data)
623{
624 int len;
625
626 len = sprintf(page, "%d\n", linuxExtEnabled);
627/* could also check if quotas are enabled in kernel
628 as a whole first */
629 len -= off;
630 *start = page + off;
631
632 if (len > count)
633 len = count;
634 else
635 *eof = 1;
636
637 if (len < 0)
638 len = 0;
639
640 return len;
641}
642static int
643linuxExtensionsEnabled_write(struct file *file, const char __user *buffer,
644 unsigned long count, void *data)
645{
646 char c;
647 int rc;
648
649 rc = get_user(c, buffer);
650 if (rc)
651 return rc;
652 if (c == '0' || c == 'n' || c == 'N')
653 linuxExtEnabled = 0;
654 else if (c == '1' || c == 'y' || c == 'Y')
655 linuxExtEnabled = 1;
656
657 return count;
658}
659
660
661static int
662lookupFlag_read(char *page, char **start, off_t off,
663 int count, int *eof, void *data)
664{
665 int len;
666
667 len = sprintf(page, "%d\n", lookupCacheEnabled);
668
669 len -= off;
670 *start = page + off;
671
672 if (len > count)
673 len = count;
674 else
675 *eof = 1;
676
677 if (len < 0)
678 len = 0;
679
680 return len;
681}
682static int
683lookupFlag_write(struct file *file, const char __user *buffer,
684 unsigned long count, void *data)
685{
686 char c;
687 int rc;
688
689 rc = get_user(c, buffer);
690 if (rc)
691 return rc;
692 if (c == '0' || c == 'n' || c == 'N')
693 lookupCacheEnabled = 0;
694 else if (c == '1' || c == 'y' || c == 'Y')
695 lookupCacheEnabled = 1;
696
697 return count;
698}
699static int
700traceSMB_read(char *page, char **start, off_t off, int count,
701 int *eof, void *data)
702{
703 int len;
704
705 len = sprintf(page, "%d\n", traceSMB);
706
707 len -= off;
708 *start = page + off;
709
710 if (len > count)
711 len = count;
712 else
713 *eof = 1;
714
715 if (len < 0)
716 len = 0;
717
718 return len;
719}
720static int
721traceSMB_write(struct file *file, const char __user *buffer,
722 unsigned long count, void *data)
723{
724 char c;
725 int rc;
726
727 rc = get_user(c, buffer);
728 if (rc)
729 return rc;
730 if (c == '0' || c == 'n' || c == 'N')
731 traceSMB = 0;
732 else if (c == '1' || c == 'y' || c == 'Y')
733 traceSMB = 1;
734
735 return count;
736}
737
738static int
739multiuser_mount_read(char *page, char **start, off_t off,
740 int count, int *eof, void *data)
741{
742 int len;
743
744 len = sprintf(page, "%d\n", multiuser_mount);
745
746 len -= off;
747 *start = page + off;
748
749 if (len > count)
750 len = count;
751 else
752 *eof = 1;
753
754 if (len < 0)
755 len = 0;
756
757 return len;
758}
759static int
760multiuser_mount_write(struct file *file, const char __user *buffer,
761 unsigned long count, void *data)
762{
763 char c;
764 int rc;
765
766 rc = get_user(c, buffer);
767 if (rc)
768 return rc;
769 if (c == '0' || c == 'n' || c == 'N')
770 multiuser_mount = 0;
771 else if (c == '1' || c == 'y' || c == 'Y')
772 multiuser_mount = 1;
773
774 return count;
775}
776
777static int
778extended_security_read(char *page, char **start, off_t off,
779 int count, int *eof, void *data)
780{
781 int len;
782
783 len = sprintf(page, "%d\n", extended_security);
784
785 len -= off;
786 *start = page + off;
787
788 if (len > count)
789 len = count;
790 else
791 *eof = 1;
792
793 if (len < 0)
794 len = 0;
795
796 return len;
797}
798static int
799extended_security_write(struct file *file, const char __user *buffer,
800 unsigned long count, void *data)
801{
802 char c;
803 int rc;
804
805 rc = get_user(c, buffer);
806 if (rc)
807 return rc;
808 if (c == '0' || c == 'n' || c == 'N')
809 extended_security = 0;
810 else if (c == '1' || c == 'y' || c == 'Y')
811 extended_security = 1;
812
813 return count;
814}
815
816static int
817ntlmv2_enabled_read(char *page, char **start, off_t off,
818 int count, int *eof, void *data)
819{
820 int len;
821
822 len = sprintf(page, "%d\n", ntlmv2_support);
823
824 len -= off;
825 *start = page + off;
826
827 if (len > count)
828 len = count;
829 else
830 *eof = 1;
831
832 if (len < 0)
833 len = 0;
834
835 return len;
836}
837static int
838ntlmv2_enabled_write(struct file *file, const char __user *buffer,
839 unsigned long count, void *data)
840{
841 char c;
842 int rc;
843
844 rc = get_user(c, buffer);
845 if (rc)
846 return rc;
847 if (c == '0' || c == 'n' || c == 'N')
848 ntlmv2_support = 0;
849 else if (c == '1' || c == 'y' || c == 'Y')
850 ntlmv2_support = 1;
851
852 return count;
853}
854
855static int
856packet_signing_enabled_read(char *page, char **start, off_t off,
857 int count, int *eof, void *data)
858{
859 int len;
860
861 len = sprintf(page, "%d\n", sign_CIFS_PDUs);
862
863 len -= off;
864 *start = page + off;
865
866 if (len > count)
867 len = count;
868 else
869 *eof = 1;
870
871 if (len < 0)
872 len = 0;
873
874 return len;
875}
876static int
877packet_signing_enabled_write(struct file *file, const char __user *buffer,
878 unsigned long count, void *data)
879{
880 char c;
881 int rc;
882
883 rc = get_user(c, buffer);
884 if (rc)
885 return rc;
886 if (c == '0' || c == 'n' || c == 'N')
887 sign_CIFS_PDUs = 0;
888 else if (c == '1' || c == 'y' || c == 'Y')
889 sign_CIFS_PDUs = 1;
890 else if (c == '2')
891 sign_CIFS_PDUs = 2;
892
893 return count;
894}
895
896
897#endif