fixed linux-uvc, didn't read nicos comment
[openwrt.git] / package / shfs / patches / 104-shfs_0.35_inode_and_fs.patch
1 Index: shfs-0.35/shfs/Linux-2.6/fcache.c
2 ===================================================================
3 --- shfs-0.35.orig/shfs/Linux-2.6/fcache.c 2007-06-04 13:22:57.997038392 +0200
4 +++ shfs-0.35/shfs/Linux-2.6/fcache.c 2007-06-04 13:22:59.019882896 +0200
5 @@ -100,7 +100,11 @@
6 VERBOSE("dir in file cache?\n");
7 return -EINVAL;
8 }
9 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
10 + p = (struct shfs_inode_info *)inode->i_private;
11 +#else
12 p = (struct shfs_inode_info *)inode->u.generic_ip;
13 +#endif
14 if (!p) {
15 VERBOSE("inode without info\n");
16 return -EINVAL;
17 @@ -127,7 +131,11 @@
18 VERBOSE("dir in file cache?\n");
19 return -EINVAL;
20 }
21 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
22 + p = (struct shfs_inode_info *)inode->i_private;
23 +#else
24 p = (struct shfs_inode_info *)inode->u.generic_ip;
25 +#endif
26 if (!p) {
27 VERBOSE("inode without info\n");
28 return -EINVAL;
29 @@ -160,7 +168,11 @@
30 if (result == 0) {
31 struct shfs_inode_info *p;
32
33 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
34 + p = (struct shfs_inode_info *)f->f_dentry->d_inode->i_private;
35 +#else
36 p = (struct shfs_inode_info *)f->f_dentry->d_inode->u.generic_ip;
37 +#endif
38 if (!p) {
39 VERBOSE("inode without info\n");
40 return -EINVAL;
41 @@ -184,7 +196,11 @@
42 return -EINVAL;
43 }
44 DEBUG("ino: %lu\n", inode->i_ino);
45 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
46 + p = (struct shfs_inode_info *)inode->i_private;
47 +#else
48 p = (struct shfs_inode_info *)inode->u.generic_ip;
49 +#endif
50 if (!p) {
51 VERBOSE("inode without info\n");
52 return -EINVAL;
53 @@ -226,7 +242,11 @@
54 VERBOSE("dir in file cache?\n");
55 return -EINVAL;
56 }
57 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
58 + p = (struct shfs_inode_info *)inode->i_private;
59 +#else
60 p = (struct shfs_inode_info *)inode->u.generic_ip;
61 +#endif
62 if (!p) {
63 VERBOSE("inode without info\n");
64 return -EINVAL;
65 @@ -327,7 +347,11 @@
66 VERBOSE("dir in file cache?\n");
67 return -EINVAL;
68 }
69 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
70 + p = (struct shfs_inode_info *)inode->i_private;
71 +#else
72 p = (struct shfs_inode_info *)inode->u.generic_ip;
73 +#endif
74 if (!p) {
75 VERBOSE("inode without info\n");
76 return -EINVAL;
77 Index: shfs-0.35/shfs/Linux-2.6/inode.c
78 ===================================================================
79 --- shfs-0.35.orig/shfs/Linux-2.6/inode.c 2007-06-04 13:22:58.637940960 +0200
80 +++ shfs-0.35/shfs/Linux-2.6/inode.c 2007-06-04 13:22:59.020882744 +0200
81 @@ -36,7 +36,11 @@
82 shfs_set_inode_attr(struct inode *inode, struct shfs_fattr *fattr)
83 {
84 struct shfs_sb_info *info = info_from_inode(inode);
85 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
86 + struct shfs_inode_info *i = inode->i_private;
87 +#else
88 struct shfs_inode_info *i = inode->u.generic_ip;
89 +#endif
90 struct timespec last_time = inode->i_mtime;
91 loff_t last_size = inode->i_size;
92
93 @@ -53,7 +57,9 @@
94 inode->i_ctime = fattr->f_ctime;
95 inode->i_atime = fattr->f_atime;
96 inode->i_mtime = fattr->f_mtime;
97 +#ifdef STRUCT_INODE_HAS_I_BLKSIZE
98 inode->i_blksize= fattr->f_blksize;
99 +#endif
100 inode->i_blocks = fattr->f_blocks;
101 inode->i_size = fattr->f_size;
102
103 @@ -76,7 +82,11 @@
104 if (!inode)
105 return NULL;
106 inode->i_ino = fattr->f_ino;
107 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
108 + i = inode->i_private = (struct shfs_inode_info *)KMEM_ALLOC("inode", inode_cache, GFP_KERNEL);
109 +#else
110 i = inode->u.generic_ip = (struct shfs_inode_info *)KMEM_ALLOC("inode", inode_cache, GFP_KERNEL);
111 +#endif
112 if (!i)
113 return NULL;
114 i->cache = NULL;
115 @@ -108,7 +118,11 @@
116 struct shfs_inode_info *i;
117
118 DEBUG("ino: %lu\n", inode->i_ino);
119 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
120 + i = (struct shfs_inode_info *)inode->i_private;
121 +#else
122 i = (struct shfs_inode_info *)inode->u.generic_ip;
123 +#endif
124 if (!i) {
125 VERBOSE("invalid inode\n");
126 goto out;
127 @@ -176,7 +190,11 @@
128 {
129 struct shfs_sb_info *info = info_from_dentry(dentry);
130 struct inode *inode = dentry->d_inode;
131 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
132 + struct shfs_inode_info *i = (struct shfs_inode_info *)inode->i_private;
133 +#else
134 struct shfs_inode_info *i = (struct shfs_inode_info *)inode->u.generic_ip;
135 +#endif
136 int result;
137
138 DEBUG("%s\n", dentry->d_name.name);
139 Index: shfs-0.35/shfs/Linux-2.6/dir.c
140 ===================================================================
141 --- shfs-0.35.orig/shfs/Linux-2.6/dir.c 2007-06-04 13:22:58.822912840 +0200
142 +++ shfs-0.35/shfs/Linux-2.6/dir.c 2007-06-04 13:22:59.020882744 +0200
143 @@ -302,8 +302,13 @@
144
145 shfs_invalid_dir_cache(dir);
146 result = shfs_instantiate(dentry);
147 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
148 + if (forced_write && dentry->d_inode && dentry->d_inode->i_private)
149 + ((struct shfs_inode_info *)dentry->d_inode->i_private)->unset_write_on_close = 1;
150 +#else
151 if (forced_write && dentry->d_inode && dentry->d_inode->u.generic_ip)
152 ((struct shfs_inode_info *)dentry->d_inode->u.generic_ip)->unset_write_on_close = 1;
153 +#endif
154 return result;
155 }
156
157 Index: shfs-0.35/shfs/Linux-2.6/file.c
158 ===================================================================
159 --- shfs-0.35.orig/shfs/Linux-2.6/file.c 2007-06-04 13:22:58.397977440 +0200
160 +++ shfs-0.35/shfs/Linux-2.6/file.c 2007-06-04 13:22:59.020882744 +0200
161 @@ -90,7 +90,11 @@
162 struct dentry *dentry = f->f_dentry;
163 struct shfs_sb_info *info = info_from_dentry(dentry);
164 struct inode *inode = p->mapping->host;
165 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
166 + struct shfs_inode_info *i = (struct shfs_inode_info *)inode->i_private;
167 +#else
168 struct shfs_inode_info *i = (struct shfs_inode_info *)inode->u.generic_ip;
169 +#endif
170 char *buffer = kmap(p) + offset;
171 int written = 0, result;
172 unsigned count = to - offset;
173 @@ -252,8 +256,13 @@
174 }
175 }
176 /* if file was forced to be writeable, change attrs back on close */
177 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
178 + if (dentry->d_inode && dentry->d_inode->i_private) {
179 + if (((struct shfs_inode_info *)dentry->d_inode->i_private)->unset_write_on_close) {
180 +#else
181 if (dentry->d_inode && dentry->d_inode->u.generic_ip) {
182 if (((struct shfs_inode_info *)dentry->d_inode->u.generic_ip)->unset_write_on_close) {
183 +#endif
184 char name[SHFS_PATH_MAX];
185
186 if (get_name(dentry, name) < 0)
187 @@ -302,7 +311,8 @@
188 goto error;
189 }
190 if (result != 0) {
191 - copy_to_user(buf, (char *)page, result);
192 + if (copy_to_user(buf, (char *)page, result))
193 + goto error;
194 *ppos += result;
195 }
196 error:
197 @@ -315,11 +325,15 @@
198 static ssize_t
199 shfs_slow_write(struct file *f, const char *buf, size_t count, loff_t *offset)
200 {
201 - int written = 0;
202 + ssize_t written = 0;
203 int result;
204
205 DEBUG("\n");
206 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
207 + written = do_sync_write(f, buf, count, offset);
208 +#else
209 written = generic_file_write(f, buf, count, offset);
210 +#endif
211 if (written > 0) {
212 result = do_file_flush(f);
213 written = result < 0 ? result: written;
214 @@ -330,14 +344,23 @@
215
216 struct file_operations shfs_file_operations = {
217 .llseek = generic_file_llseek,
218 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
219 + .read = do_sync_read,
220 + .write = do_sync_write,
221 +#else
222 .read = generic_file_read,
223 .write = generic_file_write,
224 +#endif
225 .ioctl = shfs_ioctl,
226 .mmap = generic_file_mmap,
227 .open = shfs_file_open,
228 .flush = shfs_file_flush,
229 .release = shfs_file_release,
230 .fsync = shfs_file_sync,
231 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
232 + .aio_read = generic_file_aio_read,
233 + .aio_write = generic_file_aio_write,
234 +#endif
235 };
236
237 struct file_operations shfs_slow_operations = {
238 Index: shfs-0.35/shfs/Linux-2.6/proc.c
239 ===================================================================
240 --- shfs-0.35.orig/shfs/Linux-2.6/proc.c 2007-06-04 13:22:58.398977288 +0200
241 +++ shfs-0.35/shfs/Linux-2.6/proc.c 2007-06-04 13:22:59.021882592 +0200
242 @@ -149,7 +149,12 @@
243 {
244 struct file *f = info->sock;
245 mm_segment_t fs;
246 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
247 + ssize_t result = 0;
248 + loff_t begin;
249 +#else
250 int c, result = 0;
251 +#endif
252 unsigned long flags, sigpipe;
253 sigset_t old_set;
254
255 @@ -161,7 +166,9 @@
256 return result;
257 }
258
259 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
260 c = count;
261 +#endif
262
263 fs = get_fs();
264 set_fs(get_ds());
265 @@ -173,6 +180,16 @@
266 SIGRECALC;
267 SIGUNLOCK(flags);
268
269 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
270 + begin = f->f_pos;
271 + result = do_sync_write(f, buffer, count, &f->f_pos);
272 +
273 + if (result < 0) {
274 + DEBUG("error: %d\n", result);
275 + fput(f);
276 + info->sock = NULL;
277 + }
278 +#else
279 do {
280 struct iovec vec[1];
281
282 @@ -190,6 +207,7 @@
283 buffer += result;
284 c -= result;
285 } while (c > 0);
286 +#endif
287
288 SIGLOCK(flags);
289 if (result == -EPIPE && !sigpipe) {
290 @@ -204,7 +222,11 @@
291
292 DEBUG(">%d\n", result);
293 if (result < 0)
294 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
295 + set_garbage(info, 1, count - (f->f_pos - begin));
296 +#else
297 set_garbage(info, 1, c);
298 +#endif
299 else
300 result = count;
301 return result;
302 @@ -222,6 +244,9 @@
303 int c, result = 0;
304 unsigned long flags, sigpipe;
305 sigset_t old_set;
306 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
307 + loff_t begin;
308 +#endif
309
310 if (!f)
311 return -EIO;
312 @@ -256,6 +281,20 @@
313 fs = get_fs();
314 set_fs(get_ds());
315
316 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
317 + begin = f->f_pos;
318 + result = do_sync_read(f, buffer, c, &f->f_pos);
319 +
320 + if (!result) {
321 + /* peer has closed socket */
322 + result = -EIO;
323 + }
324 + if (result < 0) {
325 + DEBUG("error: %d\n", result);
326 + fput(f);
327 + info->sock = NULL;
328 + }
329 +#else
330 do {
331 struct iovec vec[1];
332
333 @@ -277,6 +316,7 @@
334 buffer += result;
335 c -= result;
336 } while (c > 0);
337 +#endif
338
339 SIGLOCK(flags);
340 if (result == -EPIPE && !sigpipe) {
341 @@ -291,7 +331,11 @@
342
343 DEBUG("<%d\n", result);
344 if (result < 0)
345 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
346 + set_garbage(info, 0, count - (f->f_pos - begin));
347 +#else
348 set_garbage(info, 0, c);
349 +#endif
350 else
351 result = count;
352 return result;
353 @@ -316,8 +360,10 @@
354 return result;
355 }
356 while (1) {
357 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
358 struct iovec vec[1];
359
360 +#endif
361 nl = memchr(BUFFER, '\n', LEN);
362 if (nl) {
363 *nl = '\0';
364 @@ -348,9 +394,13 @@
365 fs = get_fs();
366 set_fs(get_ds());
367
368 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
369 + result = do_sync_read(f, BUFFER+LEN, c, &f->f_pos);
370 +#else
371 vec[0].iov_base = BUFFER+LEN;
372 vec[0].iov_len = c;
373 result = f->f_op->readv(f, (const struct iovec *)&vec, 1, &f->f_pos);
374 +#endif
375 SIGLOCK(flags);
376 if (result == -EPIPE && !sigpipe) {
377 sigdelset(&current->pending.signal, SIGPIPE);
This page took 0.068683 seconds and 5 git commands to generate.