0001
0002
0003
0004
0005
0006
0007
0008 #ifndef _CIFS_DFS_CACHE_H
0009 #define _CIFS_DFS_CACHE_H
0010
0011 #include <linux/nls.h>
0012 #include <linux/list.h>
0013 #include <linux/uuid.h>
0014 #include "cifsglob.h"
0015
0016 #define DFS_CACHE_TGT_LIST_INIT(var) { .tl_numtgts = 0, .tl_list = LIST_HEAD_INIT((var).tl_list), }
0017
0018 struct dfs_cache_tgt_list {
0019 int tl_numtgts;
0020 struct list_head tl_list;
0021 };
0022
0023 struct dfs_cache_tgt_iterator {
0024 char *it_name;
0025 int it_path_consumed;
0026 struct list_head it_list;
0027 };
0028
0029 int dfs_cache_init(void);
0030 void dfs_cache_destroy(void);
0031 extern const struct proc_ops dfscache_proc_ops;
0032
0033 int dfs_cache_find(const unsigned int xid, struct cifs_ses *ses, const struct nls_table *cp,
0034 int remap, const char *path, struct dfs_info3_param *ref,
0035 struct dfs_cache_tgt_list *tgt_list);
0036 int dfs_cache_noreq_find(const char *path, struct dfs_info3_param *ref,
0037 struct dfs_cache_tgt_list *tgt_list);
0038 int dfs_cache_update_tgthint(const unsigned int xid, struct cifs_ses *ses,
0039 const struct nls_table *cp, int remap, const char *path,
0040 const struct dfs_cache_tgt_iterator *it);
0041 int dfs_cache_noreq_update_tgthint(const char *path, const struct dfs_cache_tgt_iterator *it);
0042 int dfs_cache_get_tgt_referral(const char *path, const struct dfs_cache_tgt_iterator *it,
0043 struct dfs_info3_param *ref);
0044 int dfs_cache_get_tgt_share(char *path, const struct dfs_cache_tgt_iterator *it, char **share,
0045 char **prefix);
0046 void dfs_cache_put_refsrv_sessions(const uuid_t *mount_id);
0047 void dfs_cache_add_refsrv_session(const uuid_t *mount_id, struct cifs_ses *ses);
0048 char *dfs_cache_canonical_path(const char *path, const struct nls_table *cp, int remap);
0049 int dfs_cache_remount_fs(struct cifs_sb_info *cifs_sb);
0050
0051 static inline struct dfs_cache_tgt_iterator *
0052 dfs_cache_get_next_tgt(struct dfs_cache_tgt_list *tl,
0053 struct dfs_cache_tgt_iterator *it)
0054 {
0055 if (!tl || list_empty(&tl->tl_list) || !it ||
0056 list_is_last(&it->it_list, &tl->tl_list))
0057 return NULL;
0058 return list_next_entry(it, it_list);
0059 }
0060
0061 static inline struct dfs_cache_tgt_iterator *
0062 dfs_cache_get_tgt_iterator(struct dfs_cache_tgt_list *tl)
0063 {
0064 if (!tl)
0065 return NULL;
0066 return list_first_entry_or_null(&tl->tl_list,
0067 struct dfs_cache_tgt_iterator,
0068 it_list);
0069 }
0070
0071 static inline void dfs_cache_free_tgts(struct dfs_cache_tgt_list *tl)
0072 {
0073 struct dfs_cache_tgt_iterator *it, *nit;
0074
0075 if (!tl || list_empty(&tl->tl_list))
0076 return;
0077 list_for_each_entry_safe(it, nit, &tl->tl_list, it_list) {
0078 list_del(&it->it_list);
0079 kfree(it->it_name);
0080 kfree(it);
0081 }
0082 tl->tl_numtgts = 0;
0083 }
0084
0085 static inline const char *
0086 dfs_cache_get_tgt_name(const struct dfs_cache_tgt_iterator *it)
0087 {
0088 return it ? it->it_name : NULL;
0089 }
0090
0091 static inline int
0092 dfs_cache_get_nr_tgts(const struct dfs_cache_tgt_list *tl)
0093 {
0094 return tl ? tl->tl_numtgts : 0;
0095 }
0096
0097 #endif