fix
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 <miklos@szeredi.hu>
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 <linux/poll.h>
#ifdef KERNEL_2_6
#include <linux/kobject.h>
-#include <linux/miscdevice.h>
#else
#include <linux/proc_fs.h>
#endif
+#include <linux/miscdevice.h>
#include <linux/file.h>
static kmem_cache_t *fuse_req_cachep;
@@ -559,7 +559,6 @@
};
#ifdef KERNEL_2_6
-
#ifndef FUSE_MAINLINE
static decl_subsys(fs, NULL, NULL);
#endif
@@ -572,22 +571,15 @@
}
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 @@
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 @@
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 @@
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 @@
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 @@
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 <sys/param.h>
#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 @@
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 @@
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 @@
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 @@
}
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)