Linux nnpfs devfs patch

Love lha at stacken.kth.se
Mon Mar 10 01:09:49 CET 2003


Per Olofsson <pelle at dsv.su.se> writes:

> Under Linux, if nnpfs is compiled with devfs support, it doesn't
> register a legacy chrdev. This is a problem, because currently many
> people don't use devfs even though the kernel was compiled with
> support for it. AFAIK, almost all other kernel modules register both
> types. I have attached a patch that fixes this.

You I think you missed the unload case. Anyway, this is what I commited,
works ok ?

Love

2003-03-10  Love  <lha at stacken.kth.se>

	* nnpfs/linux/nnpfs_load.c (init_module): do devfs_register_chrdev
	also when using a chardev, pointed out by Per Olofsson.


Index: nnpfs_load.c
===================================================================
RCS file: /afs/stacken.kth.se/src/SourceRepository/arla/nnpfs/linux/nnpfs_load.c,v
retrieving revision 1.28
diff -u -u -w -r1.28 nnpfs_load.c
--- nnpfs_load.c	7 Sep 2002 10:47:01 -0000	1.28
+++ nnpfs_load.c	10 Mar 2003 00:03:12 -0000
@@ -93,6 +93,9 @@
 	    &nnpfs_fops, 
 	    NULL);
 #else
+    if (devfs_register_chrdev(NNPFS_MAJOR,"nnpfs",&nnpfs_fops))
+	status = -EIO;
+    else
     nnpfs_devfs_handle = 
 	devfs_register(NULL,		/* devfs_handle_t dir */
 		       "nnpfs0",		/* const char *name */ 
@@ -103,13 +106,15 @@
 		       &nnpfs_fops,	/* void *ops */
 		       NULL);		/* void *info */
 #endif
-    if (nnpfs_devfs_handle == NULL) {
 #else
-    if (register_chrdev(NNPFS_MAJOR,"nnpfs",&nnpfs_fops)) {
+    if (register_chrdev(NNPFS_MAJOR,"nnpfs",&nnpfs_fops))
+	status = -EIO;
 #endif
+
+    if (status) {
 	NNPFSDEB(XDEBVFOPS, ("nnpfs: unable to get major %d\n", NNPFS_MAJOR));
 	unregister_filesystem(&nnpfs_fs_type);
-	return -EIO;
+	return status;
     }
     nnpfs_init_device();
     NNPFSDEB(XDEBVFOPS, ("init_module exit\n"));
@@ -121,6 +126,7 @@
     unregister_filesystem(&nnpfs_fs_type);
 #ifdef DEVFS_SUPPORT
     devfs_unregister(nnpfs_devfs_handle);
+    devfs_unregister_chrdev(NNPFS_MAJOR,"nnpfs");
 #else
     unregister_chrdev(NNPFS_MAJOR,"nnpfs");
 #endif





More information about the Arla-drinkers mailing list