[PATCH] powerpc: Add support for the MPC83xx watchdog
[linux-2.6] / 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                 list_for_each(tmp, &GlobalTreeConnectionList) {
223                         tcon = list_entry(tmp, struct cifsTconInfo,
224                                         cifsConnectionList);
225                         atomic_set(&tcon->num_smbs_sent, 0);
226                         atomic_set(&tcon->num_writes, 0);
227                         atomic_set(&tcon->num_reads, 0);
228                         atomic_set(&tcon->num_oplock_brks, 0);
229                         atomic_set(&tcon->num_opens, 0);
230                         atomic_set(&tcon->num_closes, 0);
231                         atomic_set(&tcon->num_deletes, 0);
232                         atomic_set(&tcon->num_mkdirs, 0);
233                         atomic_set(&tcon->num_rmdirs, 0);
234                         atomic_set(&tcon->num_renames, 0);
235                         atomic_set(&tcon->num_t2renames, 0);
236                         atomic_set(&tcon->num_ffirst, 0);
237                         atomic_set(&tcon->num_fnext, 0);
238                         atomic_set(&tcon->num_fclose, 0);
239                         atomic_set(&tcon->num_hardlinks, 0);
240                         atomic_set(&tcon->num_symlinks, 0);
241                         atomic_set(&tcon->num_locks, 0);
242                 }
243                 read_unlock(&GlobalSMBSeslock);
244         }
245
246         return count;
247 }
248
249 static int
250 cifs_stats_read(char *buf, char **beginBuffer, off_t offset,
251                   int count, int *eof, void *data)
252 {
253         int item_length,i,length;
254         struct list_head *tmp;
255         struct cifsTconInfo *tcon;
256
257         *beginBuffer = buf + offset;
258
259         length = sprintf(buf,
260                         "Resources in use\nCIFS Session: %d\n",
261                         sesInfoAllocCount.counter);
262         buf += length;
263         item_length = 
264                 sprintf(buf,"Share (unique mount targets): %d\n",
265                         tconInfoAllocCount.counter);
266         length += item_length;
267         buf += item_length;      
268         item_length = 
269                 sprintf(buf,"SMB Request/Response Buffer: %d Pool size: %d\n",
270                         bufAllocCount.counter,
271                         cifs_min_rcv + tcpSesAllocCount.counter);
272         length += item_length;
273         buf += item_length;
274         item_length = 
275                 sprintf(buf,"SMB Small Req/Resp Buffer: %d Pool size: %d\n",
276                         smBufAllocCount.counter,cifs_min_small);
277         length += item_length;
278         buf += item_length;
279         item_length = 
280                 sprintf(buf,"Operations (MIDs): %d\n",
281                         midCount.counter);
282         length += item_length;
283         buf += item_length;
284         item_length = sprintf(buf,
285                 "\n%d session %d share reconnects\n",
286                 tcpSesReconnectCount.counter,tconInfoReconnectCount.counter);
287         length += item_length;
288         buf += item_length;
289
290         item_length = sprintf(buf,
291                 "Total vfs operations: %d maximum at one time: %d\n",
292                 GlobalCurrentXid,GlobalMaxActiveXid);
293         length += item_length;
294         buf += item_length;
295
296         i = 0;
297         read_lock(&GlobalSMBSeslock);
298         list_for_each(tmp, &GlobalTreeConnectionList) {
299                 i++;
300                 tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList);
301                 item_length = sprintf(buf,"\n%d) %s",i, tcon->treeName);
302                 buf += item_length;
303                 length += item_length;
304                 if(tcon->tidStatus == CifsNeedReconnect) {
305                         buf += sprintf(buf, "\tDISCONNECTED ");
306                         length += 14;
307                 }
308                 item_length = sprintf(buf, "\nSMBs: %d Oplock Breaks: %d",
309                         atomic_read(&tcon->num_smbs_sent),
310                         atomic_read(&tcon->num_oplock_brks));
311                 buf += item_length;
312                 length += item_length;
313                 item_length = sprintf(buf, "\nReads:  %d Bytes: %lld",
314                         atomic_read(&tcon->num_reads),
315                         (long long)(tcon->bytes_read));
316                 buf += item_length;
317                 length += item_length;
318                 item_length = sprintf(buf, "\nWrites: %d Bytes: %lld",
319                         atomic_read(&tcon->num_writes),
320                         (long long)(tcon->bytes_written));
321                 buf += item_length;
322                 length += item_length;
323                 item_length = sprintf(buf, 
324                         "\nLocks: %d HardLinks: %d Symlinks: %d",
325                         atomic_read(&tcon->num_locks),
326                         atomic_read(&tcon->num_hardlinks),
327                         atomic_read(&tcon->num_symlinks));
328                 buf += item_length;
329                 length += item_length;
330
331                 item_length = sprintf(buf, "\nOpens: %d Closes: %d Deletes: %d",
332                         atomic_read(&tcon->num_opens),
333                         atomic_read(&tcon->num_closes),
334                         atomic_read(&tcon->num_deletes));
335                 buf += item_length;
336                 length += item_length;
337                 item_length = sprintf(buf, "\nMkdirs: %d Rmdirs: %d",
338                         atomic_read(&tcon->num_mkdirs),
339                         atomic_read(&tcon->num_rmdirs));
340                 buf += item_length;
341                 length += item_length;
342                 item_length = sprintf(buf, "\nRenames: %d T2 Renames %d",
343                         atomic_read(&tcon->num_renames),
344                         atomic_read(&tcon->num_t2renames));
345                 buf += item_length;
346                 length += item_length;
347                 item_length = sprintf(buf, "\nFindFirst: %d FNext %d FClose %d",
348                         atomic_read(&tcon->num_ffirst),
349                         atomic_read(&tcon->num_fnext),
350                         atomic_read(&tcon->num_fclose));
351                 buf += item_length;
352                 length += item_length;
353         }
354         read_unlock(&GlobalSMBSeslock);
355
356         buf += sprintf(buf,"\n");
357         length++;
358
359         if(offset + count >= length)
360                 *eof = 1;
361         if(length < offset) {
362                 *eof = 1;
363                 return 0;
364         } else {
365                 length = length - offset;
366         }
367         if (length > count)
368                 length = count;
369                 
370         return length;
371 }
372 #endif
373
374 static struct proc_dir_entry *proc_fs_cifs;
375 read_proc_t cifs_txanchor_read;
376 static read_proc_t cifsFYI_read;
377 static write_proc_t cifsFYI_write;
378 static read_proc_t oplockEnabled_read;
379 static write_proc_t oplockEnabled_write;
380 static read_proc_t lookupFlag_read;
381 static write_proc_t lookupFlag_write;
382 static read_proc_t traceSMB_read;
383 static write_proc_t traceSMB_write;
384 static read_proc_t multiuser_mount_read;
385 static write_proc_t multiuser_mount_write;
386 static read_proc_t extended_security_read;
387 static write_proc_t extended_security_write;
388 static read_proc_t ntlmv2_enabled_read;
389 static write_proc_t ntlmv2_enabled_write;
390 static read_proc_t packet_signing_enabled_read;
391 static write_proc_t packet_signing_enabled_write;
392 static read_proc_t quotaEnabled_read;
393 static write_proc_t quotaEnabled_write;
394 static read_proc_t linuxExtensionsEnabled_read;
395 static write_proc_t linuxExtensionsEnabled_write;
396
397 void
398 cifs_proc_init(void)
399 {
400         struct proc_dir_entry *pde;
401
402         proc_fs_cifs = proc_mkdir("cifs", proc_root_fs);
403         if (proc_fs_cifs == NULL)
404                 return;
405
406         proc_fs_cifs->owner = THIS_MODULE;
407         create_proc_read_entry("DebugData", 0, proc_fs_cifs,
408                                 cifs_debug_data_read, NULL);
409
410 #ifdef CONFIG_CIFS_STATS
411         pde = create_proc_read_entry("Stats", 0, proc_fs_cifs,
412                                 cifs_stats_read, NULL);
413         if (pde)
414                 pde->write_proc = cifs_stats_write;
415 #endif
416         pde = create_proc_read_entry("cifsFYI", 0, proc_fs_cifs,
417                                 cifsFYI_read, NULL);
418         if (pde)
419                 pde->write_proc = cifsFYI_write;
420
421         pde =
422             create_proc_read_entry("traceSMB", 0, proc_fs_cifs,
423                                 traceSMB_read, NULL);
424         if (pde)
425                 pde->write_proc = traceSMB_write;
426
427         pde = create_proc_read_entry("OplockEnabled", 0, proc_fs_cifs,
428                                 oplockEnabled_read, NULL);
429         if (pde)
430                 pde->write_proc = oplockEnabled_write;
431
432         pde = create_proc_read_entry("Experimental", 0, proc_fs_cifs,
433                                 quotaEnabled_read, NULL);
434         if (pde)
435                 pde->write_proc = quotaEnabled_write;
436
437         pde = create_proc_read_entry("LinuxExtensionsEnabled", 0, proc_fs_cifs,
438                                 linuxExtensionsEnabled_read, NULL);
439         if (pde)
440                 pde->write_proc = linuxExtensionsEnabled_write;
441
442         pde =
443             create_proc_read_entry("MultiuserMount", 0, proc_fs_cifs,
444                                 multiuser_mount_read, NULL);
445         if (pde)
446                 pde->write_proc = multiuser_mount_write;
447
448         pde =
449             create_proc_read_entry("ExtendedSecurity", 0, proc_fs_cifs,
450                                 extended_security_read, NULL);
451         if (pde)
452                 pde->write_proc = extended_security_write;
453
454         pde =
455         create_proc_read_entry("LookupCacheEnabled", 0, proc_fs_cifs,
456                                 lookupFlag_read, NULL);
457         if (pde)
458                 pde->write_proc = lookupFlag_write;
459
460         pde =
461             create_proc_read_entry("NTLMV2Enabled", 0, proc_fs_cifs,
462                                 ntlmv2_enabled_read, NULL);
463         if (pde)
464                 pde->write_proc = ntlmv2_enabled_write;
465
466         pde =
467             create_proc_read_entry("PacketSigningEnabled", 0, proc_fs_cifs,
468                                 packet_signing_enabled_read, NULL);
469         if (pde)
470                 pde->write_proc = packet_signing_enabled_write;
471 }
472
473 void
474 cifs_proc_clean(void)
475 {
476         if (proc_fs_cifs == NULL)
477                 return;
478
479         remove_proc_entry("DebugData", proc_fs_cifs);
480         remove_proc_entry("cifsFYI", proc_fs_cifs);
481         remove_proc_entry("traceSMB", proc_fs_cifs);
482 #ifdef CONFIG_CIFS_STATS
483         remove_proc_entry("Stats", proc_fs_cifs);
484 #endif
485         remove_proc_entry("MultiuserMount", proc_fs_cifs);
486         remove_proc_entry("OplockEnabled", proc_fs_cifs);
487         remove_proc_entry("NTLMV2Enabled",proc_fs_cifs);
488         remove_proc_entry("ExtendedSecurity",proc_fs_cifs);
489         remove_proc_entry("PacketSigningEnabled",proc_fs_cifs);
490         remove_proc_entry("LinuxExtensionsEnabled",proc_fs_cifs);
491         remove_proc_entry("Experimental",proc_fs_cifs);
492         remove_proc_entry("LookupCacheEnabled",proc_fs_cifs);
493         remove_proc_entry("cifs", proc_root_fs);
494 }
495
496 static int
497 cifsFYI_read(char *page, char **start, off_t off, int count,
498              int *eof, void *data)
499 {
500         int len;
501
502         len = sprintf(page, "%d\n", cifsFYI);
503
504         len -= off;
505         *start = page + off;
506
507         if (len > count)
508                 len = count;
509         else
510                 *eof = 1;
511
512         if (len < 0)
513                 len = 0;
514
515         return len;
516 }
517 static int
518 cifsFYI_write(struct file *file, const char __user *buffer,
519               unsigned long count, void *data)
520 {
521         char c;
522         int rc;
523
524         rc = get_user(c, buffer);
525         if (rc)
526                 return rc;
527         if (c == '0' || c == 'n' || c == 'N')
528                 cifsFYI = 0;
529         else if (c == '1' || c == 'y' || c == 'Y')
530                 cifsFYI = 1;
531         else if((c > '1') && (c <= '9'))
532                 cifsFYI = (int) (c - '0'); /* see cifs_debug.h for meanings */
533
534         return count;
535 }
536
537 static int
538 oplockEnabled_read(char *page, char **start, off_t off,
539                    int count, int *eof, void *data)
540 {
541         int len;
542
543         len = sprintf(page, "%d\n", oplockEnabled);
544
545         len -= off;
546         *start = page + off;
547
548         if (len > count)
549                 len = count;
550         else
551                 *eof = 1;
552
553         if (len < 0)
554                 len = 0;
555
556         return len;
557 }
558 static int
559 oplockEnabled_write(struct file *file, const char __user *buffer,
560                     unsigned long count, void *data)
561 {
562         char c;
563         int rc;
564
565         rc = get_user(c, buffer);
566         if (rc)
567                 return rc;
568         if (c == '0' || c == 'n' || c == 'N')
569                 oplockEnabled = 0;
570         else if (c == '1' || c == 'y' || c == 'Y')
571                 oplockEnabled = 1;
572
573         return count;
574 }
575
576 static int
577 quotaEnabled_read(char *page, char **start, off_t off,
578                    int count, int *eof, void *data)
579 {
580         int len;
581
582         len = sprintf(page, "%d\n", experimEnabled);
583 /* could also check if quotas are enabled in kernel
584         as a whole first */
585         len -= off;
586         *start = page + off;
587
588         if (len > count)
589                 len = count;
590         else
591                 *eof = 1;
592
593         if (len < 0)
594                 len = 0;
595
596         return len;
597 }
598 static int
599 quotaEnabled_write(struct file *file, const char __user *buffer,
600                     unsigned long count, void *data)
601 {
602         char c;
603         int rc;
604
605         rc = get_user(c, buffer);
606         if (rc)
607                 return rc;
608         if (c == '0' || c == 'n' || c == 'N')
609                 experimEnabled = 0;
610         else if (c == '1' || c == 'y' || c == 'Y')
611                 experimEnabled = 1;
612
613         return count;
614 }
615
616 static int
617 linuxExtensionsEnabled_read(char *page, char **start, off_t off,
618                    int count, int *eof, void *data)
619 {
620         int len;
621
622         len = sprintf(page, "%d\n", linuxExtEnabled);
623 /* could also check if quotas are enabled in kernel
624         as a whole first */
625         len -= off;
626         *start = page + off;
627
628         if (len > count)
629                 len = count;
630         else
631                 *eof = 1;
632
633         if (len < 0)
634                 len = 0;
635
636         return len;
637 }
638 static int
639 linuxExtensionsEnabled_write(struct file *file, const char __user *buffer,
640                     unsigned long count, void *data)
641 {
642         char c;
643         int rc;
644
645         rc = get_user(c, buffer);
646         if (rc)
647                 return rc;
648         if (c == '0' || c == 'n' || c == 'N')
649                 linuxExtEnabled = 0;
650         else if (c == '1' || c == 'y' || c == 'Y')
651                 linuxExtEnabled = 1;
652
653         return count;
654 }
655
656
657 static int
658 lookupFlag_read(char *page, char **start, off_t off,
659                    int count, int *eof, void *data)
660 {
661         int len;
662
663         len = sprintf(page, "%d\n", lookupCacheEnabled);
664
665         len -= off;
666         *start = page + off;
667
668         if (len > count)
669                 len = count;
670         else
671                 *eof = 1;
672
673         if (len < 0)
674                 len = 0;
675
676         return len;
677 }
678 static int
679 lookupFlag_write(struct file *file, const char __user *buffer,
680                     unsigned long count, void *data)
681 {
682         char c;
683         int rc;
684
685         rc = get_user(c, buffer);
686         if (rc)
687                 return rc;
688         if (c == '0' || c == 'n' || c == 'N')
689                 lookupCacheEnabled = 0;
690         else if (c == '1' || c == 'y' || c == 'Y')
691                 lookupCacheEnabled = 1;
692
693         return count;
694 }
695 static int
696 traceSMB_read(char *page, char **start, off_t off, int count,
697               int *eof, void *data)
698 {
699         int len;
700
701         len = sprintf(page, "%d\n", traceSMB);
702
703         len -= off;
704         *start = page + off;
705
706         if (len > count)
707                 len = count;
708         else
709                 *eof = 1;
710
711         if (len < 0)
712                 len = 0;
713
714         return len;
715 }
716 static int
717 traceSMB_write(struct file *file, const char __user *buffer,
718                unsigned long count, void *data)
719 {
720         char c;
721         int rc;
722
723         rc = get_user(c, buffer);
724         if (rc)
725                 return rc;
726         if (c == '0' || c == 'n' || c == 'N')
727                 traceSMB = 0;
728         else if (c == '1' || c == 'y' || c == 'Y')
729                 traceSMB = 1;
730
731         return count;
732 }
733
734 static int
735 multiuser_mount_read(char *page, char **start, off_t off,
736                      int count, int *eof, void *data)
737 {
738         int len;
739
740         len = sprintf(page, "%d\n", multiuser_mount);
741
742         len -= off;
743         *start = page + off;
744
745         if (len > count)
746                 len = count;
747         else
748                 *eof = 1;
749
750         if (len < 0)
751                 len = 0;
752
753         return len;
754 }
755 static int
756 multiuser_mount_write(struct file *file, const char __user *buffer,
757                       unsigned long count, void *data)
758 {
759         char c;
760         int rc;
761
762         rc = get_user(c, buffer);
763         if (rc)
764                 return rc;
765         if (c == '0' || c == 'n' || c == 'N')
766                 multiuser_mount = 0;
767         else if (c == '1' || c == 'y' || c == 'Y')
768                 multiuser_mount = 1;
769
770         return count;
771 }
772
773 static int
774 extended_security_read(char *page, char **start, off_t off,
775                        int count, int *eof, void *data)
776 {
777         int len;
778
779         len = sprintf(page, "%d\n", extended_security);
780
781         len -= off;
782         *start = page + off;
783
784         if (len > count)
785                 len = count;
786         else
787                 *eof = 1;
788
789         if (len < 0)
790                 len = 0;
791
792         return len;
793 }
794 static int
795 extended_security_write(struct file *file, const char __user *buffer,
796                         unsigned long count, void *data)
797 {
798         char c;
799         int rc;
800
801         rc = get_user(c, buffer);
802         if (rc)
803                 return rc;
804         if (c == '0' || c == 'n' || c == 'N')
805                 extended_security = 0;
806         else if (c == '1' || c == 'y' || c == 'Y')
807                 extended_security = 1;
808
809         return count;
810 }
811
812 static int
813 ntlmv2_enabled_read(char *page, char **start, off_t off,
814                        int count, int *eof, void *data)
815 {
816         int len;
817
818         len = sprintf(page, "%d\n", ntlmv2_support);
819
820         len -= off;
821         *start = page + off;
822
823         if (len > count)
824                 len = count;
825         else
826                 *eof = 1;
827
828         if (len < 0)
829                 len = 0;
830
831         return len;
832 }
833 static int
834 ntlmv2_enabled_write(struct file *file, const char __user *buffer,
835                         unsigned long count, void *data)
836 {
837         char c;
838         int rc;
839
840         rc = get_user(c, buffer);
841         if (rc)
842                 return rc;
843         if (c == '0' || c == 'n' || c == 'N')
844                 ntlmv2_support = 0;
845         else if (c == '1' || c == 'y' || c == 'Y')
846                 ntlmv2_support = 1;
847
848         return count;
849 }
850
851 static int
852 packet_signing_enabled_read(char *page, char **start, off_t off,
853                        int count, int *eof, void *data)
854 {
855         int len;
856
857         len = sprintf(page, "%d\n", sign_CIFS_PDUs);
858
859         len -= off;
860         *start = page + off;
861
862         if (len > count)
863                 len = count;
864         else
865                 *eof = 1;
866
867         if (len < 0)
868                 len = 0;
869
870         return len;
871 }
872 static int
873 packet_signing_enabled_write(struct file *file, const char __user *buffer,
874                         unsigned long count, void *data)
875 {
876         char c;
877         int rc;
878
879         rc = get_user(c, buffer);
880         if (rc)
881                 return rc;
882         if (c == '0' || c == 'n' || c == 'N')
883                 sign_CIFS_PDUs = 0;
884         else if (c == '1' || c == 'y' || c == 'Y')
885                 sign_CIFS_PDUs = 1;
886         else if (c == '2')
887                 sign_CIFS_PDUs = 2;
888
889         return count;
890 }
891
892
893 #endif