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