From b318b3d69b852fa474576ddcb05286aa6c08577c Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Wed, 2 May 2007 17:48:09 +0000 Subject: [PATCH] kernel: sync with mainline... --- ChangeLog | 9 +++++++++ configure.in | 2 +- kernel/configure.ac | 2 +- kernel/control.c | 6 +++++- kernel/dev.c | 2 +- kernel/dir.c | 5 +++-- kernel/file.c | 4 ++++ kernel/fuse_i.h | 11 +++++++++++ kernel/inode.c | 10 ++++++++-- 9 files changed, 43 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index a698158..b4bddac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2007-05-02 Miklos Szeredi + + * kernel: sync with mainline: + + * Use invalidate_mapping_pages() if available + + * Fix BUG when invalid file type is supplied in mount. Patch by + Timo Savola + 2007-04-27 Miklos Szeredi * libfuse: call umount(8) directly instead of fusermount if diff --git a/configure.in b/configure.in index d722d16..5c34ef1 100644 --- a/configure.in +++ b/configure.in @@ -1,4 +1,4 @@ -AC_INIT(fuse, 2.7.0-pre1) +AC_INIT(fuse, 2.7.0-rc1) AC_CANONICAL_TARGET AM_INIT_AUTOMAKE AM_CONFIG_HEADER(include/config.h) diff --git a/kernel/configure.ac b/kernel/configure.ac index 115c428..0427afd 100644 --- a/kernel/configure.ac +++ b/kernel/configure.ac @@ -1,4 +1,4 @@ -AC_INIT(fuse-kernel, 2.7.0-pre1) +AC_INIT(fuse-kernel, 2.7.0-rc1) AC_CONFIG_HEADERS([config.h]) AC_PROG_INSTALL diff --git a/kernel/control.c b/kernel/control.c index 6b86fc0..5ffe6ba 100644 --- a/kernel/control.c +++ b/kernel/control.c @@ -77,7 +77,7 @@ struct dentry *d_alloc_name(struct dentry *parent, const char *name) { struct qstr q; - q.name = name; + q.name = (const unsigned char *) name; q.len = strlen(name); q.hash = full_name_hash(q.name, q.len); return d_alloc(parent, &q); @@ -87,7 +87,11 @@ static struct dentry *fuse_ctl_add_dentry(struct dentry *parent, struct fuse_conn *fc, const char *name, int mode, int nlink, +#ifdef KERNEL_2_6_21_PLUS + const struct inode_operations *iop, +#else struct inode_operations *iop, +#endif #ifdef KERNEL_2_6_17_PLUS const struct file_operations *fop #else diff --git a/kernel/dev.c b/kernel/dev.c index 773b923..aaef082 100644 --- a/kernel/dev.c +++ b/kernel/dev.c @@ -21,7 +21,7 @@ MODULE_ALIAS_MISCDEV(FUSE_MINOR); #endif -static kmem_cache_t *fuse_req_cachep; +static struct kmem_cache *fuse_req_cachep; static struct fuse_conn *fuse_get_conn(struct file *file) { diff --git a/kernel/dir.c b/kernel/dir.c index 32e6003..121a350 100644 --- a/kernel/dir.c +++ b/kernel/dir.c @@ -195,7 +195,7 @@ static struct dentry_operations fuse_dentry_operations = { .d_revalidate = fuse_dentry_revalidate, }; -static int valid_mode(int m) +int fuse_valid_type(int m) { return S_ISREG(m) || S_ISDIR(m) || S_ISLNK(m) || S_ISCHR(m) || S_ISBLK(m) || S_ISFIFO(m) || S_ISSOCK(m); @@ -250,7 +250,8 @@ static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry, fuse_put_request(fc, req); /* Zero nodeid is same as -ENOENT, but with valid timeout */ if (!err && outarg.nodeid && - (invalid_nodeid(outarg.nodeid) || !valid_mode(outarg.attr.mode))) + (invalid_nodeid(outarg.nodeid) || + !fuse_valid_type(outarg.attr.mode))) err = -EIO; if (!err && outarg.nodeid) { inode = fuse_iget(dir->i_sb, outarg.nodeid, outarg.generation, diff --git a/kernel/file.c b/kernel/file.c index e7b52c5..fc03b1e 100644 --- a/kernel/file.c +++ b/kernel/file.c @@ -75,7 +75,11 @@ 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_21_PLUS + invalidate_mapping_pages(inode->i_mapping, 0, -1); +#else invalidate_inode_pages(inode->i_mapping); +#endif ff->fh = outarg->fh; file->private_data = ff; } diff --git a/kernel/fuse_i.h b/kernel/fuse_i.h index 6d084e2..b9a9ac3 100644 --- a/kernel/fuse_i.h +++ b/kernel/fuse_i.h @@ -41,10 +41,16 @@ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19) # define KERNEL_2_6_19_PLUS #endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21) +# define KERNEL_2_6_21_PLUS +#endif #if defined(__arm__) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) #define DCACHE_BUG #endif +#ifndef KERNEL_2_6_15_PLUS +#define kmem_cache kmem_cache_s +#endif #include "config.h" #endif /* FUSE_MAINLINE */ @@ -617,3 +623,8 @@ int fuse_ctl_add_conn(struct fuse_conn *fc); * Remove connection from control filesystem */ void fuse_ctl_remove_conn(struct fuse_conn *fc); + +/** + * Is file type valid? + */ +int fuse_valid_type(int m); diff --git a/kernel/inode.c b/kernel/inode.c index 9cdf5b1..e529427 100644 --- a/kernel/inode.c +++ b/kernel/inode.c @@ -24,7 +24,7 @@ MODULE_DESCRIPTION("Filesystem in Userspace"); MODULE_LICENSE("GPL"); #endif -static kmem_cache_t *fuse_inode_cachep; +static struct kmem_cache *fuse_inode_cachep; struct list_head fuse_conn_list; DEFINE_MUTEX(fuse_mutex); @@ -124,7 +124,11 @@ void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr) { struct fuse_conn *fc = get_fuse_conn(inode); if (S_ISREG(inode->i_mode) && i_size_read(inode) != attr->size) +#ifdef KERNEL_2_6_21_PLUS + invalidate_mapping_pages(inode->i_mapping, 0, -1); +#else invalidate_inode_pages(inode->i_mapping); +#endif inode->i_ino = attr->ino; inode->i_mode = (inode->i_mode & S_IFMT) + (attr->mode & 07777); @@ -360,6 +364,8 @@ static int parse_fuse_opt(char *opt, struct fuse_mount_data *d, int is_bdev) case OPT_ROOTMODE: if (match_octal(&args[0], &value)) return 0; + if (!fuse_valid_type(value)) + return 0; d->rootmode = value; d->rootmode_present = 1; break; @@ -805,7 +811,7 @@ static decl_subsys(fs, NULL, NULL); static decl_subsys(fuse, NULL, NULL); static decl_subsys(connections, NULL, NULL); -static void fuse_inode_init_once(void *foo, kmem_cache_t *cachep, +static void fuse_inode_init_once(void *foo, struct kmem_cache *cachep, unsigned long flags) { struct inode * inode = foo;