blob: f4124a32bef8974edd3f02111f8e382a63f02199 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * fs/cifs_debug.c
3 *
Steve Frenchb8643e12005-04-28 22:41:07 -07004 * Copyright (C) International Business Machines Corp., 2000,2005
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 *
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"
Steve French6c91d362005-04-28 22:41:06 -070032#include "cifsfs.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070033
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;
Steve French6c91d362005-04-28 22:41:06 -070082 length = sprintf(buf,"CIFS Version %s\n",CIFS_VERSION);
83 buf += length;
Steve French131afd02005-10-07 09:51:05 -070084 length = sprintf(buf,"Active VFS Requests: %d\n", GlobalTotalActiveXid);
85 buf += length;
Steve French6c91d362005-04-28 22:41:06 -070086 length = sprintf(buf, "Servers:");
Linus Torvalds1da177e2005-04-16 15:20:36 -070087 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);
Steve French433dc242005-04-28 22:41:08 -070094 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,
Steve French131afd02005-10-07 09:51:05 -0700102 "\n%d) Name: %s Domain: %s Mounts: %d OS: %s \n\tNOS: %s\tCapability: 0x%x\n\tSMB session status: %d\t",
Steve Frenchb8643e12005-04-28 22:41:07 -0700103 i, ses->serverName, ses->serverDomain,
104 atomic_read(&ses->inUse),
105 ses->serverOS, ses->serverNOS,
106 ses->capabilities,ses->status);
Steve French433dc242005-04-28 22:41:08 -0700107 buf += length;
108 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109 if(ses->server) {
Steve French131afd02005-10-07 09:51:05 -0700110 buf += sprintf(buf, "TCP status: %d\n\tLocal Users To Server: %d SecMode: 0x%x Req On Wire: %d",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111 ses->server->tcpStatus,
112 atomic_read(&ses->server->socketUseCount),
113 ses->server->secMode,
114 atomic_read(&ses->server->inFlight));
Steve French131afd02005-10-07 09:51:05 -0700115
116#ifdef CONFIG_CIFS_STATS2
Steve French68058e72005-10-10 10:34:22 -0700117 buf += sprintf(buf, " In Send: %d In MaxReq Wait: %d",
Steve French131afd02005-10-07 09:51:05 -0700118 atomic_read(&ses->server->inSend),
119 atomic_read(&ses->server->num_waiters));
120#endif
121
Steve French6c91d362005-04-28 22:41:06 -0700122 length = sprintf(buf, "\nMIDs:\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 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) {
Steve French848f3fc2005-04-28 22:41:07 -0700131 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);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137 buf += length;
138 }
139 }
140 spin_unlock(&GlobalMid_Lock);
141 }
142
143 }
144 read_unlock(&GlobalSMBSeslock);
145 sprintf(buf, "\n");
146 buf++;
147
Steve French6c91d362005-04-28 22:41:06 -0700148 length = sprintf(buf, "Shares:");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149 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,
Steve French131afd02005-10-07 09:51:05 -0700160 "\n%d) %s Uses: %d Type: %s DevInfo: 0x%x Attributes: 0x%x\nPathComponentMax: %d Status: %d",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161 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
Steve French1047abc2005-10-11 19:58:06 -0700206
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
Steve French47c786e2005-10-11 20:03:18 -0700220 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
Steve French1047abc2005-10-11 19:58:06 -0700221 read_lock(&GlobalSMBSeslock);
Steve French4498eed2005-12-03 13:58:57 -0800222#ifdef CONFIG_CIFS_STATS2
223 atomic_set(&totBufAllocCount, 0);
224 atomic_set(&totSmBufAllocCount, 0);
225#endif /* CONFIG_CIFS_STATS2 */
Steve French1047abc2005-10-11 19:58:06 -0700226 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
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253static 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",
Steve Frenchb8643e12005-04-28 22:41:07 -0700274 bufAllocCount.counter,
275 cifs_min_rcv + tcpSesAllocCount.counter);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276 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;
Steve French07475ff2005-12-03 14:11:37 -0800283#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
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291 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 }
Steve Frencha5a2b482005-08-20 21:42:53 -0700320 item_length = sprintf(buf, "\nSMBs: %d Oplock Breaks: %d",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321 atomic_read(&tcon->num_smbs_sent),
322 atomic_read(&tcon->num_oplock_brks));
323 buf += item_length;
324 length += item_length;
Steve French0ae0efa2005-10-10 10:57:19 -0700325 item_length = sprintf(buf, "\nReads: %d Bytes: %lld",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326 atomic_read(&tcon->num_reads),
327 (long long)(tcon->bytes_read));
328 buf += item_length;
329 length += item_length;
Steve Frencha5a2b482005-08-20 21:42:53 -0700330 item_length = sprintf(buf, "\nWrites: %d Bytes: %lld",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331 atomic_read(&tcon->num_writes),
332 (long long)(tcon->bytes_written));
Steve Frencha5a2b482005-08-20 21:42:53 -0700333 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));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700347 buf += item_length;
348 length += item_length;
Steve Frencha5a2b482005-08-20 21:42:53 -0700349 item_length = sprintf(buf, "\nMkdirs: %d Rmdirs: %d",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350 atomic_read(&tcon->num_mkdirs),
351 atomic_read(&tcon->num_rmdirs));
352 buf += item_length;
353 length += item_length;
Steve Frencha5a2b482005-08-20 21:42:53 -0700354 item_length = sprintf(buf, "\nRenames: %d T2 Renames %d",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355 atomic_read(&tcon->num_renames),
356 atomic_read(&tcon->num_t2renames));
357 buf += item_length;
358 length += item_length;
Steve Frencha5a2b482005-08-20 21:42:53 -0700359 item_length = sprintf(buf, "\nFindFirst: %d FNext %d FClose %d",
Steve French0c0ff092005-06-23 19:31:17 -0500360 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;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365 }
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
386static struct proc_dir_entry *proc_fs_cifs;
387read_proc_t cifs_txanchor_read;
388static read_proc_t cifsFYI_read;
389static write_proc_t cifsFYI_write;
390static read_proc_t oplockEnabled_read;
391static write_proc_t oplockEnabled_write;
392static read_proc_t lookupFlag_read;
393static write_proc_t lookupFlag_write;
394static read_proc_t traceSMB_read;
395static write_proc_t traceSMB_write;
396static read_proc_t multiuser_mount_read;
397static write_proc_t multiuser_mount_write;
398static read_proc_t extended_security_read;
399static write_proc_t extended_security_write;
400static read_proc_t ntlmv2_enabled_read;
401static write_proc_t ntlmv2_enabled_write;
402static read_proc_t packet_signing_enabled_read;
403static write_proc_t packet_signing_enabled_write;
Steve Frenchec637e32005-12-12 20:53:18 -0800404static read_proc_t experimEnabled_read;
405static write_proc_t experimEnabled_write;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406static read_proc_t linuxExtensionsEnabled_read;
407static write_proc_t linuxExtensionsEnabled_write;
408
409void
410cifs_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
Steve French1047abc2005-10-11 19:58:06 -0700423 pde = create_proc_read_entry("Stats", 0, proc_fs_cifs,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424 cifs_stats_read, NULL);
Steve French1047abc2005-10-11 19:58:06 -0700425 if (pde)
426 pde->write_proc = cifs_stats_write;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427#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
Steve French0c0ff092005-06-23 19:31:17 -0500444 pde = create_proc_read_entry("Experimental", 0, proc_fs_cifs,
Steve Frenchec637e32005-12-12 20:53:18 -0800445 experimEnabled_read, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446 if (pde)
Steve Frenchec637e32005-12-12 20:53:18 -0800447 pde->write_proc = experimEnabled_write;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448
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
485void
486cifs_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);
Steve French0c0ff092005-06-23 19:31:17 -0500503 remove_proc_entry("Experimental",proc_fs_cifs);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504 remove_proc_entry("LookupCacheEnabled",proc_fs_cifs);
505 remove_proc_entry("cifs", proc_root_fs);
506}
507
508static int
509cifsFYI_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}
529static int
530cifsFYI_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;
Steve French1047abc2005-10-11 19:58:06 -0700543 else if((c > '1') && (c <= '9'))
544 cifsFYI = (int) (c - '0'); /* see cifs_debug.h for meanings */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545
546 return count;
547}
548
549static int
550oplockEnabled_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}
570static int
571oplockEnabled_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
588static int
Steve Frenchec637e32005-12-12 20:53:18 -0800589experimEnabled_read(char *page, char **start, off_t off,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700590 int count, int *eof, void *data)
591{
592 int len;
593
594 len = sprintf(page, "%d\n", experimEnabled);
Steve Frenchec637e32005-12-12 20:53:18 -0800595
Linus Torvalds1da177e2005-04-16 15:20:36 -0700596 len -= off;
597 *start = page + off;
598
599 if (len > count)
600 len = count;
601 else
602 *eof = 1;
603
604 if (len < 0)
605 len = 0;
606
607 return len;
608}
609static int
Steve Frenchec637e32005-12-12 20:53:18 -0800610experimEnabled_write(struct file *file, const char __user *buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700611 unsigned long count, void *data)
612{
Steve Frenchec637e32005-12-12 20:53:18 -0800613 char c;
614 int rc;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700615
Steve Frenchec637e32005-12-12 20:53:18 -0800616 rc = get_user(c, buffer);
617 if (rc)
618 return rc;
619 if (c == '0' || c == 'n' || c == 'N')
620 experimEnabled = 0;
621 else if (c == '1' || c == 'y' || c == 'Y')
622 experimEnabled = 1;
623 else if (c == '2')
624 experimEnabled = 2;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700625
Steve Frenchec637e32005-12-12 20:53:18 -0800626 return count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700627}
628
629static int
630linuxExtensionsEnabled_read(char *page, char **start, off_t off,
631 int count, int *eof, void *data)
632{
633 int len;
634
635 len = sprintf(page, "%d\n", linuxExtEnabled);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700636 len -= off;
637 *start = page + off;
638
639 if (len > count)
640 len = count;
641 else
642 *eof = 1;
643
644 if (len < 0)
645 len = 0;
646
647 return len;
648}
649static int
650linuxExtensionsEnabled_write(struct file *file, const char __user *buffer,
651 unsigned long count, void *data)
652{
653 char c;
654 int rc;
655
656 rc = get_user(c, buffer);
657 if (rc)
658 return rc;
659 if (c == '0' || c == 'n' || c == 'N')
660 linuxExtEnabled = 0;
661 else if (c == '1' || c == 'y' || c == 'Y')
662 linuxExtEnabled = 1;
663
664 return count;
665}
666
667
668static int
669lookupFlag_read(char *page, char **start, off_t off,
670 int count, int *eof, void *data)
671{
672 int len;
673
674 len = sprintf(page, "%d\n", lookupCacheEnabled);
675
676 len -= off;
677 *start = page + off;
678
679 if (len > count)
680 len = count;
681 else
682 *eof = 1;
683
684 if (len < 0)
685 len = 0;
686
687 return len;
688}
689static int
690lookupFlag_write(struct file *file, const char __user *buffer,
691 unsigned long count, void *data)
692{
693 char c;
694 int rc;
695
696 rc = get_user(c, buffer);
697 if (rc)
698 return rc;
699 if (c == '0' || c == 'n' || c == 'N')
700 lookupCacheEnabled = 0;
701 else if (c == '1' || c == 'y' || c == 'Y')
702 lookupCacheEnabled = 1;
703
704 return count;
705}
706static int
707traceSMB_read(char *page, char **start, off_t off, int count,
708 int *eof, void *data)
709{
710 int len;
711
712 len = sprintf(page, "%d\n", traceSMB);
713
714 len -= off;
715 *start = page + off;
716
717 if (len > count)
718 len = count;
719 else
720 *eof = 1;
721
722 if (len < 0)
723 len = 0;
724
725 return len;
726}
727static int
728traceSMB_write(struct file *file, const char __user *buffer,
729 unsigned long count, void *data)
730{
731 char c;
732 int rc;
733
734 rc = get_user(c, buffer);
735 if (rc)
736 return rc;
737 if (c == '0' || c == 'n' || c == 'N')
738 traceSMB = 0;
739 else if (c == '1' || c == 'y' || c == 'Y')
740 traceSMB = 1;
741
742 return count;
743}
744
745static int
746multiuser_mount_read(char *page, char **start, off_t off,
747 int count, int *eof, void *data)
748{
749 int len;
750
751 len = sprintf(page, "%d\n", multiuser_mount);
752
753 len -= off;
754 *start = page + off;
755
756 if (len > count)
757 len = count;
758 else
759 *eof = 1;
760
761 if (len < 0)
762 len = 0;
763
764 return len;
765}
766static int
767multiuser_mount_write(struct file *file, const char __user *buffer,
768 unsigned long count, void *data)
769{
770 char c;
771 int rc;
772
773 rc = get_user(c, buffer);
774 if (rc)
775 return rc;
776 if (c == '0' || c == 'n' || c == 'N')
777 multiuser_mount = 0;
778 else if (c == '1' || c == 'y' || c == 'Y')
779 multiuser_mount = 1;
780
781 return count;
782}
783
784static int
785extended_security_read(char *page, char **start, off_t off,
786 int count, int *eof, void *data)
787{
788 int len;
789
790 len = sprintf(page, "%d\n", extended_security);
791
792 len -= off;
793 *start = page + off;
794
795 if (len > count)
796 len = count;
797 else
798 *eof = 1;
799
800 if (len < 0)
801 len = 0;
802
803 return len;
804}
805static int
806extended_security_write(struct file *file, const char __user *buffer,
807 unsigned long count, void *data)
808{
809 char c;
810 int rc;
811
812 rc = get_user(c, buffer);
813 if (rc)
814 return rc;
815 if (c == '0' || c == 'n' || c == 'N')
816 extended_security = 0;
817 else if (c == '1' || c == 'y' || c == 'Y')
818 extended_security = 1;
819
820 return count;
821}
822
823static int
824ntlmv2_enabled_read(char *page, char **start, off_t off,
825 int count, int *eof, void *data)
826{
827 int len;
828
829 len = sprintf(page, "%d\n", ntlmv2_support);
830
831 len -= off;
832 *start = page + off;
833
834 if (len > count)
835 len = count;
836 else
837 *eof = 1;
838
839 if (len < 0)
840 len = 0;
841
842 return len;
843}
844static int
845ntlmv2_enabled_write(struct file *file, const char __user *buffer,
846 unsigned long count, void *data)
847{
848 char c;
849 int rc;
850
851 rc = get_user(c, buffer);
852 if (rc)
853 return rc;
854 if (c == '0' || c == 'n' || c == 'N')
855 ntlmv2_support = 0;
856 else if (c == '1' || c == 'y' || c == 'Y')
857 ntlmv2_support = 1;
858
859 return count;
860}
861
862static int
863packet_signing_enabled_read(char *page, char **start, off_t off,
864 int count, int *eof, void *data)
865{
866 int len;
867
868 len = sprintf(page, "%d\n", sign_CIFS_PDUs);
869
870 len -= off;
871 *start = page + off;
872
873 if (len > count)
874 len = count;
875 else
876 *eof = 1;
877
878 if (len < 0)
879 len = 0;
880
881 return len;
882}
883static int
884packet_signing_enabled_write(struct file *file, const char __user *buffer,
885 unsigned long count, void *data)
886{
887 char c;
888 int rc;
889
890 rc = get_user(c, buffer);
891 if (rc)
892 return rc;
893 if (c == '0' || c == 'n' || c == 'N')
894 sign_CIFS_PDUs = 0;
895 else if (c == '1' || c == 'y' || c == 'Y')
896 sign_CIFS_PDUs = 1;
897 else if (c == '2')
898 sign_CIFS_PDUs = 2;
899
900 return count;
901}
902
903
904#endif