1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-11-14 06:07:30 +02:00
openwrt-xburst/package/shfs/patches/104-shfs_0.35_inode_and_fs.patch
nbd b5cb1795de refresh all package patches in the buildroot using quilt
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@7490 3c298f89-4303-0410-b956-a3cf2f4a3e73
2007-06-04 11:25:53 +00:00

378 lines
10 KiB
Diff

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);