From: Miklos Szeredi Date: Wed, 7 Jan 2004 12:16:45 +0000 (+0000) Subject: integrated 2.6 kernel support X-Git-Tag: fuse_1_1_pre1~2 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=f85ab249900582dc9b212d89622bb4b361ef24f2;p=qemu-gpiodev%2Flibfuse.git integrated 2.6 kernel support --- diff --git a/ChangeLog b/ChangeLog index 8dfab5d..d1dc1f2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2004-01-06 Miklos Szeredi + + * Integrated 2.6 kernel support patch by Michael Grigoriev + + * Improvements and cleanups for 2.6 kernels + 2004-01-05 Miklos Szeredi * Added -d option to fusermount diff --git a/README-2.4 b/README-2.4 new file mode 100644 index 0000000..5967bfe --- /dev/null +++ b/README-2.4 @@ -0,0 +1,3 @@ +WARNING: be very careful about which gcc version you use to compile +the fuse kernel module. It must be the same as the version used to +compile the kernel otherwise nasty things will happen! diff --git a/README-2.6 b/README-2.6 new file mode 100644 index 0000000..8cc4fa1 --- /dev/null +++ b/README-2.6 @@ -0,0 +1,4 @@ +To use kbuild, you need write access to .tmp_versions/ and +.__modpost.cmd in KERNELDIR. + +HINT: chmod them 1777 diff --git a/configure.in b/configure.in index d2446b3..d64cd52 100644 --- a/configure.in +++ b/configure.in @@ -54,10 +54,10 @@ if test "$enable_kernel_module" != "no"; then *** configure the kernel before running this script]) fi AC_MSG_RESULT([$kernsrcver]) - - KERNINCLUDE=$kernelsrc/include - AC_SUBST(KERNINCLUDE) + majver=`echo "$kernsrcver" | cut -f-2 -d.` kmoduledir=/lib/modules/$kernsrcver + AC_SUBST(kernelsrc) + AC_SUBST(majver) AC_SUBST(kmoduledir) subdirs="$subdirs kernel" fi diff --git a/include/linux/fuse.h b/include/linux/fuse.h index 9f9609e..bcd85b0 100644 --- a/include/linux/fuse.h +++ b/include/linux/fuse.h @@ -20,11 +20,6 @@ /** Opening this will yield a new control file */ #define FUSE_DEV "/proc/fs/fuse/dev" -/** Read combining parameters */ -#define FUSE_BLOCK_SHIFT 16 -#define FUSE_BLOCK_SIZE 65536 -#define FUSE_BLOCK_MASK 0xffff0000 - /** Data passed to mount */ struct fuse_mount_data { /** Must be set to FUSE_KERNEL_VERSION */ @@ -131,6 +126,7 @@ struct fuse_getdir_out { void *file; /* Used by kernel only */ }; +/* FIXME: 2.6 needs 32 bit rdev */ struct fuse_mknod_in { unsigned short mode; unsigned short rdev; diff --git a/kernel/.cvsignore b/kernel/.cvsignore index e440faf..bd5fe06 100644 --- a/kernel/.cvsignore +++ b/kernel/.cvsignore @@ -1,3 +1,2 @@ -Makefile.in Makefile .deps diff --git a/kernel/Makefile.am b/kernel/Makefile.am deleted file mode 100644 index 89b1018..0000000 --- a/kernel/Makefile.am +++ /dev/null @@ -1,43 +0,0 @@ -## Process this file with automake to produce Makefile.in - -EXTRA_DIST = dev.c dir.c file.c inode.c util.c fuse_i.h - -CC = @CC@ -LD = @LD@ -CFLAGS = -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -pipe -CPPFLAGS = -I@KERNINCLUDE@ -I../include -D__KERNEL__ -DMODULE -D_LOOSE_KERNEL_NAMES -INSTALL = @INSTALL@ -fusemoduledir = @kmoduledir@/kernel/fs/fuse - -SUFFIXES = .c .o .s - - -all-local: fuse.o - -install-exec-local: fuse.o - $(mkinstalldirs) $(DESTDIR)$(fusemoduledir) - $(INSTALL) -m 644 fuse.o $(DESTDIR)$(fusemoduledir)/fuse.o - -/sbin/depmod -a - -uninstall-local: - rm -f $(DESTDIR)$(fusemoduledir)/fuse.o - -/sbin/depmod -a - -clean-local: - rm -f *.o *.s - -.c.o: - $(CC) $(CFLAGS) $(CPPFLAGS) -c $< - -fuse_objs = dev.o dir.o file.o inode.o util.o - -fuse.o: $(fuse_objs) - $(LD) -r -o fuse.o $(fuse_objs) - -fuse_headers = fuse_i.h ../include/linux/fuse.h - -dev.o: $(fuse_headers) -dir.o: $(fuse_headers) -file.o: $(fuse_headers) -inode.o: $(fuse_headers) -util.o: $(fuse_headers) diff --git a/kernel/Makefile.in b/kernel/Makefile.in new file mode 100644 index 0000000..f1bf8a1 --- /dev/null +++ b/kernel/Makefile.in @@ -0,0 +1,80 @@ +# Makefile.in for kernel module + +SHELL = /bin/sh +INSTALL = @INSTALL@ +mkinstalldirs = $(SHELL) ../mkinstalldirs +majver = @majver@ + +EXTRA_CFLAGS := -I$(PWD)/../include +DISTFILES = Makefile.in dev.c dir.c file.c inode.c util.c fuse_i.h + +fusemoduledir = @kmoduledir@/kernel/fs/fuse + +ifeq ($(majver), 2.4) +fusemodule := fuse.o +else +fusemodule := fuse.ko +endif + +all: all-spec + +install: all + @$(mkinstalldirs) $(DESTDIR)$(fusemoduledir) + $(INSTALL) -m 644 $(fusemodule) $(DESTDIR)$(fusemoduledir)/$(fusemodule) + -/sbin/depmod -a + +uninstall: + rm -f $(DESTDIR)$(fusemoduledir)/$(fusemodule) + -/sbin/depmod -a + +clean: + -rm -f $(fusemodule) *.o .*.cmd *.mod.c *.ko *.s + +distclean: clean + rm -f Makefile + +maintainer-clean: distclean + +distdir: $(DISTFILES) + cp -p $(DISTFILES) $(distdir) + + +ifeq ($(majver), 2.4) + +CC = @CC@ +LD = @LD@ +CFLAGS = -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -pipe +CPPFLAGS = -I@kernelsrc@/include -I../include -D__KERNEL__ -DMODULE -D_LOOSE_KERNEL_NAMES + +fuse_objs = dev.o dir.o file.o inode.o util.o + +SUFFIXES = .c .o .s + +all-spec: fuse.o + +.c.o: + $(CC) $(CFLAGS) $(CPPFLAGS) -c $< + +fuse.o: $(fuse_objs) + $(LD) -r -o fuse.o $(fuse_objs) + +fuse_headers = fuse_i.h ../include/linux/fuse.h + +dev.o: $(fuse_headers) +dir.o: $(fuse_headers) +file.o: $(fuse_headers) +inode.o: $(fuse_headers) +util.o: $(fuse_headers) + +else + +obj-m := fuse.o +fuse-objs := dev.o dir.o file.o inode.o util.o + +all-spec: + $(MAKE) -C @kernelsrc@ SUBDIRS=$(PWD) modules +endif + + + + diff --git a/kernel/dev.c b/kernel/dev.c index e34bee5..8b9b3fb 100644 --- a/kernel/dev.c +++ b/kernel/dev.c @@ -368,7 +368,12 @@ static int fuse_invalidate(struct fuse_conn *fc, struct fuse_user_header *uh) if (!inode) return -ENOENT; +#ifdef KERNEL_2_6 + invalidate_inode_pages(inode->i_mapping); +#else invalidate_inode_pages(inode); +#endif + iput(inode); return 0; } diff --git a/kernel/dir.c b/kernel/dir.c index d4210b5..23d1f01 100644 --- a/kernel/dir.c +++ b/kernel/dir.c @@ -25,8 +25,13 @@ static struct dentry_operations fuse_dentry_opertations; static void change_attributes(struct inode *inode, struct fuse_attr *attr) { - if(S_ISREG(inode->i_mode) && inode->i_size != attr->size) + if(S_ISREG(inode->i_mode) && inode->i_size != attr->size) { +#ifdef KERNEL_2_6 + invalidate_inode_pages(inode->i_mapping); +#else invalidate_inode_pages(inode); +#endif + } inode->i_mode = (inode->i_mode & S_IFMT) + (attr->mode & 07777); inode->i_nlink = attr->nlink; @@ -35,9 +40,18 @@ static void change_attributes(struct inode *inode, struct fuse_attr *attr) inode->i_size = 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 = 0; + inode->i_mtime.tv_sec = attr->mtime; + inode->i_mtime.tv_nsec = 0; + inode->i_ctime.tv_sec = attr->ctime; + inode->i_ctime.tv_nsec = 0; +#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) @@ -114,7 +128,7 @@ static int fuse_do_lookup(struct inode *dir, struct dentry *entry, return out.h.error; } -static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry) +static struct dentry *_fuse_lookup(struct inode *dir, struct dentry *entry) { int ret; struct fuse_lookup_out outarg; @@ -150,8 +164,8 @@ static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry) /* create needs to return a positive entry, so this is actually an mknod+lookup */ -static int fuse_mknod(struct inode *dir, struct dentry *entry, int mode, - int rdev) +static int _fuse_mknod(struct inode *dir, struct dentry *entry, int mode, + dev_t rdev) { struct fuse_conn *fc = INO_FC(dir); struct fuse_in in = FUSE_IN_INIT; @@ -199,10 +213,9 @@ static int fuse_mknod(struct inode *dir, struct dentry *entry, int mode, return 0; } - -static int fuse_create(struct inode *dir, struct dentry *entry, int mode) +static int _fuse_create(struct inode *dir, struct dentry *entry, int mode) { - return fuse_mknod(dir, entry, mode, 0); + return _fuse_mknod(dir, entry, mode, 0); } static int fuse_mkdir(struct inode *dir, struct dentry *entry, int mode) @@ -323,7 +336,7 @@ static int fuse_link(struct dentry *entry, struct inode *newdir, } -int fuse_getattr(struct inode *inode) +int fuse_do_getattr(struct inode *inode) { struct fuse_conn *fc = INO_FC(inode); struct fuse_in in = FUSE_IN_INIT; @@ -349,17 +362,16 @@ static int fuse_revalidate(struct dentry *entry) struct fuse_conn *fc = INO_FC(inode); if(inode->i_ino == FUSE_ROOT_INO) { - if(!(fc->flags & FUSE_ALLOW_OTHER) - && current->fsuid != fc->uid) + if(!(fc->flags & FUSE_ALLOW_OTHER) && + current->fsuid != fc->uid) return -EACCES; - } - else if(time_before_eq(jiffies, entry->d_time + FUSE_REVALIDATE_TIME)) + } else if(time_before_eq(jiffies, entry->d_time + FUSE_REVALIDATE_TIME)) return 0; - return fuse_getattr(inode); + return fuse_do_getattr(inode); } -static int fuse_permission(struct inode *inode, int mask) +static int _fuse_permission(struct inode *inode, int mask) { struct fuse_conn *fc = INO_FC(inode); @@ -373,7 +385,7 @@ static int fuse_permission(struct inode *inode, int mask) node will at first have no permissions */ if(err == -EACCES) { - err = fuse_getattr(inode); + err = fuse_do_getattr(inode); if(!err) err = vfs_permission(inode, mask); } @@ -393,7 +405,6 @@ static int fuse_permission(struct inode *inode, int mask) return 0; } - static int parse_dirfile(char *buf, size_t nbytes, struct file *file, void *dstbuf, filldir_t filldir) { @@ -563,8 +574,13 @@ static unsigned int iattr_to_fattr(struct iattr *iattr, /* You can only _set_ these together (they may change by themselves) */ if((ivalid & (ATTR_ATIME | ATTR_MTIME)) == (ATTR_ATIME | ATTR_MTIME)) { fvalid |= FATTR_UTIME; +#ifdef KERNEL_2_6 + fattr->atime = iattr->ia_atime.tv_sec; + fattr->mtime = iattr->ia_mtime.tv_sec; +#else fattr->atime = iattr->ia_atime; fattr->mtime = iattr->ia_mtime; +#endif } return fvalid; @@ -602,7 +618,7 @@ static int fuse_setattr(struct dentry *entry, struct iattr *attr) return out.h.error; } -static int fuse_dentry_revalidate(struct dentry *entry, int flags) +static int _fuse_dentry_revalidate(struct dentry *entry) { if(!entry->d_inode) return 0; @@ -627,6 +643,62 @@ static int fuse_dentry_revalidate(struct dentry *entry, int flags) return 1; } +#ifdef KERNEL_2_6 + +#define fuse_mknod _fuse_mknod + +static int fuse_getattr(struct vfsmount *mnt, struct dentry *entry, + struct kstat *stat) +{ + struct inode *inode = entry->d_inode; + int err = fuse_revalidate(entry); + if(!err) + generic_fillattr(inode, stat); + + return err; +} + +static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry, + struct nameidata *nd) +{ + return _fuse_lookup(dir, entry); +} + +static int fuse_create(struct inode *dir, struct dentry *entry, int mode, + struct nameidata *nd) +{ + return _fuse_create(dir, entry, mode); +} + +static int fuse_permission(struct inode *inode, int mask, + struct nameidata *nd) +{ + return _fuse_permission(inode, mask); +} + +static int fuse_dentry_revalidate(struct dentry *entry, struct nameidata *nd) +{ + return _fuse_dentry_revalidate(entry); +} +#else /* KERNEL_2_6 */ + +#define fuse_lookup _fuse_lookup +#define fuse_create _fuse_create +#define fuse_permission _fuse_permission + +static int fuse_mknod(struct inode *dir, struct dentry *entry, int mode, + int rdev) +{ + return fuse_mknod(dir, entry, mode, rdev); +} + +static int fuse_dentry_revalidate(struct dentry *entry, int flags) +{ + return _fuse_dentry_revalidate(entry); +} +#endif /* KERNEL_2_6 */ + + static struct inode_operations fuse_dir_inode_operations = { lookup: fuse_lookup, @@ -640,7 +712,11 @@ static struct inode_operations fuse_dir_inode_operations = link: fuse_link, setattr: fuse_setattr, permission: fuse_permission, +#ifdef KERNEL_2_6 + getattr: fuse_getattr, +#else revalidate: fuse_revalidate, +#endif }; static struct file_operations fuse_dir_operations = { @@ -653,7 +729,11 @@ static struct file_operations fuse_dir_operations = { static struct inode_operations fuse_file_inode_operations = { setattr: fuse_setattr, permission: fuse_permission, +#ifdef KERNEL_2_6 + getattr: fuse_getattr, +#else revalidate: fuse_revalidate, +#endif }; static struct inode_operations fuse_symlink_inode_operations = @@ -661,7 +741,11 @@ static struct inode_operations fuse_symlink_inode_operations = setattr: fuse_setattr, readlink: fuse_readlink, follow_link: fuse_follow_link, +#ifdef KERNEL_2_6 + getattr: fuse_getattr, +#else revalidate: fuse_revalidate, +#endif }; static struct dentry_operations fuse_dentry_opertations = { diff --git a/kernel/file.c b/kernel/file.c index 11e7bc0..184f938 100644 --- a/kernel/file.c +++ b/kernel/file.c @@ -9,6 +9,13 @@ #include #include +#ifdef KERNEL_2_6 +#include +#endif + +#ifndef KERNEL_2_6 +#define PageUptodate(page) Page_Uptodate(page) +#endif static int fuse_open(struct inode *inode, struct file *file) { @@ -20,7 +27,7 @@ static int fuse_open(struct inode *inode, struct file *file) /* If opening the root node, no lookup has been performed on it, so the attributes must be refreshed */ if(inode->i_ino == FUSE_ROOT_INO) { - int err = fuse_getattr(inode); + int err = fuse_do_getattr(inode); if(err) return err; } @@ -34,8 +41,13 @@ static int fuse_open(struct inode *inode, struct file *file) in.args[0].size = sizeof(inarg); in.args[0].value = &inarg; request_send(fc, &in, &out); - if(!out.h.error && !(fc->flags & FUSE_KERNEL_CACHE)) + if(!out.h.error && !(fc->flags & FUSE_KERNEL_CACHE)) { +#ifdef KERNEL_2_6 + invalidate_inode_pages(inode->i_mapping); +#else invalidate_inode_pages(inode); +#endif + } return out.h.error; } @@ -126,7 +138,7 @@ static int fuse_readpage(struct file *file, struct page *page) } kunmap(page); - UnlockPage(page); + unlock_page(page); return out.h.error; } @@ -147,7 +159,7 @@ static int fuse_is_block_uptodate(struct address_space *mapping, if (!page) return 0; - if (!Page_Uptodate(page)) { + if (!PageUptodate(page)) { page_cache_release(page); return 0; } @@ -182,7 +194,7 @@ static int fuse_cache_block(struct address_space *mapping, if (!page) return -1; - if (!Page_Uptodate(page)) { + if (!PageUptodate(page)) { buffer = kmap(page); memcpy(buffer, bl_buf + i * PAGE_CACHE_SIZE, PAGE_CACHE_SIZE); @@ -190,7 +202,7 @@ static int fuse_cache_block(struct address_space *mapping, kunmap(page); } - UnlockPage(page); + unlock_page(page); page_cache_release(page); } @@ -296,8 +308,11 @@ static int write_buffer(struct inode *inode, struct page *page, return out.h.error; } - +#ifdef KERNEL_2_6 +static int fuse_writepage(struct page *page, struct writeback_control *wbc) +#else static int fuse_writepage(struct page *page) +#endif { struct inode *inode = page->mapping->host; unsigned count; @@ -316,7 +331,7 @@ static int fuse_writepage(struct page *page) } err = write_buffer(inode, page, 0, count); out: - UnlockPage(page); + unlock_page(page); return 0; } @@ -363,6 +378,9 @@ void fuse_init_file_inode(struct inode *inode) { inode->i_fop = &fuse_file_operations; inode->i_data.a_ops = &fuse_file_aops; +#ifdef KERNEL_2_6 + inode->i_mapping->backing_dev_info->ra_pages = 0; +#endif } /* diff --git a/kernel/fuse_i.h b/kernel/fuse_i.h index 5a4a8b7..a667176 100644 --- a/kernel/fuse_i.h +++ b/kernel/fuse_i.h @@ -16,13 +16,26 @@ #endif #include #include - +#include #include #include #include +/** Read combining parameters */ +#define FUSE_BLOCK_SHIFT 16 +#define FUSE_BLOCK_SIZE 65536 +#define FUSE_BLOCK_MASK 0xffff0000 + #define FUSE_BLOCK_PAGE_SHIFT (FUSE_BLOCK_SHIFT - PAGE_CACHE_SHIFT) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) && LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) +#error Kernel version 2.5.* not supported +#endif + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) +#define KERNEL_2_6 +#endif + /** * A Fuse connection. @@ -122,8 +135,12 @@ struct fuse_req { wait_queue_head_t waitq; }; - -#define INO_FC(inode) ((struct fuse_conn *) (inode)->i_sb->u.generic_sbp) +#ifdef KERNEL_2_6 +#define SB_FC(sb) ((struct fuse_conn *) (sb)->s_fs_info) +#else +#define SB_FC(sb) ((struct fuse_conn *) (sb)->u.generic_sbp) +#endif +#define INO_FC(inode) SB_FC((inode)->i_sb) #define DEV_FC(file) ((struct fuse_conn *) (file)->private_data) @@ -191,7 +208,7 @@ int request_send_noreply(struct fuse_conn *fc, struct fuse_in *in); /** * Get the attributes of a file */ -int fuse_getattr(struct inode *inode); +int fuse_do_getattr(struct inode *inode); /* * Local Variables: diff --git a/kernel/inode.c b/kernel/inode.c index cd7fbc4..55d381c 100644 --- a/kernel/inode.c +++ b/kernel/inode.c @@ -13,9 +13,16 @@ #include #include #include +#ifdef KERNEL_2_6 +#include +#endif #define FUSE_SUPER_MAGIC 0x65735546 +#ifndef KERNEL_2_6 +#define kstatfs statfs +#endif + static void fuse_read_inode(struct inode *inode) { /* No op */ @@ -58,7 +65,7 @@ static void fuse_clear_inode(struct inode *inode) static void fuse_put_super(struct super_block *sb) { - struct fuse_conn *fc = sb->u.generic_sbp; + struct fuse_conn *fc = SB_FC(sb); spin_lock(&fuse_lock); fc->sb = NULL; @@ -67,11 +74,11 @@ static void fuse_put_super(struct super_block *sb) /* Flush all readers on this fs */ wake_up_all(&fc->waitq); fuse_release_conn(fc); - sb->u.generic_sbp = NULL; + SB_FC(sb) = NULL; spin_unlock(&fuse_lock); } -static void convert_fuse_statfs(struct statfs *stbuf, struct fuse_kstatfs *attr) +static void convert_fuse_statfs(struct kstatfs *stbuf, struct fuse_kstatfs *attr) { stbuf->f_type = FUSE_SUPER_MAGIC; stbuf->f_bsize = attr->block_size; @@ -85,9 +92,9 @@ static void convert_fuse_statfs(struct statfs *stbuf, struct fuse_kstatfs *attr) stbuf->f_namelen = attr->namelen; } -static int fuse_statfs(struct super_block *sb, struct statfs *st) +static int fuse_statfs(struct super_block *sb, struct kstatfs *buf) { - struct fuse_conn *fc = sb->u.generic_sbp; + struct fuse_conn *fc = SB_FC(sb); struct fuse_in in = FUSE_IN_INIT; struct fuse_out out = FUSE_OUT_INIT; struct fuse_statfs_out outarg; @@ -99,7 +106,7 @@ static int fuse_statfs(struct super_block *sb, struct statfs *st) out.args[0].value = &outarg; request_send(fc, &in, &out); if(!out.h.error) - convert_fuse_statfs(st,&outarg.st); + convert_fuse_statfs(buf, &outarg.st); return out.h.error; } @@ -155,8 +162,7 @@ static struct inode *get_root_inode(struct super_block *sb, unsigned int mode) return fuse_iget(sb, 1, &attr, 0); } -static struct super_block *fuse_read_super(struct super_block *sb, - void *data, int silent) +static int fuse_read_super(struct super_block *sb, void *data, int silent) { struct fuse_conn *fc; struct inode *root; @@ -170,7 +176,7 @@ static struct super_block *fuse_read_super(struct super_block *sb, root = get_root_inode(sb, d->rootmode); if(root == NULL) { printk("fuse_read_super: failed to get root inode\n"); - return NULL; + return -EINVAL; } spin_lock(&fuse_lock); @@ -183,7 +189,7 @@ static struct super_block *fuse_read_super(struct super_block *sb, goto err; } - sb->u.generic_sbp = fc; + SB_FC(sb) = fc; sb->s_root = d_alloc_root(root); if(!sb->s_root) goto err; @@ -193,16 +199,41 @@ static struct super_block *fuse_read_super(struct super_block *sb, fc->uid = d->uid; spin_unlock(&fuse_lock); - return sb; + return 0; err: spin_unlock(&fuse_lock); iput(root); - return NULL; + return -EINVAL; +} + +#ifdef KERNEL_2_6 +static struct super_block *fuse_get_sb(struct file_system_type *fs_type, + int flags, const char *dev_name, void *raw_data) +{ + return get_sb_nodev(fs_type, flags, raw_data, fuse_read_super); } +static struct file_system_type fuse_fs_type = { + .owner = THIS_MODULE, + .name = "fuse", + .get_sb = fuse_get_sb, + .kill_sb = kill_anon_super, + .fs_flags = 0 +}; +#else +static struct super_block *fuse_read_super_compat(struct super_block *sb, + void *data, int silent) +{ + int err = fuse_read_super(sb, data, silent); + if(err) + return NULL; + else + return sb; +} -static DECLARE_FSTYPE(fuse_fs_type, "fuse", fuse_read_super, 0); +static DECLARE_FSTYPE(fuse_fs_type, "fuse", fuse_read_super_compat, 0); +#endif int fuse_fs_init() { diff --git a/kernel/util.c b/kernel/util.c index ecf23ce..7296517 100644 --- a/kernel/util.c +++ b/kernel/util.c @@ -8,11 +8,11 @@ #include "fuse_i.h" +#include #include MODULE_AUTHOR("Miklos Szeredi "); MODULE_DESCRIPTION("Filesystem in Userspace"); - #ifdef MODULE_LICENSE MODULE_LICENSE("GPL"); #endif @@ -27,7 +27,7 @@ void fuse_release_conn(struct fuse_conn *fc) } } -int init_module(void) +int __init fuse_init(void) { int res; @@ -49,14 +49,17 @@ int init_module(void) return res; } -void cleanup_module(void) +void __exit fuse_exit(void) { - printk(KERN_DEBUG "fuse cleanup\n"); + printk(KERN_DEBUG "fuse exit\n"); fuse_fs_cleanup(); fuse_dev_cleanup(); } +module_init(fuse_init); +module_exit(fuse_exit); + /* * Local Variables: * indent-tabs-mode: t diff --git a/patch/fuse-2.6.patch b/patch/fuse-2.6.patch deleted file mode 100644 index 4b81f56..0000000 --- a/patch/fuse-2.6.patch +++ /dev/null @@ -1,407 +0,0 @@ -diff -ruN kernel/Makefile-2.6 kernel-2.6/Makefile-2.6 ---- kernel/Makefile-2.6 1970-01-01 01:00:00.000000000 +0100 -+++ kernel-2.6/Makefile-2.6 2003-09-08 15:30:07.000000000 +0200 -@@ -0,0 +1,26 @@ -+KERNELDIR=$(shell cd /lib/modules/`uname -r`/build; /bin/pwd) -+ -+default: -+ $(warning To use kbuild, you need write access to) -+ $(warning .tmp_versions/ and .__modpost.cmd in KERNELDIR) -+ $(warning HINT: chmod them 1777) -+ $(MAKE) -C ${KERNELDIR} SUBDIRS=$(PWD) modules -+ -+install: default -+ mkdir -p /lib/modules/`uname -r`/kernel/fs/fuse/ -+ cp fuse.ko /lib/modules/`uname -r`/kernel/fs/fuse/ -+ -+insert: install -+ if [ "`lsmod | grep fuse`" ]; then rmmod fuse; fi -+ depmod -+ modprobe fuse -+ -+clean: -+ rm -f *.o fuse.ko .*o.cmd fuse.mod.c -+ -+EXTRA_CFLAGS := -I$(PWD)/../include -+ -+obj-m += fuse.o -+fuse-objs := dev.o dir.o file.o inode.o util.o -+ -+ -diff -ruN kernel/dev.c kernel-2.6/dev.c ---- kernel/dev.c 2003-09-08 15:41:06.000000000 +0200 -+++ kernel-2.6/dev.c 2003-09-08 13:42:28.000000000 +0200 -@@ -368,7 +368,7 @@ - if (!inode) - return -ENOENT; - -- invalidate_inode_pages(inode); -+ invalidate_inode_pages(inode->i_mapping); - iput(inode); - return 0; - } -diff -ruN kernel/dir.c kernel-2.6/dir.c ---- kernel/dir.c 2003-09-08 15:41:06.000000000 +0200 -+++ kernel-2.6/dir.c 2003-09-08 13:41:12.000000000 +0200 -@@ -11,6 +11,7 @@ - #include - #include - #include -+#include - - static struct inode_operations fuse_dir_inode_operations; - static struct inode_operations fuse_file_inode_operations; -@@ -26,7 +27,7 @@ - static void change_attributes(struct inode *inode, struct fuse_attr *attr) - { - if(S_ISREG(inode->i_mode) && inode->i_size != attr->size) -- invalidate_inode_pages(inode); -+ invalidate_inode_pages(inode->i_mapping); - - inode->i_mode = (inode->i_mode & S_IFMT) + (attr->mode & 07777); - inode->i_nlink = attr->nlink; -@@ -35,9 +36,9 @@ - inode->i_size = attr->size; - inode->i_blksize = PAGE_CACHE_SIZE; - inode->i_blocks = attr->blocks; -- inode->i_atime = attr->atime; -- inode->i_mtime = attr->mtime; -- inode->i_ctime = attr->ctime; -+ inode->i_atime.tv_sec = attr->atime; -+ inode->i_mtime.tv_sec = attr->mtime; -+ inode->i_ctime.tv_sec = attr->ctime; - } - - static void fuse_init_inode(struct inode *inode, struct fuse_attr *attr) -@@ -114,7 +115,8 @@ - return out.h.error; - } - --static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry) -+static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry, -+ struct nameidata *nd) - { - int ret; - struct fuse_lookup_out outarg; -@@ -151,7 +153,7 @@ - /* create needs to return a positive entry, so this is actually an - mknod+lookup */ - static int fuse_mknod(struct inode *dir, struct dentry *entry, int mode, -- int rdev) -+ dev_t rdev) - { - struct fuse_conn *fc = INO_FC(dir); - struct fuse_in in = FUSE_IN_INIT; -@@ -200,7 +202,8 @@ - } - - --static int fuse_create(struct inode *dir, struct dentry *entry, int mode) -+static int fuse_create(struct inode *dir, struct dentry *entry, int mode, -+ struct nameidata *nd) - { - return fuse_mknod(dir, entry, mode, 0); - } -@@ -330,6 +333,12 @@ - struct fuse_out out = FUSE_OUT_INIT; - struct fuse_getattr_out arg; - -+ if(inode->i_ino == FUSE_ROOT_INO) { -+ if(!(fc->flags & FUSE_ALLOW_OTHER) -+ && current->fsuid != fc->uid) -+ return -EACCES; -+ } -+ - in.h.opcode = FUSE_GETATTR; - in.h.ino = inode->i_ino; - out.numargs = 1; -@@ -343,23 +352,8 @@ - return out.h.error; - } - --static int fuse_revalidate(struct dentry *entry) --{ -- struct inode *inode = entry->d_inode; -- struct fuse_conn *fc = INO_FC(inode); -- -- if(inode->i_ino == FUSE_ROOT_INO) { -- if(!(fc->flags & FUSE_ALLOW_OTHER) -- && current->fsuid != fc->uid) -- return -EACCES; -- } -- else if(time_before_eq(jiffies, entry->d_time + FUSE_REVALIDATE_TIME)) -- return 0; -- -- return fuse_getattr(inode); --} - --static int fuse_permission(struct inode *inode, int mask) -+static int fuse_permission(struct inode *inode, int mask, struct nameidata *nd) - { - struct fuse_conn *fc = INO_FC(inode); - -@@ -563,8 +557,8 @@ - /* You can only _set_ these together (they may change by themselves) */ - if((ivalid & (ATTR_ATIME | ATTR_MTIME)) == (ATTR_ATIME | ATTR_MTIME)) { - fvalid |= FATTR_UTIME; -- fattr->atime = iattr->ia_atime; -- fattr->mtime = iattr->ia_mtime; -+ fattr->atime = iattr->ia_atime.tv_sec; -+ fattr->mtime = iattr->ia_mtime.tv_sec; - } - - return fvalid; -@@ -602,7 +596,7 @@ - return out.h.error; - } - --static int fuse_dentry_revalidate(struct dentry *entry, int flags) -+static int fuse_dentry_revalidate(struct dentry *entry, struct nameidata *nd) - { - if(!entry->d_inode) - return 0; -@@ -640,7 +634,6 @@ - link: fuse_link, - setattr: fuse_setattr, - permission: fuse_permission, -- revalidate: fuse_revalidate, - }; - - static struct file_operations fuse_dir_operations = { -@@ -653,7 +646,6 @@ - static struct inode_operations fuse_file_inode_operations = { - setattr: fuse_setattr, - permission: fuse_permission, -- revalidate: fuse_revalidate, - }; - - static struct inode_operations fuse_symlink_inode_operations = -@@ -661,7 +653,6 @@ - setattr: fuse_setattr, - readlink: fuse_readlink, - follow_link: fuse_follow_link, -- revalidate: fuse_revalidate, - }; - - static struct dentry_operations fuse_dentry_opertations = { -diff -ruN kernel/file.c kernel-2.6/file.c ---- kernel/file.c 2003-09-08 15:41:06.000000000 +0200 -+++ kernel-2.6/file.c 2003-09-08 13:45:25.000000000 +0200 -@@ -35,7 +35,7 @@ - in.args[0].value = &inarg; - request_send(fc, &in, &out); - if(!out.h.error && !(fc->flags & FUSE_KERNEL_CACHE)) -- invalidate_inode_pages(inode); -+ invalidate_inode_pages(inode->i_mapping); - - return out.h.error; - } -@@ -107,7 +107,7 @@ - } - - kunmap(page); -- UnlockPage(page); -+ unlock_page(page); - - return out.h.error; - } -@@ -143,7 +143,7 @@ - } - - --static int fuse_writepage(struct page *page) -+static int fuse_writepage(struct page *page, struct writeback_control *wbc) - { - struct inode *inode = page->mapping->host; - unsigned count; -@@ -162,7 +162,7 @@ - } - err = write_buffer(inode, page, 0, count); - out: -- UnlockPage(page); -+ unlock_page(page); - return 0; - } - -diff -ruN kernel/fuse_i.h kernel-2.6/fuse_i.h ---- kernel/fuse_i.h 2003-09-08 15:41:06.000000000 +0200 -+++ kernel-2.6/fuse_i.h 2003-09-08 13:41:12.000000000 +0200 -@@ -121,7 +121,7 @@ - }; - - --#define INO_FC(inode) ((struct fuse_conn *) (inode)->i_sb->u.generic_sbp) -+#define INO_FC(inode) ((struct fuse_conn *) (inode)->i_sb->s_fs_info) - #define DEV_FC(file) ((struct fuse_conn *) (file)->private_data) - - -diff -ruN kernel/inode.c kernel-2.6/inode.c ---- kernel/inode.c 2003-09-08 15:41:06.000000000 +0200 -+++ kernel-2.6/inode.c 2003-09-08 13:41:12.000000000 +0200 -@@ -13,6 +13,9 @@ - #include - #include - #include -+#include -+ -+#include - - #define FUSE_SUPER_MAGIC 0x65735546 - -@@ -58,7 +61,7 @@ - - static void fuse_put_super(struct super_block *sb) - { -- struct fuse_conn *fc = sb->u.generic_sbp; -+ struct fuse_conn *fc = sb->s_fs_info; - - spin_lock(&fuse_lock); - fc->sb = NULL; -@@ -67,11 +70,11 @@ - /* Flush all readers on this fs */ - wake_up_all(&fc->waitq); - fuse_release_conn(fc); -- sb->u.generic_sbp = NULL; -+ sb->s_fs_info = NULL; - spin_unlock(&fuse_lock); - } - --static void convert_fuse_statfs(struct statfs *stbuf, struct fuse_kstatfs *attr) -+static void convert_fuse_statfs(struct kstatfs *stbuf, struct fuse_kstatfs *attr) - { - stbuf->f_type = FUSE_SUPER_MAGIC; - stbuf->f_bsize = attr->block_size; -@@ -85,9 +88,9 @@ - stbuf->f_namelen = attr->namelen; - } - --static int fuse_statfs(struct super_block *sb, struct statfs *st) -+static int fuse_statfs(struct super_block *sb, struct kstatfs *buf) - { -- struct fuse_conn *fc = sb->u.generic_sbp; -+ struct fuse_conn *fc = sb->s_fs_info; - struct fuse_in in = FUSE_IN_INIT; - struct fuse_out out = FUSE_OUT_INIT; - struct fuse_statfs_out outarg; -@@ -99,7 +102,7 @@ - out.args[0].value = &outarg; - request_send(fc, &in, &out); - if(!out.h.error) -- convert_fuse_statfs(st,&outarg.st); -+ convert_fuse_statfs(buf,&outarg.st); - - return out.h.error; - } -@@ -155,7 +158,7 @@ - return fuse_iget(sb, 1, &attr, 0); - } - --static struct super_block *fuse_read_super(struct super_block *sb, -+static int fuse_read_super(struct super_block *sb, - void *data, int silent) - { - struct fuse_conn *fc; -@@ -170,7 +173,7 @@ - root = get_root_inode(sb, d->rootmode); - if(root == NULL) { - printk("fuse_read_super: failed to get root inode\n"); -- return NULL; -+ return -EINVAL; - } - - spin_lock(&fuse_lock); -@@ -183,7 +186,7 @@ - goto err; - } - -- sb->u.generic_sbp = fc; -+ sb->s_fs_info = fc; - sb->s_root = d_alloc_root(root); - if(!sb->s_root) - goto err; -@@ -193,16 +196,31 @@ - fc->uid = d->uid; - spin_unlock(&fuse_lock); - -- return sb; -+ return 0; - - err: - spin_unlock(&fuse_lock); - iput(root); -- return NULL; -+ return -EINVAL; - } - - --static DECLARE_FSTYPE(fuse_fs_type, "fuse", fuse_read_super, 0); -+static struct super_block *fuse_get_sb(struct file_system_type *fs_type, -+ int flags, const char *dev_name, void *raw_data) -+{ -+ return get_sb_nodev(fs_type, flags, raw_data, fuse_read_super); -+} -+ -+ -+static struct file_system_type fuse_fs_type = { -+ .owner = THIS_MODULE, -+ .name = "fuse", -+ .get_sb = fuse_get_sb, -+ .kill_sb = kill_anon_super, -+ .fs_flags = 0 -+}; -+ -+ - - int fuse_fs_init() - { -diff -ruN kernel/util.c kernel-2.6/util.c ---- kernel/util.c 2003-09-08 15:41:06.000000000 +0200 -+++ kernel-2.6/util.c 2003-09-08 13:41:12.000000000 +0200 -@@ -9,6 +9,8 @@ - #include "fuse_i.h" - - #include -+#include -+#include - - MODULE_AUTHOR("Miklos Szeredi "); - MODULE_DESCRIPTION("Filesystem in Userspace"); -@@ -17,6 +19,10 @@ - MODULE_LICENSE("GPL"); - #endif - -+const char vermagic[] -+__attribute__((section("__vermagic"))) = -+VERMAGIC_STRING; -+ - spinlock_t fuse_lock = SPIN_LOCK_UNLOCKED; - - /* Must be called with the fuse lock held */ -@@ -27,7 +33,7 @@ - } - } - --int init_module(void) -+int __init fuse_init_module(void) - { - int res; - -@@ -49,7 +55,7 @@ - return res; - } - --void cleanup_module(void) -+void __exit fuse_cleanup_module(void) - { - printk(KERN_DEBUG "fuse cleanup\n"); - -@@ -57,6 +63,9 @@ - fuse_dev_cleanup(); - } - -+module_init(fuse_init_module); -+module_exit(fuse_cleanup_module); -+ - /* - * Local Variables: - * indent-tabs-mode: t