6f5d81f5eacb2e5f86246d5e913d5a5787dce188
[sfrench/cifs-2.6.git] / fs / cifs / cifs_debug.c
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
34 void
35 cifs_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
61 static int
62 cifs_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;
82         length = sprintf(buf,"CIFS Version %s\n",CIFS_VERSION);
83         buf += length;
84         length = sprintf(buf,"Active VFS Requests: %d\n", GlobalTotalActiveXid);
85         buf += length;
86         length = sprintf(buf, "Servers:");
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);
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,
102                                     "\n%d) Name: %s  Domain: %s Mounts: %d OS: %s  \n\tNOS: %s\tCapability: 0x%x\n\tSMB session status: %d\t",
103                                 i, ses->serverName, ses->serverDomain,
104                                 atomic_read(&ses->inUse),
105                                 ses->serverOS, ses->serverNOS,
106                                 ses->capabilities,ses->status);
107                         buf += length;
108                 }
109                 if(ses->server) {
110                         buf += sprintf(buf, "TCP status: %d\n\tLocal Users To Server: %d SecMode: 0x%x Req On Wire: %d",
111                                 ses->server->tcpStatus,
112                                 atomic_read(&ses->server->socketUseCount),
113                                 ses->server->secMode,
114                                 atomic_read(&ses->server->inFlight));
115
116 #ifdef CONFIG_CIFS_STATS2
117                         buf += sprintf(buf, " In Send: %d In MaxReq Wait: %d",
118                                 atomic_read(&ses->server->inSend), 
119                                 atomic_read(&ses->server->num_waiters));
120 #endif
121
122                         length = sprintf(buf, "\nMIDs:\n");
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) {
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);
137                                         buf += length;
138                                 }
139                         }
140                         spin_unlock(&GlobalMid_Lock); 
141                 }
142
143         }
144         read_unlock(&GlobalSMBSeslock);
145         sprintf(buf, "\n");
146         buf++;
147
148         length = sprintf(buf, "Shares:");
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,
160                             "\n%d) %s Uses: %d Type: %s DevInfo: 0x%x Attributes: 0x%x\nPathComponentMax: %d Status: %d",
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
206
207 static int
208 cifs_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
220         if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
221                 read_lock(&GlobalSMBSeslock);
222 #ifdef CONFIG_CIFS_STATS2
223                 atomic_set(&totBufAllocCount, 0);
224                 atomic_set(&totSmBufAllocCount, 0);
225 #endif /* CONFIG_CIFS_STATS2 */
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
253 static int
254 cifs_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",
274                         bufAllocCount.counter,
275                         cifs_min_rcv + tcpSesAllocCount.counter);
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 #ifdef CONFIG_CIFS_STATS2
284         item_length = sprintf(buf, "Total Large %d Small %d Allocations\n",
285                                 atomic_read(&totBufAllocCount),
286                                 atomic_read(&totSmBufAllocCount));
287         length += item_length;
288         buf += item_length;
289 #endif /* CONFIG_CIFS_STATS2 */
290
291         item_length = 
292                 sprintf(buf,"Operations (MIDs): %d\n",
293                         midCount.counter);
294         length += item_length;
295         buf += item_length;
296         item_length = sprintf(buf,
297                 "\n%d session %d share reconnects\n",
298                 tcpSesReconnectCount.counter,tconInfoReconnectCount.counter);
299         length += item_length;
300         buf += item_length;
301
302         item_length = sprintf(buf,
303                 "Total vfs operations: %d maximum at one time: %d\n",
304                 GlobalCurrentXid,GlobalMaxActiveXid);
305         length += item_length;
306         buf += item_length;
307
308         i = 0;
309         read_lock(&GlobalSMBSeslock);
310         list_for_each(tmp, &GlobalTreeConnectionList) {
311                 i++;
312                 tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList);
313                 item_length = sprintf(buf,"\n%d) %s",i, tcon->treeName);
314                 buf += item_length;
315                 length += item_length;
316                 if(tcon->tidStatus == CifsNeedReconnect) {
317                         buf += sprintf(buf, "\tDISCONNECTED ");
318                         length += 14;
319                 }
320                 item_length = sprintf(buf, "\nSMBs: %d Oplock Breaks: %d",
321                         atomic_read(&tcon->num_smbs_sent),
322                         atomic_read(&tcon->num_oplock_brks));
323                 buf += item_length;
324                 length += item_length;
325                 item_length = sprintf(buf, "\nReads:  %d Bytes: %lld",
326                         atomic_read(&tcon->num_reads),
327                         (long long)(tcon->bytes_read));
328                 buf += item_length;
329                 length += item_length;
330                 item_length = sprintf(buf, "\nWrites: %d Bytes: %lld",
331                         atomic_read(&tcon->num_writes),
332                         (long long)(tcon->bytes_written));
333                 buf += item_length;
334                 length += item_length;
335                 item_length = sprintf(buf, 
336                         "\nLocks: %d HardLinks: %d Symlinks: %d",
337                         atomic_read(&tcon->num_locks),
338                         atomic_read(&tcon->num_hardlinks),
339                         atomic_read(&tcon->num_symlinks));
340                 buf += item_length;
341                 length += item_length;
342
343                 item_length = sprintf(buf, "\nOpens: %d Closes: %d Deletes: %d",
344                         atomic_read(&tcon->num_opens),
345                         atomic_read(&tcon->num_closes),
346                         atomic_read(&tcon->num_deletes));
347                 buf += item_length;
348                 length += item_length;
349                 item_length = sprintf(buf, "\nMkdirs: %d Rmdirs: %d",
350                         atomic_read(&tcon->num_mkdirs),
351                         atomic_read(&tcon->num_rmdirs));
352                 buf += item_length;
353                 length += item_length;
354                 item_length = sprintf(buf, "\nRenames: %d T2 Renames %d",
355                         atomic_read(&tcon->num_renames),
356                         atomic_read(&tcon->num_t2renames));
357                 buf += item_length;
358                 length += item_length;
359                 item_length = sprintf(buf, "\nFindFirst: %d FNext %d FClose %d",
360                         atomic_read(&tcon->num_ffirst),
361                         atomic_read(&tcon->num_fnext),
362                         atomic_read(&tcon->num_fclose));
363                 buf += item_length;
364                 length += item_length;
365         }
366         read_unlock(&GlobalSMBSeslock);
367
368         buf += sprintf(buf,"\n");
369         length++;
370
371         if(offset + count >= length)
372                 *eof = 1;
373         if(length < offset) {
374                 *eof = 1;
375                 return 0;
376         } else {
377                 length = length - offset;
378         }
379         if (length > count)
380                 length = count;
381                 
382         return length;
383 }
384 #endif
385
386 static struct proc_dir_entry *proc_fs_cifs;
387 read_proc_t cifs_txanchor_read;
388 static read_proc_t cifsFYI_read;
389 static write_proc_t cifsFYI_write;
390 static read_proc_t oplockEnabled_read;
391 static write_proc_t oplockEnabled_write;
392 static read_proc_t lookupFlag_read;
393 static write_proc_t lookupFlag_write;
394 static read_proc_t traceSMB_read;
395 static write_proc_t traceSMB_write;
396 static read_proc_t multiuser_mount_read;
397 static write_proc_t multiuser_mount_write;
398 static read_proc_t extended_security_read;
399 static write_proc_t extended_security_write;
400 static read_proc_t ntlmv2_enabled_read;
401 static write_proc_t ntlmv2_enabled_write;
402 static read_proc_t packet_signing_enabled_read;
403 static write_proc_t packet_signing_enabled_write;
404 static read_proc_t quotaEnabled_read;
405 static write_proc_t quotaEnabled_write;
406 static read_proc_t linuxExtensionsEnabled_read;
407 static write_proc_t linuxExtensionsEnabled_write;
408
409 void
410 cifs_proc_init(void)
411 {
412         struct proc_dir_entry *pde;
413
414         proc_fs_cifs = proc_mkdir("cifs", proc_root_fs);
415         if (proc_fs_cifs == NULL)
416                 return;
417
418         proc_fs_cifs->owner = THIS_MODULE;
419         create_proc_read_entry("DebugData", 0, proc_fs_cifs,
420                                 cifs_debug_data_read, NULL);
421
422 #ifdef CONFIG_CIFS_STATS
423         pde = create_proc_read_entry("Stats", 0, proc_fs_cifs,
424                                 cifs_stats_read, NULL);
425         if (pde)
426                 pde->write_proc = cifs_stats_write;
427 #endif
428         pde = create_proc_read_entry("cifsFYI", 0, proc_fs_cifs,
429                                 cifsFYI_read, NULL);
430         if (pde)
431                 pde->write_proc = cifsFYI_write;
432
433         pde =
434             create_proc_read_entry("traceSMB", 0, proc_fs_cifs,
435                                 traceSMB_read, NULL);
436         if (pde)
437                 pde->write_proc = traceSMB_write;
438
439         pde = create_proc_read_entry("OplockEnabled", 0, proc_fs_cifs,
440                                 oplockEnabled_read, NULL);
441         if (pde)
442                 pde->write_proc = oplockEnabled_write;
443
444         pde = create_proc_read_entry("Experimental", 0, proc_fs_cifs,
445                                 quotaEnabled_read, NULL);
446         if (pde)
447                 pde->write_proc = quotaEnabled_write;
448
449         pde = create_proc_read_entry("LinuxExtensionsEnabled", 0, proc_fs_cifs,
450                                 linuxExtensionsEnabled_read, NULL);
451         if (pde)
452                 pde->write_proc = linuxExtensionsEnabled_write;
453
454         pde =
455             create_proc_read_entry("MultiuserMount", 0, proc_fs_cifs,
456                                 multiuser_mount_read, NULL);
457         if (pde)
458                 pde->write_proc = multiuser_mount_write;
459
460         pde =
461             create_proc_read_entry("ExtendedSecurity", 0, proc_fs_cifs,
462                                 extended_security_read, NULL);
463         if (pde)
464                 pde->write_proc = extended_security_write;
465
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
472         pde =
473             create_proc_read_entry("NTLMV2Enabled", 0, proc_fs_cifs,
474                                 ntlmv2_enabled_read, NULL);
475         if (pde)
476                 pde->write_proc = ntlmv2_enabled_write;
477
478         pde =
479             create_proc_read_entry("PacketSigningEnabled", 0, proc_fs_cifs,
480                                 packet_signing_enabled_read, NULL);
481         if (pde)
482                 pde->write_proc = packet_signing_enabled_write;
483 }
484
485 void
486 cifs_proc_clean(void)
487 {
488         if (proc_fs_cifs == NULL)
489                 return;
490
491         remove_proc_entry("DebugData", proc_fs_cifs);
492         remove_proc_entry("cifsFYI", proc_fs_cifs);
493         remove_proc_entry("traceSMB", proc_fs_cifs);
494 #ifdef CONFIG_CIFS_STATS
495         remove_proc_entry("Stats", proc_fs_cifs);
496 #endif
497         remove_proc_entry("MultiuserMount", proc_fs_cifs);
498         remove_proc_entry("OplockEnabled", proc_fs_cifs);
499         remove_proc_entry("NTLMV2Enabled",proc_fs_cifs);
500         remove_proc_entry("ExtendedSecurity",proc_fs_cifs);
501         remove_proc_entry("PacketSigningEnabled",proc_fs_cifs);
502         remove_proc_entry("LinuxExtensionsEnabled",proc_fs_cifs);
503         remove_proc_entry("Experimental",proc_fs_cifs);
504         remove_proc_entry("LookupCacheEnabled",proc_fs_cifs);
505         remove_proc_entry("cifs", proc_root_fs);
506 }
507
508 static int
509 cifsFYI_read(char *page, char **start, off_t off, int count,
510              int *eof, void *data)
511 {
512         int len;
513
514         len = sprintf(page, "%d\n", cifsFYI);
515
516         len -= off;
517         *start = page + off;
518
519         if (len > count)
520                 len = count;
521         else
522                 *eof = 1;
523
524         if (len < 0)
525                 len = 0;
526
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
536         rc = get_user(c, buffer);
537         if (rc)
538                 return rc;
539         if (c == '0' || c == 'n' || c == 'N')
540                 cifsFYI = 0;
541         else if (c == '1' || c == 'y' || c == 'Y')
542                 cifsFYI = 1;
543         else if((c > '1') && (c <= '9'))
544                 cifsFYI = (int) (c - '0'); /* see cifs_debug.h for meanings */
545
546         return count;
547 }
548
549 static int
550 oplockEnabled_read(char *page, char **start, off_t off,
551                    int count, int *eof, void *data)
552 {
553         int len;
554
555         len = sprintf(page, "%d\n", oplockEnabled);
556
557         len -= off;
558         *start = page + off;
559
560         if (len > count)
561                 len = count;
562         else
563                 *eof = 1;
564
565         if (len < 0)
566                 len = 0;
567
568         return len;
569 }
570 static int
571 oplockEnabled_write(struct file *file, const char __user *buffer,
572                     unsigned long count, void *data)
573 {
574         char c;
575         int rc;
576
577         rc = get_user(c, buffer);
578         if (rc)
579                 return rc;
580         if (c == '0' || c == 'n' || c == 'N')
581                 oplockEnabled = 0;
582         else if (c == '1' || c == 'y' || c == 'Y')
583                 oplockEnabled = 1;
584
585         return count;
586 }
587
588 static int
589 quotaEnabled_read(char *page, char **start, off_t off,
590                    int count, int *eof, void *data)
591 {
592         int len;
593
594         len = sprintf(page, "%d\n", experimEnabled);
595 /* could also check if quotas are enabled in kernel
596         as a whole first */
597         len -= off;
598         *start = page + off;
599
600         if (len > count)
601                 len = count;
602         else
603                 *eof = 1;
604
605         if (len < 0)
606                 len = 0;
607
608         return len;
609 }
610 static int
611 quotaEnabled_write(struct file *file, const char __user *buffer,
612                     unsigned long count, void *data)
613 {
614         char c;
615         int rc;
616
617         rc = get_user(c, buffer);
618         if (rc)
619                 return rc;
620         if (c == '0' || c == 'n' || c == 'N')
621                 experimEnabled = 0;
622         else if (c == '1' || c == 'y' || c == 'Y')
623                 experimEnabled = 1;
624
625         return count;
626 }
627
628 static int
629 linuxExtensionsEnabled_read(char *page, char **start, off_t off,
630                    int count, int *eof, void *data)
631 {
632         int len;
633
634         len = sprintf(page, "%d\n", linuxExtEnabled);
635 /* could also check if quotas are enabled in kernel
636         as a whole first */
637         len -= off;
638         *start = page + off;
639
640         if (len > count)
641                 len = count;
642         else
643                 *eof = 1;
644
645         if (len < 0)
646                 len = 0;
647
648         return len;
649 }
650 static int
651 linuxExtensionsEnabled_write(struct file *file, const char __user *buffer,
652                     unsigned long count, void *data)
653 {
654         char c;
655         int rc;
656
657         rc = get_user(c, buffer);
658         if (rc)
659                 return rc;
660         if (c == '0' || c == 'n' || c == 'N')
661                 linuxExtEnabled = 0;
662         else if (c == '1' || c == 'y' || c == 'Y')
663                 linuxExtEnabled = 1;
664
665         return count;
666 }
667
668
669 static int
670 lookupFlag_read(char *page, char **start, off_t off,
671                    int count, int *eof, void *data)
672 {
673         int len;
674
675         len = sprintf(page, "%d\n", lookupCacheEnabled);
676
677         len -= off;
678         *start = page + off;
679
680         if (len > count)
681                 len = count;
682         else
683                 *eof = 1;
684
685         if (len < 0)
686                 len = 0;
687
688         return len;
689 }
690 static int
691 lookupFlag_write(struct file *file, const char __user *buffer,
692                     unsigned long count, void *data)
693 {
694         char c;
695         int rc;
696
697         rc = get_user(c, buffer);
698         if (rc)
699                 return rc;
700         if (c == '0' || c == 'n' || c == 'N')
701                 lookupCacheEnabled = 0;
702         else if (c == '1' || c == 'y' || c == 'Y')
703                 lookupCacheEnabled = 1;
704
705         return count;
706 }
707 static int
708 traceSMB_read(char *page, char **start, off_t off, int count,
709               int *eof, void *data)
710 {
711         int len;
712
713         len = sprintf(page, "%d\n", traceSMB);
714
715         len -= off;
716         *start = page + off;
717
718         if (len > count)
719                 len = count;
720         else
721                 *eof = 1;
722
723         if (len < 0)
724                 len = 0;
725
726         return len;
727 }
728 static int
729 traceSMB_write(struct file *file, const char __user *buffer,
730                unsigned long count, void *data)
731 {
732         char c;
733         int rc;
734
735         rc = get_user(c, buffer);
736         if (rc)
737                 return rc;
738         if (c == '0' || c == 'n' || c == 'N')
739                 traceSMB = 0;
740         else if (c == '1' || c == 'y' || c == 'Y')
741                 traceSMB = 1;
742
743         return count;
744 }
745
746 static int
747 multiuser_mount_read(char *page, char **start, off_t off,
748                      int count, int *eof, void *data)
749 {
750         int len;
751
752         len = sprintf(page, "%d\n", multiuser_mount);
753
754         len -= off;
755         *start = page + off;
756
757         if (len > count)
758                 len = count;
759         else
760                 *eof = 1;
761
762         if (len < 0)
763                 len = 0;
764
765         return len;
766 }
767 static int
768 multiuser_mount_write(struct file *file, const char __user *buffer,
769                       unsigned long count, void *data)
770 {
771         char c;
772         int rc;
773
774         rc = get_user(c, buffer);
775         if (rc)
776                 return rc;
777         if (c == '0' || c == 'n' || c == 'N')
778                 multiuser_mount = 0;
779         else if (c == '1' || c == 'y' || c == 'Y')
780                 multiuser_mount = 1;
781
782         return count;
783 }
784
785 static int
786 extended_security_read(char *page, char **start, off_t off,
787                        int count, int *eof, void *data)
788 {
789         int len;
790
791         len = sprintf(page, "%d\n", extended_security);
792
793         len -= off;
794         *start = page + off;
795
796         if (len > count)
797                 len = count;
798         else
799                 *eof = 1;
800
801         if (len < 0)
802                 len = 0;
803
804         return len;
805 }
806 static int
807 extended_security_write(struct file *file, const char __user *buffer,
808                         unsigned long count, void *data)
809 {
810         char c;
811         int rc;
812
813         rc = get_user(c, buffer);
814         if (rc)
815                 return rc;
816         if (c == '0' || c == 'n' || c == 'N')
817                 extended_security = 0;
818         else if (c == '1' || c == 'y' || c == 'Y')
819                 extended_security = 1;
820
821         return count;
822 }
823
824 static int
825 ntlmv2_enabled_read(char *page, char **start, off_t off,
826                        int count, int *eof, void *data)
827 {
828         int len;
829
830         len = sprintf(page, "%d\n", ntlmv2_support);
831
832         len -= off;
833         *start = page + off;
834
835         if (len > count)
836                 len = count;
837         else
838                 *eof = 1;
839
840         if (len < 0)
841                 len = 0;
842
843         return len;
844 }
845 static int
846 ntlmv2_enabled_write(struct file *file, const char __user *buffer,
847                         unsigned long count, void *data)
848 {
849         char c;
850         int rc;
851
852         rc = get_user(c, buffer);
853         if (rc)
854                 return rc;
855         if (c == '0' || c == 'n' || c == 'N')
856                 ntlmv2_support = 0;
857         else if (c == '1' || c == 'y' || c == 'Y')
858                 ntlmv2_support = 1;
859
860         return count;
861 }
862
863 static int
864 packet_signing_enabled_read(char *page, char **start, off_t off,
865                        int count, int *eof, void *data)
866 {
867         int len;
868
869         len = sprintf(page, "%d\n", sign_CIFS_PDUs);
870
871         len -= off;
872         *start = page + off;
873
874         if (len > count)
875                 len = count;
876         else
877                 *eof = 1;
878
879         if (len < 0)
880                 len = 0;
881
882         return len;
883 }
884 static int
885 packet_signing_enabled_write(struct file *file, const char __user *buffer,
886                         unsigned long count, void *data)
887 {
888         char c;
889         int rc;
890
891         rc = get_user(c, buffer);
892         if (rc)
893                 return rc;
894         if (c == '0' || c == 'n' || c == 'N')
895                 sign_CIFS_PDUs = 0;
896         else if (c == '1' || c == 'y' || c == 'Y')
897                 sign_CIFS_PDUs = 1;
898         else if (c == '2')
899                 sign_CIFS_PDUs = 2;
900
901         return count;
902 }
903
904
905 #endif