xref: /linux/fs/smb/client/cifs_debug.c (revision 1b0975ee3bdd3eb19a47371c26fd7ef8f7f6b599)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  *
4  *   Copyright (C) International Business Machines  Corp., 2000,2005
5  *
6  *   Modified by Steve French (sfrench@us.ibm.com)
7  */
8 #include <linux/fs.h>
9 #include <linux/string.h>
10 #include <linux/ctype.h>
11 #include <linux/kstrtox.h>
12 #include <linux/module.h>
13 #include <linux/proc_fs.h>
14 #include <linux/uaccess.h>
15 #include <uapi/linux/ethtool.h>
16 #include "cifspdu.h"
17 #include "cifsglob.h"
18 #include "cifsproto.h"
19 #include "cifs_debug.h"
20 #include "cifsfs.h"
21 #include "fs_context.h"
22 #ifdef CONFIG_CIFS_DFS_UPCALL
23 #include "dfs_cache.h"
24 #endif
25 #ifdef CONFIG_CIFS_SMB_DIRECT
26 #include "smbdirect.h"
27 #endif
28 #include "cifs_swn.h"
29 
30 void
31 cifs_dump_mem(char *label, void *data, int length)
32 {
33 	pr_debug("%s: dump of %d bytes of data at 0x%p\n", label, length, data);
34 	print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 16, 4,
35 		       data, length, true);
36 }
37 
38 void cifs_dump_detail(void *buf, struct TCP_Server_Info *server)
39 {
40 #ifdef CONFIG_CIFS_DEBUG2
41 	struct smb_hdr *smb = buf;
42 
43 	cifs_dbg(VFS, "Cmd: %d Err: 0x%x Flags: 0x%x Flgs2: 0x%x Mid: %d Pid: %d\n",
44 		 smb->Command, smb->Status.CifsError,
45 		 smb->Flags, smb->Flags2, smb->Mid, smb->Pid);
46 	cifs_dbg(VFS, "smb buf %p len %u\n", smb,
47 		 server->ops->calc_smb_size(smb));
48 #endif /* CONFIG_CIFS_DEBUG2 */
49 }
50 
51 void cifs_dump_mids(struct TCP_Server_Info *server)
52 {
53 #ifdef CONFIG_CIFS_DEBUG2
54 	struct mid_q_entry *mid_entry;
55 
56 	if (server == NULL)
57 		return;
58 
59 	cifs_dbg(VFS, "Dump pending requests:\n");
60 	spin_lock(&server->mid_lock);
61 	list_for_each_entry(mid_entry, &server->pending_mid_q, qhead) {
62 		cifs_dbg(VFS, "State: %d Cmd: %d Pid: %d Cbdata: %p Mid %llu\n",
63 			 mid_entry->mid_state,
64 			 le16_to_cpu(mid_entry->command),
65 			 mid_entry->pid,
66 			 mid_entry->callback_data,
67 			 mid_entry->mid);
68 #ifdef CONFIG_CIFS_STATS2
69 		cifs_dbg(VFS, "IsLarge: %d buf: %p time rcv: %ld now: %ld\n",
70 			 mid_entry->large_buf,
71 			 mid_entry->resp_buf,
72 			 mid_entry->when_received,
73 			 jiffies);
74 #endif /* STATS2 */
75 		cifs_dbg(VFS, "IsMult: %d IsEnd: %d\n",
76 			 mid_entry->multiRsp, mid_entry->multiEnd);
77 		if (mid_entry->resp_buf) {
78 			cifs_dump_detail(mid_entry->resp_buf, server);
79 			cifs_dump_mem("existing buf: ",
80 				mid_entry->resp_buf, 62);
81 		}
82 	}
83 	spin_unlock(&server->mid_lock);
84 #endif /* CONFIG_CIFS_DEBUG2 */
85 }
86 
87 #ifdef CONFIG_PROC_FS
88 static void cifs_debug_tcon(struct seq_file *m, struct cifs_tcon *tcon)
89 {
90 	__u32 dev_type = le32_to_cpu(tcon->fsDevInfo.DeviceType);
91 
92 	seq_printf(m, "%s Mounts: %d ", tcon->tree_name, tcon->tc_count);
93 	if (tcon->nativeFileSystem)
94 		seq_printf(m, "Type: %s ", tcon->nativeFileSystem);
95 	seq_printf(m, "DevInfo: 0x%x Attributes: 0x%x\n\tPathComponentMax: %d Status: %d",
96 		   le32_to_cpu(tcon->fsDevInfo.DeviceCharacteristics),
97 		   le32_to_cpu(tcon->fsAttrInfo.Attributes),
98 		   le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength),
99 		   tcon->status);
100 	if (dev_type == FILE_DEVICE_DISK)
101 		seq_puts(m, " type: DISK ");
102 	else if (dev_type == FILE_DEVICE_CD_ROM)
103 		seq_puts(m, " type: CDROM ");
104 	else
105 		seq_printf(m, " type: %d ", dev_type);
106 
107 	seq_printf(m, "Serial Number: 0x%x", tcon->vol_serial_number);
108 
109 	if ((tcon->seal) ||
110 	    (tcon->ses->session_flags & SMB2_SESSION_FLAG_ENCRYPT_DATA) ||
111 	    (tcon->share_flags & SHI1005_FLAGS_ENCRYPT_DATA))
112 		seq_puts(m, " encrypted");
113 	if (tcon->nocase)
114 		seq_printf(m, " nocase");
115 	if (tcon->unix_ext)
116 		seq_printf(m, " POSIX Extensions");
117 	if (tcon->ses->server->ops->dump_share_caps)
118 		tcon->ses->server->ops->dump_share_caps(m, tcon);
119 	if (tcon->use_witness)
120 		seq_puts(m, " Witness");
121 	if (tcon->broken_sparse_sup)
122 		seq_puts(m, " nosparse");
123 	if (tcon->need_reconnect)
124 		seq_puts(m, "\tDISCONNECTED ");
125 	spin_lock(&tcon->tc_lock);
126 	if (tcon->origin_fullpath) {
127 		seq_printf(m, "\n\tDFS origin fullpath: %s",
128 			   tcon->origin_fullpath);
129 	}
130 	spin_unlock(&tcon->tc_lock);
131 	seq_putc(m, '\n');
132 }
133 
134 static void
135 cifs_dump_channel(struct seq_file *m, int i, struct cifs_chan *chan)
136 {
137 	struct TCP_Server_Info *server = chan->server;
138 
139 	seq_printf(m, "\n\n\t\tChannel: %d ConnectionId: 0x%llx"
140 		   "\n\t\tNumber of credits: %d,%d,%d Dialect 0x%x"
141 		   "\n\t\tTCP status: %d Instance: %d"
142 		   "\n\t\tLocal Users To Server: %d SecMode: 0x%x Req On Wire: %d"
143 		   "\n\t\tIn Send: %d In MaxReq Wait: %d",
144 		   i+1, server->conn_id,
145 		   server->credits,
146 		   server->echo_credits,
147 		   server->oplock_credits,
148 		   server->dialect,
149 		   server->tcpStatus,
150 		   server->reconnect_instance,
151 		   server->srv_count,
152 		   server->sec_mode,
153 		   in_flight(server),
154 		   atomic_read(&server->in_send),
155 		   atomic_read(&server->num_waiters));
156 }
157 
158 static inline const char *smb_speed_to_str(size_t bps)
159 {
160 	size_t mbps = bps / 1000 / 1000;
161 
162 	switch (mbps) {
163 	case SPEED_10:
164 		return "10Mbps";
165 	case SPEED_100:
166 		return "100Mbps";
167 	case SPEED_1000:
168 		return "1Gbps";
169 	case SPEED_2500:
170 		return "2.5Gbps";
171 	case SPEED_5000:
172 		return "5Gbps";
173 	case SPEED_10000:
174 		return "10Gbps";
175 	case SPEED_14000:
176 		return "14Gbps";
177 	case SPEED_20000:
178 		return "20Gbps";
179 	case SPEED_25000:
180 		return "25Gbps";
181 	case SPEED_40000:
182 		return "40Gbps";
183 	case SPEED_50000:
184 		return "50Gbps";
185 	case SPEED_56000:
186 		return "56Gbps";
187 	case SPEED_100000:
188 		return "100Gbps";
189 	case SPEED_200000:
190 		return "200Gbps";
191 	case SPEED_400000:
192 		return "400Gbps";
193 	case SPEED_800000:
194 		return "800Gbps";
195 	default:
196 		return "Unknown";
197 	}
198 }
199 
200 static void
201 cifs_dump_iface(struct seq_file *m, struct cifs_server_iface *iface)
202 {
203 	struct sockaddr_in *ipv4 = (struct sockaddr_in *)&iface->sockaddr;
204 	struct sockaddr_in6 *ipv6 = (struct sockaddr_in6 *)&iface->sockaddr;
205 
206 	seq_printf(m, "\tSpeed: %s\n", smb_speed_to_str(iface->speed));
207 	seq_puts(m, "\t\tCapabilities: ");
208 	if (iface->rdma_capable)
209 		seq_puts(m, "rdma ");
210 	if (iface->rss_capable)
211 		seq_puts(m, "rss ");
212 	if (!iface->rdma_capable && !iface->rss_capable)
213 		seq_puts(m, "None");
214 	seq_putc(m, '\n');
215 	if (iface->sockaddr.ss_family == AF_INET)
216 		seq_printf(m, "\t\tIPv4: %pI4\n", &ipv4->sin_addr);
217 	else if (iface->sockaddr.ss_family == AF_INET6)
218 		seq_printf(m, "\t\tIPv6: %pI6\n", &ipv6->sin6_addr);
219 	if (!iface->is_active)
220 		seq_puts(m, "\t\t[for-cleanup]\n");
221 }
222 
223 static int cifs_debug_files_proc_show(struct seq_file *m, void *v)
224 {
225 	struct TCP_Server_Info *server;
226 	struct cifs_ses *ses;
227 	struct cifs_tcon *tcon;
228 	struct cifsFileInfo *cfile;
229 
230 	seq_puts(m, "# Version:1\n");
231 	seq_puts(m, "# Format:\n");
232 	seq_puts(m, "# <tree id> <ses id> <persistent fid> <flags> <count> <pid> <uid>");
233 #ifdef CONFIG_CIFS_DEBUG2
234 	seq_printf(m, " <filename> <mid>\n");
235 #else
236 	seq_printf(m, " <filename>\n");
237 #endif /* CIFS_DEBUG2 */
238 	spin_lock(&cifs_tcp_ses_lock);
239 	list_for_each_entry(server, &cifs_tcp_ses_list, tcp_ses_list) {
240 		list_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) {
241 			list_for_each_entry(tcon, &ses->tcon_list, tcon_list) {
242 				spin_lock(&tcon->open_file_lock);
243 				list_for_each_entry(cfile, &tcon->openFileList, tlist) {
244 					seq_printf(m,
245 						"0x%x 0x%llx 0x%llx 0x%x %d %d %d %pd",
246 						tcon->tid,
247 						ses->Suid,
248 						cfile->fid.persistent_fid,
249 						cfile->f_flags,
250 						cfile->count,
251 						cfile->pid,
252 						from_kuid(&init_user_ns, cfile->uid),
253 						cfile->dentry);
254 #ifdef CONFIG_CIFS_DEBUG2
255 					seq_printf(m, " %llu\n", cfile->fid.mid);
256 #else
257 					seq_printf(m, "\n");
258 #endif /* CIFS_DEBUG2 */
259 				}
260 				spin_unlock(&tcon->open_file_lock);
261 			}
262 		}
263 	}
264 	spin_unlock(&cifs_tcp_ses_lock);
265 	seq_putc(m, '\n');
266 	return 0;
267 }
268 
269 static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
270 {
271 	struct mid_q_entry *mid_entry;
272 	struct TCP_Server_Info *server;
273 	struct TCP_Server_Info *chan_server;
274 	struct cifs_ses *ses;
275 	struct cifs_tcon *tcon;
276 	struct cifs_server_iface *iface;
277 	int c, i, j;
278 
279 	seq_puts(m,
280 		    "Display Internal CIFS Data Structures for Debugging\n"
281 		    "---------------------------------------------------\n");
282 	seq_printf(m, "CIFS Version %s\n", CIFS_VERSION);
283 	seq_printf(m, "Features:");
284 #ifdef CONFIG_CIFS_DFS_UPCALL
285 	seq_printf(m, " DFS");
286 #endif
287 #ifdef CONFIG_CIFS_FSCACHE
288 	seq_printf(m, ",FSCACHE");
289 #endif
290 #ifdef CONFIG_CIFS_SMB_DIRECT
291 	seq_printf(m, ",SMB_DIRECT");
292 #endif
293 #ifdef CONFIG_CIFS_STATS2
294 	seq_printf(m, ",STATS2");
295 #else
296 	seq_printf(m, ",STATS");
297 #endif
298 #ifdef CONFIG_CIFS_DEBUG2
299 	seq_printf(m, ",DEBUG2");
300 #elif defined(CONFIG_CIFS_DEBUG)
301 	seq_printf(m, ",DEBUG");
302 #endif
303 #ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
304 	seq_printf(m, ",ALLOW_INSECURE_LEGACY");
305 #endif
306 #ifdef CONFIG_CIFS_POSIX
307 	seq_printf(m, ",CIFS_POSIX");
308 #endif
309 #ifdef CONFIG_CIFS_UPCALL
310 	seq_printf(m, ",UPCALL(SPNEGO)");
311 #endif
312 #ifdef CONFIG_CIFS_XATTR
313 	seq_printf(m, ",XATTR");
314 #endif
315 	seq_printf(m, ",ACL");
316 #ifdef CONFIG_CIFS_SWN_UPCALL
317 	seq_puts(m, ",WITNESS");
318 #endif
319 	seq_putc(m, '\n');
320 	seq_printf(m, "CIFSMaxBufSize: %d\n", CIFSMaxBufSize);
321 	seq_printf(m, "Active VFS Requests: %d\n", GlobalTotalActiveXid);
322 
323 	seq_printf(m, "\nServers: ");
324 
325 	c = 0;
326 	spin_lock(&cifs_tcp_ses_lock);
327 	list_for_each_entry(server, &cifs_tcp_ses_list, tcp_ses_list) {
328 		/* channel info will be printed as a part of sessions below */
329 		if (CIFS_SERVER_IS_CHAN(server))
330 			continue;
331 
332 		c++;
333 		seq_printf(m, "\n%d) ConnectionId: 0x%llx ",
334 			c, server->conn_id);
335 
336 		spin_lock(&server->srv_lock);
337 		if (server->hostname)
338 			seq_printf(m, "Hostname: %s ", server->hostname);
339 		seq_printf(m, "\nClientGUID: %pUL", server->client_guid);
340 		spin_unlock(&server->srv_lock);
341 #ifdef CONFIG_CIFS_SMB_DIRECT
342 		if (!server->rdma)
343 			goto skip_rdma;
344 
345 		if (!server->smbd_conn) {
346 			seq_printf(m, "\nSMBDirect transport not available");
347 			goto skip_rdma;
348 		}
349 
350 		seq_printf(m, "\nSMBDirect (in hex) protocol version: %x "
351 			"transport status: %x",
352 			server->smbd_conn->protocol,
353 			server->smbd_conn->transport_status);
354 		seq_printf(m, "\nConn receive_credit_max: %x "
355 			"send_credit_target: %x max_send_size: %x",
356 			server->smbd_conn->receive_credit_max,
357 			server->smbd_conn->send_credit_target,
358 			server->smbd_conn->max_send_size);
359 		seq_printf(m, "\nConn max_fragmented_recv_size: %x "
360 			"max_fragmented_send_size: %x max_receive_size:%x",
361 			server->smbd_conn->max_fragmented_recv_size,
362 			server->smbd_conn->max_fragmented_send_size,
363 			server->smbd_conn->max_receive_size);
364 		seq_printf(m, "\nConn keep_alive_interval: %x "
365 			"max_readwrite_size: %x rdma_readwrite_threshold: %x",
366 			server->smbd_conn->keep_alive_interval,
367 			server->smbd_conn->max_readwrite_size,
368 			server->smbd_conn->rdma_readwrite_threshold);
369 		seq_printf(m, "\nDebug count_get_receive_buffer: %x "
370 			"count_put_receive_buffer: %x count_send_empty: %x",
371 			server->smbd_conn->count_get_receive_buffer,
372 			server->smbd_conn->count_put_receive_buffer,
373 			server->smbd_conn->count_send_empty);
374 		seq_printf(m, "\nRead Queue count_reassembly_queue: %x "
375 			"count_enqueue_reassembly_queue: %x "
376 			"count_dequeue_reassembly_queue: %x "
377 			"fragment_reassembly_remaining: %x "
378 			"reassembly_data_length: %x "
379 			"reassembly_queue_length: %x",
380 			server->smbd_conn->count_reassembly_queue,
381 			server->smbd_conn->count_enqueue_reassembly_queue,
382 			server->smbd_conn->count_dequeue_reassembly_queue,
383 			server->smbd_conn->fragment_reassembly_remaining,
384 			server->smbd_conn->reassembly_data_length,
385 			server->smbd_conn->reassembly_queue_length);
386 		seq_printf(m, "\nCurrent Credits send_credits: %x "
387 			"receive_credits: %x receive_credit_target: %x",
388 			atomic_read(&server->smbd_conn->send_credits),
389 			atomic_read(&server->smbd_conn->receive_credits),
390 			server->smbd_conn->receive_credit_target);
391 		seq_printf(m, "\nPending send_pending: %x ",
392 			atomic_read(&server->smbd_conn->send_pending));
393 		seq_printf(m, "\nReceive buffers count_receive_queue: %x "
394 			"count_empty_packet_queue: %x",
395 			server->smbd_conn->count_receive_queue,
396 			server->smbd_conn->count_empty_packet_queue);
397 		seq_printf(m, "\nMR responder_resources: %x "
398 			"max_frmr_depth: %x mr_type: %x",
399 			server->smbd_conn->responder_resources,
400 			server->smbd_conn->max_frmr_depth,
401 			server->smbd_conn->mr_type);
402 		seq_printf(m, "\nMR mr_ready_count: %x mr_used_count: %x",
403 			atomic_read(&server->smbd_conn->mr_ready_count),
404 			atomic_read(&server->smbd_conn->mr_used_count));
405 skip_rdma:
406 #endif
407 		seq_printf(m, "\nNumber of credits: %d,%d,%d Dialect 0x%x",
408 			server->credits,
409 			server->echo_credits,
410 			server->oplock_credits,
411 			server->dialect);
412 		if (server->compress_algorithm == SMB3_COMPRESS_LZNT1)
413 			seq_printf(m, " COMPRESS_LZNT1");
414 		else if (server->compress_algorithm == SMB3_COMPRESS_LZ77)
415 			seq_printf(m, " COMPRESS_LZ77");
416 		else if (server->compress_algorithm == SMB3_COMPRESS_LZ77_HUFF)
417 			seq_printf(m, " COMPRESS_LZ77_HUFF");
418 		if (server->sign)
419 			seq_printf(m, " signed");
420 		if (server->posix_ext_supported)
421 			seq_printf(m, " posix");
422 		if (server->nosharesock)
423 			seq_printf(m, " nosharesock");
424 
425 		if (server->rdma)
426 			seq_printf(m, "\nRDMA ");
427 		seq_printf(m, "\nTCP status: %d Instance: %d"
428 				"\nLocal Users To Server: %d SecMode: 0x%x Req On Wire: %d",
429 				server->tcpStatus,
430 				server->reconnect_instance,
431 				server->srv_count,
432 				server->sec_mode, in_flight(server));
433 
434 		seq_printf(m, "\nIn Send: %d In MaxReq Wait: %d",
435 				atomic_read(&server->in_send),
436 				atomic_read(&server->num_waiters));
437 		if (server->leaf_fullpath) {
438 			seq_printf(m, "\nDFS leaf full path: %s",
439 				   server->leaf_fullpath);
440 		}
441 
442 		seq_printf(m, "\n\n\tSessions: ");
443 		i = 0;
444 		list_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) {
445 			i++;
446 			if ((ses->serverDomain == NULL) ||
447 				(ses->serverOS == NULL) ||
448 				(ses->serverNOS == NULL)) {
449 				seq_printf(m, "\n\t%d) Address: %s Uses: %d Capability: 0x%x\tSession Status: %d ",
450 					i, ses->ip_addr, ses->ses_count,
451 					ses->capabilities, ses->ses_status);
452 				if (ses->session_flags & SMB2_SESSION_FLAG_IS_GUEST)
453 					seq_printf(m, "Guest ");
454 				else if (ses->session_flags & SMB2_SESSION_FLAG_IS_NULL)
455 					seq_printf(m, "Anonymous ");
456 			} else {
457 				seq_printf(m,
458 				    "\n\t%d) Name: %s  Domain: %s Uses: %d OS: %s "
459 				    "\n\tNOS: %s\tCapability: 0x%x"
460 					"\n\tSMB session status: %d ",
461 				i, ses->ip_addr, ses->serverDomain,
462 				ses->ses_count, ses->serverOS, ses->serverNOS,
463 				ses->capabilities, ses->ses_status);
464 			}
465 
466 			seq_printf(m, "\n\tSecurity type: %s ",
467 				get_security_type_str(server->ops->select_sectype(server, ses->sectype)));
468 
469 			/* dump session id helpful for use with network trace */
470 			seq_printf(m, " SessionId: 0x%llx", ses->Suid);
471 			if (ses->session_flags & SMB2_SESSION_FLAG_ENCRYPT_DATA) {
472 				seq_puts(m, " encrypted");
473 				/* can help in debugging to show encryption type */
474 				if (server->cipher_type == SMB2_ENCRYPTION_AES256_GCM)
475 					seq_puts(m, "(gcm256)");
476 			}
477 			if (ses->sign)
478 				seq_puts(m, " signed");
479 
480 			seq_printf(m, "\n\tUser: %d Cred User: %d",
481 				   from_kuid(&init_user_ns, ses->linux_uid),
482 				   from_kuid(&init_user_ns, ses->cred_uid));
483 
484 			if (ses->dfs_root_ses) {
485 				seq_printf(m, "\n\tDFS root session id: 0x%llx",
486 					   ses->dfs_root_ses->Suid);
487 			}
488 
489 			spin_lock(&ses->chan_lock);
490 			if (CIFS_CHAN_NEEDS_RECONNECT(ses, 0))
491 				seq_puts(m, "\tPrimary channel: DISCONNECTED ");
492 			if (CIFS_CHAN_IN_RECONNECT(ses, 0))
493 				seq_puts(m, "\t[RECONNECTING] ");
494 
495 			if (ses->chan_count > 1) {
496 				seq_printf(m, "\n\n\tExtra Channels: %zu ",
497 					   ses->chan_count-1);
498 				for (j = 1; j < ses->chan_count; j++) {
499 					cifs_dump_channel(m, j, &ses->chans[j]);
500 					if (CIFS_CHAN_NEEDS_RECONNECT(ses, j))
501 						seq_puts(m, "\tDISCONNECTED ");
502 					if (CIFS_CHAN_IN_RECONNECT(ses, j))
503 						seq_puts(m, "\t[RECONNECTING] ");
504 				}
505 			}
506 			spin_unlock(&ses->chan_lock);
507 
508 			seq_puts(m, "\n\n\tShares: ");
509 			j = 0;
510 
511 			seq_printf(m, "\n\t%d) IPC: ", j);
512 			if (ses->tcon_ipc)
513 				cifs_debug_tcon(m, ses->tcon_ipc);
514 			else
515 				seq_puts(m, "none\n");
516 
517 			list_for_each_entry(tcon, &ses->tcon_list, tcon_list) {
518 				++j;
519 				seq_printf(m, "\n\t%d) ", j);
520 				cifs_debug_tcon(m, tcon);
521 			}
522 
523 			spin_lock(&ses->iface_lock);
524 			if (ses->iface_count)
525 				seq_printf(m, "\n\n\tServer interfaces: %zu"
526 					   "\tLast updated: %lu seconds ago",
527 					   ses->iface_count,
528 					   (jiffies - ses->iface_last_update) / HZ);
529 			j = 0;
530 			list_for_each_entry(iface, &ses->iface_list,
531 						 iface_head) {
532 				seq_printf(m, "\n\t%d)", ++j);
533 				cifs_dump_iface(m, iface);
534 				if (is_ses_using_iface(ses, iface))
535 					seq_puts(m, "\t\t[CONNECTED]\n");
536 			}
537 			spin_unlock(&ses->iface_lock);
538 
539 			seq_puts(m, "\n\n\tMIDs: ");
540 			spin_lock(&ses->chan_lock);
541 			for (j = 0; j < ses->chan_count; j++) {
542 				chan_server = ses->chans[j].server;
543 				if (!chan_server)
544 					continue;
545 
546 				if (list_empty(&chan_server->pending_mid_q))
547 					continue;
548 
549 				seq_printf(m, "\n\tServer ConnectionId: 0x%llx",
550 					   chan_server->conn_id);
551 				spin_lock(&chan_server->mid_lock);
552 				list_for_each_entry(mid_entry, &chan_server->pending_mid_q, qhead) {
553 					seq_printf(m, "\n\t\tState: %d com: %d pid: %d cbdata: %p mid %llu",
554 						   mid_entry->mid_state,
555 						   le16_to_cpu(mid_entry->command),
556 						   mid_entry->pid,
557 						   mid_entry->callback_data,
558 						   mid_entry->mid);
559 				}
560 				spin_unlock(&chan_server->mid_lock);
561 			}
562 			spin_unlock(&ses->chan_lock);
563 			seq_puts(m, "\n--\n");
564 		}
565 		if (i == 0)
566 			seq_printf(m, "\n\t\t[NONE]");
567 	}
568 	if (c == 0)
569 		seq_printf(m, "\n\t[NONE]");
570 
571 	spin_unlock(&cifs_tcp_ses_lock);
572 	seq_putc(m, '\n');
573 	cifs_swn_dump(m);
574 
575 	/* BB add code to dump additional info such as TCP session info now */
576 	return 0;
577 }
578 
579 static ssize_t cifs_stats_proc_write(struct file *file,
580 		const char __user *buffer, size_t count, loff_t *ppos)
581 {
582 	bool bv;
583 	int rc;
584 	struct TCP_Server_Info *server;
585 	struct cifs_ses *ses;
586 	struct cifs_tcon *tcon;
587 
588 	rc = kstrtobool_from_user(buffer, count, &bv);
589 	if (rc == 0) {
590 #ifdef CONFIG_CIFS_STATS2
591 		int i;
592 
593 		atomic_set(&total_buf_alloc_count, 0);
594 		atomic_set(&total_small_buf_alloc_count, 0);
595 #endif /* CONFIG_CIFS_STATS2 */
596 		atomic_set(&tcpSesReconnectCount, 0);
597 		atomic_set(&tconInfoReconnectCount, 0);
598 
599 		spin_lock(&GlobalMid_Lock);
600 		GlobalMaxActiveXid = 0;
601 		GlobalCurrentXid = 0;
602 		spin_unlock(&GlobalMid_Lock);
603 		spin_lock(&cifs_tcp_ses_lock);
604 		list_for_each_entry(server, &cifs_tcp_ses_list, tcp_ses_list) {
605 			server->max_in_flight = 0;
606 #ifdef CONFIG_CIFS_STATS2
607 			for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
608 				atomic_set(&server->num_cmds[i], 0);
609 				atomic_set(&server->smb2slowcmd[i], 0);
610 				server->time_per_cmd[i] = 0;
611 				server->slowest_cmd[i] = 0;
612 				server->fastest_cmd[0] = 0;
613 			}
614 #endif /* CONFIG_CIFS_STATS2 */
615 			list_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) {
616 				list_for_each_entry(tcon, &ses->tcon_list, tcon_list) {
617 					atomic_set(&tcon->num_smbs_sent, 0);
618 					spin_lock(&tcon->stat_lock);
619 					tcon->bytes_read = 0;
620 					tcon->bytes_written = 0;
621 					spin_unlock(&tcon->stat_lock);
622 					if (server->ops->clear_stats)
623 						server->ops->clear_stats(tcon);
624 				}
625 			}
626 		}
627 		spin_unlock(&cifs_tcp_ses_lock);
628 	} else {
629 		return rc;
630 	}
631 
632 	return count;
633 }
634 
635 static int cifs_stats_proc_show(struct seq_file *m, void *v)
636 {
637 	int i;
638 #ifdef CONFIG_CIFS_STATS2
639 	int j;
640 #endif /* STATS2 */
641 	struct TCP_Server_Info *server;
642 	struct cifs_ses *ses;
643 	struct cifs_tcon *tcon;
644 
645 	seq_printf(m, "Resources in use\nCIFS Session: %d\n",
646 			sesInfoAllocCount.counter);
647 	seq_printf(m, "Share (unique mount targets): %d\n",
648 			tconInfoAllocCount.counter);
649 	seq_printf(m, "SMB Request/Response Buffer: %d Pool size: %d\n",
650 			buf_alloc_count.counter,
651 			cifs_min_rcv + tcpSesAllocCount.counter);
652 	seq_printf(m, "SMB Small Req/Resp Buffer: %d Pool size: %d\n",
653 			small_buf_alloc_count.counter, cifs_min_small);
654 #ifdef CONFIG_CIFS_STATS2
655 	seq_printf(m, "Total Large %d Small %d Allocations\n",
656 				atomic_read(&total_buf_alloc_count),
657 				atomic_read(&total_small_buf_alloc_count));
658 #endif /* CONFIG_CIFS_STATS2 */
659 
660 	seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&mid_count));
661 	seq_printf(m,
662 		"\n%d session %d share reconnects\n",
663 		tcpSesReconnectCount.counter, tconInfoReconnectCount.counter);
664 
665 	seq_printf(m,
666 		"Total vfs operations: %d maximum at one time: %d\n",
667 		GlobalCurrentXid, GlobalMaxActiveXid);
668 
669 	i = 0;
670 	spin_lock(&cifs_tcp_ses_lock);
671 	list_for_each_entry(server, &cifs_tcp_ses_list, tcp_ses_list) {
672 		seq_printf(m, "\nMax requests in flight: %d", server->max_in_flight);
673 #ifdef CONFIG_CIFS_STATS2
674 		seq_puts(m, "\nTotal time spent processing by command. Time ");
675 		seq_printf(m, "units are jiffies (%d per second)\n", HZ);
676 		seq_puts(m, "  SMB3 CMD\tNumber\tTotal Time\tFastest\tSlowest\n");
677 		seq_puts(m, "  --------\t------\t----------\t-------\t-------\n");
678 		for (j = 0; j < NUMBER_OF_SMB2_COMMANDS; j++)
679 			seq_printf(m, "  %d\t\t%d\t%llu\t\t%u\t%u\n", j,
680 				atomic_read(&server->num_cmds[j]),
681 				server->time_per_cmd[j],
682 				server->fastest_cmd[j],
683 				server->slowest_cmd[j]);
684 		for (j = 0; j < NUMBER_OF_SMB2_COMMANDS; j++)
685 			if (atomic_read(&server->smb2slowcmd[j])) {
686 				spin_lock(&server->srv_lock);
687 				seq_printf(m, "  %d slow responses from %s for command %d\n",
688 					atomic_read(&server->smb2slowcmd[j]),
689 					server->hostname, j);
690 				spin_unlock(&server->srv_lock);
691 			}
692 #endif /* STATS2 */
693 		list_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) {
694 			list_for_each_entry(tcon, &ses->tcon_list, tcon_list) {
695 				i++;
696 				seq_printf(m, "\n%d) %s", i, tcon->tree_name);
697 				if (tcon->need_reconnect)
698 					seq_puts(m, "\tDISCONNECTED ");
699 				seq_printf(m, "\nSMBs: %d",
700 					   atomic_read(&tcon->num_smbs_sent));
701 				if (server->ops->print_stats)
702 					server->ops->print_stats(m, tcon);
703 			}
704 		}
705 	}
706 	spin_unlock(&cifs_tcp_ses_lock);
707 
708 	seq_putc(m, '\n');
709 	return 0;
710 }
711 
712 static int cifs_stats_proc_open(struct inode *inode, struct file *file)
713 {
714 	return single_open(file, cifs_stats_proc_show, NULL);
715 }
716 
717 static const struct proc_ops cifs_stats_proc_ops = {
718 	.proc_open	= cifs_stats_proc_open,
719 	.proc_read	= seq_read,
720 	.proc_lseek	= seq_lseek,
721 	.proc_release	= single_release,
722 	.proc_write	= cifs_stats_proc_write,
723 };
724 
725 #ifdef CONFIG_CIFS_SMB_DIRECT
726 #define PROC_FILE_DEFINE(name) \
727 static ssize_t name##_write(struct file *file, const char __user *buffer, \
728 	size_t count, loff_t *ppos) \
729 { \
730 	int rc; \
731 	rc = kstrtoint_from_user(buffer, count, 10, & name); \
732 	if (rc) \
733 		return rc; \
734 	return count; \
735 } \
736 static int name##_proc_show(struct seq_file *m, void *v) \
737 { \
738 	seq_printf(m, "%d\n", name ); \
739 	return 0; \
740 } \
741 static int name##_open(struct inode *inode, struct file *file) \
742 { \
743 	return single_open(file, name##_proc_show, NULL); \
744 } \
745 \
746 static const struct proc_ops cifs_##name##_proc_fops = { \
747 	.proc_open	= name##_open, \
748 	.proc_read	= seq_read, \
749 	.proc_lseek	= seq_lseek, \
750 	.proc_release	= single_release, \
751 	.proc_write	= name##_write, \
752 }
753 
754 PROC_FILE_DEFINE(rdma_readwrite_threshold);
755 PROC_FILE_DEFINE(smbd_max_frmr_depth);
756 PROC_FILE_DEFINE(smbd_keep_alive_interval);
757 PROC_FILE_DEFINE(smbd_max_receive_size);
758 PROC_FILE_DEFINE(smbd_max_fragmented_recv_size);
759 PROC_FILE_DEFINE(smbd_max_send_size);
760 PROC_FILE_DEFINE(smbd_send_credit_target);
761 PROC_FILE_DEFINE(smbd_receive_credit_max);
762 #endif
763 
764 static struct proc_dir_entry *proc_fs_cifs;
765 static const struct proc_ops cifsFYI_proc_ops;
766 static const struct proc_ops cifs_lookup_cache_proc_ops;
767 static const struct proc_ops traceSMB_proc_ops;
768 static const struct proc_ops cifs_security_flags_proc_ops;
769 static const struct proc_ops cifs_linux_ext_proc_ops;
770 static const struct proc_ops cifs_mount_params_proc_ops;
771 
772 void
773 cifs_proc_init(void)
774 {
775 	proc_fs_cifs = proc_mkdir("fs/cifs", NULL);
776 	if (proc_fs_cifs == NULL)
777 		return;
778 
779 	proc_create_single("DebugData", 0, proc_fs_cifs,
780 			cifs_debug_data_proc_show);
781 
782 	proc_create_single("open_files", 0400, proc_fs_cifs,
783 			cifs_debug_files_proc_show);
784 
785 	proc_create("Stats", 0644, proc_fs_cifs, &cifs_stats_proc_ops);
786 	proc_create("cifsFYI", 0644, proc_fs_cifs, &cifsFYI_proc_ops);
787 	proc_create("traceSMB", 0644, proc_fs_cifs, &traceSMB_proc_ops);
788 	proc_create("LinuxExtensionsEnabled", 0644, proc_fs_cifs,
789 		    &cifs_linux_ext_proc_ops);
790 	proc_create("SecurityFlags", 0644, proc_fs_cifs,
791 		    &cifs_security_flags_proc_ops);
792 	proc_create("LookupCacheEnabled", 0644, proc_fs_cifs,
793 		    &cifs_lookup_cache_proc_ops);
794 
795 	proc_create("mount_params", 0444, proc_fs_cifs, &cifs_mount_params_proc_ops);
796 
797 #ifdef CONFIG_CIFS_DFS_UPCALL
798 	proc_create("dfscache", 0644, proc_fs_cifs, &dfscache_proc_ops);
799 #endif
800 
801 #ifdef CONFIG_CIFS_SMB_DIRECT
802 	proc_create("rdma_readwrite_threshold", 0644, proc_fs_cifs,
803 		&cifs_rdma_readwrite_threshold_proc_fops);
804 	proc_create("smbd_max_frmr_depth", 0644, proc_fs_cifs,
805 		&cifs_smbd_max_frmr_depth_proc_fops);
806 	proc_create("smbd_keep_alive_interval", 0644, proc_fs_cifs,
807 		&cifs_smbd_keep_alive_interval_proc_fops);
808 	proc_create("smbd_max_receive_size", 0644, proc_fs_cifs,
809 		&cifs_smbd_max_receive_size_proc_fops);
810 	proc_create("smbd_max_fragmented_recv_size", 0644, proc_fs_cifs,
811 		&cifs_smbd_max_fragmented_recv_size_proc_fops);
812 	proc_create("smbd_max_send_size", 0644, proc_fs_cifs,
813 		&cifs_smbd_max_send_size_proc_fops);
814 	proc_create("smbd_send_credit_target", 0644, proc_fs_cifs,
815 		&cifs_smbd_send_credit_target_proc_fops);
816 	proc_create("smbd_receive_credit_max", 0644, proc_fs_cifs,
817 		&cifs_smbd_receive_credit_max_proc_fops);
818 #endif
819 }
820 
821 void
822 cifs_proc_clean(void)
823 {
824 	if (proc_fs_cifs == NULL)
825 		return;
826 
827 	remove_proc_entry("DebugData", proc_fs_cifs);
828 	remove_proc_entry("open_files", proc_fs_cifs);
829 	remove_proc_entry("cifsFYI", proc_fs_cifs);
830 	remove_proc_entry("traceSMB", proc_fs_cifs);
831 	remove_proc_entry("Stats", proc_fs_cifs);
832 	remove_proc_entry("SecurityFlags", proc_fs_cifs);
833 	remove_proc_entry("LinuxExtensionsEnabled", proc_fs_cifs);
834 	remove_proc_entry("LookupCacheEnabled", proc_fs_cifs);
835 	remove_proc_entry("mount_params", proc_fs_cifs);
836 
837 #ifdef CONFIG_CIFS_DFS_UPCALL
838 	remove_proc_entry("dfscache", proc_fs_cifs);
839 #endif
840 #ifdef CONFIG_CIFS_SMB_DIRECT
841 	remove_proc_entry("rdma_readwrite_threshold", proc_fs_cifs);
842 	remove_proc_entry("smbd_max_frmr_depth", proc_fs_cifs);
843 	remove_proc_entry("smbd_keep_alive_interval", proc_fs_cifs);
844 	remove_proc_entry("smbd_max_receive_size", proc_fs_cifs);
845 	remove_proc_entry("smbd_max_fragmented_recv_size", proc_fs_cifs);
846 	remove_proc_entry("smbd_max_send_size", proc_fs_cifs);
847 	remove_proc_entry("smbd_send_credit_target", proc_fs_cifs);
848 	remove_proc_entry("smbd_receive_credit_max", proc_fs_cifs);
849 #endif
850 	remove_proc_entry("fs/cifs", NULL);
851 }
852 
853 static int cifsFYI_proc_show(struct seq_file *m, void *v)
854 {
855 	seq_printf(m, "%d\n", cifsFYI);
856 	return 0;
857 }
858 
859 static int cifsFYI_proc_open(struct inode *inode, struct file *file)
860 {
861 	return single_open(file, cifsFYI_proc_show, NULL);
862 }
863 
864 static ssize_t cifsFYI_proc_write(struct file *file, const char __user *buffer,
865 		size_t count, loff_t *ppos)
866 {
867 	char c[2] = { '\0' };
868 	bool bv;
869 	int rc;
870 
871 	rc = get_user(c[0], buffer);
872 	if (rc)
873 		return rc;
874 	if (kstrtobool(c, &bv) == 0)
875 		cifsFYI = bv;
876 	else if ((c[0] > '1') && (c[0] <= '9'))
877 		cifsFYI = (int) (c[0] - '0'); /* see cifs_debug.h for meanings */
878 	else
879 		return -EINVAL;
880 
881 	return count;
882 }
883 
884 static const struct proc_ops cifsFYI_proc_ops = {
885 	.proc_open	= cifsFYI_proc_open,
886 	.proc_read	= seq_read,
887 	.proc_lseek	= seq_lseek,
888 	.proc_release	= single_release,
889 	.proc_write	= cifsFYI_proc_write,
890 };
891 
892 static int cifs_linux_ext_proc_show(struct seq_file *m, void *v)
893 {
894 	seq_printf(m, "%d\n", linuxExtEnabled);
895 	return 0;
896 }
897 
898 static int cifs_linux_ext_proc_open(struct inode *inode, struct file *file)
899 {
900 	return single_open(file, cifs_linux_ext_proc_show, NULL);
901 }
902 
903 static ssize_t cifs_linux_ext_proc_write(struct file *file,
904 		const char __user *buffer, size_t count, loff_t *ppos)
905 {
906 	int rc;
907 
908 	rc = kstrtobool_from_user(buffer, count, &linuxExtEnabled);
909 	if (rc)
910 		return rc;
911 
912 	return count;
913 }
914 
915 static const struct proc_ops cifs_linux_ext_proc_ops = {
916 	.proc_open	= cifs_linux_ext_proc_open,
917 	.proc_read	= seq_read,
918 	.proc_lseek	= seq_lseek,
919 	.proc_release	= single_release,
920 	.proc_write	= cifs_linux_ext_proc_write,
921 };
922 
923 static int cifs_lookup_cache_proc_show(struct seq_file *m, void *v)
924 {
925 	seq_printf(m, "%d\n", lookupCacheEnabled);
926 	return 0;
927 }
928 
929 static int cifs_lookup_cache_proc_open(struct inode *inode, struct file *file)
930 {
931 	return single_open(file, cifs_lookup_cache_proc_show, NULL);
932 }
933 
934 static ssize_t cifs_lookup_cache_proc_write(struct file *file,
935 		const char __user *buffer, size_t count, loff_t *ppos)
936 {
937 	int rc;
938 
939 	rc = kstrtobool_from_user(buffer, count, &lookupCacheEnabled);
940 	if (rc)
941 		return rc;
942 
943 	return count;
944 }
945 
946 static const struct proc_ops cifs_lookup_cache_proc_ops = {
947 	.proc_open	= cifs_lookup_cache_proc_open,
948 	.proc_read	= seq_read,
949 	.proc_lseek	= seq_lseek,
950 	.proc_release	= single_release,
951 	.proc_write	= cifs_lookup_cache_proc_write,
952 };
953 
954 static int traceSMB_proc_show(struct seq_file *m, void *v)
955 {
956 	seq_printf(m, "%d\n", traceSMB);
957 	return 0;
958 }
959 
960 static int traceSMB_proc_open(struct inode *inode, struct file *file)
961 {
962 	return single_open(file, traceSMB_proc_show, NULL);
963 }
964 
965 static ssize_t traceSMB_proc_write(struct file *file, const char __user *buffer,
966 		size_t count, loff_t *ppos)
967 {
968 	int rc;
969 
970 	rc = kstrtobool_from_user(buffer, count, &traceSMB);
971 	if (rc)
972 		return rc;
973 
974 	return count;
975 }
976 
977 static const struct proc_ops traceSMB_proc_ops = {
978 	.proc_open	= traceSMB_proc_open,
979 	.proc_read	= seq_read,
980 	.proc_lseek	= seq_lseek,
981 	.proc_release	= single_release,
982 	.proc_write	= traceSMB_proc_write,
983 };
984 
985 static int cifs_security_flags_proc_show(struct seq_file *m, void *v)
986 {
987 	seq_printf(m, "0x%x\n", global_secflags);
988 	return 0;
989 }
990 
991 static int cifs_security_flags_proc_open(struct inode *inode, struct file *file)
992 {
993 	return single_open(file, cifs_security_flags_proc_show, NULL);
994 }
995 
996 /*
997  * Ensure that if someone sets a MUST flag, that we disable all other MAY
998  * flags except for the ones corresponding to the given MUST flag. If there are
999  * multiple MUST flags, then try to prefer more secure ones.
1000  */
1001 static void
1002 cifs_security_flags_handle_must_flags(unsigned int *flags)
1003 {
1004 	unsigned int signflags = *flags & CIFSSEC_MUST_SIGN;
1005 
1006 	if ((*flags & CIFSSEC_MUST_KRB5) == CIFSSEC_MUST_KRB5)
1007 		*flags = CIFSSEC_MUST_KRB5;
1008 	else if ((*flags & CIFSSEC_MUST_NTLMSSP) == CIFSSEC_MUST_NTLMSSP)
1009 		*flags = CIFSSEC_MUST_NTLMSSP;
1010 	else if ((*flags & CIFSSEC_MUST_NTLMV2) == CIFSSEC_MUST_NTLMV2)
1011 		*flags = CIFSSEC_MUST_NTLMV2;
1012 
1013 	*flags |= signflags;
1014 }
1015 
1016 static ssize_t cifs_security_flags_proc_write(struct file *file,
1017 		const char __user *buffer, size_t count, loff_t *ppos)
1018 {
1019 	int rc;
1020 	unsigned int flags;
1021 	char flags_string[12];
1022 	bool bv;
1023 
1024 	if ((count < 1) || (count > 11))
1025 		return -EINVAL;
1026 
1027 	memset(flags_string, 0, 12);
1028 
1029 	if (copy_from_user(flags_string, buffer, count))
1030 		return -EFAULT;
1031 
1032 	if (count < 3) {
1033 		/* single char or single char followed by null */
1034 		if (kstrtobool(flags_string, &bv) == 0) {
1035 			global_secflags = bv ? CIFSSEC_MAX : CIFSSEC_DEF;
1036 			return count;
1037 		} else if (!isdigit(flags_string[0])) {
1038 			cifs_dbg(VFS, "Invalid SecurityFlags: %s\n",
1039 					flags_string);
1040 			return -EINVAL;
1041 		}
1042 	}
1043 
1044 	/* else we have a number */
1045 	rc = kstrtouint(flags_string, 0, &flags);
1046 	if (rc) {
1047 		cifs_dbg(VFS, "Invalid SecurityFlags: %s\n",
1048 				flags_string);
1049 		return rc;
1050 	}
1051 
1052 	cifs_dbg(FYI, "sec flags 0x%x\n", flags);
1053 
1054 	if (flags == 0)  {
1055 		cifs_dbg(VFS, "Invalid SecurityFlags: %s\n", flags_string);
1056 		return -EINVAL;
1057 	}
1058 
1059 	if (flags & ~CIFSSEC_MASK) {
1060 		cifs_dbg(VFS, "Unsupported security flags: 0x%x\n",
1061 			 flags & ~CIFSSEC_MASK);
1062 		return -EINVAL;
1063 	}
1064 
1065 	cifs_security_flags_handle_must_flags(&flags);
1066 
1067 	/* flags look ok - update the global security flags for cifs module */
1068 	global_secflags = flags;
1069 	if (global_secflags & CIFSSEC_MUST_SIGN) {
1070 		/* requiring signing implies signing is allowed */
1071 		global_secflags |= CIFSSEC_MAY_SIGN;
1072 		cifs_dbg(FYI, "packet signing now required\n");
1073 	} else if ((global_secflags & CIFSSEC_MAY_SIGN) == 0) {
1074 		cifs_dbg(FYI, "packet signing disabled\n");
1075 	}
1076 	/* BB should we turn on MAY flags for other MUST options? */
1077 	return count;
1078 }
1079 
1080 static const struct proc_ops cifs_security_flags_proc_ops = {
1081 	.proc_open	= cifs_security_flags_proc_open,
1082 	.proc_read	= seq_read,
1083 	.proc_lseek	= seq_lseek,
1084 	.proc_release	= single_release,
1085 	.proc_write	= cifs_security_flags_proc_write,
1086 };
1087 
1088 /* To make it easier to debug, can help to show mount params */
1089 static int cifs_mount_params_proc_show(struct seq_file *m, void *v)
1090 {
1091 	const struct fs_parameter_spec *p;
1092 	const char *type;
1093 
1094 	for (p = smb3_fs_parameters; p->name; p++) {
1095 		/* cannot use switch with pointers... */
1096 		if (!p->type) {
1097 			if (p->flags == fs_param_neg_with_no)
1098 				type = "noflag";
1099 			else
1100 				type = "flag";
1101 		} else if (p->type == fs_param_is_bool)
1102 			type = "bool";
1103 		else if (p->type == fs_param_is_u32)
1104 			type = "u32";
1105 		else if (p->type == fs_param_is_u64)
1106 			type = "u64";
1107 		else if (p->type == fs_param_is_string)
1108 			type = "string";
1109 		else
1110 			type = "unknown";
1111 
1112 		seq_printf(m, "%s:%s\n", p->name, type);
1113 	}
1114 
1115 	return 0;
1116 }
1117 
1118 static int cifs_mount_params_proc_open(struct inode *inode, struct file *file)
1119 {
1120 	return single_open(file, cifs_mount_params_proc_show, NULL);
1121 }
1122 
1123 static const struct proc_ops cifs_mount_params_proc_ops = {
1124 	.proc_open	= cifs_mount_params_proc_open,
1125 	.proc_read	= seq_read,
1126 	.proc_lseek	= seq_lseek,
1127 	.proc_release	= single_release,
1128 	/* No need for write for now */
1129 	/* .proc_write	= cifs_mount_params_proc_write, */
1130 };
1131 
1132 #else
1133 inline void cifs_proc_init(void)
1134 {
1135 }
1136 
1137 inline void cifs_proc_clean(void)
1138 {
1139 }
1140 #endif /* PROC_FS */
1141