e8f761e37191355e107a6a79ecbb10333354c604
[librecmc/librecmc.git] / package / fuse / patches / 300-2.6.24_fixes.patch
1 # HG changeset patch
2 # User mszeredi
3 # Date 1197485983 0
4 # Node ID 5b8914cfe0fb7ccfb6e7f61512374d8541f2a193
5 # Parent 81a85541800582144b7381e0b022c10245facc61
6 Fix kernel module compile for 2.6.24
7
8 --- a/kernel/dir.c      Wed Dec 12 14:33:17 2007 +0000
9 +++ b/kernel/dir.c      Wed Dec 12 18:59:43 2007 +0000
10 @@ -191,7 +191,7 @@ static int invalid_nodeid(u64 nodeid)
11         return !nodeid || nodeid == FUSE_ROOT_ID;
12  }
13  
14 -static struct dentry_operations fuse_dentry_operations = {
15 +struct dentry_operations fuse_dentry_operations = {
16         .d_revalidate   = fuse_dentry_revalidate,
17  };
18  
19 @@ -378,6 +378,7 @@ static int fuse_create_open(struct inode
20         }
21         fuse_put_request(fc, forget_req);
22         d_instantiate(entry, inode);
23 +       fuse_invalidate_attr(dir);
24         fuse_change_timeout(entry, &outentry);
25         file = lookup_instantiate_filp(nd, entry, generic_file_open);
26         if (IS_ERR(file)) {
27 @@ -619,6 +620,9 @@ static int fuse_rename(struct inode *old
28         err = req->out.h.error;
29         fuse_put_request(fc, req);
30         if (!err) {
31 +               /* ctime changes */
32 +               fuse_invalidate_attr(oldent->d_inode);
33 +
34                 fuse_invalidate_attr(olddir);
35                 if (olddir != newdir)
36                         fuse_invalidate_attr(newdir);
37 --- a/kernel/fuse_i.h   Wed Dec 12 14:33:17 2007 +0000
38 +++ b/kernel/fuse_i.h   Wed Dec 12 18:59:43 2007 +0000
39 @@ -47,6 +47,9 @@
40  #endif
41  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)
42  #  define KERNEL_2_6_23_PLUS
43 +#endif
44 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
45 +#  define KERNEL_2_6_24_PLUS
46  #endif
47  
48  #if defined(__arm__) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
49 @@ -647,3 +650,5 @@ int fuse_valid_type(int m);
50   * Is task allowed to perform filesystem operation?
51   */
52  int fuse_allow_task(struct fuse_conn *fc, struct task_struct *task);
53 +
54 +extern struct dentry_operations fuse_dentry_operations;
55 --- a/kernel/inode.c    Wed Dec 12 14:33:17 2007 +0000
56 +++ b/kernel/inode.c    Wed Dec 12 18:59:43 2007 +0000
57 @@ -520,21 +520,26 @@ static struct inode *get_root_inode(stru
58  #ifdef HAVE_EXPORTFS_H
59  #include <linux/exportfs.h>
60  #endif
61 -static struct dentry *fuse_get_dentry(struct super_block *sb, void *vobjp)
62 +
63 +struct fuse_inode_handle
64  {
65 -       __u32 *objp = vobjp;
66 -       unsigned long nodeid = objp[0];
67 -       __u32 generation = objp[1];
68 +       u64 nodeid;
69 +       u32 generation;
70 +};
71 +
72 +static struct dentry *fuse_get_dentry(struct super_block *sb,
73 +                                     struct fuse_inode_handle *handle)
74 +{
75         struct inode *inode;
76         struct dentry *entry;
77  
78 -       if (nodeid == 0)
79 +       if (handle->nodeid == 0)
80                 return ERR_PTR(-ESTALE);
81  
82 -       inode = ilookup5(sb, nodeid, fuse_inode_eq, &nodeid);
83 +       inode = ilookup5(sb, handle->nodeid, fuse_inode_eq, &handle->nodeid);
84         if (!inode)
85                 return ERR_PTR(-ESTALE);
86 -       if (inode->i_generation != generation) {
87 +       if (inode->i_generation != handle->generation) {
88                 iput(inode);
89                 return ERR_PTR(-ESTALE);
90         }
91 @@ -544,42 +549,130 @@ static struct dentry *fuse_get_dentry(st
92                 iput(inode);
93                 return ERR_PTR(-ENOMEM);
94         }
95 +       entry->d_op = &fuse_dentry_operations;
96  
97         return entry;
98  }
99  
100 -static int fuse_encode_fh(struct dentry *dentry, __u32 *fh, int *max_len,
101 -                         int connectable)
102 +static int fuse_encode_fh(struct dentry *dentry, u32 *fh, int *max_len,
103 +                          int connectable)
104  {
105         struct inode *inode = dentry->d_inode;
106         int len = *max_len;
107         int type = 1;
108 +       u64 nodeid;
109 +       u32 generation;
110  
111 -       if (len < 2 || (connectable && len < 4))
112 -               return 255;
113 +       if (len < 3 || (connectable && len < 6))
114 +               return  255;
115  
116 -       len = 2;
117 -       fh[0] = get_fuse_inode(inode)->nodeid;
118 -       fh[1] = inode->i_generation;
119 +       nodeid = get_fuse_inode(inode)->nodeid;
120 +       generation = inode->i_generation;
121 +
122 +       len = 3;
123 +       fh[0] = (u32)(nodeid >> 32);
124 +       fh[1] = (u32)(nodeid & 0xffffffff);
125 +       fh[2] = generation;
126 +
127         if (connectable && !S_ISDIR(inode->i_mode)) {
128                 struct inode *parent;
129  
130                 spin_lock(&dentry->d_lock);
131                 parent = dentry->d_parent->d_inode;
132 -               fh[2] = get_fuse_inode(parent)->nodeid;
133 -               fh[3] = parent->i_generation;
134 +               nodeid = get_fuse_inode(parent)->nodeid;
135 +               generation = parent->i_generation;
136 +
137 +               fh[3] = (u32)(nodeid >> 32);
138 +               fh[4] = (u32)(nodeid & 0xffffffff);
139 +               fh[5] = generation;
140                 spin_unlock(&dentry->d_lock);
141 -               len = 4;
142 +
143 +               len = 6;
144                 type = 2;
145         }
146 +
147         *max_len = len;
148         return type;
149  }
150  
151 +#ifdef KERNEL_2_6_24_PLUS
152 +static struct dentry *fuse_fh_to_dentry(struct super_block *sb,
153 +               struct fid *fid, int fh_len, int fh_type)
154 +{
155 +       struct fuse_inode_handle handle;
156 +
157 +       if (fh_len < 3 || fh_type > 2)
158 +               return NULL;
159 +
160 +       handle.nodeid = (u64) fid->raw[0] << 32;
161 +       handle.nodeid |= (u64) fid->raw[1];
162 +       handle.generation = fid->raw[2];
163 +       return fuse_get_dentry(sb, &handle);
164 +}
165 +
166 +static struct dentry *fuse_fh_to_parent(struct super_block *sb,
167 +               struct fid *fid, int fh_len, int fh_type)
168 +{
169 +       struct fuse_inode_handle parent;
170 +
171 +       if (fh_type != 2 || fh_len < 6)
172 +               return NULL;
173 +
174 +       parent.nodeid = (u64) fid->raw[3] << 32;
175 +       parent.nodeid |= (u64) fid->raw[4];
176 +       parent.generation = fid->raw[5];
177 +       return fuse_get_dentry(sb, &parent);
178 +}
179 +
180 +
181 +static const struct export_operations fuse_export_operations = {
182 +       .fh_to_dentry   = fuse_fh_to_dentry,
183 +       .fh_to_parent   = fuse_fh_to_parent,
184 +       .encode_fh      = fuse_encode_fh,
185 +};
186 +#else
187 +static struct dentry *fuse_get_dentry_old(struct super_block *sb, void *objp)
188 +{
189 +       return fuse_get_dentry(sb, objp);
190 +}
191 +
192 +static struct dentry *fuse_decode_fh(struct super_block *sb, u32 *fh,
193 +                       int fh_len, int fileid_type,
194 +                       int (*acceptable)(void *context, struct dentry *de),
195 +                       void *context)
196 +{
197 +       struct fuse_inode_handle handle;
198 +       struct fuse_inode_handle parent;
199 +
200 +       if (fh_len < 3 || fileid_type > 2)
201 +               return NULL;
202 +
203 +       if (fileid_type == 2) {
204 +               if (fh_len < 6)
205 +                       return NULL;
206 +
207 +               parent.nodeid = (u64) fh[3] << 32;
208 +               parent.nodeid |= (u64) fh[4];
209 +               parent.generation = fh[5];
210 +       } else {
211 +               parent.nodeid = 0;
212 +               parent.generation = 0;
213 +       }
214 +
215 +       handle.nodeid = (u64) fh[0] << 32;
216 +       handle.nodeid |= (u64) fh[1];
217 +       handle.generation = fh[2];
218 +
219 +       return ret = fuse_export_operations.
220 +               find_exported_dentry(sb, &handle, &parent, acceptable, context);
221 +}
222 +
223  static struct export_operations fuse_export_operations = {
224 -       .get_dentry     = fuse_get_dentry,
225 +       .get_dentry     = fuse_get_dentry_old,
226         .encode_fh      = fuse_encode_fh,
227 +       .decode_fh      = fuse_decode_fh,
228  };
229 +#endif
230  #endif
231  
232  static struct super_operations fuse_super_operations = {
233 @@ -845,8 +938,12 @@ static decl_subsys(fuse, NULL, NULL);
234  static decl_subsys(fuse, NULL, NULL);
235  static decl_subsys(connections, NULL, NULL);
236  
237 +#ifdef KERNEL_2_6_24_PLUS
238 +static void fuse_inode_init_once(struct kmem_cache *cachep, void *foo)
239 +#else
240  static void fuse_inode_init_once(void *foo, struct kmem_cache *cachep,
241                                  unsigned long flags)
242 +#endif
243  {
244         struct inode * inode = foo;
245  
246