Blame view

fs/cifs/dfs_cache.h 2.8 KB
54be1f6c1   Paulo Alcantara   cifs: Add DFS cac...
1
2
3
4
  /* SPDX-License-Identifier: GPL-2.0 */
  /*
   * DFS referral cache routines
   *
5072010cc   Paulo Alcantara (SUSE)   cifs: Fix DFS cac...
5
   * Copyright (c) 2018-2019 Paulo Alcantara <palcantara@suse.de>
54be1f6c1   Paulo Alcantara   cifs: Add DFS cac...
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
   */
  
  #ifndef _CIFS_DFS_CACHE_H
  #define _CIFS_DFS_CACHE_H
  
  #include <linux/nls.h>
  #include <linux/list.h>
  #include "cifsglob.h"
  
  struct dfs_cache_tgt_list {
  	int tl_numtgts;
  	struct list_head tl_list;
  };
  
  struct dfs_cache_tgt_iterator {
  	char *it_name;
7548e1da8   Paulo Alcantara   cifs: handle RESP...
22
  	int it_path_consumed;
54be1f6c1   Paulo Alcantara   cifs: Add DFS cac...
23
24
25
26
27
  	struct list_head it_list;
  };
  
  extern int dfs_cache_init(void);
  extern void dfs_cache_destroy(void);
97a32539b   Alexey Dobriyan   proc: convert eve...
28
  extern const struct proc_ops dfscache_proc_ops;
54be1f6c1   Paulo Alcantara   cifs: Add DFS cac...
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
  
  extern int dfs_cache_find(const unsigned int xid, struct cifs_ses *ses,
  			  const struct nls_table *nls_codepage, int remap,
  			  const char *path, struct dfs_info3_param *ref,
  			  struct dfs_cache_tgt_list *tgt_list);
  extern int dfs_cache_noreq_find(const char *path, struct dfs_info3_param *ref,
  				struct dfs_cache_tgt_list *tgt_list);
  extern int dfs_cache_update_tgthint(const unsigned int xid,
  				    struct cifs_ses *ses,
  				    const struct nls_table *nls_codepage,
  				    int remap, const char *path,
  				    const struct dfs_cache_tgt_iterator *it);
  extern int
  dfs_cache_noreq_update_tgthint(const char *path,
  			       const struct dfs_cache_tgt_iterator *it);
  extern int dfs_cache_get_tgt_referral(const char *path,
  				      const struct dfs_cache_tgt_iterator *it,
  				      struct dfs_info3_param *ref);
5072010cc   Paulo Alcantara (SUSE)   cifs: Fix DFS cac...
47
48
  extern int dfs_cache_add_vol(char *mntdata, struct smb_vol *vol,
  			const char *fullpath);
54be1f6c1   Paulo Alcantara   cifs: Add DFS cac...
49
50
51
  extern int dfs_cache_update_vol(const char *fullpath,
  				struct TCP_Server_Info *server);
  extern void dfs_cache_del_vol(const char *fullpath);
7548e1da8   Paulo Alcantara   cifs: handle RESP...
52
53
  extern int dfs_cache_get_tgt_share(char *path, const struct dfs_cache_tgt_iterator *it,
  				   char **share, char **prefix);
bacd704a9   Paulo Alcantara (SUSE)   cifs: handle pref...
54

54be1f6c1   Paulo Alcantara   cifs: Add DFS cac...
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
  static inline struct dfs_cache_tgt_iterator *
  dfs_cache_get_next_tgt(struct dfs_cache_tgt_list *tl,
  		       struct dfs_cache_tgt_iterator *it)
  {
  	if (!tl || list_empty(&tl->tl_list) || !it ||
  	    list_is_last(&it->it_list, &tl->tl_list))
  		return NULL;
  	return list_next_entry(it, it_list);
  }
  
  static inline struct dfs_cache_tgt_iterator *
  dfs_cache_get_tgt_iterator(struct dfs_cache_tgt_list *tl)
  {
  	if (!tl)
  		return NULL;
  	return list_first_entry_or_null(&tl->tl_list,
  					struct dfs_cache_tgt_iterator,
  					it_list);
  }
  
  static inline void dfs_cache_free_tgts(struct dfs_cache_tgt_list *tl)
  {
  	struct dfs_cache_tgt_iterator *it, *nit;
  
  	if (!tl || list_empty(&tl->tl_list))
  		return;
  	list_for_each_entry_safe(it, nit, &tl->tl_list, it_list) {
  		list_del(&it->it_list);
  		kfree(it->it_name);
  		kfree(it);
  	}
  	tl->tl_numtgts = 0;
  }
  
  static inline const char *
  dfs_cache_get_tgt_name(const struct dfs_cache_tgt_iterator *it)
  {
  	return it ? it->it_name : NULL;
  }
  
  static inline int
  dfs_cache_get_nr_tgts(const struct dfs_cache_tgt_list *tl)
  {
  	return tl ? tl->tl_numtgts : 0;
  }
  
  #endif /* _CIFS_DFS_CACHE_H */