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
27struct fscache_netfs cifs_fscache_netfs = {
28 .name = "cifs",
29 .version = 0,
30};
31
32
33
34
35int cifs_fscache_register(void)
36{
37 return fscache_register_netfs(&cifs_fscache_netfs);
38}
39
40
41
42
43void cifs_fscache_unregister(void)
44{
45 fscache_unregister_netfs(&cifs_fscache_netfs);
46}
47
48
49
50
51const struct fscache_cookie_def cifs_fscache_server_index_def = {
52 .name = "CIFS.server",
53 .type = FSCACHE_COOKIE_TYPE_INDEX,
54};
55
56static enum
57fscache_checkaux cifs_fscache_super_check_aux(void *cookie_netfs_data,
58 const void *data,
59 uint16_t datalen,
60 loff_t object_size)
61{
62 struct cifs_fscache_super_auxdata auxdata;
63 const struct cifs_tcon *tcon = cookie_netfs_data;
64
65 if (datalen != sizeof(auxdata))
66 return FSCACHE_CHECKAUX_OBSOLETE;
67
68 memset(&auxdata, 0, sizeof(auxdata));
69 auxdata.resource_id = tcon->resource_id;
70 auxdata.vol_create_time = tcon->vol_create_time;
71 auxdata.vol_serial_number = tcon->vol_serial_number;
72
73 if (memcmp(data, &auxdata, datalen) != 0)
74 return FSCACHE_CHECKAUX_OBSOLETE;
75
76 return FSCACHE_CHECKAUX_OKAY;
77}
78
79
80
81
82const struct fscache_cookie_def cifs_fscache_super_index_def = {
83 .name = "CIFS.super",
84 .type = FSCACHE_COOKIE_TYPE_INDEX,
85 .check_aux = cifs_fscache_super_check_aux,
86};
87
88static enum
89fscache_checkaux cifs_fscache_inode_check_aux(void *cookie_netfs_data,
90 const void *data,
91 uint16_t datalen,
92 loff_t object_size)
93{
94 struct cifs_fscache_inode_auxdata auxdata;
95 struct cifsInodeInfo *cifsi = cookie_netfs_data;
96
97 if (datalen != sizeof(auxdata))
98 return FSCACHE_CHECKAUX_OBSOLETE;
99
100 memset(&auxdata, 0, sizeof(auxdata));
101 auxdata.eof = cifsi->server_eof;
102 auxdata.last_write_time_sec = cifsi->vfs_inode.i_mtime.tv_sec;
103 auxdata.last_change_time_sec = cifsi->vfs_inode.i_ctime.tv_sec;
104 auxdata.last_write_time_nsec = cifsi->vfs_inode.i_mtime.tv_nsec;
105 auxdata.last_change_time_nsec = cifsi->vfs_inode.i_ctime.tv_nsec;
106
107 if (memcmp(data, &auxdata, datalen) != 0)
108 return FSCACHE_CHECKAUX_OBSOLETE;
109
110 return FSCACHE_CHECKAUX_OKAY;
111}
112
113const struct fscache_cookie_def cifs_fscache_inode_object_def = {
114 .name = "CIFS.uniqueid",
115 .type = FSCACHE_COOKIE_TYPE_DATAFILE,
116 .check_aux = cifs_fscache_inode_check_aux,
117};
118