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 ");
150 read_unlock(&GlobalSMBSeslock);
152 length = sprintf(buf, "\n");
156 /* BB add code to dump additional info such as TCP session info now */
158 if (offset >= (buf - buf_start))
163 *beginBuffer = buf + offset;
164 if ((buf - buf_start - offset) > count)
167 return (buf - buf_start - offset);
171 cifs_total_xid_read(char *buf, char **beginBuffer, off_t offset,
172 int length, int *eof, void *data)
177 "Total vfs operations: %d and maximum simultaneous serviced by this filesystem: %d\n",
178 GlobalCurrentXid,GlobalMaxActiveXid);
183 #ifdef CONFIG_CIFS_STATS
185 cifs_stats_read(char *buf, char **beginBuffer, off_t offset,
186 int length, int *eof, void *data)
189 struct list_head *tmp;
190 struct cifsTconInfo *tcon;
192 length = sprintf(buf,
193 "Resources in use\nCIFS Session: %d\n",
194 sesInfoAllocCount.counter);
197 sprintf(buf,"Share (unique mount targets): %d\n",
198 tconInfoAllocCount.counter);
199 length += item_length;
202 sprintf(buf,"SMB Request/Response Buffer: %d\n",
203 bufAllocCount.counter);
204 length += item_length;
207 sprintf(buf,"Operations (MIDs): %d\n",
209 length += item_length;
211 item_length = sprintf(buf,
212 "\n%d session %d share reconnects\n",
213 tcpSesReconnectCount.counter,tconInfoReconnectCount.counter);
214 length += item_length;
218 read_lock(&GlobalSMBSeslock);
219 list_for_each(tmp, &GlobalTreeConnectionList) {
221 tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList);
222 item_length = sprintf(buf,"\n%d) %s",i, tcon->treeName);
224 length += item_length;
225 if(tcon->tidStatus == CifsNeedReconnect) {
226 buf += sprintf(buf, "\tDISCONNECTED ");
229 item_length = sprintf(buf,"\nSMBs: %d Oplock Breaks: %d",
230 atomic_read(&tcon->num_smbs_sent),
231 atomic_read(&tcon->num_oplock_brks));
233 length += item_length;
234 item_length = sprintf(buf,"\nReads: %d Bytes %lld",
235 atomic_read(&tcon->num_reads),
236 (long long)(tcon->bytes_read));
238 item_length = sprintf(buf,"\nWrites: %d Bytes: %lld",
239 atomic_read(&tcon->num_writes),
240 (long long)(tcon->bytes_written));
242 item_length = sprintf(buf,
243 "\nOpens: %d Deletes: %d\nMkdirs: %d Rmdirs: %d",
244 atomic_read(&tcon->num_opens),
245 atomic_read(&tcon->num_deletes),
246 atomic_read(&tcon->num_mkdirs),
247 atomic_read(&tcon->num_rmdirs));
249 length += item_length;
251 read_unlock(&GlobalSMBSeslock);
258 struct proc_dir_entry *proc_fs_cifs;
259 read_proc_t cifs_txanchor_read;
260 static read_proc_t cifsFYI_read;
261 static write_proc_t cifsFYI_write;
262 static read_proc_t oplockEnabled_read;
263 static write_proc_t oplockEnabled_write;
264 static read_proc_t lookupFlag_read;
265 static write_proc_t lookupFlag_write;
266 static read_proc_t traceSMB_read;
267 static write_proc_t traceSMB_write;
268 static read_proc_t multiuser_mount_read;
269 static write_proc_t multiuser_mount_write;
270 static read_proc_t extended_security_read;
271 static write_proc_t extended_security_write;
272 static read_proc_t ntlmv2_enabled_read;
273 static write_proc_t ntlmv2_enabled_write;
274 static read_proc_t packet_signing_enabled_read;
275 static write_proc_t packet_signing_enabled_write;
276 static read_proc_t quotaEnabled_read;
277 static write_proc_t quotaEnabled_write;
278 static read_proc_t linuxExtensionsEnabled_read;
279 static write_proc_t linuxExtensionsEnabled_write;
284 struct proc_dir_entry *pde;
286 proc_fs_cifs = proc_mkdir("cifs", proc_root_fs);
287 if (proc_fs_cifs == NULL)
290 proc_fs_cifs->owner = THIS_MODULE;
291 create_proc_read_entry("DebugData", 0, proc_fs_cifs,
292 cifs_debug_data_read, 0);
294 create_proc_read_entry("SimultaneousOps", 0, proc_fs_cifs,
295 cifs_total_xid_read, 0);
296 #ifdef CONFIG_CIFS_STATS
297 create_proc_read_entry("Stats", 0, proc_fs_cifs,
300 pde = create_proc_read_entry("cifsFYI", 0, proc_fs_cifs,
303 pde->write_proc = cifsFYI_write;
306 create_proc_read_entry("traceSMB", 0, proc_fs_cifs,
309 pde->write_proc = traceSMB_write;
311 pde = create_proc_read_entry("OplockEnabled", 0, proc_fs_cifs,
312 oplockEnabled_read, 0);
314 pde->write_proc = oplockEnabled_write;
316 pde = create_proc_read_entry("QuotaEnabled", 0, proc_fs_cifs,
317 quotaEnabled_read, 0);
319 pde->write_proc = quotaEnabled_write;
321 pde = create_proc_read_entry("LinuxExtensionsEnabled", 0, proc_fs_cifs,
322 linuxExtensionsEnabled_read, 0);
324 pde->write_proc = linuxExtensionsEnabled_write;
327 create_proc_read_entry("MultiuserMount", 0, proc_fs_cifs,
328 multiuser_mount_read, 0);
330 pde->write_proc = multiuser_mount_write;
333 create_proc_read_entry("ExtendedSecurity", 0, proc_fs_cifs,
334 extended_security_read, 0);
336 pde->write_proc = extended_security_write;
339 create_proc_read_entry("LookupCacheEnabled", 0, proc_fs_cifs,
342 pde->write_proc = lookupFlag_write;
345 create_proc_read_entry("NTLMV2Enabled", 0, proc_fs_cifs,
346 ntlmv2_enabled_read, 0);
348 pde->write_proc = ntlmv2_enabled_write;
351 create_proc_read_entry("PacketSigningEnabled", 0, proc_fs_cifs,
352 packet_signing_enabled_read, 0);
354 pde->write_proc = packet_signing_enabled_write;
358 cifs_proc_clean(void)
360 if (proc_fs_cifs == NULL)
363 remove_proc_entry("DebugData", proc_fs_cifs);
364 remove_proc_entry("cifsFYI", proc_fs_cifs);
365 remove_proc_entry("traceSMB", proc_fs_cifs);
366 remove_proc_entry("SimultaneousOps", proc_fs_cifs);
367 #ifdef CONFIG_CIFS_STATS
368 remove_proc_entry("Stats", proc_fs_cifs);
370 remove_proc_entry("MultiuserMount", proc_fs_cifs);
371 remove_proc_entry("OplockEnabled", proc_fs_cifs);
372 remove_proc_entry("NTLMV2Enabled",proc_fs_cifs);
373 remove_proc_entry("ExtendedSecurity",proc_fs_cifs);
374 remove_proc_entry("PacketSigningEnabled",proc_fs_cifs);
375 remove_proc_entry("LinuxExtensionsEnabled",proc_fs_cifs);
376 remove_proc_entry("QuotaEnabled",proc_fs_cifs);
377 remove_proc_entry("LookupCacheEnabled",proc_fs_cifs);
378 remove_proc_entry("cifs", proc_root_fs);
382 cifsFYI_read(char *page, char **start, off_t off, int count,
383 int *eof, void *data)
387 len = sprintf(page, "%d\n", cifsFYI);
403 cifsFYI_write(struct file *file, const char __user *buffer,
404 unsigned long count, void *data)
409 rc = get_user(c, buffer);
412 if (c == '0' || c == 'n' || c == 'N')
414 else if (c == '1' || c == 'y' || c == 'Y')
421 oplockEnabled_read(char *page, char **start, off_t off,
422 int count, int *eof, void *data)
426 len = sprintf(page, "%d\n", oplockEnabled);
442 oplockEnabled_write(struct file *file, const char __user *buffer,
443 unsigned long count, void *data)
448 rc = get_user(c, buffer);
451 if (c == '0' || c == 'n' || c == 'N')
453 else if (c == '1' || c == 'y' || c == 'Y')
460 quotaEnabled_read(char *page, char **start, off_t off,
461 int count, int *eof, void *data)
465 len = sprintf(page, "%d\n", quotaEnabled);
466 /* could also check if quotas are enabled in kernel
482 quotaEnabled_write(struct file *file, const char __user *buffer,
483 unsigned long count, void *data)
488 rc = get_user(c, buffer);
491 if (c == '0' || c == 'n' || c == 'N')
493 else if (c == '1' || c == 'y' || c == 'Y')
500 linuxExtensionsEnabled_read(char *page, char **start, off_t off,
501 int count, int *eof, void *data)
505 len = sprintf(page, "%d\n", linuxExtEnabled);
506 /* could also check if quotas are enabled in kernel
522 linuxExtensionsEnabled_write(struct file *file, const char __user *buffer,
523 unsigned long count, void *data)
528 rc = get_user(c, buffer);
531 if (c == '0' || c == 'n' || c == 'N')
533 else if (c == '1' || c == 'y' || c == 'Y')
541 lookupFlag_read(char *page, char **start, off_t off,
542 int count, int *eof, void *data)
546 len = sprintf(page, "%d\n", lookupCacheEnabled);
562 lookupFlag_write(struct file *file, const char __user *buffer,
563 unsigned long count, void *data)
568 rc = get_user(c, buffer);
571 if (c == '0' || c == 'n' || c == 'N')
572 lookupCacheEnabled = 0;
573 else if (c == '1' || c == 'y' || c == 'Y')
574 lookupCacheEnabled = 1;
579 traceSMB_read(char *page, char **start, off_t off, int count,
580 int *eof, void *data)
584 len = sprintf(page, "%d\n", traceSMB);
600 traceSMB_write(struct file *file, const char __user *buffer,
601 unsigned long count, void *data)
606 rc = get_user(c, buffer);
609 if (c == '0' || c == 'n' || c == 'N')
611 else if (c == '1' || c == 'y' || c == 'Y')
618 multiuser_mount_read(char *page, char **start, off_t off,
619 int count, int *eof, void *data)
623 len = sprintf(page, "%d\n", multiuser_mount);
639 multiuser_mount_write(struct file *file, const char __user *buffer,
640 unsigned long count, void *data)
645 rc = get_user(c, buffer);
648 if (c == '0' || c == 'n' || c == 'N')
650 else if (c == '1' || c == 'y' || c == 'Y')
657 extended_security_read(char *page, char **start, off_t off,
658 int count, int *eof, void *data)
662 len = sprintf(page, "%d\n", extended_security);
678 extended_security_write(struct file *file, const char __user *buffer,
679 unsigned long count, void *data)
684 rc = get_user(c, buffer);
687 if (c == '0' || c == 'n' || c == 'N')
688 extended_security = 0;
689 else if (c == '1' || c == 'y' || c == 'Y')
690 extended_security = 1;
696 ntlmv2_enabled_read(char *page, char **start, off_t off,
697 int count, int *eof, void *data)
701 len = sprintf(page, "%d\n", ntlmv2_support);
717 ntlmv2_enabled_write(struct file *file, const char __user *buffer,
718 unsigned long count, void *data)
723 rc = get_user(c, buffer);
726 if (c == '0' || c == 'n' || c == 'N')
728 else if (c == '1' || c == 'y' || c == 'Y')
735 packet_signing_enabled_read(char *page, char **start, off_t off,
736 int count, int *eof, void *data)
740 len = sprintf(page, "%d\n", sign_CIFS_PDUs);
756 packet_signing_enabled_write(struct file *file, const char __user *buffer,
757 unsigned long count, void *data)
762 rc = get_user(c, buffer);
765 if (c == '0' || c == 'n' || c == 'N')
767 else if (c == '1' || c == 'y' || c == 'Y')