This source file includes following definitions.
- cifs_fscache_register
- cifs_fscache_unregister
- extract_sharename
- cifs_fscache_super_check_aux
- cifs_fscache_inode_check_aux
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 #include "fscache.h"
22 #include "cifs_debug.h"
23
24
25
26
27 struct fscache_netfs cifs_fscache_netfs = {
28 .name = "cifs",
29 .version = 0,
30 };
31
32
33
34
35 int cifs_fscache_register(void)
36 {
37 return fscache_register_netfs(&cifs_fscache_netfs);
38 }
39
40
41
42
43 void cifs_fscache_unregister(void)
44 {
45 fscache_unregister_netfs(&cifs_fscache_netfs);
46 }
47
48
49
50
51 const struct fscache_cookie_def cifs_fscache_server_index_def = {
52 .name = "CIFS.server",
53 .type = FSCACHE_COOKIE_TYPE_INDEX,
54 };
55
56
57
58
59 struct cifs_fscache_super_auxdata {
60 u64 resource_id;
61 };
62
63 char *extract_sharename(const char *treename)
64 {
65 const char *src;
66 char *delim, *dst;
67 int len;
68
69
70 src = treename + 2;
71
72
73 delim = strchr(src, '\\');
74 if (!delim)
75 return ERR_PTR(-EINVAL);
76 delim++;
77 len = strlen(delim);
78
79
80 dst = kstrndup(delim, len, GFP_KERNEL);
81 if (!dst)
82 return ERR_PTR(-ENOMEM);
83
84 return dst;
85 }
86
87 static enum
88 fscache_checkaux cifs_fscache_super_check_aux(void *cookie_netfs_data,
89 const void *data,
90 uint16_t datalen,
91 loff_t object_size)
92 {
93 struct cifs_fscache_super_auxdata auxdata;
94 const struct cifs_tcon *tcon = cookie_netfs_data;
95
96 if (datalen != sizeof(auxdata))
97 return FSCACHE_CHECKAUX_OBSOLETE;
98
99 memset(&auxdata, 0, sizeof(auxdata));
100 auxdata.resource_id = tcon->resource_id;
101
102 if (memcmp(data, &auxdata, datalen) != 0)
103 return FSCACHE_CHECKAUX_OBSOLETE;
104
105 return FSCACHE_CHECKAUX_OKAY;
106 }
107
108
109
110
111 const struct fscache_cookie_def cifs_fscache_super_index_def = {
112 .name = "CIFS.super",
113 .type = FSCACHE_COOKIE_TYPE_INDEX,
114 .check_aux = cifs_fscache_super_check_aux,
115 };
116
117 static enum
118 fscache_checkaux cifs_fscache_inode_check_aux(void *cookie_netfs_data,
119 const void *data,
120 uint16_t datalen,
121 loff_t object_size)
122 {
123 struct cifs_fscache_inode_auxdata auxdata;
124 struct cifsInodeInfo *cifsi = cookie_netfs_data;
125
126 if (datalen != sizeof(auxdata))
127 return FSCACHE_CHECKAUX_OBSOLETE;
128
129 memset(&auxdata, 0, sizeof(auxdata));
130 auxdata.eof = cifsi->server_eof;
131 auxdata.last_write_time_sec = cifsi->vfs_inode.i_mtime.tv_sec;
132 auxdata.last_change_time_sec = cifsi->vfs_inode.i_ctime.tv_sec;
133 auxdata.last_write_time_nsec = cifsi->vfs_inode.i_mtime.tv_nsec;
134 auxdata.last_change_time_nsec = cifsi->vfs_inode.i_ctime.tv_nsec;
135
136 if (memcmp(data, &auxdata, datalen) != 0)
137 return FSCACHE_CHECKAUX_OBSOLETE;
138
139 return FSCACHE_CHECKAUX_OKAY;
140 }
141
142 const struct fscache_cookie_def cifs_fscache_inode_object_def = {
143 .name = "CIFS.uniqueid",
144 .type = FSCACHE_COOKIE_TYPE_DATAFILE,
145 .check_aux = cifs_fscache_inode_check_aux,
146 };