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