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 |
| 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 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 | |
| 42 | printk(KERN_DEBUG "%s: dump of %d bytes of data at 0x%p\n\n", |
| 43 | label, length, data); |
| 44 | for (i = 0; i < length; i += 16) { |
| 45 | line[0] = 0; |
| 46 | for (j = 0; (j < 4) && (i + j * 4 < length); j++) { |
| 47 | sprintf(buf, " %08x", intptr[i / 4 + j]); |
| 48 | strcat(line, buf); |
| 49 | } |
| 50 | buf[0] = ' '; |
| 51 | buf[2] = 0; |
| 52 | for (j = 0; (j < 16) && (i + j < length); j++) { |
| 53 | buf[1] = isprint(charptr[i + j]) ? charptr[i + j] : '.'; |
| 54 | strcat(line, buf); |
| 55 | } |
| 56 | printk(KERN_DEBUG "%s\n", line); |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | #ifdef CONFIG_PROC_FS |
| 61 | static int |
| 62 | cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset, |
| 63 | int count, int *eof, void *data) |
| 64 | { |
| 65 | struct list_head *tmp; |
| 66 | struct list_head *tmp1; |
| 67 | struct mid_q_entry * mid_entry; |
| 68 | struct cifsSesInfo *ses; |
| 69 | struct cifsTconInfo *tcon; |
| 70 | int i; |
| 71 | int length = 0; |
| 72 | char * original_buf = buf; |
| 73 | |
| 74 | *beginBuffer = buf + offset; |
| 75 | |
| 76 | |
| 77 | length = |
| 78 | sprintf(buf, |
| 79 | "Display Internal CIFS Data Structures for Debugging\n" |
| 80 | "---------------------------------------------------\n"); |
| 81 | buf += length; |
Steve French | 6c91d36 | 2005-04-28 22:41:06 -0700 | [diff] [blame] | 82 | length = sprintf(buf,"CIFS Version %s\n",CIFS_VERSION); |
| 83 | buf += length; |
| 84 | length = sprintf(buf, "Servers:"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | buf += length; |
| 86 | |
| 87 | i = 0; |
| 88 | read_lock(&GlobalSMBSeslock); |
| 89 | list_for_each(tmp, &GlobalSMBSessionList) { |
| 90 | i++; |
| 91 | ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList); |
Steve French | 433dc24 | 2005-04-28 22:41:08 -0700 | [diff] [blame] | 92 | if((ses->serverDomain == NULL) || (ses->serverOS == NULL) || |
| 93 | (ses->serverNOS == NULL)) { |
| 94 | buf += sprintf("\nentry for %s not fully displayed\n\t", |
| 95 | ses->serverName); |
| 96 | |
| 97 | } else { |
| 98 | length = |
| 99 | sprintf(buf, |
| 100 | "\n%d) Name: %s Domain: %s Mounts: %d ServerOS: %s \n\tServerNOS: %s\tCapabilities: 0x%x\n\tSMB session status: %d\t", |
Steve French | b8643e1 | 2005-04-28 22:41:07 -0700 | [diff] [blame] | 101 | i, ses->serverName, ses->serverDomain, |
| 102 | atomic_read(&ses->inUse), |
| 103 | ses->serverOS, ses->serverNOS, |
| 104 | ses->capabilities,ses->status); |
Steve French | 433dc24 | 2005-04-28 22:41:08 -0700 | [diff] [blame] | 105 | buf += length; |
| 106 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | if(ses->server) { |
| 108 | buf += sprintf(buf, "TCP status: %d\n\tLocal Users To Server: %d SecMode: 0x%x Req Active: %d", |
| 109 | ses->server->tcpStatus, |
| 110 | atomic_read(&ses->server->socketUseCount), |
| 111 | ses->server->secMode, |
| 112 | atomic_read(&ses->server->inFlight)); |
| 113 | |
Steve French | 6c91d36 | 2005-04-28 22:41:06 -0700 | [diff] [blame] | 114 | length = sprintf(buf, "\nMIDs:\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | buf += length; |
| 116 | |
| 117 | spin_lock(&GlobalMid_Lock); |
| 118 | list_for_each(tmp1, &ses->server->pending_mid_q) { |
| 119 | mid_entry = list_entry(tmp1, struct |
| 120 | mid_q_entry, |
| 121 | qhead); |
| 122 | if(mid_entry) { |
Steve French | 848f3fc | 2005-04-28 22:41:07 -0700 | [diff] [blame] | 123 | length = sprintf(buf,"State: %d com: %d pid: %d tsk: %p mid %d\n", |
| 124 | mid_entry->midState, |
| 125 | (int)mid_entry->command, |
| 126 | mid_entry->pid, |
| 127 | mid_entry->tsk, |
| 128 | mid_entry->mid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | buf += length; |
| 130 | } |
| 131 | } |
| 132 | spin_unlock(&GlobalMid_Lock); |
| 133 | } |
| 134 | |
| 135 | } |
| 136 | read_unlock(&GlobalSMBSeslock); |
| 137 | sprintf(buf, "\n"); |
| 138 | buf++; |
| 139 | |
Steve French | 6c91d36 | 2005-04-28 22:41:06 -0700 | [diff] [blame] | 140 | length = sprintf(buf, "Shares:"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | buf += length; |
| 142 | |
| 143 | i = 0; |
| 144 | read_lock(&GlobalSMBSeslock); |
| 145 | list_for_each(tmp, &GlobalTreeConnectionList) { |
| 146 | __u32 dev_type; |
| 147 | i++; |
| 148 | tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); |
| 149 | dev_type = le32_to_cpu(tcon->fsDevInfo.DeviceType); |
| 150 | length = |
| 151 | sprintf(buf, |
| 152 | "\n%d) %s Uses: %d Type: %s Characteristics: 0x%x Attributes: 0x%x\nPathComponentMax: %d Status: %d", |
| 153 | i, tcon->treeName, |
| 154 | atomic_read(&tcon->useCount), |
| 155 | tcon->nativeFileSystem, |
| 156 | le32_to_cpu(tcon->fsDevInfo.DeviceCharacteristics), |
| 157 | le32_to_cpu(tcon->fsAttrInfo.Attributes), |
| 158 | le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength), |
| 159 | tcon->tidStatus); |
| 160 | buf += length; |
| 161 | if (dev_type == FILE_DEVICE_DISK) |
| 162 | length = sprintf(buf, " type: DISK "); |
| 163 | else if (dev_type == FILE_DEVICE_CD_ROM) |
| 164 | length = sprintf(buf, " type: CDROM "); |
| 165 | else |
| 166 | length = |
| 167 | sprintf(buf, " type: %d ", dev_type); |
| 168 | buf += length; |
| 169 | if(tcon->tidStatus == CifsNeedReconnect) { |
| 170 | buf += sprintf(buf, "\tDISCONNECTED "); |
| 171 | length += 14; |
| 172 | } |
| 173 | } |
| 174 | read_unlock(&GlobalSMBSeslock); |
| 175 | |
| 176 | length = sprintf(buf, "\n"); |
| 177 | buf += length; |
| 178 | |
| 179 | /* BB add code to dump additional info such as TCP session info now */ |
| 180 | /* Now calculate total size of returned data */ |
| 181 | length = buf - original_buf; |
| 182 | |
| 183 | if(offset + count >= length) |
| 184 | *eof = 1; |
| 185 | if(length < offset) { |
| 186 | *eof = 1; |
| 187 | return 0; |
| 188 | } else { |
| 189 | length = length - offset; |
| 190 | } |
| 191 | if (length > count) |
| 192 | length = count; |
| 193 | |
| 194 | return length; |
| 195 | } |
| 196 | |
| 197 | #ifdef CONFIG_CIFS_STATS |
| 198 | static int |
| 199 | cifs_stats_read(char *buf, char **beginBuffer, off_t offset, |
| 200 | int count, int *eof, void *data) |
| 201 | { |
| 202 | int item_length,i,length; |
| 203 | struct list_head *tmp; |
| 204 | struct cifsTconInfo *tcon; |
| 205 | |
| 206 | *beginBuffer = buf + offset; |
| 207 | |
| 208 | length = sprintf(buf, |
| 209 | "Resources in use\nCIFS Session: %d\n", |
| 210 | sesInfoAllocCount.counter); |
| 211 | buf += length; |
| 212 | item_length = |
| 213 | sprintf(buf,"Share (unique mount targets): %d\n", |
| 214 | tconInfoAllocCount.counter); |
| 215 | length += item_length; |
| 216 | buf += item_length; |
| 217 | item_length = |
| 218 | sprintf(buf,"SMB Request/Response Buffer: %d Pool size: %d\n", |
Steve French | b8643e1 | 2005-04-28 22:41:07 -0700 | [diff] [blame] | 219 | bufAllocCount.counter, |
| 220 | cifs_min_rcv + tcpSesAllocCount.counter); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | length += item_length; |
| 222 | buf += item_length; |
| 223 | item_length = |
| 224 | sprintf(buf,"SMB Small Req/Resp Buffer: %d Pool size: %d\n", |
| 225 | smBufAllocCount.counter,cifs_min_small); |
| 226 | length += item_length; |
| 227 | buf += item_length; |
| 228 | item_length = |
| 229 | sprintf(buf,"Operations (MIDs): %d\n", |
| 230 | midCount.counter); |
| 231 | length += item_length; |
| 232 | buf += item_length; |
| 233 | item_length = sprintf(buf, |
| 234 | "\n%d session %d share reconnects\n", |
| 235 | tcpSesReconnectCount.counter,tconInfoReconnectCount.counter); |
| 236 | length += item_length; |
| 237 | buf += item_length; |
| 238 | |
| 239 | item_length = sprintf(buf, |
| 240 | "Total vfs operations: %d maximum at one time: %d\n", |
| 241 | GlobalCurrentXid,GlobalMaxActiveXid); |
| 242 | length += item_length; |
| 243 | buf += item_length; |
| 244 | |
| 245 | i = 0; |
| 246 | read_lock(&GlobalSMBSeslock); |
| 247 | list_for_each(tmp, &GlobalTreeConnectionList) { |
| 248 | i++; |
| 249 | tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); |
| 250 | item_length = sprintf(buf,"\n%d) %s",i, tcon->treeName); |
| 251 | buf += item_length; |
| 252 | length += item_length; |
| 253 | if(tcon->tidStatus == CifsNeedReconnect) { |
| 254 | buf += sprintf(buf, "\tDISCONNECTED "); |
| 255 | length += 14; |
| 256 | } |
| 257 | item_length = sprintf(buf,"\nSMBs: %d Oplock Breaks: %d", |
| 258 | atomic_read(&tcon->num_smbs_sent), |
| 259 | atomic_read(&tcon->num_oplock_brks)); |
| 260 | buf += item_length; |
| 261 | length += item_length; |
| 262 | item_length = sprintf(buf,"\nReads: %d Bytes %lld", |
| 263 | atomic_read(&tcon->num_reads), |
| 264 | (long long)(tcon->bytes_read)); |
| 265 | buf += item_length; |
| 266 | length += item_length; |
| 267 | item_length = sprintf(buf,"\nWrites: %d Bytes: %lld", |
| 268 | atomic_read(&tcon->num_writes), |
| 269 | (long long)(tcon->bytes_written)); |
| 270 | buf += item_length; |
| 271 | length += item_length; |
| 272 | item_length = sprintf(buf, |
| 273 | "\nOpens: %d Deletes: %d\nMkdirs: %d Rmdirs: %d", |
| 274 | atomic_read(&tcon->num_opens), |
| 275 | atomic_read(&tcon->num_deletes), |
| 276 | atomic_read(&tcon->num_mkdirs), |
| 277 | atomic_read(&tcon->num_rmdirs)); |
| 278 | buf += item_length; |
| 279 | length += item_length; |
| 280 | item_length = sprintf(buf, |
| 281 | "\nRenames: %d T2 Renames %d", |
| 282 | atomic_read(&tcon->num_renames), |
| 283 | atomic_read(&tcon->num_t2renames)); |
| 284 | buf += item_length; |
| 285 | length += item_length; |
| 286 | } |
| 287 | read_unlock(&GlobalSMBSeslock); |
| 288 | |
| 289 | buf += sprintf(buf,"\n"); |
| 290 | length++; |
| 291 | |
| 292 | if(offset + count >= length) |
| 293 | *eof = 1; |
| 294 | if(length < offset) { |
| 295 | *eof = 1; |
| 296 | return 0; |
| 297 | } else { |
| 298 | length = length - offset; |
| 299 | } |
| 300 | if (length > count) |
| 301 | length = count; |
| 302 | |
| 303 | return length; |
| 304 | } |
| 305 | #endif |
| 306 | |
| 307 | static struct proc_dir_entry *proc_fs_cifs; |
| 308 | read_proc_t cifs_txanchor_read; |
| 309 | static read_proc_t cifsFYI_read; |
| 310 | static write_proc_t cifsFYI_write; |
| 311 | static read_proc_t oplockEnabled_read; |
| 312 | static write_proc_t oplockEnabled_write; |
| 313 | static read_proc_t lookupFlag_read; |
| 314 | static write_proc_t lookupFlag_write; |
| 315 | static read_proc_t traceSMB_read; |
| 316 | static write_proc_t traceSMB_write; |
| 317 | static read_proc_t multiuser_mount_read; |
| 318 | static write_proc_t multiuser_mount_write; |
| 319 | static read_proc_t extended_security_read; |
| 320 | static write_proc_t extended_security_write; |
| 321 | static read_proc_t ntlmv2_enabled_read; |
| 322 | static write_proc_t ntlmv2_enabled_write; |
| 323 | static read_proc_t packet_signing_enabled_read; |
| 324 | static write_proc_t packet_signing_enabled_write; |
| 325 | static read_proc_t quotaEnabled_read; |
| 326 | static write_proc_t quotaEnabled_write; |
| 327 | static read_proc_t linuxExtensionsEnabled_read; |
| 328 | static write_proc_t linuxExtensionsEnabled_write; |
| 329 | |
| 330 | void |
| 331 | cifs_proc_init(void) |
| 332 | { |
| 333 | struct proc_dir_entry *pde; |
| 334 | |
| 335 | proc_fs_cifs = proc_mkdir("cifs", proc_root_fs); |
| 336 | if (proc_fs_cifs == NULL) |
| 337 | return; |
| 338 | |
| 339 | proc_fs_cifs->owner = THIS_MODULE; |
| 340 | create_proc_read_entry("DebugData", 0, proc_fs_cifs, |
| 341 | cifs_debug_data_read, NULL); |
| 342 | |
| 343 | #ifdef CONFIG_CIFS_STATS |
| 344 | create_proc_read_entry("Stats", 0, proc_fs_cifs, |
| 345 | cifs_stats_read, NULL); |
| 346 | #endif |
| 347 | pde = create_proc_read_entry("cifsFYI", 0, proc_fs_cifs, |
| 348 | cifsFYI_read, NULL); |
| 349 | if (pde) |
| 350 | pde->write_proc = cifsFYI_write; |
| 351 | |
| 352 | pde = |
| 353 | create_proc_read_entry("traceSMB", 0, proc_fs_cifs, |
| 354 | traceSMB_read, NULL); |
| 355 | if (pde) |
| 356 | pde->write_proc = traceSMB_write; |
| 357 | |
| 358 | pde = create_proc_read_entry("OplockEnabled", 0, proc_fs_cifs, |
| 359 | oplockEnabled_read, NULL); |
| 360 | if (pde) |
| 361 | pde->write_proc = oplockEnabled_write; |
| 362 | |
| 363 | pde = create_proc_read_entry("ReenableOldCifsReaddirCode", 0, proc_fs_cifs, |
| 364 | quotaEnabled_read, NULL); |
| 365 | if (pde) |
| 366 | pde->write_proc = quotaEnabled_write; |
| 367 | |
| 368 | pde = create_proc_read_entry("LinuxExtensionsEnabled", 0, proc_fs_cifs, |
| 369 | linuxExtensionsEnabled_read, NULL); |
| 370 | if (pde) |
| 371 | pde->write_proc = linuxExtensionsEnabled_write; |
| 372 | |
| 373 | pde = |
| 374 | create_proc_read_entry("MultiuserMount", 0, proc_fs_cifs, |
| 375 | multiuser_mount_read, NULL); |
| 376 | if (pde) |
| 377 | pde->write_proc = multiuser_mount_write; |
| 378 | |
| 379 | pde = |
| 380 | create_proc_read_entry("ExtendedSecurity", 0, proc_fs_cifs, |
| 381 | extended_security_read, NULL); |
| 382 | if (pde) |
| 383 | pde->write_proc = extended_security_write; |
| 384 | |
| 385 | pde = |
| 386 | create_proc_read_entry("LookupCacheEnabled", 0, proc_fs_cifs, |
| 387 | lookupFlag_read, NULL); |
| 388 | if (pde) |
| 389 | pde->write_proc = lookupFlag_write; |
| 390 | |
| 391 | pde = |
| 392 | create_proc_read_entry("NTLMV2Enabled", 0, proc_fs_cifs, |
| 393 | ntlmv2_enabled_read, NULL); |
| 394 | if (pde) |
| 395 | pde->write_proc = ntlmv2_enabled_write; |
| 396 | |
| 397 | pde = |
| 398 | create_proc_read_entry("PacketSigningEnabled", 0, proc_fs_cifs, |
| 399 | packet_signing_enabled_read, NULL); |
| 400 | if (pde) |
| 401 | pde->write_proc = packet_signing_enabled_write; |
| 402 | } |
| 403 | |
| 404 | void |
| 405 | cifs_proc_clean(void) |
| 406 | { |
| 407 | if (proc_fs_cifs == NULL) |
| 408 | return; |
| 409 | |
| 410 | remove_proc_entry("DebugData", proc_fs_cifs); |
| 411 | remove_proc_entry("cifsFYI", proc_fs_cifs); |
| 412 | remove_proc_entry("traceSMB", proc_fs_cifs); |
| 413 | #ifdef CONFIG_CIFS_STATS |
| 414 | remove_proc_entry("Stats", proc_fs_cifs); |
| 415 | #endif |
| 416 | remove_proc_entry("MultiuserMount", proc_fs_cifs); |
| 417 | remove_proc_entry("OplockEnabled", proc_fs_cifs); |
| 418 | remove_proc_entry("NTLMV2Enabled",proc_fs_cifs); |
| 419 | remove_proc_entry("ExtendedSecurity",proc_fs_cifs); |
| 420 | remove_proc_entry("PacketSigningEnabled",proc_fs_cifs); |
| 421 | remove_proc_entry("LinuxExtensionsEnabled",proc_fs_cifs); |
| 422 | remove_proc_entry("ReenableOldCifsReaddirCode",proc_fs_cifs); |
| 423 | remove_proc_entry("LookupCacheEnabled",proc_fs_cifs); |
| 424 | remove_proc_entry("cifs", proc_root_fs); |
| 425 | } |
| 426 | |
| 427 | static int |
| 428 | cifsFYI_read(char *page, char **start, off_t off, int count, |
| 429 | int *eof, void *data) |
| 430 | { |
| 431 | int len; |
| 432 | |
| 433 | len = sprintf(page, "%d\n", cifsFYI); |
| 434 | |
| 435 | len -= off; |
| 436 | *start = page + off; |
| 437 | |
| 438 | if (len > count) |
| 439 | len = count; |
| 440 | else |
| 441 | *eof = 1; |
| 442 | |
| 443 | if (len < 0) |
| 444 | len = 0; |
| 445 | |
| 446 | return len; |
| 447 | } |
| 448 | static int |
| 449 | cifsFYI_write(struct file *file, const char __user *buffer, |
| 450 | unsigned long count, void *data) |
| 451 | { |
| 452 | char c; |
| 453 | int rc; |
| 454 | |
| 455 | rc = get_user(c, buffer); |
| 456 | if (rc) |
| 457 | return rc; |
| 458 | if (c == '0' || c == 'n' || c == 'N') |
| 459 | cifsFYI = 0; |
| 460 | else if (c == '1' || c == 'y' || c == 'Y') |
| 461 | cifsFYI = 1; |
| 462 | |
| 463 | return count; |
| 464 | } |
| 465 | |
| 466 | static int |
| 467 | oplockEnabled_read(char *page, char **start, off_t off, |
| 468 | int count, int *eof, void *data) |
| 469 | { |
| 470 | int len; |
| 471 | |
| 472 | len = sprintf(page, "%d\n", oplockEnabled); |
| 473 | |
| 474 | len -= off; |
| 475 | *start = page + off; |
| 476 | |
| 477 | if (len > count) |
| 478 | len = count; |
| 479 | else |
| 480 | *eof = 1; |
| 481 | |
| 482 | if (len < 0) |
| 483 | len = 0; |
| 484 | |
| 485 | return len; |
| 486 | } |
| 487 | static int |
| 488 | oplockEnabled_write(struct file *file, const char __user *buffer, |
| 489 | unsigned long count, void *data) |
| 490 | { |
| 491 | char c; |
| 492 | int rc; |
| 493 | |
| 494 | rc = get_user(c, buffer); |
| 495 | if (rc) |
| 496 | return rc; |
| 497 | if (c == '0' || c == 'n' || c == 'N') |
| 498 | oplockEnabled = 0; |
| 499 | else if (c == '1' || c == 'y' || c == 'Y') |
| 500 | oplockEnabled = 1; |
| 501 | |
| 502 | return count; |
| 503 | } |
| 504 | |
| 505 | static int |
| 506 | quotaEnabled_read(char *page, char **start, off_t off, |
| 507 | int count, int *eof, void *data) |
| 508 | { |
| 509 | int len; |
| 510 | |
| 511 | len = sprintf(page, "%d\n", experimEnabled); |
| 512 | /* could also check if quotas are enabled in kernel |
| 513 | as a whole first */ |
| 514 | len -= off; |
| 515 | *start = page + off; |
| 516 | |
| 517 | if (len > count) |
| 518 | len = count; |
| 519 | else |
| 520 | *eof = 1; |
| 521 | |
| 522 | if (len < 0) |
| 523 | len = 0; |
| 524 | |
| 525 | return len; |
| 526 | } |
| 527 | static int |
| 528 | quotaEnabled_write(struct file *file, const char __user *buffer, |
| 529 | unsigned long count, void *data) |
| 530 | { |
| 531 | char c; |
| 532 | int rc; |
| 533 | |
| 534 | rc = get_user(c, buffer); |
| 535 | if (rc) |
| 536 | return rc; |
| 537 | if (c == '0' || c == 'n' || c == 'N') |
| 538 | experimEnabled = 0; |
| 539 | else if (c == '1' || c == 'y' || c == 'Y') |
| 540 | experimEnabled = 1; |
| 541 | |
| 542 | return count; |
| 543 | } |
| 544 | |
| 545 | static int |
| 546 | linuxExtensionsEnabled_read(char *page, char **start, off_t off, |
| 547 | int count, int *eof, void *data) |
| 548 | { |
| 549 | int len; |
| 550 | |
| 551 | len = sprintf(page, "%d\n", linuxExtEnabled); |
| 552 | /* could also check if quotas are enabled in kernel |
| 553 | as a whole first */ |
| 554 | len -= off; |
| 555 | *start = page + off; |
| 556 | |
| 557 | if (len > count) |
| 558 | len = count; |
| 559 | else |
| 560 | *eof = 1; |
| 561 | |
| 562 | if (len < 0) |
| 563 | len = 0; |
| 564 | |
| 565 | return len; |
| 566 | } |
| 567 | static int |
| 568 | linuxExtensionsEnabled_write(struct file *file, const char __user *buffer, |
| 569 | unsigned long count, void *data) |
| 570 | { |
| 571 | char c; |
| 572 | int rc; |
| 573 | |
| 574 | rc = get_user(c, buffer); |
| 575 | if (rc) |
| 576 | return rc; |
| 577 | if (c == '0' || c == 'n' || c == 'N') |
| 578 | linuxExtEnabled = 0; |
| 579 | else if (c == '1' || c == 'y' || c == 'Y') |
| 580 | linuxExtEnabled = 1; |
| 581 | |
| 582 | return count; |
| 583 | } |
| 584 | |
| 585 | |
| 586 | static int |
| 587 | lookupFlag_read(char *page, char **start, off_t off, |
| 588 | int count, int *eof, void *data) |
| 589 | { |
| 590 | int len; |
| 591 | |
| 592 | len = sprintf(page, "%d\n", lookupCacheEnabled); |
| 593 | |
| 594 | len -= off; |
| 595 | *start = page + off; |
| 596 | |
| 597 | if (len > count) |
| 598 | len = count; |
| 599 | else |
| 600 | *eof = 1; |
| 601 | |
| 602 | if (len < 0) |
| 603 | len = 0; |
| 604 | |
| 605 | return len; |
| 606 | } |
| 607 | static int |
| 608 | lookupFlag_write(struct file *file, const char __user *buffer, |
| 609 | unsigned long count, void *data) |
| 610 | { |
| 611 | char c; |
| 612 | int rc; |
| 613 | |
| 614 | rc = get_user(c, buffer); |
| 615 | if (rc) |
| 616 | return rc; |
| 617 | if (c == '0' || c == 'n' || c == 'N') |
| 618 | lookupCacheEnabled = 0; |
| 619 | else if (c == '1' || c == 'y' || c == 'Y') |
| 620 | lookupCacheEnabled = 1; |
| 621 | |
| 622 | return count; |
| 623 | } |
| 624 | static int |
| 625 | traceSMB_read(char *page, char **start, off_t off, int count, |
| 626 | int *eof, void *data) |
| 627 | { |
| 628 | int len; |
| 629 | |
| 630 | len = sprintf(page, "%d\n", traceSMB); |
| 631 | |
| 632 | len -= off; |
| 633 | *start = page + off; |
| 634 | |
| 635 | if (len > count) |
| 636 | len = count; |
| 637 | else |
| 638 | *eof = 1; |
| 639 | |
| 640 | if (len < 0) |
| 641 | len = 0; |
| 642 | |
| 643 | return len; |
| 644 | } |
| 645 | static int |
| 646 | traceSMB_write(struct file *file, const char __user *buffer, |
| 647 | unsigned long count, void *data) |
| 648 | { |
| 649 | char c; |
| 650 | int rc; |
| 651 | |
| 652 | rc = get_user(c, buffer); |
| 653 | if (rc) |
| 654 | return rc; |
| 655 | if (c == '0' || c == 'n' || c == 'N') |
| 656 | traceSMB = 0; |
| 657 | else if (c == '1' || c == 'y' || c == 'Y') |
| 658 | traceSMB = 1; |
| 659 | |
| 660 | return count; |
| 661 | } |
| 662 | |
| 663 | static int |
| 664 | multiuser_mount_read(char *page, char **start, off_t off, |
| 665 | int count, int *eof, void *data) |
| 666 | { |
| 667 | int len; |
| 668 | |
| 669 | len = sprintf(page, "%d\n", multiuser_mount); |
| 670 | |
| 671 | len -= off; |
| 672 | *start = page + off; |
| 673 | |
| 674 | if (len > count) |
| 675 | len = count; |
| 676 | else |
| 677 | *eof = 1; |
| 678 | |
| 679 | if (len < 0) |
| 680 | len = 0; |
| 681 | |
| 682 | return len; |
| 683 | } |
| 684 | static int |
| 685 | multiuser_mount_write(struct file *file, const char __user *buffer, |
| 686 | unsigned long count, void *data) |
| 687 | { |
| 688 | char c; |
| 689 | int rc; |
| 690 | |
| 691 | rc = get_user(c, buffer); |
| 692 | if (rc) |
| 693 | return rc; |
| 694 | if (c == '0' || c == 'n' || c == 'N') |
| 695 | multiuser_mount = 0; |
| 696 | else if (c == '1' || c == 'y' || c == 'Y') |
| 697 | multiuser_mount = 1; |
| 698 | |
| 699 | return count; |
| 700 | } |
| 701 | |
| 702 | static int |
| 703 | extended_security_read(char *page, char **start, off_t off, |
| 704 | int count, int *eof, void *data) |
| 705 | { |
| 706 | int len; |
| 707 | |
| 708 | len = sprintf(page, "%d\n", extended_security); |
| 709 | |
| 710 | len -= off; |
| 711 | *start = page + off; |
| 712 | |
| 713 | if (len > count) |
| 714 | len = count; |
| 715 | else |
| 716 | *eof = 1; |
| 717 | |
| 718 | if (len < 0) |
| 719 | len = 0; |
| 720 | |
| 721 | return len; |
| 722 | } |
| 723 | static int |
| 724 | extended_security_write(struct file *file, const char __user *buffer, |
| 725 | unsigned long count, void *data) |
| 726 | { |
| 727 | char c; |
| 728 | int rc; |
| 729 | |
| 730 | rc = get_user(c, buffer); |
| 731 | if (rc) |
| 732 | return rc; |
| 733 | if (c == '0' || c == 'n' || c == 'N') |
| 734 | extended_security = 0; |
| 735 | else if (c == '1' || c == 'y' || c == 'Y') |
| 736 | extended_security = 1; |
| 737 | |
| 738 | return count; |
| 739 | } |
| 740 | |
| 741 | static int |
| 742 | ntlmv2_enabled_read(char *page, char **start, off_t off, |
| 743 | int count, int *eof, void *data) |
| 744 | { |
| 745 | int len; |
| 746 | |
| 747 | len = sprintf(page, "%d\n", ntlmv2_support); |
| 748 | |
| 749 | len -= off; |
| 750 | *start = page + off; |
| 751 | |
| 752 | if (len > count) |
| 753 | len = count; |
| 754 | else |
| 755 | *eof = 1; |
| 756 | |
| 757 | if (len < 0) |
| 758 | len = 0; |
| 759 | |
| 760 | return len; |
| 761 | } |
| 762 | static int |
| 763 | ntlmv2_enabled_write(struct file *file, const char __user *buffer, |
| 764 | unsigned long count, void *data) |
| 765 | { |
| 766 | char c; |
| 767 | int rc; |
| 768 | |
| 769 | rc = get_user(c, buffer); |
| 770 | if (rc) |
| 771 | return rc; |
| 772 | if (c == '0' || c == 'n' || c == 'N') |
| 773 | ntlmv2_support = 0; |
| 774 | else if (c == '1' || c == 'y' || c == 'Y') |
| 775 | ntlmv2_support = 1; |
| 776 | |
| 777 | return count; |
| 778 | } |
| 779 | |
| 780 | static int |
| 781 | packet_signing_enabled_read(char *page, char **start, off_t off, |
| 782 | int count, int *eof, void *data) |
| 783 | { |
| 784 | int len; |
| 785 | |
| 786 | len = sprintf(page, "%d\n", sign_CIFS_PDUs); |
| 787 | |
| 788 | len -= off; |
| 789 | *start = page + off; |
| 790 | |
| 791 | if (len > count) |
| 792 | len = count; |
| 793 | else |
| 794 | *eof = 1; |
| 795 | |
| 796 | if (len < 0) |
| 797 | len = 0; |
| 798 | |
| 799 | return len; |
| 800 | } |
| 801 | static int |
| 802 | packet_signing_enabled_write(struct file *file, const char __user *buffer, |
| 803 | unsigned long count, void *data) |
| 804 | { |
| 805 | char c; |
| 806 | int rc; |
| 807 | |
| 808 | rc = get_user(c, buffer); |
| 809 | if (rc) |
| 810 | return rc; |
| 811 | if (c == '0' || c == 'n' || c == 'N') |
| 812 | sign_CIFS_PDUs = 0; |
| 813 | else if (c == '1' || c == 'y' || c == 'Y') |
| 814 | sign_CIFS_PDUs = 1; |
| 815 | else if (c == '2') |
| 816 | sign_CIFS_PDUs = 2; |
| 817 | |
| 818 | return count; |
| 819 | } |
| 820 | |
| 821 | |
| 822 | #endif |