Drop support for kernels earlier than 2.6.9
authorMiklos Szeredi <miklos@szeredi.hu>
Sat, 30 Sep 2006 07:39:33 +0000 (07:39 +0000)
committerMiklos Szeredi <miklos@szeredi.hu>
Sat, 30 Sep 2006 07:39:33 +0000 (07:39 +0000)
ChangeLog
kernel/Makefile.in
kernel/configure.ac
kernel/dev.c
kernel/dir.c
kernel/file.c
kernel/fuse_i.h
kernel/inode.c

index 5f75e15f97cecd11fed4aef08469c8d2ca0bbed2..57b2d005edcac9cf34341a848d314b5bf622ccc8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+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
index a8361ac818b7b5edd7ff2c3c6a314d565397eb41..c016d1a682bce956b743f391b218e57bbd81eaac 100644 (file)
@@ -3,7 +3,6 @@
 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 \
@@ -12,11 +11,7 @@ COMPATDISTFILES = compat/parser.c compat/parser.h
 
 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@
@@ -52,35 +47,6 @@ distdir: $(DISTFILES) $(COMPATDISTFILES)
        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
@@ -88,4 +54,3 @@ fuse-objs := dev.o dir.o file.o inode.o control.o
 
 all-spec:
        $(MAKE) -C @kernelsrc@ SUBDIRS=$(PWD) @KERNELMAKE_PARAMS@ modules
-endif
index 910e125634900f8e4c9502269f2a661e5d529c03..67049b5b79ee8165a7182b901cabe35d5d1135ce 100644 (file)
@@ -4,6 +4,7 @@ AC_CONFIG_HEADERS([config.h])
 AC_PROG_INSTALL
 
 runver=`uname -r`
+bad_kernel_version=no
 ENABLE_FUSE_MODULE=y
 KERNELCFLAGS=
 
@@ -88,38 +89,17 @@ if test "$ENABLE_FUSE_MODULE" = y; then
        *** 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
@@ -137,25 +117,22 @@ if test "$ENABLE_FUSE_MODULE" = y; then
 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])
index 62c41a7ab52ada4594a9b7e51b9fceb55dabd7fc..d7e5e553f69ef6a2949542da76f164f1a6d146bc 100644 (file)
@@ -54,7 +54,6 @@ void fuse_request_free(struct fuse_req *req)
        kmem_cache_free(fuse_req_cachep, req);
 }
 
-#ifdef KERNEL_2_6
 static void block_sigs(sigset_t *oldset)
 {
        sigset_t mask;
@@ -67,43 +66,6 @@ static void restore_sigs(sigset_t *oldset)
 {
        sigprocmask(SIG_SETMASK, oldset, NULL);
 }
-#else
-#ifdef HAVE_RECALC_SIGPENDING_TSK
-static void block_sigs(sigset_t *oldset)
-{
-       spin_lock_irq(&current->sighand->siglock);
-       *oldset = current->blocked;
-       siginitsetinv(&current->blocked, sigmask(SIGKILL) & ~oldset->sig[0]);
-       recalc_sigpending();
-       spin_unlock_irq(&current->sighand->siglock);
-}
-
-static void restore_sigs(sigset_t *oldset)
-{
-       spin_lock_irq(&current->sighand->siglock);
-       current->blocked = *oldset;
-       recalc_sigpending();
-       spin_unlock_irq(&current->sighand->siglock);
-}
-#else
-static void block_sigs(sigset_t *oldset)
-{
-       spin_lock_irq(&current->sigmask_lock);
-       *oldset = current->blocked;
-       siginitsetinv(&current->blocked, sigmask(SIGKILL) & ~oldset->sig[0]);
-       recalc_sigpending(current);
-       spin_unlock_irq(&current->sigmask_lock);
-}
-
-static void restore_sigs(sigset_t *oldset)
-{
-       spin_lock_irq(&current->sigmask_lock);
-       current->blocked = *oldset;
-       recalc_sigpending(current);
-       spin_unlock_irq(&current->sigmask_lock);
-}
-#endif
-#endif
 
 static void __fuse_get_request(struct fuse_req *req)
 {
@@ -681,17 +643,6 @@ static void request_wait(struct fuse_conn *fc)
        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
  *
index 66dac792b790ccfeb13de8257d7f6e1d4fa16046..c238674e1185ca8549d6649b392e297b4ef487aa 100644 (file)
 
 #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)
@@ -189,7 +183,7 @@ static int dir_alias(struct inode *inode)
 {
        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;
@@ -209,19 +203,9 @@ static int invalid_nodeid(u64 nodeid)
 {
        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)
@@ -236,7 +220,7 @@ static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry,
        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);
@@ -272,7 +256,7 @@ static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry,
                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);
@@ -283,7 +267,7 @@ static struct dentry *fuse_lookup(struct inode *dir, struct dentry *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;
@@ -748,7 +732,6 @@ static int fuse_revalidate(struct dentry *entry)
        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);
@@ -779,7 +762,6 @@ static int fuse_access(struct inode *inode, int mask)
        }
        return err;
 }
-#endif
 
 /*
  * Check permission.  The two basic access models of FUSE are:
@@ -836,10 +818,8 @@ static int fuse_permission(struct inode *inode, int mask, struct nameidata *nd)
                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;
        }
 }
@@ -956,7 +936,7 @@ static void fuse_put_link(struct dentry *dentry, struct nameidata *nd, void *c)
 {
        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));
@@ -967,29 +947,6 @@ static void fuse_put_link(struct dentry *dentry, struct nameidata *nd)
 {
        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)
@@ -1023,13 +980,8 @@ static void iattr_to_fattr(struct iattr *iattr, struct fuse_setattr_in *arg)
        /* 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) {
@@ -1123,7 +1075,6 @@ static int fuse_setattr(struct dentry *entry, struct iattr *attr)
        return err;
 }
 
-#ifdef KERNEL_2_6
 static int fuse_getattr(struct vfsmount *mnt, struct dentry *entry,
                        struct kstat *stat)
 {
@@ -1134,37 +1085,9 @@ static int fuse_getattr(struct vfsmount *mnt, struct dentry *entry,
 
        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);
@@ -1326,14 +1249,9 @@ static int fuse_removexattr(struct dentry *entry, const char *name)
        }
        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,
@@ -1341,23 +1259,14 @@ static struct inode_operations fuse_dir_inode_operations = {
        .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 = {
@@ -1371,41 +1280,24 @@ 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)
index f01fc995923154eca74fc96d0c605abc75f49169..9e50109c440932a2a29750f1509492f26b45c905 100644 (file)
 #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)
 {
@@ -79,11 +75,7 @@ void fuse_finish_open(struct inode *inode, struct file *file,
        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;
 }
@@ -344,7 +336,6 @@ static int fuse_readpage(struct file *file, struct page *page)
        return err;
 }
 
-#ifdef KERNEL_2_6
 static void fuse_readpages_end(struct fuse_conn *fc, struct fuse_req *req)
 {
        int i;
@@ -442,105 +433,6 @@ static int fuse_readpages(struct file *file, struct address_space *mapping,
        }
        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)
@@ -742,27 +634,6 @@ static ssize_t fuse_direct_write(struct file *file, const char __user *buf,
        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)) {
@@ -774,14 +645,12 @@ static int fuse_file_mmap(struct file *file, struct vm_area_struct *vma)
        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)
@@ -938,22 +807,15 @@ static int fuse_file_lock(struct file *file, int cmd, 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 = {
@@ -972,10 +834,8 @@ static struct address_space_operations fuse_file_aops  = {
        .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)
index e95f2ee748406f48fddabf4710e358a919a05064..2515df2f77284d8a4711c58352b1268311d5e275 100644 (file)
 #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
 
@@ -139,11 +102,6 @@ extern struct mutex fuse_mutex;
 #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 {
@@ -444,10 +402,8 @@ struct fuse_conn {
        /** 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;
index 475513b2bf675faf7ab160dc8a4d20ca09ff31e5..949b456c411373f75445dd4ba31e2e269cf41612 100644 (file)
 #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");
@@ -34,9 +30,6 @@ DEFINE_MUTEX(fuse_mutex);
 
 #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
@@ -62,9 +55,6 @@ static struct inode *fuse_alloc_inode(struct super_block *sb)
        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;
@@ -132,11 +122,7 @@ static int fuse_remount_fs(struct super_block *sb, int *flags, char *data)
 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);
@@ -146,18 +132,12 @@ void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr)
        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)
@@ -180,7 +160,6 @@ 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;
@@ -211,11 +190,7 @@ struct inode *fuse_iget(struct super_block *sb, unsigned long nodeid,
                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);
@@ -234,48 +209,6 @@ struct inode *fuse_iget(struct super_block *sb, unsigned long nodeid,
        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)
@@ -313,9 +246,7 @@ static void convert_fuse_statfs(struct kstatfs *stbuf, struct fuse_kstatfs *attr
 {
        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;
@@ -368,9 +299,6 @@ enum {
        OPT_GROUP_ID,
        OPT_DEFAULT_PERMISSIONS,
        OPT_ALLOW_OTHER,
-#ifndef KERNEL_2_6
-       OPT_LARGE_READ,
-#endif
        OPT_MAX_READ,
        OPT_ERR
 };
@@ -382,9 +310,6 @@ static match_table_t tokens = {
        {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}
 };
@@ -440,11 +365,6 @@ static int parse_fuse_opt(char *opt, struct fuse_mount_data *d)
                        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;
@@ -473,10 +393,6 @@ static int fuse_show_options(struct seq_file *m, struct vfsmount *mnt)
                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;
@@ -506,10 +422,8 @@ static struct fuse_conn *new_conn(void)
                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));
@@ -539,7 +453,6 @@ static struct inode *get_root_inode(struct super_block *sb, unsigned mode)
        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;
@@ -601,7 +514,6 @@ static struct export_operations fuse_export_operations = {
        .encode_fh      = fuse_encode_fh,
 };
 #endif
-#endif
 
 static struct super_operations fuse_super_operations = {
        .alloc_inode    = fuse_alloc_inode,
@@ -622,7 +534,6 @@ static void process_init_reply(struct fuse_conn *fc, struct fuse_req *req)
        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) {
@@ -637,7 +548,6 @@ static void process_init_reply(struct fuse_conn *fc, struct fuse_req *req)
                }
 
                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;
        }
@@ -652,10 +562,8 @@ static void fuse_send_init(struct fuse_conn *fc, struct fuse_req *req)
 
        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);
@@ -699,9 +607,7 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
        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);
@@ -775,7 +681,6 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
        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,
@@ -798,27 +703,12 @@ static struct file_system_type fuse_fs_type = {
        .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)
@@ -857,7 +747,6 @@ static void fuse_fs_cleanup(void)
        kmem_cache_destroy(fuse_inode_cachep);
 }
 
-#ifdef KERNEL_2_6
 static int fuse_sysfs_init(void)
 {
        int err;
@@ -896,15 +785,6 @@ static void fuse_sysfs_cleanup(void)
        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)
 {