xref: /linux/fs/smb/server/mgmt/tree_connect.h (revision 6b4aa469f04999c3f244515fa7491b4d093c5167)
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 struct ksmbd_work;
17 
18 enum {
19 	TREE_NEW = 0,
20 	TREE_CONNECTED,
21 	TREE_DISCONNECTED
22 };
23 
24 struct ksmbd_tree_connect {
25 	int				id;
26 
27 	unsigned int			flags;
28 	struct ksmbd_share_config	*share_conf;
29 	struct ksmbd_user		*user;
30 
31 	struct list_head		list;
32 
33 	int				maximal_access;
34 	bool				posix_extensions;
35 	atomic_t			refcount;
36 	wait_queue_head_t		refcount_q;
37 	unsigned int			t_state;
38 };
39 
40 struct ksmbd_tree_conn_status {
41 	unsigned int			ret;
42 	struct ksmbd_tree_connect	*tree_conn;
43 };
44 
test_tree_conn_flag(struct ksmbd_tree_connect * tree_conn,int flag)45 static inline int test_tree_conn_flag(struct ksmbd_tree_connect *tree_conn,
46 				      int flag)
47 {
48 	return tree_conn->flags & flag;
49 }
50 
51 struct ksmbd_session;
52 
53 struct ksmbd_tree_conn_status
54 ksmbd_tree_conn_connect(struct ksmbd_work *work, 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