Blame view
fs/cifs/cifs_debug.c
21.1 KB
1da177e4c
|
1 2 3 |
/* * fs/cifs_debug.c * |
b8643e1b5
|
4 |
* Copyright (C) International Business Machines Corp., 2000,2005 |
1da177e4c
|
5 6 7 8 9 |
* * Modified by Steve French (sfrench@us.ibm.com) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by |
221601c3d
|
10 |
* the Free Software Foundation; either version 2 of the License, or |
1da177e4c
|
11 |
* (at your option) any later version. |
221601c3d
|
12 |
* |
1da177e4c
|
13 14 15 16 17 18 |
* This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See * the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License |
221601c3d
|
19 |
* along with this program; if not, write to the Free Software |
1da177e4c
|
20 21 22 23 24 25 26 27 28 29 30 31 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <linux/fs.h> #include <linux/string.h> #include <linux/ctype.h> #include <linux/module.h> #include <linux/proc_fs.h> #include <asm/uaccess.h> #include "cifspdu.h" #include "cifsglob.h" #include "cifsproto.h" #include "cifs_debug.h" |
6c91d362f
|
32 |
#include "cifsfs.h" |
1da177e4c
|
33 34 35 36 37 38 39 40 |
void cifs_dump_mem(char *label, void *data, int length) { int i, j; int *intptr = data; char *charptr = data; char buf[10], line[80]; |
221601c3d
|
41 42 |
printk(KERN_DEBUG "%s: dump of %d bytes of data at 0x%p ", |
1da177e4c
|
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
label, length, data); for (i = 0; i < length; i += 16) { line[0] = 0; for (j = 0; (j < 4) && (i + j * 4 < length); j++) { sprintf(buf, " %08x", intptr[i / 4 + j]); strcat(line, buf); } buf[0] = ' '; buf[2] = 0; for (j = 0; (j < 16) && (i + j < length); j++) { buf[1] = isprint(charptr[i + j]) ? charptr[i + j] : '.'; strcat(line, buf); } printk(KERN_DEBUG "%s ", line); } } |
3979877e5
|
60 |
#ifdef CONFIG_CIFS_DEBUG2 |
ffdd6e4d1
|
61 |
void cifs_dump_detail(struct smb_hdr *smb) |
3979877e5
|
62 |
{ |
b6b38f704
|
63 |
cERROR(1, "Cmd: %d Err: 0x%x Flags: 0x%x Flgs2: 0x%x Mid: %d Pid: %d", |
3979877e5
|
64 |
smb->Command, smb->Status.CifsError, |
b6b38f704
|
65 |
smb->Flags, smb->Flags2, smb->Mid, smb->Pid); |
820a803ff
|
66 |
cERROR(1, "smb buf %p len %d", smb, smbCalcSize(smb)); |
3979877e5
|
67 |
} |
ffdd6e4d1
|
68 |
void cifs_dump_mids(struct TCP_Server_Info *server) |
3979877e5
|
69 70 |
{ struct list_head *tmp; |
ffdd6e4d1
|
71 |
struct mid_q_entry *mid_entry; |
3979877e5
|
72 |
|
221601c3d
|
73 |
if (server == NULL) |
3979877e5
|
74 |
return; |
b6b38f704
|
75 |
cERROR(1, "Dump pending requests:"); |
3979877e5
|
76 77 78 |
spin_lock(&GlobalMid_Lock); list_for_each(tmp, &server->pending_mid_q) { mid_entry = list_entry(tmp, struct mid_q_entry, qhead); |
2b84a36c5
|
79 |
cERROR(1, "State: %d Cmd: %d Pid: %d Cbdata: %p Mid %d", |
ad8b15f0f
|
80 81 82 |
mid_entry->midState, (int)mid_entry->command, mid_entry->pid, |
2b84a36c5
|
83 |
mid_entry->callback_data, |
b6b38f704
|
84 |
mid_entry->mid); |
3979877e5
|
85 |
#ifdef CONFIG_CIFS_STATS2 |
b6b38f704
|
86 |
cERROR(1, "IsLarge: %d buf: %p time rcv: %ld now: %ld", |
ad8b15f0f
|
87 88 89 |
mid_entry->largeBuf, mid_entry->resp_buf, mid_entry->when_received, |
b6b38f704
|
90 |
jiffies); |
3979877e5
|
91 |
#endif /* STATS2 */ |
b6b38f704
|
92 93 |
cERROR(1, "IsMult: %d IsEnd: %d", mid_entry->multiRsp, mid_entry->multiEnd); |
ad8b15f0f
|
94 95 96 97 |
if (mid_entry->resp_buf) { cifs_dump_detail(mid_entry->resp_buf); cifs_dump_mem("existing buf: ", mid_entry->resp_buf, 62); |
3979877e5
|
98 99 100 101 102 |
} } spin_unlock(&GlobalMid_Lock); } #endif /* CONFIG_CIFS_DEBUG2 */ |
1da177e4c
|
103 |
#ifdef CONFIG_PROC_FS |
f984c7b98
|
104 |
static int cifs_debug_data_proc_show(struct seq_file *m, void *v) |
1da177e4c
|
105 |
{ |
f1987b44f
|
106 |
struct list_head *tmp1, *tmp2, *tmp3; |
ffdd6e4d1
|
107 |
struct mid_q_entry *mid_entry; |
14fbf50d6
|
108 |
struct TCP_Server_Info *server; |
96daf2b09
|
109 110 |
struct cifs_ses *ses; struct cifs_tcon *tcon; |
f1987b44f
|
111 112 |
int i, j; __u32 dev_type; |
1da177e4c
|
113 |
|
f984c7b98
|
114 |
seq_puts(m, |
1da177e4c
|
115 116 117 118 |
"Display Internal CIFS Data Structures for Debugging " "--------------------------------------------------- "); |
f984c7b98
|
119 120 |
seq_printf(m, "CIFS Version %s ", CIFS_VERSION); |
ca40b714b
|
121 |
seq_printf(m, "Features:"); |
f579903ef
|
122 |
#ifdef CONFIG_CIFS_DFS_UPCALL |
ca40b714b
|
123 |
seq_printf(m, " dfs"); |
f579903ef
|
124 125 |
#endif #ifdef CONFIG_CIFS_FSCACHE |
ca40b714b
|
126 |
seq_printf(m, " fscache"); |
f579903ef
|
127 128 |
#endif #ifdef CONFIG_CIFS_WEAK_PW_HASH |
ca40b714b
|
129 |
seq_printf(m, " lanman"); |
f579903ef
|
130 131 |
#endif #ifdef CONFIG_CIFS_POSIX |
ca40b714b
|
132 |
seq_printf(m, " posix"); |
f579903ef
|
133 134 |
#endif #ifdef CONFIG_CIFS_UPCALL |
ca40b714b
|
135 |
seq_printf(m, " spnego"); |
f579903ef
|
136 137 |
#endif #ifdef CONFIG_CIFS_XATTR |
ca40b714b
|
138 139 140 141 |
seq_printf(m, " xattr"); #endif #ifdef CONFIG_CIFS_ACL seq_printf(m, " acl"); |
f579903ef
|
142 143 144 |
#endif seq_putc(m, ' '); |
f984c7b98
|
145 146 147 |
seq_printf(m, "Active VFS Requests: %d ", GlobalTotalActiveXid); seq_printf(m, "Servers:"); |
1da177e4c
|
148 149 |
i = 0; |
3f9bcca78
|
150 |
spin_lock(&cifs_tcp_ses_lock); |
f1987b44f
|
151 152 |
list_for_each(tmp1, &cifs_tcp_ses_list) { server = list_entry(tmp1, struct TCP_Server_Info, |
14fbf50d6
|
153 |
tcp_ses_list); |
1da177e4c
|
154 |
i++; |
14fbf50d6
|
155 |
list_for_each(tmp2, &server->smb_ses_list) { |
96daf2b09
|
156 |
ses = list_entry(tmp2, struct cifs_ses, |
14fbf50d6
|
157 158 159 160 |
smb_ses_list); if ((ses->serverDomain == NULL) || (ses->serverOS == NULL) || (ses->serverNOS == NULL)) { |
f1987b44f
|
161 162 163 164 |
seq_printf(m, " %d) entry for %s not fully " "displayed \t", i, ses->serverName); |
14fbf50d6
|
165 166 |
} else { seq_printf(m, |
f1987b44f
|
167 168 169 170 171 |
" %d) Name: %s Domain: %s Uses: %d OS:" " %s \tNOS: %s\tCapability: 0x%x \tSMB" |
221601c3d
|
172 |
" session status: %d\t", |
b8643e1b5
|
173 |
i, ses->serverName, ses->serverDomain, |
14fbf50d6
|
174 |
ses->ses_count, ses->serverOS, ses->serverNOS, |
221601c3d
|
175 |
ses->capabilities, ses->status); |
14fbf50d6
|
176 |
} |
f984c7b98
|
177 178 |
seq_printf(m, "TCP status: %d \tLocal Users To " |
14fbf50d6
|
179 180 |
"Server: %d SecMode: 0x%x Req On Wire: %d", server->tcpStatus, server->srv_count, |
96daf2b09
|
181 |
server->sec_mode, |
14fbf50d6
|
182 |
atomic_read(&server->inFlight)); |
131afd0b7
|
183 184 |
#ifdef CONFIG_CIFS_STATS2 |
f984c7b98
|
185 |
seq_printf(m, " In Send: %d In MaxReq Wait: %d", |
789e66612
|
186 |
atomic_read(&server->in_send), |
14fbf50d6
|
187 |
atomic_read(&server->num_waiters)); |
131afd0b7
|
188 |
#endif |
f1987b44f
|
189 190 191 192 |
seq_puts(m, " \tShares:"); j = 0; list_for_each(tmp3, &ses->tcon_list) { |
96daf2b09
|
193 |
tcon = list_entry(tmp3, struct cifs_tcon, |
f1987b44f
|
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
tcon_list); ++j; dev_type = le32_to_cpu(tcon->fsDevInfo.DeviceType); seq_printf(m, " \t%d) %s Mounts: %d ", j, tcon->treeName, tcon->tc_count); if (tcon->nativeFileSystem) { seq_printf(m, "Type: %s ", tcon->nativeFileSystem); } seq_printf(m, "DevInfo: 0x%x Attributes: 0x%x" " PathComponentMax: %d Status: 0x%d", le32_to_cpu(tcon->fsDevInfo.DeviceCharacteristics), le32_to_cpu(tcon->fsAttrInfo.Attributes), le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength), tcon->tidStatus); if (dev_type == FILE_DEVICE_DISK) seq_puts(m, " type: DISK "); else if (dev_type == FILE_DEVICE_CD_ROM) seq_puts(m, " type: CDROM "); else seq_printf(m, " type: %d ", dev_type); if (tcon->need_reconnect) seq_puts(m, "\tDISCONNECTED "); seq_putc(m, ' '); } seq_puts(m, " \tMIDs: "); |
1da177e4c
|
227 228 |
spin_lock(&GlobalMid_Lock); |
14fbf50d6
|
229 |
list_for_each(tmp3, &server->pending_mid_q) { |
f1987b44f
|
230 |
mid_entry = list_entry(tmp3, struct mid_q_entry, |
1da177e4c
|
231 |
qhead); |
f1987b44f
|
232 |
seq_printf(m, "\tState: %d com: %d pid:" |
2b84a36c5
|
233 234 |
" %d cbdata: %p mid %d ", |
ad8b15f0f
|
235 236 237 |
mid_entry->midState, (int)mid_entry->command, mid_entry->pid, |
2b84a36c5
|
238 |
mid_entry->callback_data, |
ad8b15f0f
|
239 |
mid_entry->mid); |
1da177e4c
|
240 |
} |
221601c3d
|
241 |
spin_unlock(&GlobalMid_Lock); |
1da177e4c
|
242 |
} |
1da177e4c
|
243 |
} |
3f9bcca78
|
244 |
spin_unlock(&cifs_tcp_ses_lock); |
f984c7b98
|
245 246 |
seq_putc(m, ' '); |
1da177e4c
|
247 |
|
1da177e4c
|
248 |
/* BB add code to dump additional info such as TCP session info now */ |
f984c7b98
|
249 250 |
return 0; } |
1da177e4c
|
251 |
|
f984c7b98
|
252 253 254 |
static int cifs_debug_data_proc_open(struct inode *inode, struct file *file) { return single_open(file, cifs_debug_data_proc_show, NULL); |
1da177e4c
|
255 |
} |
f984c7b98
|
256 257 258 259 260 261 262 |
static const struct file_operations cifs_debug_data_proc_fops = { .owner = THIS_MODULE, .open = cifs_debug_data_proc_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, }; |
1047abc15
|
263 |
|
f984c7b98
|
264 265 266 |
#ifdef CONFIG_CIFS_STATS static ssize_t cifs_stats_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) |
1047abc15
|
267 |
{ |
221601c3d
|
268 269 |
char c; int rc; |
f1987b44f
|
270 271 |
struct list_head *tmp1, *tmp2, *tmp3; struct TCP_Server_Info *server; |
96daf2b09
|
272 273 |
struct cifs_ses *ses; struct cifs_tcon *tcon; |
1047abc15
|
274 |
|
221601c3d
|
275 276 277 |
rc = get_user(c, buffer); if (rc) return rc; |
1047abc15
|
278 |
|
221601c3d
|
279 |
if (c == '1' || c == 'y' || c == 'Y' || c == '0') { |
4498eed50
|
280 281 282 283 |
#ifdef CONFIG_CIFS_STATS2 atomic_set(&totBufAllocCount, 0); atomic_set(&totSmBufAllocCount, 0); #endif /* CONFIG_CIFS_STATS2 */ |
3f9bcca78
|
284 |
spin_lock(&cifs_tcp_ses_lock); |
f1987b44f
|
285 286 287 |
list_for_each(tmp1, &cifs_tcp_ses_list) { server = list_entry(tmp1, struct TCP_Server_Info, tcp_ses_list); |
c2b3382cd
|
288 |
list_for_each(tmp2, &server->smb_ses_list) { |
96daf2b09
|
289 |
ses = list_entry(tmp2, struct cifs_ses, |
c2b3382cd
|
290 |
smb_ses_list); |
f1987b44f
|
291 292 |
list_for_each(tmp3, &ses->tcon_list) { tcon = list_entry(tmp3, |
96daf2b09
|
293 |
struct cifs_tcon, |
f1987b44f
|
294 295 296 297 298 299 |
tcon_list); atomic_set(&tcon->num_smbs_sent, 0); atomic_set(&tcon->num_writes, 0); atomic_set(&tcon->num_reads, 0); atomic_set(&tcon->num_oplock_brks, 0); atomic_set(&tcon->num_opens, 0); |
65bc98b00
|
300 301 |
atomic_set(&tcon->num_posixopens, 0); atomic_set(&tcon->num_posixmkdirs, 0); |
f1987b44f
|
302 303 304 305 306 307 308 309 310 311 312 313 314 315 |
atomic_set(&tcon->num_closes, 0); atomic_set(&tcon->num_deletes, 0); atomic_set(&tcon->num_mkdirs, 0); atomic_set(&tcon->num_rmdirs, 0); atomic_set(&tcon->num_renames, 0); atomic_set(&tcon->num_t2renames, 0); atomic_set(&tcon->num_ffirst, 0); atomic_set(&tcon->num_fnext, 0); atomic_set(&tcon->num_fclose, 0); atomic_set(&tcon->num_hardlinks, 0); atomic_set(&tcon->num_symlinks, 0); atomic_set(&tcon->num_locks, 0); } } |
1047abc15
|
316 |
} |
3f9bcca78
|
317 |
spin_unlock(&cifs_tcp_ses_lock); |
1047abc15
|
318 |
} |
221601c3d
|
319 |
return count; |
1047abc15
|
320 |
} |
f984c7b98
|
321 |
static int cifs_stats_proc_show(struct seq_file *m, void *v) |
1da177e4c
|
322 |
{ |
f984c7b98
|
323 |
int i; |
f1987b44f
|
324 325 |
struct list_head *tmp1, *tmp2, *tmp3; struct TCP_Server_Info *server; |
96daf2b09
|
326 327 |
struct cifs_ses *ses; struct cifs_tcon *tcon; |
1da177e4c
|
328 |
|
f984c7b98
|
329 |
seq_printf(m, |
1da177e4c
|
330 331 332 333 |
"Resources in use CIFS Session: %d ", sesInfoAllocCount.counter); |
f984c7b98
|
334 335 |
seq_printf(m, "Share (unique mount targets): %d ", |
1da177e4c
|
336 |
tconInfoAllocCount.counter); |
f984c7b98
|
337 338 |
seq_printf(m, "SMB Request/Response Buffer: %d Pool size: %d ", |
b8643e1b5
|
339 340 |
bufAllocCount.counter, cifs_min_rcv + tcpSesAllocCount.counter); |
f984c7b98
|
341 342 |
seq_printf(m, "SMB Small Req/Resp Buffer: %d Pool size: %d ", |
221601c3d
|
343 |
smBufAllocCount.counter, cifs_min_small); |
07475ffba
|
344 |
#ifdef CONFIG_CIFS_STATS2 |
f984c7b98
|
345 346 |
seq_printf(m, "Total Large %d Small %d Allocations ", |
07475ffba
|
347 |
atomic_read(&totBufAllocCount), |
221601c3d
|
348 |
atomic_read(&totSmBufAllocCount)); |
07475ffba
|
349 |
#endif /* CONFIG_CIFS_STATS2 */ |
8097531a5
|
350 351 |
seq_printf(m, "Operations (MIDs): %d ", atomic_read(&midCount)); |
f984c7b98
|
352 |
seq_printf(m, |
1da177e4c
|
353 354 355 |
" %d session %d share reconnects ", |
221601c3d
|
356 |
tcpSesReconnectCount.counter, tconInfoReconnectCount.counter); |
1da177e4c
|
357 |
|
f984c7b98
|
358 |
seq_printf(m, |
1da177e4c
|
359 360 |
"Total vfs operations: %d maximum at one time: %d ", |
221601c3d
|
361 |
GlobalCurrentXid, GlobalMaxActiveXid); |
1da177e4c
|
362 363 |
i = 0; |
3f9bcca78
|
364 |
spin_lock(&cifs_tcp_ses_lock); |
f1987b44f
|
365 366 367 368 |
list_for_each(tmp1, &cifs_tcp_ses_list) { server = list_entry(tmp1, struct TCP_Server_Info, tcp_ses_list); list_for_each(tmp2, &server->smb_ses_list) { |
96daf2b09
|
369 |
ses = list_entry(tmp2, struct cifs_ses, |
f1987b44f
|
370 371 372 |
smb_ses_list); list_for_each(tmp3, &ses->tcon_list) { tcon = list_entry(tmp3, |
96daf2b09
|
373 |
struct cifs_tcon, |
f1987b44f
|
374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 |
tcon_list); i++; seq_printf(m, " %d) %s", i, tcon->treeName); if (tcon->need_reconnect) seq_puts(m, "\tDISCONNECTED "); seq_printf(m, " SMBs: %d Oplock Breaks: %d", atomic_read(&tcon->num_smbs_sent), atomic_read(&tcon->num_oplock_brks)); seq_printf(m, " Reads: %d Bytes: %lld", atomic_read(&tcon->num_reads), (long long)(tcon->bytes_read)); seq_printf(m, " Writes: %d Bytes: %lld", atomic_read(&tcon->num_writes), (long long)(tcon->bytes_written)); |
b298f2235
|
392 393 394 |
seq_printf(m, " Flushes: %d", atomic_read(&tcon->num_flushes)); |
f1987b44f
|
395 396 397 398 399 400 |
seq_printf(m, " Locks: %d HardLinks: %d " "Symlinks: %d", atomic_read(&tcon->num_locks), atomic_read(&tcon->num_hardlinks), atomic_read(&tcon->num_symlinks)); |
65bc98b00
|
401 402 |
seq_printf(m, " Opens: %d Closes: %d " |
f1987b44f
|
403 404 405 406 |
"Deletes: %d", atomic_read(&tcon->num_opens), atomic_read(&tcon->num_closes), atomic_read(&tcon->num_deletes)); |
65bc98b00
|
407 408 409 410 411 |
seq_printf(m, " Posix Opens: %d " "Posix Mkdirs: %d", atomic_read(&tcon->num_posixopens), atomic_read(&tcon->num_posixmkdirs)); |
f1987b44f
|
412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 |
seq_printf(m, " Mkdirs: %d Rmdirs: %d", atomic_read(&tcon->num_mkdirs), atomic_read(&tcon->num_rmdirs)); seq_printf(m, " Renames: %d T2 Renames %d", atomic_read(&tcon->num_renames), atomic_read(&tcon->num_t2renames)); seq_printf(m, " FindFirst: %d FNext %d " "FClose %d", atomic_read(&tcon->num_ffirst), atomic_read(&tcon->num_fnext), atomic_read(&tcon->num_fclose)); } } |
1da177e4c
|
428 |
} |
3f9bcca78
|
429 |
spin_unlock(&cifs_tcp_ses_lock); |
1da177e4c
|
430 |
|
f984c7b98
|
431 432 433 434 |
seq_putc(m, ' '); return 0; } |
221601c3d
|
435 |
|
f984c7b98
|
436 437 438 |
static int cifs_stats_proc_open(struct inode *inode, struct file *file) { return single_open(file, cifs_stats_proc_show, NULL); |
1da177e4c
|
439 |
} |
f984c7b98
|
440 441 442 443 444 445 446 447 448 |
static const struct file_operations cifs_stats_proc_fops = { .owner = THIS_MODULE, .open = cifs_stats_proc_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, .write = cifs_stats_proc_write, }; |
90c81e0b0
|
449 |
#endif /* STATS */ |
1da177e4c
|
450 451 |
static struct proc_dir_entry *proc_fs_cifs; |
f984c7b98
|
452 453 454 455 456 457 |
static const struct file_operations cifsFYI_proc_fops; static const struct file_operations cifs_oplock_proc_fops; static const struct file_operations cifs_lookup_cache_proc_fops; static const struct file_operations traceSMB_proc_fops; static const struct file_operations cifs_multiuser_mount_proc_fops; static const struct file_operations cifs_security_flags_proc_fops; |
f984c7b98
|
458 |
static const struct file_operations cifs_linux_ext_proc_fops; |
1da177e4c
|
459 460 461 462 |
void cifs_proc_init(void) { |
36a5aeb87
|
463 |
proc_fs_cifs = proc_mkdir("fs/cifs", NULL); |
1da177e4c
|
464 465 |
if (proc_fs_cifs == NULL) return; |
f984c7b98
|
466 |
proc_create("DebugData", 0, proc_fs_cifs, &cifs_debug_data_proc_fops); |
1da177e4c
|
467 468 |
#ifdef CONFIG_CIFS_STATS |
f984c7b98
|
469 |
proc_create("Stats", 0, proc_fs_cifs, &cifs_stats_proc_fops); |
90c81e0b0
|
470 |
#endif /* STATS */ |
f984c7b98
|
471 472 473 |
proc_create("cifsFYI", 0, proc_fs_cifs, &cifsFYI_proc_fops); proc_create("traceSMB", 0, proc_fs_cifs, &traceSMB_proc_fops); proc_create("OplockEnabled", 0, proc_fs_cifs, &cifs_oplock_proc_fops); |
99b1f5b2f
|
474 475 476 477 478 479 480 481 |
proc_create("LinuxExtensionsEnabled", 0, proc_fs_cifs, &cifs_linux_ext_proc_fops); proc_create("MultiuserMount", 0, proc_fs_cifs, &cifs_multiuser_mount_proc_fops); proc_create("SecurityFlags", 0, proc_fs_cifs, &cifs_security_flags_proc_fops); proc_create("LookupCacheEnabled", 0, proc_fs_cifs, &cifs_lookup_cache_proc_fops); |
1da177e4c
|
482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 |
} void cifs_proc_clean(void) { if (proc_fs_cifs == NULL) return; remove_proc_entry("DebugData", proc_fs_cifs); remove_proc_entry("cifsFYI", proc_fs_cifs); remove_proc_entry("traceSMB", proc_fs_cifs); #ifdef CONFIG_CIFS_STATS remove_proc_entry("Stats", proc_fs_cifs); #endif remove_proc_entry("MultiuserMount", proc_fs_cifs); remove_proc_entry("OplockEnabled", proc_fs_cifs); |
221601c3d
|
498 |
remove_proc_entry("SecurityFlags", proc_fs_cifs); |
221601c3d
|
499 |
remove_proc_entry("LinuxExtensionsEnabled", proc_fs_cifs); |
221601c3d
|
500 |
remove_proc_entry("LookupCacheEnabled", proc_fs_cifs); |
36a5aeb87
|
501 |
remove_proc_entry("fs/cifs", NULL); |
1da177e4c
|
502 |
} |
f984c7b98
|
503 |
static int cifsFYI_proc_show(struct seq_file *m, void *v) |
1da177e4c
|
504 |
{ |
f984c7b98
|
505 506 507 508 |
seq_printf(m, "%d ", cifsFYI); return 0; } |
1da177e4c
|
509 |
|
f984c7b98
|
510 511 512 |
static int cifsFYI_proc_open(struct inode *inode, struct file *file) { return single_open(file, cifsFYI_proc_show, NULL); |
1da177e4c
|
513 |
} |
f984c7b98
|
514 515 516 |
static ssize_t cifsFYI_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) |
1da177e4c
|
517 518 519 520 521 522 523 524 525 526 527 |
{ char c; int rc; rc = get_user(c, buffer); if (rc) return rc; if (c == '0' || c == 'n' || c == 'N') cifsFYI = 0; else if (c == '1' || c == 'y' || c == 'Y') cifsFYI = 1; |
221601c3d
|
528 |
else if ((c > '1') && (c <= '9')) |
1047abc15
|
529 |
cifsFYI = (int) (c - '0'); /* see cifs_debug.h for meanings */ |
1da177e4c
|
530 531 532 |
return count; } |
f984c7b98
|
533 534 535 536 537 538 539 540 |
static const struct file_operations cifsFYI_proc_fops = { .owner = THIS_MODULE, .open = cifsFYI_proc_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, .write = cifsFYI_proc_write, }; |
1da177e4c
|
541 |
|
f984c7b98
|
542 543 |
static int cifs_oplock_proc_show(struct seq_file *m, void *v) { |
e75047344
|
544 545 |
seq_printf(m, "%d ", enable_oplocks); |
f984c7b98
|
546 547 |
return 0; } |
1da177e4c
|
548 |
|
f984c7b98
|
549 550 551 |
static int cifs_oplock_proc_open(struct inode *inode, struct file *file) { return single_open(file, cifs_oplock_proc_show, NULL); |
1da177e4c
|
552 |
} |
f984c7b98
|
553 554 555 |
static ssize_t cifs_oplock_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) |
1da177e4c
|
556 557 558 |
{ char c; int rc; |
8bc4392a1
|
559 560 561 562 |
printk(KERN_WARNING "CIFS: The /proc/fs/cifs/OplockEnabled interface " "will be removed in kernel version 3.4. Please migrate to " "using the 'enable_oplocks' module parameter in cifs.ko. "); |
1da177e4c
|
563 564 565 566 |
rc = get_user(c, buffer); if (rc) return rc; if (c == '0' || c == 'n' || c == 'N') |
e75047344
|
567 |
enable_oplocks = false; |
1da177e4c
|
568 |
else if (c == '1' || c == 'y' || c == 'Y') |
e75047344
|
569 |
enable_oplocks = true; |
1da177e4c
|
570 571 572 |
return count; } |
f984c7b98
|
573 574 575 576 577 578 579 580 |
static const struct file_operations cifs_oplock_proc_fops = { .owner = THIS_MODULE, .open = cifs_oplock_proc_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, .write = cifs_oplock_proc_write, }; |
1da177e4c
|
581 |
|
f984c7b98
|
582 583 584 585 586 587 |
static int cifs_linux_ext_proc_show(struct seq_file *m, void *v) { seq_printf(m, "%d ", linuxExtEnabled); return 0; } |
1da177e4c
|
588 |
|
f984c7b98
|
589 590 591 |
static int cifs_linux_ext_proc_open(struct inode *inode, struct file *file) { return single_open(file, cifs_linux_ext_proc_show, NULL); |
1da177e4c
|
592 |
} |
f984c7b98
|
593 594 595 |
static ssize_t cifs_linux_ext_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) |
1da177e4c
|
596 |
{ |
221601c3d
|
597 598 599 600 601 602 603 604 605 606 607 608 |
char c; int rc; rc = get_user(c, buffer); if (rc) return rc; if (c == '0' || c == 'n' || c == 'N') linuxExtEnabled = 0; else if (c == '1' || c == 'y' || c == 'Y') linuxExtEnabled = 1; return count; |
1da177e4c
|
609 |
} |
f984c7b98
|
610 611 612 613 614 615 616 617 |
static const struct file_operations cifs_linux_ext_proc_fops = { .owner = THIS_MODULE, .open = cifs_linux_ext_proc_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, .write = cifs_linux_ext_proc_write, }; |
1da177e4c
|
618 |
|
f984c7b98
|
619 |
static int cifs_lookup_cache_proc_show(struct seq_file *m, void *v) |
1da177e4c
|
620 |
{ |
f984c7b98
|
621 622 623 624 |
seq_printf(m, "%d ", lookupCacheEnabled); return 0; } |
1da177e4c
|
625 |
|
f984c7b98
|
626 627 628 |
static int cifs_lookup_cache_proc_open(struct inode *inode, struct file *file) { return single_open(file, cifs_lookup_cache_proc_show, NULL); |
1da177e4c
|
629 |
} |
f984c7b98
|
630 631 632 |
static ssize_t cifs_lookup_cache_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) |
1da177e4c
|
633 634 635 636 637 638 639 640 641 642 643 644 645 646 |
{ char c; int rc; rc = get_user(c, buffer); if (rc) return rc; if (c == '0' || c == 'n' || c == 'N') lookupCacheEnabled = 0; else if (c == '1' || c == 'y' || c == 'Y') lookupCacheEnabled = 1; return count; } |
1da177e4c
|
647 |
|
f984c7b98
|
648 649 650 651 652 653 654 655 |
static const struct file_operations cifs_lookup_cache_proc_fops = { .owner = THIS_MODULE, .open = cifs_lookup_cache_proc_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, .write = cifs_lookup_cache_proc_write, }; |
1da177e4c
|
656 |
|
f984c7b98
|
657 658 659 660 661 662 |
static int traceSMB_proc_show(struct seq_file *m, void *v) { seq_printf(m, "%d ", traceSMB); return 0; } |
1da177e4c
|
663 |
|
f984c7b98
|
664 665 666 |
static int traceSMB_proc_open(struct inode *inode, struct file *file) { return single_open(file, traceSMB_proc_show, NULL); |
1da177e4c
|
667 |
} |
f984c7b98
|
668 669 670 |
static ssize_t traceSMB_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) |
1da177e4c
|
671 672 673 674 675 676 677 678 679 680 681 682 683 684 |
{ char c; int rc; rc = get_user(c, buffer); if (rc) return rc; if (c == '0' || c == 'n' || c == 'N') traceSMB = 0; else if (c == '1' || c == 'y' || c == 'Y') traceSMB = 1; return count; } |
f984c7b98
|
685 686 687 688 689 690 691 692 |
static const struct file_operations traceSMB_proc_fops = { .owner = THIS_MODULE, .open = traceSMB_proc_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, .write = traceSMB_proc_write, }; |
1da177e4c
|
693 |
|
f984c7b98
|
694 695 696 697 698 699 |
static int cifs_multiuser_mount_proc_show(struct seq_file *m, void *v) { seq_printf(m, "%d ", multiuser_mount); return 0; } |
1da177e4c
|
700 |
|
99b1f5b2f
|
701 |
static int cifs_multiuser_mount_proc_open(struct inode *inode, struct file *fh) |
f984c7b98
|
702 |
{ |
99b1f5b2f
|
703 |
return single_open(fh, cifs_multiuser_mount_proc_show, NULL); |
1da177e4c
|
704 |
} |
f984c7b98
|
705 706 707 |
static ssize_t cifs_multiuser_mount_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) |
1da177e4c
|
708 709 710 711 712 713 714 715 716 717 718 719 720 721 |
{ char c; int rc; rc = get_user(c, buffer); if (rc) return rc; if (c == '0' || c == 'n' || c == 'N') multiuser_mount = 0; else if (c == '1' || c == 'y' || c == 'Y') multiuser_mount = 1; return count; } |
f984c7b98
|
722 723 724 725 726 727 728 729 |
static const struct file_operations cifs_multiuser_mount_proc_fops = { .owner = THIS_MODULE, .open = cifs_multiuser_mount_proc_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, .write = cifs_multiuser_mount_proc_write, }; |
1da177e4c
|
730 |
|
f984c7b98
|
731 732 |
static int cifs_security_flags_proc_show(struct seq_file *m, void *v) { |
04912d6a2
|
733 734 |
seq_printf(m, "0x%x ", global_secflags); |
f984c7b98
|
735 736 |
return 0; } |
1da177e4c
|
737 |
|
f984c7b98
|
738 739 740 |
static int cifs_security_flags_proc_open(struct inode *inode, struct file *file) { return single_open(file, cifs_security_flags_proc_show, NULL); |
1da177e4c
|
741 |
} |
f984c7b98
|
742 743 744 |
static ssize_t cifs_security_flags_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) |
1da177e4c
|
745 |
{ |
bdc4bf6e8
|
746 747 |
unsigned int flags; char flags_string[12]; |
1da177e4c
|
748 |
char c; |
bdc4bf6e8
|
749 |
|
221601c3d
|
750 |
if ((count < 1) || (count > 11)) |
3979877e5
|
751 |
return -EINVAL; |
1da177e4c
|
752 |
|
bdc4bf6e8
|
753 |
memset(flags_string, 0, 12); |
3979877e5
|
754 |
|
221601c3d
|
755 |
if (copy_from_user(flags_string, buffer, count)) |
bdc4bf6e8
|
756 |
return -EFAULT; |
3979877e5
|
757 |
|
221601c3d
|
758 |
if (count < 3) { |
bdc4bf6e8
|
759 760 |
/* single char or single char followed by null */ c = flags_string[0]; |
a013689dd
|
761 |
if (c == '0' || c == 'n' || c == 'N') { |
04912d6a2
|
762 |
global_secflags = CIFSSEC_DEF; /* default */ |
a013689dd
|
763 764 |
return count; } else if (c == '1' || c == 'y' || c == 'Y') { |
04912d6a2
|
765 |
global_secflags = CIFSSEC_MAX; |
a013689dd
|
766 767 |
return count; } else if (!isdigit(c)) { |
b6b38f704
|
768 |
cERROR(1, "invalid flag %c", c); |
a013689dd
|
769 770 |
return -EINVAL; } |
bdc4bf6e8
|
771 772 773 774 |
} /* else we have a number */ flags = simple_strtoul(flags_string, NULL, 0); |
b6b38f704
|
775 |
cFYI(1, "sec flags 0x%x", flags); |
bdc4bf6e8
|
776 |
|
221601c3d
|
777 |
if (flags <= 0) { |
b6b38f704
|
778 |
cERROR(1, "invalid security flags %s", flags_string); |
bdc4bf6e8
|
779 780 |
return -EINVAL; } |
1da177e4c
|
781 |
|
221601c3d
|
782 |
if (flags & ~CIFSSEC_MASK) { |
b6b38f704
|
783 784 |
cERROR(1, "attempt to set unsupported security flags 0x%x", flags & ~CIFSSEC_MASK); |
bdc4bf6e8
|
785 786 787 |
return -EINVAL; } /* flags look ok - update the global security flags for cifs module */ |
04912d6a2
|
788 789 |
global_secflags = flags; if (global_secflags & CIFSSEC_MUST_SIGN) { |
762e5ab77
|
790 |
/* requiring signing implies signing is allowed */ |
04912d6a2
|
791 |
global_secflags |= CIFSSEC_MAY_SIGN; |
b6b38f704
|
792 |
cFYI(1, "packet signing now required"); |
04912d6a2
|
793 |
} else if ((global_secflags & CIFSSEC_MAY_SIGN) == 0) { |
b6b38f704
|
794 |
cFYI(1, "packet signing disabled"); |
762e5ab77
|
795 796 |
} /* BB should we turn on MAY flags for other MUST options? */ |
1da177e4c
|
797 798 |
return count; } |
f984c7b98
|
799 800 801 802 803 804 805 806 807 |
static const struct file_operations cifs_security_flags_proc_fops = { .owner = THIS_MODULE, .open = cifs_security_flags_proc_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, .write = cifs_security_flags_proc_write, }; |
90c81e0b0
|
808 |
#else |
e086fcea8
|
809 |
inline void cifs_proc_init(void) |
90c81e0b0
|
810 811 |
{ } |
e086fcea8
|
812 |
inline void cifs_proc_clean(void) |
90c81e0b0
|
813 814 815 |
{ } #endif /* PROC_FS */ |