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
6 VERBOSE("dir in file cache?\n");
9 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
10 + p = (struct shfs_inode_info *)inode->i_private;
12 p = (struct shfs_inode_info *)inode->u.generic_ip;
15 VERBOSE("inode without info\n");
18 VERBOSE("dir in file cache?\n");
21 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
22 + p = (struct shfs_inode_info *)inode->i_private;
24 p = (struct shfs_inode_info *)inode->u.generic_ip;
27 VERBOSE("inode without info\n");
31 struct shfs_inode_info *p;
33 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
34 + p = (struct shfs_inode_info *)f->f_dentry->d_inode->i_private;
36 p = (struct shfs_inode_info *)f->f_dentry->d_inode->u.generic_ip;
39 VERBOSE("inode without info\n");
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;
48 p = (struct shfs_inode_info *)inode->u.generic_ip;
51 VERBOSE("inode without info\n");
54 VERBOSE("dir in file cache?\n");
57 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
58 + p = (struct shfs_inode_info *)inode->i_private;
60 p = (struct shfs_inode_info *)inode->u.generic_ip;
63 VERBOSE("inode without info\n");
66 VERBOSE("dir in file cache?\n");
69 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
70 + p = (struct shfs_inode_info *)inode->i_private;
72 p = (struct shfs_inode_info *)inode->u.generic_ip;
75 VERBOSE("inode without info\n");
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
82 shfs_set_inode_attr(struct inode *inode, struct shfs_fattr *fattr)
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;
88 struct shfs_inode_info *i = inode->u.generic_ip;
90 struct timespec last_time = inode->i_mtime;
91 loff_t last_size = inode->i_size;
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;
100 inode->i_blocks = fattr->f_blocks;
101 inode->i_size = fattr->f_size;
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);
110 i = inode->u.generic_ip = (struct shfs_inode_info *)KMEM_ALLOC("inode", inode_cache, GFP_KERNEL);
116 struct shfs_inode_info *i;
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;
122 i = (struct shfs_inode_info *)inode->u.generic_ip;
125 VERBOSE("invalid inode\n");
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;
134 struct shfs_inode_info *i = (struct shfs_inode_info *)inode->u.generic_ip;
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
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;
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;
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
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;
168 struct shfs_inode_info *i = (struct shfs_inode_info *)inode->u.generic_ip;
170 char *buffer = kmap(p) + offset;
171 int written = 0, result;
172 unsigned count = to - offset;
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) {
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) {
184 char name[SHFS_PATH_MAX];
186 if (get_name(dentry, name) < 0)
191 - copy_to_user(buf, (char *)page, result);
192 + if (copy_to_user(buf, (char *)page, result))
197 @@ -315,11 +325,15 @@
199 shfs_slow_write(struct file *f, const char *buf, size_t count, loff_t *offset)
202 + ssize_t written = 0;
206 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
207 + written = do_sync_write(f, buf, count, offset);
209 written = generic_file_write(f, buf, count, offset);
212 result = do_file_flush(f);
213 written = result < 0 ? result: written;
214 @@ -330,14 +344,23 @@
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,
222 .read = generic_file_read,
223 .write = generic_file_write,
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,
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
244 struct file *f = info->sock;
246 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
247 + ssize_t result = 0;
252 unsigned long flags, sigpipe;
259 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
269 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
271 + result = do_sync_write(f, buffer, count, &f->f_pos);
274 + DEBUG("error: %d\n", result);
289 if (result == -EPIPE && !sigpipe) {
292 DEBUG(">%d\n", result);
294 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
295 + set_garbage(info, 1, count - (f->f_pos - begin));
297 set_garbage(info, 1, c);
304 unsigned long flags, sigpipe;
306 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
316 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
318 + result = do_sync_read(f, buffer, c, &f->f_pos);
321 + /* peer has closed socket */
325 + DEBUG("error: %d\n", result);
340 if (result == -EPIPE && !sigpipe) {
343 DEBUG("<%d\n", result);
345 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
346 + set_garbage(info, 0, count - (f->f_pos - begin));
348 set_garbage(info, 0, c);
357 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
361 nl = memchr(BUFFER, '\n', LEN);
368 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
369 + result = do_sync_read(f, BUFFER+LEN, c, &f->f_pos);
371 vec[0].iov_base = BUFFER+LEN;
373 result = f->f_op->readv(f, (const struct iovec *)&vec, 1, &f->f_pos);
376 if (result == -EPIPE && !sigpipe) {
377 sigdelset(¤t->pending.signal, SIGPIPE);