4 * Copyright (C) International Business Machines Corp., 2000,2003
6 * Modified by Steve French (sfrench@us.ibm.com)
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
16 * the GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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>
30 #include "cifsproto.h"
31 #include "cifs_debug.h"
34 cifs_dump_mem(char *label, void *data, int length)
39 char buf[10], line[80];
41 printk(KERN_DEBUG "%s: dump of %d bytes of data at 0x%p\n\n",
43 for (i = 0; i < length; i += 16) {
45 for (j = 0; (j < 4) && (i + j * 4 < length); j++) {
46 sprintf(buf, " %08x", intptr[i / 4 + j]);
51 for (j = 0; (j < 16) && (i + j < length); j++) {
52 buf[1] = isprint(charptr[i + j]) ? charptr[i + j] : '.';
55 printk(KERN_DEBUG "%s\n", line);
61 cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
62 int count, int *eof, void *data)
64 struct list_head *tmp;
65 struct cifsSesInfo *ses;
66 struct cifsTconInfo *tcon;
69 char *buf_start = buf;
73 "Display Internal CIFS Data Structures for Debugging\n"
74 "---------------------------------------------------\n");
77 length = sprintf(buf, "Servers:\n");
81 read_lock(&GlobalSMBSeslock);
82 list_for_each(tmp, &GlobalSMBSessionList) {
84 ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList);
87 "\n%d) Name: %s Domain: %s Mounts: %d ServerOS: %s \n\tServerNOS: %s\tCapabilities: 0x%x\n\tSMB session status: %d\tTCP status: %d",
88 i, ses->serverName, ses->serverDomain, atomic_read(&ses->inUse),
89 ses->serverOS, ses->serverNOS, ses->capabilities,ses->status,ses->server->tcpStatus);
92 buf += sprintf(buf, "\n\tLocal Users To Server: %d SecMode: 0x%x Req Active: %d",
93 atomic_read(&ses->server->socketUseCount),
95 atomic_read(&ses->server->inFlight));
97 /* length = sprintf(buf, "\nMIDs: \n");
100 spin_lock(&GlobalMid_Lock);
101 list_for_each(tmp1, &ses->server->pending_mid_q) {
102 mid_entry = list_entry(tmp1, struct
106 length = sprintf(buf,"State: %d com: %d pid: %d tsk: %p\n",mid_entry->midState,mid_entry->command,mid_entry->pid,mid_entry->tsk);
110 spin_unlock(&GlobalMid_Lock); */
114 read_unlock(&GlobalSMBSeslock);
118 length = sprintf(buf, "\nShares:\n");
122 read_lock(&GlobalSMBSeslock);
123 list_for_each(tmp, &GlobalTreeConnectionList) {
125 tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList);
128 "\n%d) %s Uses: %d Type: %s Characteristics: 0x%x Attributes: 0x%x\nPathComponentMax: %d Status: %d",
130 atomic_read(&tcon->useCount),
131 tcon->nativeFileSystem,
132 tcon->fsDevInfo.DeviceCharacteristics,
133 tcon->fsAttrInfo.Attributes,
134 tcon->fsAttrInfo.MaxPathNameComponentLength,tcon->tidStatus);
136 if (tcon->fsDevInfo.DeviceType == FILE_DEVICE_DISK)
137 length = sprintf(buf, " type: DISK ");
138 else if (tcon->fsDevInfo.DeviceType == FILE_DEVICE_CD_ROM)
139 length = sprintf(buf, " type: CDROM ");
142 sprintf(buf, " type: %d ",
143 tcon->fsDevInfo.DeviceType);
145 if(tcon->tidStatus == CifsNeedReconnect)
146 buf += sprintf(buf, "\tDISCONNECTED ");
147 #ifdef CONFIG_CIFS_STATS
148 length = sprintf(buf,"\nSMBs: %d Oplock Breaks: %d",
149 atomic_read(&tcon->num_smbs_sent),
150 atomic_read(&tcon->num_oplock_brks));
152 length = sprintf(buf,"\nReads: %d Bytes %lld",
153 atomic_read(&tcon->num_reads),
154 (long long)(tcon->bytes_read));
156 length = sprintf(buf,"\nWrites: %d Bytes: %lld",
157 atomic_read(&tcon->num_writes),
158 (long long)(tcon->bytes_written));
160 length = sprintf(buf,
161 "\nOpens: %d Deletes: %d\nMkdirs: %d Rmdirs: %d",
162 atomic_read(&tcon->num_opens),
163 atomic_read(&tcon->num_deletes),
164 atomic_read(&tcon->num_mkdirs),
165 atomic_read(&tcon->num_rmdirs));
170 read_unlock(&GlobalSMBSeslock);
172 length = sprintf(buf, "\n");
176 /* BB add code to dump additional info such as TCP session info now */
178 if (offset >= (buf - buf_start))
183 *beginBuffer = buf + offset;
184 if ((buf - buf_start - offset) > count)
187 return (buf - buf_start - offset);
191 cifs_total_xid_read(char *buf, char **beginBuffer, off_t offset,
192 int length, int *eof, void *data)
197 "Total vfs operations: %d and maximum simultaneous serviced by this filesystem: %d\n",
198 GlobalCurrentXid,GlobalMaxActiveXid);
204 cifs_stats_read(char *buf, char **beginBuffer, off_t offset,
205 int length, int *eof, void *data)
210 "Currently Allocated structures\nCIFS Sessions: %d\n",sesInfoAllocCount.counter);
213 sprintf(buf,"Shares (unique mount targets): %d\n",tconInfoAllocCount.counter);
214 length += item_length;
217 sprintf(buf,"Allocated SMB Request and Response Buffers: %d\n",bufAllocCount.counter);
218 length += item_length;
221 sprintf(buf,"Active Operations (MIDs in use): %d\n",midCount.counter);
222 length += item_length;
224 item_length = sprintf(buf,"%d sessions and %d shares reconnected after failure\n",tcpSesReconnectCount.counter,tconInfoReconnectCount.counter);
225 length += item_length;
230 struct proc_dir_entry *proc_fs_cifs;
231 read_proc_t cifs_txanchor_read;
232 static read_proc_t cifsFYI_read;
233 static write_proc_t cifsFYI_write;
234 static read_proc_t oplockEnabled_read;
235 static write_proc_t oplockEnabled_write;
236 static read_proc_t lookupFlag_read;
237 static write_proc_t lookupFlag_write;
238 static read_proc_t traceSMB_read;
239 static write_proc_t traceSMB_write;
240 static read_proc_t multiuser_mount_read;
241 static write_proc_t multiuser_mount_write;
242 static read_proc_t extended_security_read;
243 static write_proc_t extended_security_write;
244 static read_proc_t ntlmv2_enabled_read;
245 static write_proc_t ntlmv2_enabled_write;
246 static read_proc_t packet_signing_enabled_read;
247 static write_proc_t packet_signing_enabled_write;
248 static read_proc_t quotaEnabled_read;
249 static write_proc_t quotaEnabled_write;
250 static read_proc_t linuxExtensionsEnabled_read;
251 static write_proc_t linuxExtensionsEnabled_write;
256 struct proc_dir_entry *pde;
258 proc_fs_cifs = proc_mkdir("cifs", proc_root_fs);
259 if (proc_fs_cifs == NULL)
262 proc_fs_cifs->owner = THIS_MODULE;
263 create_proc_read_entry("DebugData", 0, proc_fs_cifs,
264 cifs_debug_data_read, 0);
266 create_proc_read_entry("SimultaneousOps", 0, proc_fs_cifs,
267 cifs_total_xid_read, 0);
269 create_proc_read_entry("Stats", 0, proc_fs_cifs,
272 pde = create_proc_read_entry("cifsFYI", 0, proc_fs_cifs,
275 pde->write_proc = cifsFYI_write;
278 create_proc_read_entry("traceSMB", 0, proc_fs_cifs,
281 pde->write_proc = traceSMB_write;
283 pde = create_proc_read_entry("OplockEnabled", 0, proc_fs_cifs,
284 oplockEnabled_read, 0);
286 pde->write_proc = oplockEnabled_write;
288 pde = create_proc_read_entry("QuotaEnabled", 0, proc_fs_cifs,
289 quotaEnabled_read, 0);
291 pde->write_proc = quotaEnabled_write;
293 pde = create_proc_read_entry("LinuxExtensionsEnabled", 0, proc_fs_cifs,
294 linuxExtensionsEnabled_read, 0);
296 pde->write_proc = linuxExtensionsEnabled_write;
299 create_proc_read_entry("MultiuserMount", 0, proc_fs_cifs,
300 multiuser_mount_read, 0);
302 pde->write_proc = multiuser_mount_write;
305 create_proc_read_entry("ExtendedSecurity", 0, proc_fs_cifs,
306 extended_security_read, 0);
308 pde->write_proc = extended_security_write;
311 create_proc_read_entry("LookupCacheEnabled", 0, proc_fs_cifs,
314 pde->write_proc = lookupFlag_write;
317 create_proc_read_entry("NTLMV2Enabled", 0, proc_fs_cifs,
318 ntlmv2_enabled_read, 0);
320 pde->write_proc = ntlmv2_enabled_write;
323 create_proc_read_entry("PacketSigningEnabled", 0, proc_fs_cifs,
324 packet_signing_enabled_read, 0);
326 pde->write_proc = packet_signing_enabled_write;
330 cifs_proc_clean(void)
332 if (proc_fs_cifs == NULL)
335 remove_proc_entry("DebugData", proc_fs_cifs);
336 remove_proc_entry("cifsFYI", proc_fs_cifs);
337 remove_proc_entry("traceSMB", proc_fs_cifs);
338 remove_proc_entry("SimultaneousOps", proc_fs_cifs);
339 remove_proc_entry("Stats", proc_fs_cifs);
340 remove_proc_entry("MultiuserMount", proc_fs_cifs);
341 remove_proc_entry("OplockEnabled", proc_fs_cifs);
342 remove_proc_entry("NTLMV2Enabled",proc_fs_cifs);
343 remove_proc_entry("ExtendedSecurity",proc_fs_cifs);
344 remove_proc_entry("PacketSigningEnabled",proc_fs_cifs);
345 remove_proc_entry("LinuxExtensionsEnabled",proc_fs_cifs);
346 remove_proc_entry("QuotaEnabled",proc_fs_cifs);
347 remove_proc_entry("LookupCacheEnabled",proc_fs_cifs);
348 remove_proc_entry("cifs", proc_root_fs);
352 cifsFYI_read(char *page, char **start, off_t off, int count,
353 int *eof, void *data)
357 len = sprintf(page, "%d\n", cifsFYI);
373 cifsFYI_write(struct file *file, const char *buffer,
374 unsigned long count, void *data)
379 rc = get_user(c, buffer);
382 if (c == '0' || c == 'n' || c == 'N')
384 else if (c == '1' || c == 'y' || c == 'Y')
391 oplockEnabled_read(char *page, char **start, off_t off,
392 int count, int *eof, void *data)
396 len = sprintf(page, "%d\n", oplockEnabled);
412 oplockEnabled_write(struct file *file, const char *buffer,
413 unsigned long count, void *data)
418 rc = get_user(c, buffer);
421 if (c == '0' || c == 'n' || c == 'N')
423 else if (c == '1' || c == 'y' || c == 'Y')
430 quotaEnabled_read(char *page, char **start, off_t off,
431 int count, int *eof, void *data)
435 len = sprintf(page, "%d\n", quotaEnabled);
436 /* could also check if quotas are enabled in kernel
452 quotaEnabled_write(struct file *file, const char *buffer,
453 unsigned long count, void *data)
458 rc = get_user(c, buffer);
461 if (c == '0' || c == 'n' || c == 'N')
463 else if (c == '1' || c == 'y' || c == 'Y')
470 linuxExtensionsEnabled_read(char *page, char **start, off_t off,
471 int count, int *eof, void *data)
475 len = sprintf(page, "%d\n", linuxExtEnabled);
476 /* could also check if quotas are enabled in kernel
492 linuxExtensionsEnabled_write(struct file *file, const char *buffer,
493 unsigned long count, void *data)
498 rc = get_user(c, buffer);
501 if (c == '0' || c == 'n' || c == 'N')
503 else if (c == '1' || c == 'y' || c == 'Y')
511 lookupFlag_read(char *page, char **start, off_t off,
512 int count, int *eof, void *data)
516 len = sprintf(page, "%d\n", lookupCacheEnabled);
532 lookupFlag_write(struct file *file, const char *buffer,
533 unsigned long count, void *data)
538 rc = get_user(c, buffer);
541 if (c == '0' || c == 'n' || c == 'N')
542 lookupCacheEnabled = 0;
543 else if (c == '1' || c == 'y' || c == 'Y')
544 lookupCacheEnabled = 1;
549 traceSMB_read(char *page, char **start, off_t off, int count,
550 int *eof, void *data)
554 len = sprintf(page, "%d\n", traceSMB);
570 traceSMB_write(struct file *file, const char *buffer,
571 unsigned long count, void *data)
576 rc = get_user(c, buffer);
579 if (c == '0' || c == 'n' || c == 'N')
581 else if (c == '1' || c == 'y' || c == 'Y')
588 multiuser_mount_read(char *page, char **start, off_t off,
589 int count, int *eof, void *data)
593 len = sprintf(page, "%d\n", multiuser_mount);
609 multiuser_mount_write(struct file *file, const char *buffer,
610 unsigned long count, void *data)
615 rc = get_user(c, buffer);
618 if (c == '0' || c == 'n' || c == 'N')
620 else if (c == '1' || c == 'y' || c == 'Y')
627 extended_security_read(char *page, char **start, off_t off,
628 int count, int *eof, void *data)
632 len = sprintf(page, "%d\n", extended_security);
648 extended_security_write(struct file *file, const char *buffer,
649 unsigned long count, void *data)
654 rc = get_user(c, buffer);
657 if (c == '0' || c == 'n' || c == 'N')
658 extended_security = 0;
659 else if (c == '1' || c == 'y' || c == 'Y')
660 extended_security = 1;
666 ntlmv2_enabled_read(char *page, char **start, off_t off,
667 int count, int *eof, void *data)
671 len = sprintf(page, "%d\n", ntlmv2_support);
687 ntlmv2_enabled_write(struct file *file, const char *buffer,
688 unsigned long count, void *data)
693 rc = get_user(c, buffer);
696 if (c == '0' || c == 'n' || c == 'N')
698 else if (c == '1' || c == 'y' || c == 'Y')
705 packet_signing_enabled_read(char *page, char **start, off_t off,
706 int count, int *eof, void *data)
710 len = sprintf(page, "%d\n", sign_CIFS_PDUs);
726 packet_signing_enabled_write(struct file *file, const char *buffer,
727 unsigned long count, void *data)
732 rc = get_user(c, buffer);
735 if (c == '0' || c == 'n' || c == 'N')
737 else if (c == '1' || c == 'y' || c == 'Y')