+2006-09-30 Miklos Szeredi <miklos@szeredi.hu>
+
+ * Drop support for kernels earlier than 2.6.9. Kernel module from
+ previous (2.5.x) release can be used with library from this
+ release
+
2006-09-29 Miklos Szeredi <miklos@szeredi.hu>
* Fix compilation on 2.6.9. Report from Troy Ayers
SHELL = /bin/sh
INSTALL = @INSTALL@
mkdir_p = mkdir -p
-majver = @majver@
VERSION = @PACKAGE_VERSION@
DISTFILES = Makefile.in configure.ac configure config.h.in ../install-sh \
fusemoduledir = @kmoduledir@/kernel/fs/fuse
-ifeq ($(majver), 2.4)
-fusemodule := fuse.o
-else
fusemodule := fuse.ko
-endif
all: all-@ENABLE_FUSE_MODULE@
install: install-@ENABLE_FUSE_MODULE@
mkdir $(distdir)/compat
cp -p $(COMPATDISTFILES) $(distdir)/compat
-ifeq ($(majver), 2.4)
-
-CC = gcc
-LD = ld
-CFLAGS = -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -pipe @KERNELCFLAGS@
-CPPFLAGS = -I@kernelsrc@/include -I. -D__KERNEL__ -DMODULE -D_LOOSE_KERNEL_NAMES -DFUSE_VERSION=\"$(VERSION)\" @KERNELCPPFLAGS@
-
-fuse_objs = dev.o dir.o file.o inode.o compat/parser.o control.o
-
-SUFFIXES = .c .o .s
-
-all-spec: fuse.o
-
-.c.o:
- $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
-
-fuse.o: $(fuse_objs)
- $(LD) -r -o fuse.o $(fuse_objs)
-
-fuse_headers = fuse_i.h fuse_kernel.h
-
-dev.o: $(fuse_headers)
-dir.o: $(fuse_headers)
-file.o: $(fuse_headers)
-inode.o: $(fuse_headers)
-control.o: $(fuse_headers)
-
-else
-
EXTRA_CFLAGS += -DFUSE_VERSION=\"$(VERSION)\"
obj-m := fuse.o
all-spec:
$(MAKE) -C @kernelsrc@ SUBDIRS=$(PWD) @KERNELMAKE_PARAMS@ modules
-endif
AC_PROG_INSTALL
runver=`uname -r`
+bad_kernel_version=no
ENABLE_FUSE_MODULE=y
KERNELCFLAGS=
*** prepare the kernel before running this script])
fi
AC_MSG_RESULT([$kernsrcver])
- majver=`echo "$kernsrcver" | cut -f-2 -d.`
kmoduledir=${INSTALL_MOD_PATH}/lib/modules/$kernsrcver
AC_SUBST(kernelsrc)
- AC_SUBST(majver)
AC_SUBST(kmoduledir)
- if echo "$kernsrcver" | grep -q "^2.4"; then
- old_cflags="$CFLAGS"
- CFLAGS="-I${kernelsrc}/include -Wall -O2 -fno-strict-aliasing -D__KERNEL__"
- AC_CHECK_DECL(i_size_read,
- AC_DEFINE(HAVE_I_SIZE_FUNC, 1,
- [Kernel has i_size_read() and i_size_write() functions]),,
- [#include <linux/fs.h>])
- AC_CHECK_DECL(recalc_sigpending_tsk,
- AC_DEFINE(HAVE_RECALC_SIGPENDING_TSK, 1,
- [Kernel has recalc_sigpending_tsk() function]),,
- [#include <linux/sched.h>])
- AC_MSG_CHECKING([if '-msoft-float' option is valid])
- CFLAGS="-msoft-float"
- have_msoft_float=no
- AC_TRY_COMPILE([], [], [have_msoft_float=yes])
- AC_MSG_RESULT([$have_msoft_float])
- if test "$have_msoft_float" = yes; then
- KERNELCFLAGS="$CFLAGS"
- fi
- CFLAGS="$old_cflags"
- AC_MSG_CHECKING([architecture])
- arch=`/bin/ls -l ${kernelsrc}/include/asm | sed "s/.*-> asm-//"`
- AC_MSG_RESULT([$arch])
- if test "$arch" = x86_64; then
- KERNELCFLAGS="$KERNELCFLAGS -mno-red-zone -mcmodel=kernel -fno-reorder-blocks -finline-limit=2000"
- fi
+ if echo "$kernsrcver" | egrep -q ["^(2.4|2.6.[0-8]([^0-9]|\$))"]; then
+ bad_kernel_version=yes
+ AC_MSG_NOTICE([
+NOTE: Disabled building the kernel module, because this release only
+NOTE: supports Linux versions 2.6.9 or later. You can use the kernel
+NOTE: module from an earlier FUSE release with the library from this
+NOTE: release.])
else
fuse_configured=no
kernel_autoconf=$kernelbuild/include/linux/autoconf.h
fi
if test "$ENABLE_FUSE_MODULE" = n; then
- AC_MSG_NOTICE([NOTE: Detected that FUSE is already present in the kernel, so])
- AC_MSG_NOTICE([NOTE: building of kernel module is disabled. To force building])
- AC_MSG_NOTICE([NOTE: of kernel module use the '--enable-kernel-module' option.])
+ AC_MSG_NOTICE([
+NOTE: Detected that FUSE is already present in the kernel, so
+NOTE: building of kernel module is disabled. To force building
+NOTE: of kernel module use the '--enable-kernel-module' option.])
fi
if test "$enable_kernel_module" = no; then
ENABLE_FUSE_MODULE=n
fi
+if test "$bad_kernel_version" = yes; then
+ ENABLE_FUSE_MODULE=n
+fi
AC_SUBST(ENABLE_FUSE_MODULE)
if test "$ENABLE_FUSE_MODULE" = y; then
- AC_MSG_CHECKING([if kernel has extended attribute support])
- if test -f $kernelsrc/include/linux/xattr.h; then
- AC_DEFINE(HAVE_KERNEL_XATTR, 1, [Kernel has xattr support])
- AC_MSG_RESULT([yes])
- else
- AC_MSG_RESULT([no])
- fi
AC_MSG_CHECKING([if kernel defines kzalloc function])
if egrep -qw "kzalloc" $kernelsrc/include/linux/slab.h; then
AC_DEFINE(HAVE_KZALLOC, 1, [kzalloc() is defined])
kmem_cache_free(fuse_req_cachep, req);
}
-#ifdef KERNEL_2_6
static void block_sigs(sigset_t *oldset)
{
sigset_t mask;
{
sigprocmask(SIG_SETMASK, oldset, NULL);
}
-#else
-#ifdef HAVE_RECALC_SIGPENDING_TSK
-static void block_sigs(sigset_t *oldset)
-{
- spin_lock_irq(¤t->sighand->siglock);
- *oldset = current->blocked;
- siginitsetinv(¤t->blocked, sigmask(SIGKILL) & ~oldset->sig[0]);
- recalc_sigpending();
- spin_unlock_irq(¤t->sighand->siglock);
-}
-
-static void restore_sigs(sigset_t *oldset)
-{
- spin_lock_irq(¤t->sighand->siglock);
- current->blocked = *oldset;
- recalc_sigpending();
- spin_unlock_irq(¤t->sighand->siglock);
-}
-#else
-static void block_sigs(sigset_t *oldset)
-{
- spin_lock_irq(¤t->sigmask_lock);
- *oldset = current->blocked;
- siginitsetinv(¤t->blocked, sigmask(SIGKILL) & ~oldset->sig[0]);
- recalc_sigpending(current);
- spin_unlock_irq(¤t->sigmask_lock);
-}
-
-static void restore_sigs(sigset_t *oldset)
-{
- spin_lock_irq(¤t->sigmask_lock);
- current->blocked = *oldset;
- recalc_sigpending(current);
- spin_unlock_irq(¤t->sigmask_lock);
-}
-#endif
-#endif
static void __fuse_get_request(struct fuse_req *req)
{
remove_wait_queue(&fc->waitq, &wait);
}
-#ifndef KERNEL_2_6
-static size_t iov_length(const struct iovec *iov, unsigned long nr_segs)
-{
- unsigned long seg;
- size_t ret = 0;
-
- for (seg = 0; seg < nr_segs; seg++)
- ret += iov[seg].iov_len;
- return ret;
-}
-#endif
/*
* Transfer an interrupt request to userspace
*
#include <linux/pagemap.h>
#include <linux/file.h>
-#ifdef KERNEL_2_6
#include <linux/gfp.h>
-#else
-#include <linux/mm.h>
-#endif
#include <linux/sched.h>
-#ifdef KERNEL_2_6
#include <linux/namei.h>
-#endif
#if BITS_PER_LONG >= 64
static inline void fuse_dentry_settime(struct dentry *entry, u64 time)
{
if (S_ISDIR(inode->i_mode)) {
struct dentry *alias = d_find_alias(inode);
-#if defined(FUSE_MAINLINE) || !defined(KERNEL_2_6)
+#if defined(FUSE_MAINLINE)
if (alias) {
dput(alias);
return 1;
{
return !nodeid || nodeid == FUSE_ROOT_ID;
}
-#ifndef KERNEL_2_6
-static int fuse_dentry_revalidate_2_4(struct dentry *entry, int flags)
-{
- return fuse_dentry_revalidate(entry, NULL);
-}
-#endif
static struct dentry_operations fuse_dentry_operations = {
-#ifdef KERNEL_2_6
.d_revalidate = fuse_dentry_revalidate,
-#else
- .d_revalidate = fuse_dentry_revalidate_2_4,
-#endif
};
static int valid_mode(int m)
int err;
struct fuse_entry_out outarg;
struct inode *inode = NULL;
-#if !defined(FUSE_MAINLINE) && defined(KERNEL_2_6)
+#if !defined(FUSE_MAINLINE)
struct dentry *newent;
#endif
struct fuse_conn *fc = get_fuse_conn(dir);
iput(inode);
return ERR_PTR(-EIO);
}
-#if defined(FUSE_MAINLINE) || !defined(KERNEL_2_6)
+#if defined(FUSE_MAINLINE)
d_add(entry, inode);
#else
newent = d_splice_alias(inode, entry);
fuse_change_timeout(entry, &outarg);
else
fuse_invalidate_entry_cache(entry);
-#if defined(FUSE_MAINLINE) || !defined(KERNEL_2_6)
+#if defined(FUSE_MAINLINE)
return NULL;
#else
return newent;
return fuse_do_getattr(inode);
}
-#ifdef KERNEL_2_6
static int fuse_access(struct inode *inode, int mask)
{
struct fuse_conn *fc = get_fuse_conn(inode);
}
return err;
}
-#endif
/*
* Check permission. The two basic access models of FUSE are:
if ((mask & MAY_EXEC) && !S_ISDIR(mode) && !(mode & S_IXUGO))
return -EACCES;
-#ifdef KERNEL_2_6
if (nd && (nd->flags & LOOKUP_ACCESS))
return fuse_access(inode, mask);
-#endif
return 0;
}
}
{
free_link(nd_get_link(nd));
}
-#elif defined(KERNEL_2_6_8_PLUS)
+#else
static int fuse_follow_link(struct dentry *dentry, struct nameidata *nd)
{
nd_set_link(nd, read_link(dentry));
{
free_link(nd_get_link(nd));
}
-#else
-static int fuse_readlink(struct dentry *dentry, char __user *buffer,
- int buflen)
-{
- int ret;
- char *link;
-
- link = read_link(dentry);
- ret = vfs_readlink(dentry, buffer, buflen, link);
- free_link(link);
- return ret;
-}
-
-static int fuse_follow_link(struct dentry *dentry, struct nameidata *nd)
-{
- int ret;
- char *link;
-
- link = read_link(dentry);
- ret = vfs_follow_link(nd, link);
- free_link(link);
- return ret;
-}
#endif
static int fuse_dir_open(struct inode *inode, struct file *file)
/* You can only _set_ these together (they may change by themselves) */
if ((ivalid & (ATTR_ATIME | ATTR_MTIME)) == (ATTR_ATIME | ATTR_MTIME)) {
arg->valid |= FATTR_ATIME | FATTR_MTIME;
-#ifdef KERNEL_2_6
arg->atime = iattr->ia_atime.tv_sec;
arg->mtime = iattr->ia_mtime.tv_sec;
-#else
- arg->atime = iattr->ia_atime;
- arg->mtime = iattr->ia_mtime;
-#endif
}
#ifdef ATTR_FILE
if (ivalid & ATTR_FILE) {
return err;
}
-#ifdef KERNEL_2_6
static int fuse_getattr(struct vfsmount *mnt, struct dentry *entry,
struct kstat *stat)
{
return err;
}
-#else /* KERNEL_2_6 */
-static struct dentry *fuse_lookup_2_4(struct inode *dir, struct dentry *entry)
-{
- return fuse_lookup(dir, entry, NULL);
-}
-
-static int fuse_mknod_2_4(struct inode *dir, struct dentry *entry, int mode,
- int rdev)
-{
- return fuse_mknod(dir, entry, mode, rdev);
-}
-
-static int fuse_create_2_4(struct inode *dir, struct dentry *entry, int mode)
-{
- return fuse_create(dir, entry, mode, NULL);
-}
-static int fuse_permission_2_4(struct inode *inode, int mask)
-{
- return fuse_permission(inode, mask, NULL);
-}
-#endif /* KERNEL_2_6 */
-
-#ifdef HAVE_KERNEL_XATTR
-#ifdef KERNEL_2_6
static int fuse_setxattr(struct dentry *entry, const char *name,
const void *value, size_t size, int flags)
-#else
-static int fuse_setxattr(struct dentry *entry, const char *name,
- void *value, size_t size, int flags)
-#endif
{
struct inode *inode = entry->d_inode;
struct fuse_conn *fc = get_fuse_conn(inode);
}
return err;
}
-#endif
static struct inode_operations fuse_dir_inode_operations = {
-#ifdef KERNEL_2_6
.lookup = fuse_lookup,
-#else
- .lookup = fuse_lookup_2_4,
-#endif
.mkdir = fuse_mkdir,
.symlink = fuse_symlink,
.unlink = fuse_unlink,
.rename = fuse_rename,
.link = fuse_link,
.setattr = fuse_setattr,
-#ifdef KERNEL_2_6
.create = fuse_create,
.mknod = fuse_mknod,
.permission = fuse_permission,
.getattr = fuse_getattr,
-#else
- .create = fuse_create_2_4,
- .mknod = fuse_mknod_2_4,
- .permission = fuse_permission_2_4,
- .revalidate = fuse_revalidate,
-#endif
-#ifdef HAVE_KERNEL_XATTR
.setxattr = fuse_setxattr,
.getxattr = fuse_getxattr,
.listxattr = fuse_listxattr,
.removexattr = fuse_removexattr,
-#endif
};
static struct file_operations fuse_dir_operations = {
static struct inode_operations fuse_common_inode_operations = {
.setattr = fuse_setattr,
-#ifdef KERNEL_2_6
.permission = fuse_permission,
.getattr = fuse_getattr,
-#else
- .permission = fuse_permission_2_4,
- .revalidate = fuse_revalidate,
-#endif
-#ifdef HAVE_KERNEL_XATTR
.setxattr = fuse_setxattr,
.getxattr = fuse_getxattr,
.listxattr = fuse_listxattr,
.removexattr = fuse_removexattr,
-#endif
};
static struct inode_operations fuse_symlink_inode_operations = {
.setattr = fuse_setattr,
.follow_link = fuse_follow_link,
-#ifdef KERNEL_2_6_8_PLUS
.put_link = fuse_put_link,
.readlink = generic_readlink,
-#else
- .readlink = fuse_readlink,
-#endif
-#ifdef KERNEL_2_6
.getattr = fuse_getattr,
-#else
- .revalidate = fuse_revalidate,
-#endif
-#ifdef HAVE_KERNEL_XATTR
.setxattr = fuse_setxattr,
.getxattr = fuse_getxattr,
.listxattr = fuse_listxattr,
.removexattr = fuse_removexattr,
-#endif
};
void fuse_init_common(struct inode *inode)
#include <linux/slab.h>
#include <linux/kernel.h>
-#ifndef KERNEL_2_6
-#define PageUptodate(page) Page_Uptodate(page)
-#define clear_page_dirty(page) ClearPageDirty(page)
-#endif
#ifndef KERNEL_2_6_11_PLUS
static inline loff_t page_offset(struct page *page)
{
if (outarg->open_flags & FOPEN_DIRECT_IO)
file->f_op = &fuse_direct_io_file_operations;
if (!(outarg->open_flags & FOPEN_KEEP_CACHE))
-#ifdef KERNEL_2_6
invalidate_inode_pages(inode->i_mapping);
-#else
- invalidate_inode_pages(inode);
-#endif
ff->fh = outarg->fh;
file->private_data = ff;
}
return err;
}
-#ifdef KERNEL_2_6
static void fuse_readpages_end(struct fuse_conn *fc, struct fuse_req *req)
{
int i;
}
return err;
}
-#else /* KERNEL_2_6 */
-#define FUSE_BLOCK_SHIFT 16
-#define FUSE_BLOCK_SIZE (1UL << FUSE_BLOCK_SHIFT)
-#define FUSE_BLOCK_MASK (~(FUSE_BLOCK_SIZE-1))
-#if (1UL << (FUSE_BLOCK_SHIFT - PAGE_CACHE_SHIFT)) > FUSE_MAX_PAGES_PER_REQ
-#error FUSE_BLOCK_SHIFT too large
-#endif
-
-static int fuse_is_block_uptodate(struct inode *inode, unsigned start,
- unsigned end)
-{
- int index;
-
- for (index = start; index < end; index++) {
- struct page *page = find_get_page(inode->i_mapping, index);
- if (!page)
- return 0;
- if (!PageUptodate(page)) {
- page_cache_release(page);
- return 0;
- }
- page_cache_release(page);
- }
- return 1;
-}
-
-static int fuse_file_read_block(struct fuse_req *req, struct file *file,
- struct inode *inode, unsigned start,
- unsigned end)
-{
- loff_t pos;
- size_t count;
- int index;
- int err = -EBUSY;
- int i;
-
- for (index = start; index < end; index++) {
- struct page *page = grab_cache_page(inode->i_mapping, index);
- if (!page)
- goto out;
- if (PageUptodate(page)) {
- unlock_page(page);
- page_cache_release(page);
- page = NULL;
- }
- req->pages[req->num_pages++] = page;
- }
- pos = (loff_t) start << PAGE_CACHE_SHIFT;
- count = req->num_pages << PAGE_CACHE_SHIFT;
- fuse_send_read(req, file, inode, pos, count);
- err = req->out.h.error;
- out:
- for (i = 0; i < req->num_pages; i++) {
- struct page *page = req->pages[i];
- if (page) {
- if (!err)
- SetPageUptodate(page);
- unlock_page(page);
- page_cache_release(page);
- }
- }
- return err;
-}
-
-static int fuse_file_bigread(struct file *file, struct inode *inode,
- loff_t pos, size_t count)
-{
- struct fuse_conn *fc = get_fuse_conn(inode);
- unsigned starti;
- unsigned endi;
- unsigned nexti;
- struct fuse_req *req;
- loff_t size = i_size_read(inode);
- loff_t end = (pos + count + FUSE_BLOCK_SIZE - 1) & FUSE_BLOCK_MASK;
- end = min(end, size);
- if (end <= pos)
- return 0;
-
- starti = (pos & FUSE_BLOCK_MASK) >> PAGE_CACHE_SHIFT;
- endi = (end + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
-
- req = fuse_get_req(fc);
- if (IS_ERR(req))
- return PTR_ERR(req);
-
- for (; starti < endi; starti = nexti) {
- nexti = starti + (FUSE_BLOCK_SIZE >> PAGE_CACHE_SHIFT);
- nexti = min(nexti, endi);
- if (!fuse_is_block_uptodate(inode, starti, nexti)) {
- if (fuse_file_read_block(req, file, inode, starti, nexti))
- break;
-
- fuse_reset_request(req);
- }
- }
- fuse_put_request(fc, req);
- return 0;
-}
-#endif /* KERNEL_2_6 */
static size_t fuse_send_write(struct fuse_req *req, struct file *file,
struct inode *inode, loff_t pos, size_t count)
return res;
}
-#ifndef KERNEL_2_6
-static ssize_t fuse_file_read(struct file *file, char __user *buf,
- size_t count, loff_t *ppos)
-{
- struct inode *inode = file->f_dentry->d_inode;
- struct fuse_conn *fc = get_fuse_conn(inode);
-
- if (is_bad_inode(inode))
- return -EIO;
-
- if (fc->flags & FUSE_LARGE_READ) {
- int res;
- down(&inode->i_sem);
- res = fuse_file_bigread(file, inode, *ppos, count);
- up(&inode->i_sem);
- if (res)
- return res;
- }
- return generic_file_read(file, buf, count, ppos);
-}
-#endif
static int fuse_file_mmap(struct file *file, struct vm_area_struct *vma)
{
if ((vma->vm_flags & VM_SHARED)) {
return generic_file_mmap(file, vma);
}
-#ifdef KERNEL_2_6
static int fuse_set_page_dirty(struct page *page)
{
printk("fuse_set_page_dirty: should not happen\n");
dump_stack();
return 0;
}
-#endif
static int convert_fuse_file_lock(const struct fuse_file_lock *ffl,
struct file_lock *fl)
static struct file_operations fuse_file_operations = {
.llseek = generic_file_llseek,
-#ifdef KERNEL_2_6
.read = generic_file_read,
.write = generic_file_write,
-#else
- .read = fuse_file_read,
- .write = generic_file_write,
-#endif
.mmap = fuse_file_mmap,
.open = fuse_open,
.flush = fuse_flush,
.release = fuse_release,
.fsync = fuse_fsync,
.lock = fuse_file_lock,
-#ifdef KERNEL_2_6
.sendfile = generic_file_sendfile,
-#endif
};
static struct file_operations fuse_direct_io_file_operations = {
.readpage = fuse_readpage,
.prepare_write = fuse_prepare_write,
.commit_write = fuse_commit_write,
-#ifdef KERNEL_2_6
.readpages = fuse_readpages,
.set_page_dirty = fuse_set_page_dirty,
-#endif
};
void fuse_init_file_inode(struct inode *inode)
#include <linux/version.h>
#include <linux/utsname.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) && LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
-#error Kernel version 2.5.* not supported
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9)
+#error Kernel versions earlier than 2.6.9 are not supported
#endif
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
-# define KERNEL_2_6
-# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,6)
-# define KERNEL_2_6_6_PLUS
-# endif
-# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,8)
-# define KERNEL_2_6_8_PLUS
-# endif
-# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,9)
-# define KERNEL_2_6_9_PLUS
-# endif
-# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10)
-# define KERNEL_2_6_10_PLUS
-# endif
-# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11)
-# define KERNEL_2_6_11_PLUS
-# endif
-# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,12)
-# define KERNEL_2_6_12_PLUS
-# endif
-# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)
-# define KERNEL_2_6_13_PLUS
-# endif
-# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
-# define KERNEL_2_6_16_PLUS
-# endif
-# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,17)
-# define KERNEL_2_6_17_PLUS
-# endif
-# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
-# define KERNEL_2_6_18_PLUS
-# endif
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10)
+# define KERNEL_2_6_10_PLUS
+#endif
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11)
+# define KERNEL_2_6_11_PLUS
+#endif
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,12)
+# define KERNEL_2_6_12_PLUS
+#endif
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)
+# define KERNEL_2_6_13_PLUS
+#endif
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+# define KERNEL_2_6_16_PLUS
+#endif
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,17)
+# define KERNEL_2_6_17_PLUS
+#endif
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
+# define KERNEL_2_6_18_PLUS
#endif
#ifdef __arm__
#endif
#include "config.h"
-#ifndef KERNEL_2_6
-# include <linux/config.h>
-# ifdef CONFIG_MODVERSIONS
-# define MODVERSIONS
-# include <linux/modversions.h>
-# endif
-# ifndef HAVE_I_SIZE_FUNC
-# define i_size_read(inode) ((inode)->i_size)
-# define i_size_write(inode, size) do { (inode)->i_size = size; } while(0)
-# endif
-# define new_decode_dev(x) (x)
-# define new_encode_dev(x) (x)
-# define s_fs_info u.generic_sbp
-#endif /* KERNEL_2_6 */
#endif /* FUSE_MAINLINE */
#include <linux/fs.h>
#include <linux/mount.h>
#include <linux/wait.h>
#include <linux/list.h>
#include <linux/spinlock.h>
-#ifdef KERNEL_2_6
#include <linux/mm.h>
#include <linux/backing-dev.h>
-#endif
#ifdef KERNEL_2_6_17_PLUS
#include <linux/mutex.h>
#else
#ifndef __user
#define __user
#endif
-#ifndef KERNEL_2_6
-#include <linux/pagemap.h>
-static inline void set_page_dirty_lock(struct page *page)
-{
- lock_page(page);
- set_page_dirty(page);
- unlock_page(page);
-}
-#endif
/** Max number of pages that can be used in a single read request */
#define FUSE_MAX_PAGES_PER_REQ 32
#else
extern struct semaphore fuse_mutex;
#endif
-#ifndef KERNEL_2_6
-/** Allow FUSE to combine reads into 64k chunks. This is useful if
- the filesystem is better at handling large chunks */
-#define FUSE_LARGE_READ (1 << 31)
-#endif
/** FUSE inode */
struct fuse_inode {
/** Negotiated minor version */
unsigned minor;
-#ifdef KERNEL_2_6
/** Backing dev info */
struct backing_dev_info bdi;
-#endif
/** Entry on the fuse_conn_list */
struct list_head entry;
#include <linux/seq_file.h>
#include <linux/init.h>
#include <linux/module.h>
-#ifdef KERNEL_2_6
#include <linux/parser.h>
#include <linux/statfs.h>
#include <linux/random.h>
-#else
-#include "compat/parser.h"
-#endif
MODULE_AUTHOR("Miklos Szeredi <miklos@szeredi.hu>");
MODULE_DESCRIPTION("Filesystem in Userspace");
#define FUSE_SUPER_MAGIC 0x65735546
-#ifndef KERNEL_2_6
-#define kstatfs statfs
-#endif
#ifndef MAX_LFS_FILESIZE
#define MAX_LFS_FILESIZE (((u64)PAGE_CACHE_SIZE << (BITS_PER_LONG-1))-1)
#endif
if (!inode)
return NULL;
-#ifndef KERNEL_2_6
- inode->u.generic_ip = NULL;
-#endif
fi = get_fuse_inode(inode);
fi->i_time = 0;
fi->nodeid = 0;
void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr)
{
if (S_ISREG(inode->i_mode) && i_size_read(inode) != attr->size)
-#ifdef KERNEL_2_6
invalidate_inode_pages(inode->i_mapping);
-#else
- invalidate_inode_pages(inode);
-#endif
inode->i_ino = attr->ino;
inode->i_mode = (inode->i_mode & S_IFMT) + (attr->mode & 07777);
i_size_write(inode, attr->size);
inode->i_blksize = PAGE_CACHE_SIZE;
inode->i_blocks = attr->blocks;
-#ifdef KERNEL_2_6
inode->i_atime.tv_sec = attr->atime;
inode->i_atime.tv_nsec = attr->atimensec;
inode->i_mtime.tv_sec = attr->mtime;
inode->i_mtime.tv_nsec = attr->mtimensec;
inode->i_ctime.tv_sec = attr->ctime;
inode->i_ctime.tv_nsec = attr->ctimensec;
-#else
- inode->i_atime = attr->atime;
- inode->i_mtime = attr->mtime;
- inode->i_ctime = attr->ctime;
-#endif
}
static void fuse_init_inode(struct inode *inode, struct fuse_attr *attr)
BUG();
}
-#ifdef KERNEL_2_6
static int fuse_inode_eq(struct inode *inode, void *_nodeidp)
{
unsigned long nodeid = *(unsigned long *) _nodeidp;
return NULL;
if ((inode->i_state & I_NEW)) {
-#ifdef KERNEL_2_6_8_PLUS
inode->i_flags |= S_NOATIME|S_NOCMTIME;
-#else
- inode->i_flags |= S_NOATIME;
-#endif
inode->i_generation = generation;
inode->i_data.backing_dev_info = &fc->bdi;
fuse_init_inode(inode, attr);
fuse_change_attributes(inode, attr);
return inode;
}
-#else
-static int fuse_inode_eq(struct inode *inode, unsigned long ino, void *_nodeidp){
- unsigned long nodeid = *(unsigned long *) _nodeidp;
- if (inode->u.generic_ip && get_node_id(inode) == nodeid)
- return 1;
- else
- return 0;
-}
-
-struct inode *fuse_iget(struct super_block *sb, unsigned long nodeid,
- int generation, struct fuse_attr *attr)
-{
- struct inode *inode;
- struct fuse_inode *fi;
- int retried = 0;
-
- retry:
- inode = iget4(sb, attr->ino, fuse_inode_eq, &nodeid);
- if (!inode)
- return NULL;
-
- if (!inode->u.generic_ip) {
- get_fuse_inode(inode)->nodeid = nodeid;
- inode->u.generic_ip = inode;
- inode->i_generation = generation;
- fuse_init_inode(inode, attr);
- } else if ((inode->i_mode ^ attr->mode) & S_IFMT) {
- BUG_ON(retried);
- /* Inode has changed type, any I/O on the old should fail */
- remove_inode_hash(inode);
- make_bad_inode(inode);
- iput(inode);
- retried = 1;
- goto retry;
- }
-
- fi = get_fuse_inode(inode);
- fi->nlookup ++;
- fuse_change_attributes(inode, attr);
- return inode;
-}
-#endif
#ifdef KERNEL_2_6_18_PLUS
static void fuse_umount_begin(struct vfsmount *vfsmnt, int flags)
{
stbuf->f_type = FUSE_SUPER_MAGIC;
stbuf->f_bsize = attr->bsize;
-#ifdef KERNEL_2_6
stbuf->f_frsize = attr->frsize;
-#endif
stbuf->f_blocks = attr->blocks;
stbuf->f_bfree = attr->bfree;
stbuf->f_bavail = attr->bavail;
OPT_GROUP_ID,
OPT_DEFAULT_PERMISSIONS,
OPT_ALLOW_OTHER,
-#ifndef KERNEL_2_6
- OPT_LARGE_READ,
-#endif
OPT_MAX_READ,
OPT_ERR
};
{OPT_GROUP_ID, "group_id=%u"},
{OPT_DEFAULT_PERMISSIONS, "default_permissions"},
{OPT_ALLOW_OTHER, "allow_other"},
-#ifndef KERNEL_2_6
- {OPT_LARGE_READ, "large_read"},
-#endif
{OPT_MAX_READ, "max_read=%u"},
{OPT_ERR, NULL}
};
d->flags |= FUSE_ALLOW_OTHER;
break;
-#ifndef KERNEL_2_6
- case OPT_LARGE_READ:
- d->flags |= FUSE_LARGE_READ;
- break;
-#endif
case OPT_MAX_READ:
if (match_int(&args[0], &value))
return 0;
seq_puts(m, ",default_permissions");
if (fc->flags & FUSE_ALLOW_OTHER)
seq_puts(m, ",allow_other");
-#ifndef KERNEL_2_6
- if (fc->flags & FUSE_LARGE_READ)
- seq_puts(m, ",large_read");
-#endif
if (fc->max_read != ~0)
seq_printf(m, ",max_read=%u", fc->max_read);
return 0;
INIT_LIST_HEAD(&fc->io);
INIT_LIST_HEAD(&fc->interrupts);
atomic_set(&fc->num_waiting, 0);
-#ifdef KERNEL_2_6_6_PLUS
fc->bdi.ra_pages = (VM_MAX_READAHEAD * 1024) / PAGE_CACHE_SIZE;
fc->bdi.unplug_io_fn = default_unplug_io_fn;
-#endif
fc->reqctr = 0;
fc->blocked = 1;
get_random_bytes(&fc->scramble_key, sizeof(fc->scramble_key));
return fuse_iget(sb, 1, 0, &attr);
}
#ifndef FUSE_MAINLINE
-#ifdef KERNEL_2_6
static struct dentry *fuse_get_dentry(struct super_block *sb, void *vobjp)
{
__u32 *objp = vobjp;
.encode_fh = fuse_encode_fh,
};
#endif
-#endif
static struct super_operations fuse_super_operations = {
.alloc_inode = fuse_alloc_inode,
if (req->out.h.error || arg->major != FUSE_KERNEL_VERSION)
fc->conn_error = 1;
else {
-#ifdef KERNEL_2_6
unsigned long ra_pages;
if (arg->minor >= 6) {
}
fc->bdi.ra_pages = min(fc->bdi.ra_pages, ra_pages);
-#endif
fc->minor = arg->minor;
fc->max_write = arg->minor < 5 ? 4096 : arg->max_write;
}
arg->major = FUSE_KERNEL_VERSION;
arg->minor = FUSE_KERNEL_MINOR_VERSION;
-#ifdef KERNEL_2_6
arg->max_readahead = fc->bdi.ra_pages * PAGE_CACHE_SIZE;
arg->flags |= FUSE_ASYNC_READ | FUSE_POSIX_LOCKS;
-#endif
req->in.h.opcode = FUSE_INIT;
req->in.numargs = 1;
req->in.args[0].size = sizeof(*arg);
sb->s_op = &fuse_super_operations;
sb->s_maxbytes = MAX_LFS_FILESIZE;
#ifndef FUSE_MAINLINE
-#ifdef KERNEL_2_6
sb->s_export_op = &fuse_export_operations;
-#endif
#endif
file = fget(d.fd);
return err;
}
-#ifdef KERNEL_2_6
#ifdef KERNEL_2_6_18_PLUS
static int fuse_get_sb(struct file_system_type *fs_type,
int flags, const char *dev_name,
.get_sb = fuse_get_sb,
.kill_sb = kill_anon_super,
};
-#else
-static struct super_block *fuse_read_super_compat(struct super_block *sb,
- void *data, int silent)
-{
- int err = fuse_fill_super(sb, data, silent);
- if (err)
- return NULL;
- else
- return sb;
-}
-static DECLARE_FSTYPE(fuse_fs_type, "fuse", fuse_read_super_compat, 0);
-#endif
-
-#ifdef KERNEL_2_6
#ifndef HAVE_FS_SUBSYS
static decl_subsys(fs, NULL, NULL);
#endif
static decl_subsys(fuse, NULL, NULL);
static decl_subsys(connections, NULL, NULL);
-#endif /* KERNEL_2_6 */
static void fuse_inode_init_once(void *foo, kmem_cache_t *cachep,
unsigned long flags)
kmem_cache_destroy(fuse_inode_cachep);
}
-#ifdef KERNEL_2_6
static int fuse_sysfs_init(void)
{
int err;
subsystem_unregister(&fs_subsys);
#endif
}
-#else /* KERNEL_2_6 */
-static int fuse_sysfs_init(void)
-{
- return 0;
-}
-static void fuse_sysfs_cleanup(void)
-{
-}
-#endif /* KERNEL_2_6 */
static int __init fuse_init(void)
{