1 /* SPDX-License-Identifier: GPL-2.0 */
3 * DFS referral cache routines
5 * Copyright (c) 2018-2019 Paulo Alcantara <palcantara@suse.de>
8 #ifndef _CIFS_DFS_CACHE_H
9 #define _CIFS_DFS_CACHE_H
11 #include <linux/nls.h>
12 #include <linux/list.h>
15 struct dfs_cache_tgt_list
{
17 struct list_head tl_list
;
20 struct dfs_cache_tgt_iterator
{
23 struct list_head it_list
;
26 extern int dfs_cache_init(void);
27 extern void dfs_cache_destroy(void);
28 extern const struct proc_ops dfscache_proc_ops
;
30 extern int dfs_cache_find(const unsigned int xid
, struct cifs_ses
*ses
,
31 const struct nls_table
*nls_codepage
, int remap
,
32 const char *path
, struct dfs_info3_param
*ref
,
33 struct dfs_cache_tgt_list
*tgt_list
);
34 extern int dfs_cache_noreq_find(const char *path
, struct dfs_info3_param
*ref
,
35 struct dfs_cache_tgt_list
*tgt_list
);
36 extern int dfs_cache_update_tgthint(const unsigned int xid
,
38 const struct nls_table
*nls_codepage
,
39 int remap
, const char *path
,
40 const struct dfs_cache_tgt_iterator
*it
);
42 dfs_cache_noreq_update_tgthint(const char *path
,
43 const struct dfs_cache_tgt_iterator
*it
);
44 extern int dfs_cache_get_tgt_referral(const char *path
,
45 const struct dfs_cache_tgt_iterator
*it
,
46 struct dfs_info3_param
*ref
);
47 extern int dfs_cache_add_vol(char *mntdata
, struct smb3_fs_context
*ctx
,
48 const char *fullpath
);
49 extern int dfs_cache_update_vol(const char *fullpath
,
50 struct TCP_Server_Info
*server
);
51 extern void dfs_cache_del_vol(const char *fullpath
);
52 extern int dfs_cache_get_tgt_share(char *path
, const struct dfs_cache_tgt_iterator
*it
,
53 char **share
, char **prefix
);
55 static inline struct dfs_cache_tgt_iterator
*
56 dfs_cache_get_next_tgt(struct dfs_cache_tgt_list
*tl
,
57 struct dfs_cache_tgt_iterator
*it
)
59 if (!tl
|| list_empty(&tl
->tl_list
) || !it
||
60 list_is_last(&it
->it_list
, &tl
->tl_list
))
62 return list_next_entry(it
, it_list
);
65 static inline struct dfs_cache_tgt_iterator
*
66 dfs_cache_get_tgt_iterator(struct dfs_cache_tgt_list
*tl
)
70 return list_first_entry_or_null(&tl
->tl_list
,
71 struct dfs_cache_tgt_iterator
,
75 static inline void dfs_cache_free_tgts(struct dfs_cache_tgt_list
*tl
)
77 struct dfs_cache_tgt_iterator
*it
, *nit
;
79 if (!tl
|| list_empty(&tl
->tl_list
))
81 list_for_each_entry_safe(it
, nit
, &tl
->tl_list
, it_list
) {
82 list_del(&it
->it_list
);
89 static inline const char *
90 dfs_cache_get_tgt_name(const struct dfs_cache_tgt_iterator
*it
)
92 return it
? it
->it_name
: NULL
;
96 dfs_cache_get_nr_tgts(const struct dfs_cache_tgt_list
*tl
)
98 return tl
? tl
->tl_numtgts
: 0;
101 #endif /* _CIFS_DFS_CACHE_H */