Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/miscfs/specfs if_config processing wants to auto-load mo...



details:   https://anonhg.NetBSD.org/src/rev/55202a897954
branches:  trunk
changeset: 347632:55202a897954
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Thu Sep 08 00:07:48 2016 +0000

description:
if_config processing wants to auto-load modules named with an if_ prefix,
while specfc wants to auto-load modules without the prefix.  For modules
which can be loaded both ways (ie, if_tap and if_tun), provide a simple
conversion table for specfs so it can auto-load the if_ module.

This table should always be quite small, and the auto-load operation is
relatively infrequent, so the additional overhead of comparing names should
be tolerable.

diffstat:

 sys/miscfs/specfs/spec_vnops.c |  35 +++++++++++++++++++++++++++++++++--
 1 files changed, 33 insertions(+), 2 deletions(-)

diffs (77 lines):

diff -r 0e9d725cd19e -r 55202a897954 sys/miscfs/specfs/spec_vnops.c
--- a/sys/miscfs/specfs/spec_vnops.c    Wed Sep 07 15:41:44 2016 +0000
+++ b/sys/miscfs/specfs/spec_vnops.c    Thu Sep 08 00:07:48 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: spec_vnops.c,v 1.163 2016/08/20 12:37:09 hannken Exp $ */
+/*     $NetBSD: spec_vnops.c,v 1.164 2016/09/08 00:07:48 pgoyette Exp $        */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.163 2016/08/20 12:37:09 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.164 2016/09/08 00:07:48 pgoyette Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -482,6 +482,16 @@
 
 typedef int (*spec_ioctl_t)(dev_t, u_long, void *, int, struct lwp *);
 
+struct dev_to_mod {
+       const char *dev_name, *mod_name;
+};
+
+struct dev_to_mod dev_mod_table[] = {
+       { "tap", "if_tap" },
+       { "tun", "if_tun" },
+       { NULL, NULL }
+};
+       
 /*
  * Open a special file.
  */
@@ -505,6 +515,7 @@
        u_int gen;
        const char *name;
        struct partinfo pi;
+       struct dev_to_mod *conv;
        
        l = curlwp;
        vp = ap->a_vp;
@@ -571,6 +582,16 @@
                        /* Get device name from devsw_conv array */
                        if ((name = cdevsw_getname(major(dev))) == NULL)
                                break;
+
+                       /* Check exception table for alternate module name */
+                       conv = dev_mod_table;
+                       while (conv->dev_name != NULL) {
+                               if (strcmp(conv->dev_name, name) == 0) {
+                                       name = conv->mod_name;
+                                       break;
+                               }
+                               conv++;
+                       }
                        
                        /* Try to autoload device module */
                        (void) module_autoload(name, MODULE_CLASS_DRIVER);
@@ -623,6 +644,16 @@
 
                        VOP_UNLOCK(vp);
 
+                       /* Check exception table for alternate module name */
+                       conv = dev_mod_table;
+                       while (conv->dev_name != NULL) {
+                               if (strcmp(conv->dev_name, name) == 0) {
+                                       name = conv->mod_name;
+                                       break;
+                               }
+                               conv++;
+                       }
+
                         /* Try to autoload device module */
                        (void) module_autoload(name, MODULE_CLASS_DRIVER);
                        



Home | Main Index | Thread Index | Old Index