1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  *   Copyright (C) 2018 Samsung Electronics Co., Ltd.
4  */
5 
6 #ifndef __TREE_CONNECT_MANAGEMENT_H__
7 #define __TREE_CONNECT_MANAGEMENT_H__
8 
9 #include <linux/hashtable.h>
10 
11 #include "../ksmbd_netlink.h"
12 
13 struct ksmbd_share_config;
14 struct ksmbd_user;
15 struct ksmbd_conn;
16 
17 enum {
18 	TREE_NEW = 0,
19 	TREE_CONNECTED,
20 	TREE_DISCONNECTED
21 };
22 
23 struct ksmbd_tree_connect {
24 	int				id;
25 
26 	unsigned int			flags;
27 	struct ksmbd_share_config	*share_conf;
28 	struct ksmbd_user		*user;
29 
30 	struct list_head		list;
31 
32 	int				maximal_access;
33 	bool				posix_extensions;
34 	atomic_t			refcount;
35 	wait_queue_head_t		refcount_q;
36 	unsigned int			t_state;
37 };
38 
39 struct ksmbd_tree_conn_status {
40 	unsigned int			ret;
41 	struct ksmbd_tree_connect	*tree_conn;
42 };
43 
test_tree_conn_flag(struct ksmbd_tree_connect * tree_conn,int flag)44 static inline int test_tree_conn_flag(struct ksmbd_tree_connect *tree_conn,
45 				      int flag)
46 {
47 	return tree_conn->flags & flag;
48 }
49 
50 struct ksmbd_session;
51 
52 struct ksmbd_tree_conn_status
53 ksmbd_tree_conn_connect(struct ksmbd_conn *conn, struct ksmbd_session *sess,
54 			const char *share_name);
55 void ksmbd_tree_connect_put(struct ksmbd_tree_connect *tcon);
56 
57 int ksmbd_tree_conn_disconnect(struct ksmbd_session *sess,
58 			       struct ksmbd_tree_connect *tree_conn);
59 
60 struct ksmbd_tree_connect *ksmbd_tree_conn_lookup(struct ksmbd_session *sess,
61 						  unsigned int id);
62 
63 int ksmbd_tree_conn_session_logoff(struct ksmbd_session *sess);
64 
65 #endif /* __TREE_CONNECT_MANAGEMENT_H__ */
66