+2006-10-13 Miklos Szeredi <miklos@szeredi.hu>
+
+ * kernel: Fix compilation on patched 2.6.18 (fc6) and 2.6.9.
+ Report from David Shaw
+
2006-10-10 Miklos Szeredi <miklos@szeredi.hu>
* kernel: Check for signature of super_operations->umount_begin().
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])
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])
#include <linux/module.h>
#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
{
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);
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;
}
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,
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);
}
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)
{
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)
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)
{
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)
{
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,
/* 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);
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)
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;
}
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;
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,
#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
#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)
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;