Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * fs/cifs_debug.c |
| 3 | * |
Steve French | b8643e1 | 2005-04-28 22:41:07 -0700 | [diff] [blame] | 4 | * Copyright (C) International Business Machines Corp., 2000,2005 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 10 | * the Free Software Foundation; either version 2 of the License, or |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | * (at your option) any later version. |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 12 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 19 | * along with this program; if not, write to the Free Software |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 French | 6c91d36 | 2005-04-28 22:41:06 -0700 | [diff] [blame] | 32 | #include "cifsfs.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 42 | printk(KERN_DEBUG "%s: dump of %d bytes of data at 0x%p\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 60 | #ifdef CONFIG_CIFS_DEBUG2 |
Steve French | ffdd6e4 | 2007-06-24 21:15:44 +0000 | [diff] [blame] | 61 | void cifs_dump_detail(struct smb_hdr *smb) |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 62 | { |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 63 | cERROR(1, ("Cmd: %d Err: 0x%x Flags: 0x%x Flgs2: 0x%x Mid: %d Pid: %d", |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 64 | smb->Command, smb->Status.CifsError, |
| 65 | smb->Flags, smb->Flags2, smb->Mid, smb->Pid)); |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 66 | cERROR(1, ("smb buf %p len %d", smb, smbCalcSize_LE(smb))); |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | |
Steve French | ffdd6e4 | 2007-06-24 21:15:44 +0000 | [diff] [blame] | 70 | void cifs_dump_mids(struct TCP_Server_Info *server) |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 71 | { |
| 72 | struct list_head *tmp; |
Steve French | ffdd6e4 | 2007-06-24 21:15:44 +0000 | [diff] [blame] | 73 | struct mid_q_entry *mid_entry; |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 74 | |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 75 | if (server == NULL) |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 76 | return; |
| 77 | |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 78 | cERROR(1, ("Dump pending requests:")); |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 79 | spin_lock(&GlobalMid_Lock); |
| 80 | list_for_each(tmp, &server->pending_mid_q) { |
| 81 | mid_entry = list_entry(tmp, struct mid_q_entry, qhead); |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 82 | if (mid_entry) { |
| 83 | cERROR(1, ("State: %d Cmd: %d Pid: %d Tsk: %p Mid %d", |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 84 | mid_entry->midState, |
| 85 | (int)mid_entry->command, |
| 86 | mid_entry->pid, |
| 87 | mid_entry->tsk, |
| 88 | mid_entry->mid)); |
| 89 | #ifdef CONFIG_CIFS_STATS2 |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 90 | cERROR(1, ("IsLarge: %d buf: %p time rcv: %ld now: %ld", |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 91 | mid_entry->largeBuf, |
| 92 | mid_entry->resp_buf, |
| 93 | mid_entry->when_received, |
| 94 | jiffies)); |
| 95 | #endif /* STATS2 */ |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 96 | cERROR(1, ("IsMult: %d IsEnd: %d", mid_entry->multiRsp, |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 97 | mid_entry->multiEnd)); |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 98 | if (mid_entry->resp_buf) { |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 99 | cifs_dump_detail(mid_entry->resp_buf); |
| 100 | cifs_dump_mem("existing buf: ", |
Steve French | ad7a292 | 2008-02-07 23:25:02 +0000 | [diff] [blame] | 101 | mid_entry->resp_buf, 62); |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 102 | } |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 103 | } |
| 104 | } |
| 105 | spin_unlock(&GlobalMid_Lock); |
| 106 | } |
| 107 | #endif /* CONFIG_CIFS_DEBUG2 */ |
| 108 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | #ifdef CONFIG_PROC_FS |
| 110 | static int |
| 111 | cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset, |
| 112 | int count, int *eof, void *data) |
| 113 | { |
| 114 | struct list_head *tmp; |
| 115 | struct list_head *tmp1; |
Steve French | ffdd6e4 | 2007-06-24 21:15:44 +0000 | [diff] [blame] | 116 | struct mid_q_entry *mid_entry; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | struct cifsSesInfo *ses; |
| 118 | struct cifsTconInfo *tcon; |
| 119 | int i; |
| 120 | int length = 0; |
Steve French | ffdd6e4 | 2007-06-24 21:15:44 +0000 | [diff] [blame] | 121 | char *original_buf = buf; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | |
| 123 | *beginBuffer = buf + offset; |
| 124 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | length = |
| 126 | sprintf(buf, |
| 127 | "Display Internal CIFS Data Structures for Debugging\n" |
| 128 | "---------------------------------------------------\n"); |
| 129 | buf += length; |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 130 | length = sprintf(buf, "CIFS Version %s\n", CIFS_VERSION); |
Steve French | 6c91d36 | 2005-04-28 22:41:06 -0700 | [diff] [blame] | 131 | buf += length; |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 132 | length = sprintf(buf, |
| 133 | "Active VFS Requests: %d\n", GlobalTotalActiveXid); |
Steve French | 131afd0b | 2005-10-07 09:51:05 -0700 | [diff] [blame] | 134 | buf += length; |
Steve French | 6c91d36 | 2005-04-28 22:41:06 -0700 | [diff] [blame] | 135 | length = sprintf(buf, "Servers:"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | buf += length; |
| 137 | |
| 138 | i = 0; |
| 139 | read_lock(&GlobalSMBSeslock); |
| 140 | list_for_each(tmp, &GlobalSMBSessionList) { |
| 141 | i++; |
| 142 | ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList); |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 143 | if ((ses->serverDomain == NULL) || (ses->serverOS == NULL) || |
Steve French | 433dc24 | 2005-04-28 22:41:08 -0700 | [diff] [blame] | 144 | (ses->serverNOS == NULL)) { |
Steve French | bd2abf1 | 2007-01-21 23:19:01 +0000 | [diff] [blame] | 145 | buf += sprintf(buf, "\nentry for %s not fully " |
| 146 | "displayed\n\t", ses->serverName); |
Steve French | 433dc24 | 2005-04-28 22:41:08 -0700 | [diff] [blame] | 147 | } else { |
| 148 | length = |
| 149 | sprintf(buf, |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 150 | "\n%d) Name: %s Domain: %s Mounts: %d OS:" |
| 151 | " %s \n\tNOS: %s\tCapability: 0x%x\n\tSMB" |
| 152 | " session status: %d\t", |
Steve French | b8643e1 | 2005-04-28 22:41:07 -0700 | [diff] [blame] | 153 | i, ses->serverName, ses->serverDomain, |
| 154 | atomic_read(&ses->inUse), |
| 155 | ses->serverOS, ses->serverNOS, |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 156 | ses->capabilities, ses->status); |
Steve French | 433dc24 | 2005-04-28 22:41:08 -0700 | [diff] [blame] | 157 | buf += length; |
| 158 | } |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 159 | if (ses->server) { |
| 160 | buf += sprintf(buf, "TCP status: %d\n\tLocal Users To " |
| 161 | "Server: %d SecMode: 0x%x Req On Wire: %d", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | ses->server->tcpStatus, |
| 163 | atomic_read(&ses->server->socketUseCount), |
| 164 | ses->server->secMode, |
| 165 | atomic_read(&ses->server->inFlight)); |
Steve French | 131afd0b | 2005-10-07 09:51:05 -0700 | [diff] [blame] | 166 | |
| 167 | #ifdef CONFIG_CIFS_STATS2 |
Steve French | 68058e7 | 2005-10-10 10:34:22 -0700 | [diff] [blame] | 168 | buf += sprintf(buf, " In Send: %d In MaxReq Wait: %d", |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 169 | atomic_read(&ses->server->inSend), |
Steve French | 131afd0b | 2005-10-07 09:51:05 -0700 | [diff] [blame] | 170 | atomic_read(&ses->server->num_waiters)); |
| 171 | #endif |
| 172 | |
Steve French | 6c91d36 | 2005-04-28 22:41:06 -0700 | [diff] [blame] | 173 | length = sprintf(buf, "\nMIDs:\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | buf += length; |
| 175 | |
| 176 | spin_lock(&GlobalMid_Lock); |
| 177 | list_for_each(tmp1, &ses->server->pending_mid_q) { |
| 178 | mid_entry = list_entry(tmp1, struct |
| 179 | mid_q_entry, |
| 180 | qhead); |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 181 | if (mid_entry) { |
| 182 | length = sprintf(buf, |
| 183 | "State: %d com: %d pid:" |
| 184 | " %d tsk: %p mid %d\n", |
| 185 | mid_entry->midState, |
| 186 | (int)mid_entry->command, |
| 187 | mid_entry->pid, |
| 188 | mid_entry->tsk, |
| 189 | mid_entry->mid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | buf += length; |
| 191 | } |
| 192 | } |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 193 | spin_unlock(&GlobalMid_Lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | } |
| 195 | |
| 196 | } |
| 197 | read_unlock(&GlobalSMBSeslock); |
| 198 | sprintf(buf, "\n"); |
| 199 | buf++; |
| 200 | |
Steve French | 6c91d36 | 2005-04-28 22:41:06 -0700 | [diff] [blame] | 201 | length = sprintf(buf, "Shares:"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | buf += length; |
| 203 | |
| 204 | i = 0; |
| 205 | read_lock(&GlobalSMBSeslock); |
| 206 | list_for_each(tmp, &GlobalTreeConnectionList) { |
| 207 | __u32 dev_type; |
| 208 | i++; |
| 209 | tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); |
| 210 | dev_type = le32_to_cpu(tcon->fsDevInfo.DeviceType); |
Steve French | 88f370a | 2007-09-15 03:01:17 +0000 | [diff] [blame] | 211 | length = sprintf(buf, "\n%d) %s Uses: %d ", i, |
| 212 | tcon->treeName, atomic_read(&tcon->useCount)); |
| 213 | buf += length; |
| 214 | if (tcon->nativeFileSystem) { |
Steve French | a23d306 | 2007-09-15 03:43:47 +0000 | [diff] [blame] | 215 | length = sprintf(buf, "Type: %s ", |
| 216 | tcon->nativeFileSystem); |
Steve French | 88f370a | 2007-09-15 03:01:17 +0000 | [diff] [blame] | 217 | buf += length; |
| 218 | } |
| 219 | length = sprintf(buf, "DevInfo: 0x%x Attributes: 0x%x" |
| 220 | "\nPathComponentMax: %d Status: %d", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | le32_to_cpu(tcon->fsDevInfo.DeviceCharacteristics), |
| 222 | le32_to_cpu(tcon->fsAttrInfo.Attributes), |
| 223 | le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength), |
| 224 | tcon->tidStatus); |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 225 | buf += length; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | if (dev_type == FILE_DEVICE_DISK) |
| 227 | length = sprintf(buf, " type: DISK "); |
| 228 | else if (dev_type == FILE_DEVICE_CD_ROM) |
| 229 | length = sprintf(buf, " type: CDROM "); |
| 230 | else |
| 231 | length = |
| 232 | sprintf(buf, " type: %d ", dev_type); |
| 233 | buf += length; |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 234 | if (tcon->tidStatus == CifsNeedReconnect) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | buf += sprintf(buf, "\tDISCONNECTED "); |
| 236 | length += 14; |
| 237 | } |
| 238 | } |
| 239 | read_unlock(&GlobalSMBSeslock); |
| 240 | |
| 241 | length = sprintf(buf, "\n"); |
| 242 | buf += length; |
| 243 | |
| 244 | /* BB add code to dump additional info such as TCP session info now */ |
| 245 | /* Now calculate total size of returned data */ |
| 246 | length = buf - original_buf; |
| 247 | |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 248 | if (offset + count >= length) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 249 | *eof = 1; |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 250 | if (length < offset) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 251 | *eof = 1; |
| 252 | return 0; |
| 253 | } else { |
| 254 | length = length - offset; |
| 255 | } |
| 256 | if (length > count) |
| 257 | length = count; |
| 258 | |
| 259 | return length; |
| 260 | } |
| 261 | |
| 262 | #ifdef CONFIG_CIFS_STATS |
Steve French | 1047abc | 2005-10-11 19:58:06 -0700 | [diff] [blame] | 263 | |
| 264 | static int |
| 265 | cifs_stats_write(struct file *file, const char __user *buffer, |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 266 | unsigned long count, void *data) |
Steve French | 1047abc | 2005-10-11 19:58:06 -0700 | [diff] [blame] | 267 | { |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 268 | char c; |
| 269 | int rc; |
Steve French | 1047abc | 2005-10-11 19:58:06 -0700 | [diff] [blame] | 270 | struct list_head *tmp; |
| 271 | struct cifsTconInfo *tcon; |
| 272 | |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 273 | rc = get_user(c, buffer); |
| 274 | if (rc) |
| 275 | return rc; |
Steve French | 1047abc | 2005-10-11 19:58:06 -0700 | [diff] [blame] | 276 | |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 277 | if (c == '1' || c == 'y' || c == 'Y' || c == '0') { |
Steve French | 1047abc | 2005-10-11 19:58:06 -0700 | [diff] [blame] | 278 | read_lock(&GlobalSMBSeslock); |
Steve French | 4498eed5 | 2005-12-03 13:58:57 -0800 | [diff] [blame] | 279 | #ifdef CONFIG_CIFS_STATS2 |
| 280 | atomic_set(&totBufAllocCount, 0); |
| 281 | atomic_set(&totSmBufAllocCount, 0); |
| 282 | #endif /* CONFIG_CIFS_STATS2 */ |
Steve French | 1047abc | 2005-10-11 19:58:06 -0700 | [diff] [blame] | 283 | list_for_each(tmp, &GlobalTreeConnectionList) { |
| 284 | tcon = list_entry(tmp, struct cifsTconInfo, |
| 285 | cifsConnectionList); |
| 286 | atomic_set(&tcon->num_smbs_sent, 0); |
| 287 | atomic_set(&tcon->num_writes, 0); |
| 288 | atomic_set(&tcon->num_reads, 0); |
| 289 | atomic_set(&tcon->num_oplock_brks, 0); |
| 290 | atomic_set(&tcon->num_opens, 0); |
| 291 | atomic_set(&tcon->num_closes, 0); |
| 292 | atomic_set(&tcon->num_deletes, 0); |
| 293 | atomic_set(&tcon->num_mkdirs, 0); |
| 294 | atomic_set(&tcon->num_rmdirs, 0); |
| 295 | atomic_set(&tcon->num_renames, 0); |
| 296 | atomic_set(&tcon->num_t2renames, 0); |
| 297 | atomic_set(&tcon->num_ffirst, 0); |
| 298 | atomic_set(&tcon->num_fnext, 0); |
| 299 | atomic_set(&tcon->num_fclose, 0); |
| 300 | atomic_set(&tcon->num_hardlinks, 0); |
| 301 | atomic_set(&tcon->num_symlinks, 0); |
| 302 | atomic_set(&tcon->num_locks, 0); |
| 303 | } |
| 304 | read_unlock(&GlobalSMBSeslock); |
| 305 | } |
| 306 | |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 307 | return count; |
Steve French | 1047abc | 2005-10-11 19:58:06 -0700 | [diff] [blame] | 308 | } |
| 309 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | static int |
| 311 | cifs_stats_read(char *buf, char **beginBuffer, off_t offset, |
| 312 | int count, int *eof, void *data) |
| 313 | { |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 314 | int item_length, i, length; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | struct list_head *tmp; |
| 316 | struct cifsTconInfo *tcon; |
| 317 | |
| 318 | *beginBuffer = buf + offset; |
| 319 | |
| 320 | length = sprintf(buf, |
| 321 | "Resources in use\nCIFS Session: %d\n", |
| 322 | sesInfoAllocCount.counter); |
| 323 | buf += length; |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 324 | item_length = |
| 325 | sprintf(buf, "Share (unique mount targets): %d\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | tconInfoAllocCount.counter); |
| 327 | length += item_length; |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 328 | buf += item_length; |
| 329 | item_length = |
| 330 | sprintf(buf, "SMB Request/Response Buffer: %d Pool size: %d\n", |
Steve French | b8643e1 | 2005-04-28 22:41:07 -0700 | [diff] [blame] | 331 | bufAllocCount.counter, |
| 332 | cifs_min_rcv + tcpSesAllocCount.counter); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | length += item_length; |
| 334 | buf += item_length; |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 335 | item_length = |
| 336 | sprintf(buf, "SMB Small Req/Resp Buffer: %d Pool size: %d\n", |
| 337 | smBufAllocCount.counter, cifs_min_small); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | length += item_length; |
| 339 | buf += item_length; |
Steve French | 07475ff | 2005-12-03 14:11:37 -0800 | [diff] [blame] | 340 | #ifdef CONFIG_CIFS_STATS2 |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 341 | item_length = sprintf(buf, "Total Large %d Small %d Allocations\n", |
Steve French | 07475ff | 2005-12-03 14:11:37 -0800 | [diff] [blame] | 342 | atomic_read(&totBufAllocCount), |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 343 | atomic_read(&totSmBufAllocCount)); |
Steve French | 07475ff | 2005-12-03 14:11:37 -0800 | [diff] [blame] | 344 | length += item_length; |
| 345 | buf += item_length; |
| 346 | #endif /* CONFIG_CIFS_STATS2 */ |
| 347 | |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 348 | item_length = |
| 349 | sprintf(buf, "Operations (MIDs): %d\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | midCount.counter); |
| 351 | length += item_length; |
| 352 | buf += item_length; |
| 353 | item_length = sprintf(buf, |
| 354 | "\n%d session %d share reconnects\n", |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 355 | tcpSesReconnectCount.counter, tconInfoReconnectCount.counter); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 356 | length += item_length; |
| 357 | buf += item_length; |
| 358 | |
| 359 | item_length = sprintf(buf, |
| 360 | "Total vfs operations: %d maximum at one time: %d\n", |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 361 | GlobalCurrentXid, GlobalMaxActiveXid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 362 | length += item_length; |
| 363 | buf += item_length; |
| 364 | |
| 365 | i = 0; |
| 366 | read_lock(&GlobalSMBSeslock); |
| 367 | list_for_each(tmp, &GlobalTreeConnectionList) { |
| 368 | i++; |
| 369 | tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 370 | item_length = sprintf(buf, "\n%d) %s", i, tcon->treeName); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 371 | buf += item_length; |
| 372 | length += item_length; |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 373 | if (tcon->tidStatus == CifsNeedReconnect) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 374 | buf += sprintf(buf, "\tDISCONNECTED "); |
| 375 | length += 14; |
| 376 | } |
Steve French | a5a2b48 | 2005-08-20 21:42:53 -0700 | [diff] [blame] | 377 | item_length = sprintf(buf, "\nSMBs: %d Oplock Breaks: %d", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | atomic_read(&tcon->num_smbs_sent), |
| 379 | atomic_read(&tcon->num_oplock_brks)); |
| 380 | buf += item_length; |
| 381 | length += item_length; |
Steve French | 0ae0efa | 2005-10-10 10:57:19 -0700 | [diff] [blame] | 382 | item_length = sprintf(buf, "\nReads: %d Bytes: %lld", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 383 | atomic_read(&tcon->num_reads), |
| 384 | (long long)(tcon->bytes_read)); |
| 385 | buf += item_length; |
| 386 | length += item_length; |
Steve French | a5a2b48 | 2005-08-20 21:42:53 -0700 | [diff] [blame] | 387 | item_length = sprintf(buf, "\nWrites: %d Bytes: %lld", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 388 | atomic_read(&tcon->num_writes), |
| 389 | (long long)(tcon->bytes_written)); |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 390 | buf += item_length; |
| 391 | length += item_length; |
| 392 | item_length = sprintf(buf, |
Steve French | a5a2b48 | 2005-08-20 21:42:53 -0700 | [diff] [blame] | 393 | "\nLocks: %d HardLinks: %d Symlinks: %d", |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 394 | atomic_read(&tcon->num_locks), |
Steve French | a5a2b48 | 2005-08-20 21:42:53 -0700 | [diff] [blame] | 395 | atomic_read(&tcon->num_hardlinks), |
| 396 | atomic_read(&tcon->num_symlinks)); |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 397 | buf += item_length; |
| 398 | length += item_length; |
Steve French | a5a2b48 | 2005-08-20 21:42:53 -0700 | [diff] [blame] | 399 | |
| 400 | item_length = sprintf(buf, "\nOpens: %d Closes: %d Deletes: %d", |
| 401 | atomic_read(&tcon->num_opens), |
| 402 | atomic_read(&tcon->num_closes), |
| 403 | atomic_read(&tcon->num_deletes)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 404 | buf += item_length; |
| 405 | length += item_length; |
Steve French | a5a2b48 | 2005-08-20 21:42:53 -0700 | [diff] [blame] | 406 | item_length = sprintf(buf, "\nMkdirs: %d Rmdirs: %d", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 407 | atomic_read(&tcon->num_mkdirs), |
| 408 | atomic_read(&tcon->num_rmdirs)); |
| 409 | buf += item_length; |
| 410 | length += item_length; |
Steve French | a5a2b48 | 2005-08-20 21:42:53 -0700 | [diff] [blame] | 411 | item_length = sprintf(buf, "\nRenames: %d T2 Renames %d", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 412 | atomic_read(&tcon->num_renames), |
| 413 | atomic_read(&tcon->num_t2renames)); |
| 414 | buf += item_length; |
| 415 | length += item_length; |
Steve French | a5a2b48 | 2005-08-20 21:42:53 -0700 | [diff] [blame] | 416 | item_length = sprintf(buf, "\nFindFirst: %d FNext %d FClose %d", |
Steve French | 0c0ff09 | 2005-06-23 19:31:17 -0500 | [diff] [blame] | 417 | atomic_read(&tcon->num_ffirst), |
| 418 | atomic_read(&tcon->num_fnext), |
| 419 | atomic_read(&tcon->num_fclose)); |
| 420 | buf += item_length; |
| 421 | length += item_length; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 422 | } |
| 423 | read_unlock(&GlobalSMBSeslock); |
| 424 | |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 425 | buf += sprintf(buf, "\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | length++; |
| 427 | |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 428 | if (offset + count >= length) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 429 | *eof = 1; |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 430 | if (length < offset) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 431 | *eof = 1; |
| 432 | return 0; |
| 433 | } else { |
| 434 | length = length - offset; |
| 435 | } |
| 436 | if (length > count) |
| 437 | length = count; |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 438 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 439 | return length; |
| 440 | } |
Steve French | 90c81e0 | 2008-02-12 20:32:36 +0000 | [diff] [blame] | 441 | #endif /* STATS */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 442 | |
| 443 | static struct proc_dir_entry *proc_fs_cifs; |
| 444 | read_proc_t cifs_txanchor_read; |
| 445 | static read_proc_t cifsFYI_read; |
| 446 | static write_proc_t cifsFYI_write; |
| 447 | static read_proc_t oplockEnabled_read; |
| 448 | static write_proc_t oplockEnabled_write; |
| 449 | static read_proc_t lookupFlag_read; |
| 450 | static write_proc_t lookupFlag_write; |
| 451 | static read_proc_t traceSMB_read; |
| 452 | static write_proc_t traceSMB_write; |
| 453 | static read_proc_t multiuser_mount_read; |
| 454 | static write_proc_t multiuser_mount_write; |
Steve French | bdc4bf6e | 2006-06-02 22:57:13 +0000 | [diff] [blame] | 455 | static read_proc_t security_flags_read; |
| 456 | static write_proc_t security_flags_write; |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 457 | /* static read_proc_t ntlmv2_enabled_read; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 458 | static write_proc_t ntlmv2_enabled_write; |
| 459 | static read_proc_t packet_signing_enabled_read; |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 460 | static write_proc_t packet_signing_enabled_write;*/ |
Steve French | ec637e3 | 2005-12-12 20:53:18 -0800 | [diff] [blame] | 461 | static read_proc_t experimEnabled_read; |
| 462 | static write_proc_t experimEnabled_write; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 463 | static read_proc_t linuxExtensionsEnabled_read; |
| 464 | static write_proc_t linuxExtensionsEnabled_write; |
| 465 | |
| 466 | void |
| 467 | cifs_proc_init(void) |
| 468 | { |
| 469 | struct proc_dir_entry *pde; |
| 470 | |
| 471 | proc_fs_cifs = proc_mkdir("cifs", proc_root_fs); |
| 472 | if (proc_fs_cifs == NULL) |
| 473 | return; |
| 474 | |
| 475 | proc_fs_cifs->owner = THIS_MODULE; |
| 476 | create_proc_read_entry("DebugData", 0, proc_fs_cifs, |
| 477 | cifs_debug_data_read, NULL); |
| 478 | |
| 479 | #ifdef CONFIG_CIFS_STATS |
Steve French | 1047abc | 2005-10-11 19:58:06 -0700 | [diff] [blame] | 480 | pde = create_proc_read_entry("Stats", 0, proc_fs_cifs, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 481 | cifs_stats_read, NULL); |
Steve French | 1047abc | 2005-10-11 19:58:06 -0700 | [diff] [blame] | 482 | if (pde) |
| 483 | pde->write_proc = cifs_stats_write; |
Steve French | 90c81e0 | 2008-02-12 20:32:36 +0000 | [diff] [blame] | 484 | #endif /* STATS */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 485 | pde = create_proc_read_entry("cifsFYI", 0, proc_fs_cifs, |
| 486 | cifsFYI_read, NULL); |
| 487 | if (pde) |
| 488 | pde->write_proc = cifsFYI_write; |
| 489 | |
| 490 | pde = |
| 491 | create_proc_read_entry("traceSMB", 0, proc_fs_cifs, |
| 492 | traceSMB_read, NULL); |
| 493 | if (pde) |
| 494 | pde->write_proc = traceSMB_write; |
| 495 | |
| 496 | pde = create_proc_read_entry("OplockEnabled", 0, proc_fs_cifs, |
| 497 | oplockEnabled_read, NULL); |
| 498 | if (pde) |
| 499 | pde->write_proc = oplockEnabled_write; |
| 500 | |
Steve French | 0c0ff09 | 2005-06-23 19:31:17 -0500 | [diff] [blame] | 501 | pde = create_proc_read_entry("Experimental", 0, proc_fs_cifs, |
Steve French | ec637e3 | 2005-12-12 20:53:18 -0800 | [diff] [blame] | 502 | experimEnabled_read, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 503 | if (pde) |
Steve French | ec637e3 | 2005-12-12 20:53:18 -0800 | [diff] [blame] | 504 | pde->write_proc = experimEnabled_write; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 505 | |
| 506 | pde = create_proc_read_entry("LinuxExtensionsEnabled", 0, proc_fs_cifs, |
| 507 | linuxExtensionsEnabled_read, NULL); |
| 508 | if (pde) |
| 509 | pde->write_proc = linuxExtensionsEnabled_write; |
| 510 | |
| 511 | pde = |
| 512 | create_proc_read_entry("MultiuserMount", 0, proc_fs_cifs, |
| 513 | multiuser_mount_read, NULL); |
| 514 | if (pde) |
| 515 | pde->write_proc = multiuser_mount_write; |
| 516 | |
| 517 | pde = |
Steve French | 7c7b25b | 2006-06-01 19:20:10 +0000 | [diff] [blame] | 518 | create_proc_read_entry("SecurityFlags", 0, proc_fs_cifs, |
Steve French | bdc4bf6e | 2006-06-02 22:57:13 +0000 | [diff] [blame] | 519 | security_flags_read, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 520 | if (pde) |
Steve French | bdc4bf6e | 2006-06-02 22:57:13 +0000 | [diff] [blame] | 521 | pde->write_proc = security_flags_write; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 522 | |
| 523 | pde = |
| 524 | create_proc_read_entry("LookupCacheEnabled", 0, proc_fs_cifs, |
| 525 | lookupFlag_read, NULL); |
| 526 | if (pde) |
| 527 | pde->write_proc = lookupFlag_write; |
| 528 | |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 529 | /* pde = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 530 | create_proc_read_entry("NTLMV2Enabled", 0, proc_fs_cifs, |
| 531 | ntlmv2_enabled_read, NULL); |
| 532 | if (pde) |
| 533 | pde->write_proc = ntlmv2_enabled_write; |
| 534 | |
| 535 | pde = |
| 536 | create_proc_read_entry("PacketSigningEnabled", 0, proc_fs_cifs, |
| 537 | packet_signing_enabled_read, NULL); |
| 538 | if (pde) |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 539 | pde->write_proc = packet_signing_enabled_write;*/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 540 | } |
| 541 | |
| 542 | void |
| 543 | cifs_proc_clean(void) |
| 544 | { |
| 545 | if (proc_fs_cifs == NULL) |
| 546 | return; |
| 547 | |
| 548 | remove_proc_entry("DebugData", proc_fs_cifs); |
| 549 | remove_proc_entry("cifsFYI", proc_fs_cifs); |
| 550 | remove_proc_entry("traceSMB", proc_fs_cifs); |
| 551 | #ifdef CONFIG_CIFS_STATS |
| 552 | remove_proc_entry("Stats", proc_fs_cifs); |
| 553 | #endif |
| 554 | remove_proc_entry("MultiuserMount", proc_fs_cifs); |
| 555 | remove_proc_entry("OplockEnabled", proc_fs_cifs); |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 556 | /* remove_proc_entry("NTLMV2Enabled",proc_fs_cifs); */ |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 557 | remove_proc_entry("SecurityFlags", proc_fs_cifs); |
| 558 | /* remove_proc_entry("PacketSigningEnabled", proc_fs_cifs); */ |
| 559 | remove_proc_entry("LinuxExtensionsEnabled", proc_fs_cifs); |
| 560 | remove_proc_entry("Experimental", proc_fs_cifs); |
| 561 | remove_proc_entry("LookupCacheEnabled", proc_fs_cifs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 562 | remove_proc_entry("cifs", proc_root_fs); |
| 563 | } |
| 564 | |
| 565 | static int |
| 566 | cifsFYI_read(char *page, char **start, off_t off, int count, |
| 567 | int *eof, void *data) |
| 568 | { |
| 569 | int len; |
| 570 | |
| 571 | len = sprintf(page, "%d\n", cifsFYI); |
| 572 | |
| 573 | len -= off; |
| 574 | *start = page + off; |
| 575 | |
| 576 | if (len > count) |
| 577 | len = count; |
| 578 | else |
| 579 | *eof = 1; |
| 580 | |
| 581 | if (len < 0) |
| 582 | len = 0; |
| 583 | |
| 584 | return len; |
| 585 | } |
| 586 | static int |
| 587 | cifsFYI_write(struct file *file, const char __user *buffer, |
| 588 | unsigned long count, void *data) |
| 589 | { |
| 590 | char c; |
| 591 | int rc; |
| 592 | |
| 593 | rc = get_user(c, buffer); |
| 594 | if (rc) |
| 595 | return rc; |
| 596 | if (c == '0' || c == 'n' || c == 'N') |
| 597 | cifsFYI = 0; |
| 598 | else if (c == '1' || c == 'y' || c == 'Y') |
| 599 | cifsFYI = 1; |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 600 | else if ((c > '1') && (c <= '9')) |
Steve French | 1047abc | 2005-10-11 19:58:06 -0700 | [diff] [blame] | 601 | cifsFYI = (int) (c - '0'); /* see cifs_debug.h for meanings */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 602 | |
| 603 | return count; |
| 604 | } |
| 605 | |
| 606 | static int |
| 607 | oplockEnabled_read(char *page, char **start, off_t off, |
| 608 | int count, int *eof, void *data) |
| 609 | { |
| 610 | int len; |
| 611 | |
| 612 | len = sprintf(page, "%d\n", oplockEnabled); |
| 613 | |
| 614 | len -= off; |
| 615 | *start = page + off; |
| 616 | |
| 617 | if (len > count) |
| 618 | len = count; |
| 619 | else |
| 620 | *eof = 1; |
| 621 | |
| 622 | if (len < 0) |
| 623 | len = 0; |
| 624 | |
| 625 | return len; |
| 626 | } |
| 627 | static int |
| 628 | oplockEnabled_write(struct file *file, const char __user *buffer, |
| 629 | unsigned long count, void *data) |
| 630 | { |
| 631 | char c; |
| 632 | int rc; |
| 633 | |
| 634 | rc = get_user(c, buffer); |
| 635 | if (rc) |
| 636 | return rc; |
| 637 | if (c == '0' || c == 'n' || c == 'N') |
| 638 | oplockEnabled = 0; |
| 639 | else if (c == '1' || c == 'y' || c == 'Y') |
| 640 | oplockEnabled = 1; |
| 641 | |
| 642 | return count; |
| 643 | } |
| 644 | |
| 645 | static int |
Steve French | ec637e3 | 2005-12-12 20:53:18 -0800 | [diff] [blame] | 646 | experimEnabled_read(char *page, char **start, off_t off, |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 647 | int count, int *eof, void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 648 | { |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 649 | int len; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 650 | |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 651 | len = sprintf(page, "%d\n", experimEnabled); |
Steve French | ec637e3 | 2005-12-12 20:53:18 -0800 | [diff] [blame] | 652 | |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 653 | len -= off; |
| 654 | *start = page + off; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 655 | |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 656 | if (len > count) |
| 657 | len = count; |
| 658 | else |
| 659 | *eof = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 660 | |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 661 | if (len < 0) |
| 662 | len = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 663 | |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 664 | return len; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 665 | } |
| 666 | static int |
Steve French | ec637e3 | 2005-12-12 20:53:18 -0800 | [diff] [blame] | 667 | experimEnabled_write(struct file *file, const char __user *buffer, |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 668 | unsigned long count, void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 669 | { |
Steve French | ec637e3 | 2005-12-12 20:53:18 -0800 | [diff] [blame] | 670 | char c; |
| 671 | int rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 672 | |
Steve French | ec637e3 | 2005-12-12 20:53:18 -0800 | [diff] [blame] | 673 | rc = get_user(c, buffer); |
| 674 | if (rc) |
| 675 | return rc; |
| 676 | if (c == '0' || c == 'n' || c == 'N') |
| 677 | experimEnabled = 0; |
| 678 | else if (c == '1' || c == 'y' || c == 'Y') |
| 679 | experimEnabled = 1; |
| 680 | else if (c == '2') |
| 681 | experimEnabled = 2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 682 | |
Steve French | ec637e3 | 2005-12-12 20:53:18 -0800 | [diff] [blame] | 683 | return count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 684 | } |
| 685 | |
| 686 | static int |
| 687 | linuxExtensionsEnabled_read(char *page, char **start, off_t off, |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 688 | int count, int *eof, void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 689 | { |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 690 | int len; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 691 | |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 692 | len = sprintf(page, "%d\n", linuxExtEnabled); |
| 693 | len -= off; |
| 694 | *start = page + off; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 695 | |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 696 | if (len > count) |
| 697 | len = count; |
| 698 | else |
| 699 | *eof = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 700 | |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 701 | if (len < 0) |
| 702 | len = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 703 | |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 704 | return len; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 705 | } |
| 706 | static int |
| 707 | linuxExtensionsEnabled_write(struct file *file, const char __user *buffer, |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 708 | unsigned long count, void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 709 | { |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 710 | char c; |
| 711 | int rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 712 | |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 713 | rc = get_user(c, buffer); |
| 714 | if (rc) |
| 715 | return rc; |
| 716 | if (c == '0' || c == 'n' || c == 'N') |
| 717 | linuxExtEnabled = 0; |
| 718 | else if (c == '1' || c == 'y' || c == 'Y') |
| 719 | linuxExtEnabled = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 720 | |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 721 | return count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 722 | } |
| 723 | |
| 724 | |
| 725 | static int |
| 726 | lookupFlag_read(char *page, char **start, off_t off, |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 727 | int count, int *eof, void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 728 | { |
| 729 | int len; |
| 730 | |
| 731 | len = sprintf(page, "%d\n", lookupCacheEnabled); |
| 732 | |
| 733 | len -= off; |
| 734 | *start = page + off; |
| 735 | |
| 736 | if (len > count) |
| 737 | len = count; |
| 738 | else |
| 739 | *eof = 1; |
| 740 | |
| 741 | if (len < 0) |
| 742 | len = 0; |
| 743 | |
| 744 | return len; |
| 745 | } |
| 746 | static int |
| 747 | lookupFlag_write(struct file *file, const char __user *buffer, |
| 748 | unsigned long count, void *data) |
| 749 | { |
| 750 | char c; |
| 751 | int rc; |
| 752 | |
| 753 | rc = get_user(c, buffer); |
| 754 | if (rc) |
| 755 | return rc; |
| 756 | if (c == '0' || c == 'n' || c == 'N') |
| 757 | lookupCacheEnabled = 0; |
| 758 | else if (c == '1' || c == 'y' || c == 'Y') |
| 759 | lookupCacheEnabled = 1; |
| 760 | |
| 761 | return count; |
| 762 | } |
| 763 | static int |
| 764 | traceSMB_read(char *page, char **start, off_t off, int count, |
| 765 | int *eof, void *data) |
| 766 | { |
| 767 | int len; |
| 768 | |
| 769 | len = sprintf(page, "%d\n", traceSMB); |
| 770 | |
| 771 | len -= off; |
| 772 | *start = page + off; |
| 773 | |
| 774 | if (len > count) |
| 775 | len = count; |
| 776 | else |
| 777 | *eof = 1; |
| 778 | |
| 779 | if (len < 0) |
| 780 | len = 0; |
| 781 | |
| 782 | return len; |
| 783 | } |
| 784 | static int |
| 785 | traceSMB_write(struct file *file, const char __user *buffer, |
| 786 | unsigned long count, void *data) |
| 787 | { |
| 788 | char c; |
| 789 | int rc; |
| 790 | |
| 791 | rc = get_user(c, buffer); |
| 792 | if (rc) |
| 793 | return rc; |
| 794 | if (c == '0' || c == 'n' || c == 'N') |
| 795 | traceSMB = 0; |
| 796 | else if (c == '1' || c == 'y' || c == 'Y') |
| 797 | traceSMB = 1; |
| 798 | |
| 799 | return count; |
| 800 | } |
| 801 | |
| 802 | static int |
| 803 | multiuser_mount_read(char *page, char **start, off_t off, |
| 804 | int count, int *eof, void *data) |
| 805 | { |
| 806 | int len; |
| 807 | |
| 808 | len = sprintf(page, "%d\n", multiuser_mount); |
| 809 | |
| 810 | len -= off; |
| 811 | *start = page + off; |
| 812 | |
| 813 | if (len > count) |
| 814 | len = count; |
| 815 | else |
| 816 | *eof = 1; |
| 817 | |
| 818 | if (len < 0) |
| 819 | len = 0; |
| 820 | |
| 821 | return len; |
| 822 | } |
| 823 | static int |
| 824 | multiuser_mount_write(struct file *file, const char __user *buffer, |
| 825 | unsigned long count, void *data) |
| 826 | { |
| 827 | char c; |
| 828 | int rc; |
| 829 | |
| 830 | rc = get_user(c, buffer); |
| 831 | if (rc) |
| 832 | return rc; |
| 833 | if (c == '0' || c == 'n' || c == 'N') |
| 834 | multiuser_mount = 0; |
| 835 | else if (c == '1' || c == 'y' || c == 'Y') |
| 836 | multiuser_mount = 1; |
| 837 | |
| 838 | return count; |
| 839 | } |
| 840 | |
| 841 | static int |
Steve French | bdc4bf6e | 2006-06-02 22:57:13 +0000 | [diff] [blame] | 842 | security_flags_read(char *page, char **start, off_t off, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 843 | int count, int *eof, void *data) |
| 844 | { |
| 845 | int len; |
| 846 | |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 847 | len = sprintf(page, "0x%x\n", extended_security); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 848 | |
| 849 | len -= off; |
| 850 | *start = page + off; |
| 851 | |
| 852 | if (len > count) |
| 853 | len = count; |
| 854 | else |
| 855 | *eof = 1; |
| 856 | |
| 857 | if (len < 0) |
| 858 | len = 0; |
| 859 | |
| 860 | return len; |
| 861 | } |
| 862 | static int |
Steve French | bdc4bf6e | 2006-06-02 22:57:13 +0000 | [diff] [blame] | 863 | security_flags_write(struct file *file, const char __user *buffer, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 864 | unsigned long count, void *data) |
| 865 | { |
Steve French | bdc4bf6e | 2006-06-02 22:57:13 +0000 | [diff] [blame] | 866 | unsigned int flags; |
| 867 | char flags_string[12]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 868 | char c; |
Steve French | bdc4bf6e | 2006-06-02 22:57:13 +0000 | [diff] [blame] | 869 | |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 870 | if ((count < 1) || (count > 11)) |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 871 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 872 | |
Steve French | bdc4bf6e | 2006-06-02 22:57:13 +0000 | [diff] [blame] | 873 | memset(flags_string, 0, 12); |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 874 | |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 875 | if (copy_from_user(flags_string, buffer, count)) |
Steve French | bdc4bf6e | 2006-06-02 22:57:13 +0000 | [diff] [blame] | 876 | return -EFAULT; |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 877 | |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 878 | if (count < 3) { |
Steve French | bdc4bf6e | 2006-06-02 22:57:13 +0000 | [diff] [blame] | 879 | /* single char or single char followed by null */ |
| 880 | c = flags_string[0]; |
Steve French | a013689 | 2007-10-04 20:05:09 +0000 | [diff] [blame] | 881 | if (c == '0' || c == 'n' || c == 'N') { |
Steve French | bdc4bf6e | 2006-06-02 22:57:13 +0000 | [diff] [blame] | 882 | extended_security = CIFSSEC_DEF; /* default */ |
Steve French | a013689 | 2007-10-04 20:05:09 +0000 | [diff] [blame] | 883 | return count; |
| 884 | } else if (c == '1' || c == 'y' || c == 'Y') { |
Steve French | bdc4bf6e | 2006-06-02 22:57:13 +0000 | [diff] [blame] | 885 | extended_security = CIFSSEC_MAX; |
Steve French | a013689 | 2007-10-04 20:05:09 +0000 | [diff] [blame] | 886 | return count; |
| 887 | } else if (!isdigit(c)) { |
| 888 | cERROR(1, ("invalid flag %c", c)); |
| 889 | return -EINVAL; |
| 890 | } |
Steve French | bdc4bf6e | 2006-06-02 22:57:13 +0000 | [diff] [blame] | 891 | } |
| 892 | /* else we have a number */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 893 | |
Steve French | bdc4bf6e | 2006-06-02 22:57:13 +0000 | [diff] [blame] | 894 | flags = simple_strtoul(flags_string, NULL, 0); |
| 895 | |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 896 | cFYI(1, ("sec flags 0x%x", flags)); |
Steve French | bdc4bf6e | 2006-06-02 22:57:13 +0000 | [diff] [blame] | 897 | |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 898 | if (flags <= 0) { |
| 899 | cERROR(1, ("invalid security flags %s", flags_string)); |
Steve French | bdc4bf6e | 2006-06-02 22:57:13 +0000 | [diff] [blame] | 900 | return -EINVAL; |
| 901 | } |
| 902 | |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 903 | if (flags & ~CIFSSEC_MASK) { |
| 904 | cERROR(1, ("attempt to set unsupported security flags 0x%x", |
Steve French | bdc4bf6e | 2006-06-02 22:57:13 +0000 | [diff] [blame] | 905 | flags & ~CIFSSEC_MASK)); |
| 906 | return -EINVAL; |
| 907 | } |
| 908 | /* flags look ok - update the global security flags for cifs module */ |
| 909 | extended_security = flags; |
Steve French | 762e5ab | 2007-06-28 18:41:42 +0000 | [diff] [blame] | 910 | if (extended_security & CIFSSEC_MUST_SIGN) { |
| 911 | /* requiring signing implies signing is allowed */ |
| 912 | extended_security |= CIFSSEC_MAY_SIGN; |
| 913 | cFYI(1, ("packet signing now required")); |
| 914 | } else if ((extended_security & CIFSSEC_MAY_SIGN) == 0) { |
| 915 | cFYI(1, ("packet signing disabled")); |
| 916 | } |
| 917 | /* BB should we turn on MAY flags for other MUST options? */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 918 | return count; |
| 919 | } |
Steve French | 90c81e0 | 2008-02-12 20:32:36 +0000 | [diff] [blame] | 920 | #else |
Steve French | e086fce | 2008-02-18 04:03:58 +0000 | [diff] [blame] | 921 | inline void cifs_proc_init(void) |
Steve French | 90c81e0 | 2008-02-12 20:32:36 +0000 | [diff] [blame] | 922 | { |
| 923 | } |
| 924 | |
Steve French | e086fce | 2008-02-18 04:03:58 +0000 | [diff] [blame] | 925 | inline void cifs_proc_clean(void) |
Steve French | 90c81e0 | 2008-02-12 20:32:36 +0000 | [diff] [blame] | 926 | { |
| 927 | } |
| 928 | #endif /* PROC_FS */ |