From: Miklos Szeredi Date: Fri, 13 Oct 2006 09:54:24 +0000 (+0000) Subject: kernel: Fix compilation on patched 2.6.18 (fc6) and 2.6.9 X-Git-Tag: fuse_2_6_0_rc3~3 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=d6f8db71b84a139c1d74d6d0c654659951219c38;p=qemu-gpiodev%2Flibfuse.git kernel: Fix compilation on patched 2.6.18 (fc6) and 2.6.9 --- diff --git a/ChangeLog b/ChangeLog index fd82cfd..822cff9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-10-13 Miklos Szeredi + + * kernel: Fix compilation on patched 2.6.18 (fc6) and 2.6.9. + Report from David Shaw + 2006-10-10 Miklos Szeredi * kernel: Check for signature of super_operations->umount_begin(). diff --git a/kernel/configure.ac b/kernel/configure.ac index 29e6ee3..bf4c8cd 100644 --- a/kernel/configure.ac +++ b/kernel/configure.ac @@ -149,6 +149,14 @@ if test "$ENABLE_FUSE_MODULE" = y; then AC_MSG_RESULT([no]) fi + AC_MSG_CHECKING([whether lookup_instantiate_filp is defined]) + if test -f $kernelsrc/include/linux/namei.h && egrep -q "lookup_instantiate_filp" $kernelsrc/include/linux/namei.h; then + AC_DEFINE(HAVE_LOOKUP_INSTANTIATE_FILP, 1, [lookup_instantiate_filp() is defined]) + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + fi + AC_MSG_CHECKING([if umount_begin is passed a vfsmount]) if egrep -q "\(\*umount_begin\) *\(struct vfsmount \*" $kernelsrc/include/linux/fs.h; then AC_DEFINE(UMOUNT_BEGIN_VFSMOUNT, 1, [umount_begin is passed a vfsmount]) @@ -157,9 +165,16 @@ if test "$ENABLE_FUSE_MODULE" = y; then AC_MSG_RESULT([no]) fi - AC_MSG_CHECKING([whether lookup_instantiate_filp is defined]) - if test -f $kernelsrc/include/linux/namei.h && egrep -q "lookup_instantiate_filp" $kernelsrc/include/linux/namei.h; then - AC_DEFINE(HAVE_LOOKUP_INSTANTIATE_FILP, 1, [lookup_instantiate_filp() is defined]) + AC_MSG_CHECKING([if inode has i_blksize field]) + if egrep -qw "i_blksize" $kernelsrc/include/linux/fs.h; then + AC_DEFINE(HAVE_I_BLKSIZE, 1, [inode has i_blksize field]) + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + fi + AC_MSG_CHECKING([if inode has i_private field]) + if egrep -qw "i_private" $kernelsrc/include/linux/fs.h; then + AC_DEFINE(HAVE_I_PRIVATE, 1, [inode has i_private field]) AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) diff --git a/kernel/control.c b/kernel/control.c index 380630d..24e8fa4 100644 --- a/kernel/control.c +++ b/kernel/control.c @@ -12,6 +12,9 @@ #include #define FUSE_CTL_SUPER_MAGIC 0x65735543 +#ifndef HAVE_I_PRIVATE +#define i_private u.generic_ip +#endif /* * This is non-NULL when the single instance of the control filesystem @@ -23,7 +26,7 @@ static struct fuse_conn *fuse_ctl_file_conn_get(struct file *file) { struct fuse_conn *fc; mutex_lock(&fuse_mutex); - fc = file->f_dentry->d_inode->u.generic_ip; + fc = file->f_dentry->d_inode->i_private; if (fc) fc = fuse_conn_get(fc); mutex_unlock(&fuse_mutex); @@ -114,7 +117,7 @@ static struct dentry *fuse_ctl_add_dentry(struct dentry *parent, inode->i_op = iop; inode->i_fop = fop; inode->i_nlink = nlink; - inode->u.generic_ip = fc; + inode->i_private = fc; d_add(dentry, inode); return dentry; } @@ -132,7 +135,7 @@ int fuse_ctl_add_conn(struct fuse_conn *fc) return 0; parent = fuse_control_sb->s_root; - parent->d_inode->i_nlink++; + inc_nlink(parent->d_inode); sprintf(name, "%llu", (unsigned long long) fc->id); parent = fuse_ctl_add_dentry(parent, fc, name, S_IFDIR | 0500, 2, &simple_dir_inode_operations, @@ -166,7 +169,7 @@ void fuse_ctl_remove_conn(struct fuse_conn *fc) for (i = fc->ctl_ndents - 1; i >= 0; i--) { struct dentry *dentry = fc->ctl_dentry[i]; - dentry->d_inode->u.generic_ip = NULL; + dentry->d_inode->i_private = NULL; d_drop(dentry); dput(dentry); } diff --git a/kernel/dev.c b/kernel/dev.c index d7e5e55..c96d0cc 100644 --- a/kernel/dev.c +++ b/kernel/dev.c @@ -772,6 +772,7 @@ static ssize_t fuse_dev_readv(struct file *file, const struct iovec *iov, return err; } +#ifndef KERNEL_2_6_19_PLUS static ssize_t fuse_dev_read(struct file *file, char __user *buf, size_t nbytes, loff_t *off) { @@ -780,6 +781,13 @@ static ssize_t fuse_dev_read(struct file *file, char __user *buf, iov.iov_base = buf; return fuse_dev_readv(file, &iov, 1, off); } +#else +static ssize_t fuse_dev_read(struct kiocb *iocb, const struct iovec *iov, + unsigned long nr_segs, loff_t pos) +{ + return fuse_dev_readv(iocb->ki_filp, iov, nr_segs, &pos); +} +#endif /* Look up request on processing list by unique ID */ static struct fuse_req *request_find(struct fuse_conn *fc, u64 unique) @@ -909,6 +917,7 @@ static ssize_t fuse_dev_writev(struct file *file, const struct iovec *iov, return err; } +#ifndef KERNEL_2_6_19_PLUS static ssize_t fuse_dev_write(struct file *file, const char __user *buf, size_t nbytes, loff_t *off) { @@ -917,6 +926,13 @@ static ssize_t fuse_dev_write(struct file *file, const char __user *buf, iov.iov_base = (char __user *) buf; return fuse_dev_writev(file, &iov, 1, off); } +#else +static ssize_t fuse_dev_write(struct kiocb *iocb, const struct iovec *iov, + unsigned long nr_segs, loff_t pos) +{ + return fuse_dev_writev(iocb->ki_filp, iov, nr_segs, &pos); +} +#endif static unsigned fuse_dev_poll(struct file *file, poll_table *wait) { @@ -1052,10 +1068,17 @@ static int fuse_dev_fasync(int fd, struct file *file, int on) struct file_operations fuse_dev_operations = { .owner = THIS_MODULE, .llseek = no_llseek, +#ifndef KERNEL_2_6_19_PLUS .read = fuse_dev_read, .readv = fuse_dev_readv, .write = fuse_dev_write, .writev = fuse_dev_writev, +#else + .read = do_sync_read, + .aio_read = fuse_dev_read, + .write = do_sync_write, + .aio_write = fuse_dev_write, +#endif .poll = fuse_dev_poll, .release = fuse_dev_release, .fasync = fuse_dev_fasync, diff --git a/kernel/dir.c b/kernel/dir.c index c2f7d4e..3f12e19 100644 --- a/kernel/dir.c +++ b/kernel/dir.c @@ -529,7 +529,7 @@ static int fuse_unlink(struct inode *dir, struct dentry *entry) /* Set nlink to zero so the inode can be cleared, if the inode does have more links this will be discovered at the next lookup/getattr */ - inode->i_nlink = 0; + clear_nlink(inode); fuse_invalidate_attr(inode); fuse_invalidate_attr(dir); fuse_invalidate_entry_cache(entry); @@ -555,7 +555,7 @@ static int fuse_rmdir(struct inode *dir, struct dentry *entry) err = req->out.h.error; fuse_put_request(fc, req); if (!err) { - entry->d_inode->i_nlink = 0; + clear_nlink(entry->d_inode); fuse_invalidate_attr(dir); fuse_invalidate_entry_cache(entry); } else if (err == -EINTR) @@ -815,7 +815,10 @@ static int fuse_permission(struct inode *inode, int mask, struct nameidata *nd) if ((mask & MAY_EXEC) && !S_ISDIR(mode) && !(mode & S_IXUGO)) return -EACCES; - if (nd && (nd->flags & LOOKUP_ACCESS)) +#ifndef LOOKUP_CHDIR +#define LOOKUP_CHDIR 0 +#endif + if (nd && (nd->flags & (LOOKUP_ACCESS | LOOKUP_CHDIR))) return fuse_access(inode, mask); return 0; } @@ -1078,6 +1081,8 @@ static int fuse_getattr(struct vfsmount *mnt, struct dentry *entry, struct inode *inode = entry->d_inode; int err = fuse_revalidate(entry); if (!err) + /* FIXME: may want specialized function because of + st_blksize on block devices on 2.6.19+ */ generic_fillattr(inode, stat); return err; diff --git a/kernel/file.c b/kernel/file.c index fb381da..b9d86ed 100644 --- a/kernel/file.c +++ b/kernel/file.c @@ -843,8 +843,15 @@ static sector_t fuse_bmap(struct address_space *mapping, sector_t block) static struct file_operations fuse_file_operations = { .llseek = generic_file_llseek, +#ifndef KERNEL_2_6_19_PLUS .read = generic_file_read, .write = generic_file_write, +#else + .read = do_sync_read, + .aio_read = generic_file_aio_read, + .write = do_sync_write, + .aio_write = generic_file_aio_write, +#endif .mmap = fuse_file_mmap, .open = fuse_open, .flush = fuse_flush, diff --git a/kernel/fuse_i.h b/kernel/fuse_i.h index 9be2de1..22f7514 100644 --- a/kernel/fuse_i.h +++ b/kernel/fuse_i.h @@ -38,6 +38,9 @@ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18) # define KERNEL_2_6_18_PLUS #endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19) +# define KERNEL_2_6_19_PLUS +#endif #ifdef __arm__ #define DCACHE_BUG @@ -63,6 +66,10 @@ #define mutex_unlock(m) up(m) #define mutex semaphore #endif +#ifndef KERNEL_2_6_19_PLUS +#define clear_nlink(inode) (inode)->i_nlink = 0 +#define inc_nlink(inode) (inode)->i_nlink++ +#endif #ifndef BUG_ON #define BUG_ON(x) diff --git a/kernel/inode.c b/kernel/inode.c index aada038..e3f98db 100644 --- a/kernel/inode.c +++ b/kernel/inode.c @@ -134,7 +134,9 @@ void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr) inode->i_uid = attr->uid; inode->i_gid = attr->gid; i_size_write(inode, attr->size); +#ifdef HAVE_I_BLKSIZE inode->i_blksize = PAGE_CACHE_SIZE; +#endif inode->i_blocks = attr->blocks; inode->i_atime.tv_sec = attr->atime; inode->i_atime.tv_nsec = attr->atimensec;