From 162bcbbff3d531c7d1a630da706a2d0be80f8995 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Mon, 29 Nov 2004 23:43:44 +0000 Subject: [PATCH] fix --- ChangeLog | 2 ++ kernel/dev.c | 78 ++++++++++++++++----------------------------- kernel/linux/fuse.h | 6 ---- lib/fuse.c | 3 +- util/fusermount.c | 10 +++--- 5 files changed, 38 insertions(+), 61 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8265a6d..0173f98 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,8 @@ since no allocation is done. * fusermount: fix warning if fuse module is not loaded + + * kernel: use /dev/fuse on 2.4 too 2004-11-26 Miklos Szeredi diff --git a/kernel/dev.c b/kernel/dev.c index da41e59..0eebd31 100644 --- a/kernel/dev.c +++ b/kernel/dev.c @@ -13,10 +13,10 @@ #include #ifdef KERNEL_2_6 #include -#include #else #include #endif +#include #include static kmem_cache_t *fuse_req_cachep; @@ -559,7 +559,6 @@ struct file_operations fuse_dev_operations = { }; #ifdef KERNEL_2_6 - #ifndef FUSE_MAINLINE static decl_subsys(fs, NULL, NULL); #endif @@ -572,22 +571,15 @@ static ssize_t version_show(struct subsystem *subsys, char *buf) } static struct subsys_attribute fuse_attr_version = __ATTR_RO(version); -static struct miscdevice fuse_miscdevice = { - .minor = FUSE_MINOR, - .name = "fuse", - .fops = &fuse_dev_operations, -}; - -static int __init fuse_sysfs_init(void) +static int __init fuse_version_init(void) { int err; -#ifdef FUSE_MAINLINE - err = fs_subsys_register(&fuse_subsys); -#else + +#ifndef FUSE_MAINLINE subsystem_register(&fs_subsys); +#endif kset_set_kset_s(&fuse_subsys, fs_subsys); err = subsystem_register(&fuse_subsys); -#endif if (err) return err; err = subsys_create_file(&fuse_subsys, &fuse_attr_version); @@ -601,7 +593,7 @@ static int __init fuse_sysfs_init(void) return 0; } -static void fuse_sysfs_clean(void) +static void fuse_version_clean(void) { subsys_remove_file(&fuse_subsys, &fuse_attr_version); subsystem_unregister(&fuse_subsys); @@ -609,26 +601,6 @@ static void fuse_sysfs_clean(void) subsystem_unregister(&fs_subsys); #endif } - -static int __init fuse_device_init(void) -{ - int err = fuse_sysfs_init(); - if (err) - return err; - - err = misc_register(&fuse_miscdevice); - if (err) { - fuse_sysfs_clean(); - return err; - } - return 0; -} - -static void fuse_device_clean(void) -{ - misc_deregister(&fuse_miscdevice); - fuse_sysfs_clean(); -} #else static struct proc_dir_entry *proc_fs_fuse; @@ -641,19 +613,12 @@ static int read_version(char *page, char **start, off_t off, int count, return s - page; } -static int fuse_device_init(void) +static int fuse_version_init(void) { proc_fs_fuse = proc_mkdir("fuse", proc_root_fs); if (proc_fs_fuse) { struct proc_dir_entry *de; - proc_fs_fuse->owner = THIS_MODULE; - de = create_proc_entry("dev", S_IFSOCK | 0666, - proc_fs_fuse); - if (de) { - de->owner = THIS_MODULE; - de->proc_fops = &fuse_dev_operations; - } de = create_proc_entry("version", S_IFREG | 0444, proc_fs_fuse); if (de) { de->owner = THIS_MODULE; @@ -663,20 +628,25 @@ static int fuse_device_init(void) return 0; } -static void fuse_device_clean(void) +static void fuse_version_clean(void) { if (proc_fs_fuse) { - remove_proc_entry("dev", proc_fs_fuse); remove_proc_entry("version", proc_fs_fuse); remove_proc_entry("fuse", proc_root_fs); } } #endif +static struct miscdevice fuse_miscdevice = { + .minor = FUSE_MINOR, + .name = "fuse", + .fops = &fuse_dev_operations, +}; + int __init fuse_dev_init(void) { int err; - err = fuse_device_init(); + err = fuse_version_init(); if (err) goto out; @@ -685,18 +655,26 @@ int __init fuse_dev_init(void) sizeof(struct fuse_req), 0, 0, NULL, NULL); if (!fuse_req_cachep) - goto out_device_clean; + goto out_version_clean; + + err = misc_register(&fuse_miscdevice); + if (err) + goto out_cache_clean; + return 0; - - out_device_clean: - fuse_device_clean(); + + out_cache_clean: + kmem_cache_destroy(fuse_req_cachep); + out_version_clean: + fuse_version_clean(); out: return err; } void fuse_dev_cleanup(void) { - fuse_device_clean(); + misc_deregister(&fuse_miscdevice); kmem_cache_destroy(fuse_req_cachep); + fuse_version_clean(); } diff --git a/kernel/linux/fuse.h b/kernel/linux/fuse.h index ea640e9..63973a7 100644 --- a/kernel/linux/fuse.h +++ b/kernel/linux/fuse.h @@ -23,12 +23,6 @@ /** The minor number of the fuse character device */ #define FUSE_MINOR 229 -/** Opening this will yield a new control file */ -#define FUSE_DEV "/dev/fuse" - -/** The file containing the version in the form MAJOR.MINOR */ -#define FUSE_VERSION_FILE "/sys/fs/fuse/version" - struct fuse_attr { unsigned long ino; unsigned int mode; diff --git a/lib/fuse.c b/lib/fuse.c index 66474fb..eb10cdf 100644 --- a/lib/fuse.c +++ b/lib/fuse.c @@ -18,6 +18,7 @@ #include #define FUSE_VERSION_FILE_OLD "/proc/fs/fuse/version" +#define FUSE_VERSION_FILE_NEW "/sys/fs/fuse/version" #define FUSE_DEV_OLD "/proc/fs/fuse/dev" #define FUSE_MAX_PATH 4096 @@ -1744,7 +1745,7 @@ void __fuse_set_getcontext_func(struct fuse_context *(*func)(void)) static int check_version(struct fuse *f) { int res; - const char *version_file = FUSE_VERSION_FILE; + const char *version_file = FUSE_VERSION_FILE_NEW; FILE *vf = fopen(version_file, "r"); if (vf == NULL) { version_file = FUSE_VERSION_FILE_OLD; diff --git a/util/fusermount.c b/util/fusermount.c index e3d5b29..d8490db 100644 --- a/util/fusermount.c +++ b/util/fusermount.c @@ -38,8 +38,10 @@ #define FUSE_COMMFD_ENV "_FUSE_COMMFD" #define FUSE_DEV_OLD "/proc/fs/fuse/dev" +#define FUSE_DEV_NEW "/dev/fuse" #define FUSE_SYS_DEV "/sys/class/misc/fuse/dev" #define FUSE_VERSION_FILE_OLD "/proc/fs/fuse/version" +#define FUSE_VERSION_FILE_NEW "/sys/fs/fuse/version" const char *progname; @@ -521,7 +523,7 @@ static int check_version(const char *dev) if (isold) version_file = FUSE_VERSION_FILE_OLD; else - version_file = FUSE_VERSION_FILE; + version_file = FUSE_VERSION_FILE_NEW; vf = fopen(version_file, "r"); if (vf == NULL) { @@ -664,13 +666,13 @@ static int try_open_new(char **devp, int final) if (fd == -1) { if (!final) return -2; - fd = try_open(FUSE_DEV, devp, 1); + fd = try_open(FUSE_DEV_NEW, devp, 1); if (fd == -2) return -2; fd = try_open_new_temp(FUSE_MAJOR << 8 | FUSE_MINOR, devp, 1); if (fd == -2) return -2; - return try_open(FUSE_DEV, devp, 0); + return try_open(FUSE_DEV_NEW, devp, 0); } res = read(fd, buf, sizeof(buf)-1); @@ -689,7 +691,7 @@ static int try_open_new(char **devp, int final) } devnum = (major << 8) + (minor & 0xff) + ((minor & 0xff00) << 12); - dev = FUSE_DEV; + dev = FUSE_DEV_NEW; res = stat(dev, &stbuf); if (res == -1) { if (major == FUSE_MAJOR && minor == FUSE_MINOR) -- 2.30.2