Source-Changes-HG archive

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

[src/trunk]: src/sys/netsmb Try to unbreak module a little. It would be real...



details:   https://anonhg.NetBSD.org/src/rev/4baec0505fa2
branches:  trunk
changeset: 759826:4baec0505fa2
user:      pooka <pooka%NetBSD.org@localhost>
date:      Fri Dec 17 13:24:45 2010 +0000

description:
Try to unbreak module a little.  It would be really nice to not
utterly break things in the name of modularization, especially if
avoiding breakage takes 2min.

diffstat:

 sys/netsmb/smb_dev.c |  37 +++++++++++++++++++++++++++----------
 1 files changed, 27 insertions(+), 10 deletions(-)

diffs (87 lines):

diff -r 49af4cc25836 -r 4baec0505fa2 sys/netsmb/smb_dev.c
--- a/sys/netsmb/smb_dev.c      Fri Dec 17 13:05:29 2010 +0000
+++ b/sys/netsmb/smb_dev.c      Fri Dec 17 13:24:45 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: smb_dev.c,v 1.37 2010/12/17 13:05:29 pooka Exp $       */
+/*     $NetBSD: smb_dev.c,v 1.38 2010/12/17 13:24:45 pooka Exp $       */
 
 /*
  * Copyright (c) 2000-2001 Boris Popov
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: smb_dev.c,v 1.37 2010/12/17 13:05:29 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: smb_dev.c,v 1.38 2010/12/17 13:24:45 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -90,11 +90,16 @@
 
 
 void nsmbattach(int);
+static bool nsmb_inited = false;
 
 void
 nsmbattach(int num)
 {
 
+       if (nsmb_inited)
+               return;
+       nsmb_inited = true;
+
        if (num <= 0) {
 #ifdef DIAGNOSTIC
                panic("nsmbattach: count <= 0");
@@ -124,6 +129,17 @@
        smb_rqpool_init();
 }
 
+static void
+nsmbdetach(void)
+{
+
+       smb_iod_done();
+       smb_sm_done();
+       smb_rqpool_fini();
+       free(smb_devtbl, M_NSMBDEV);
+       nsmb_inited = false;
+}
+
 int
 nsmb_dev_open(dev_t dev, int oflags, int devtype,
     struct lwp *l)
@@ -358,24 +374,25 @@
                nsmbattach(1);
                error =
                    devsw_attach("nsmb", NULL, &bmajor, &nsmb_cdevsw, &cmajor);
-               if (error)
-                       return error;
+               if (error == EEXIST) /* builtin */
+                       error = 0;
+               if (error) {
+                       nsmbdetach();
+               }
 
                break;
            case MODULE_CMD_FINI:
-               smb_iod_done();
-               smb_sm_done();
-               smb_rqpool_fini();
                error = devsw_detach(NULL, &nsmb_cdevsw);
-               free(smb_devtbl, M_NSMBDEV);
+               if (error)
+                       break;
+               nsmbdetach();
                break;
            default:
                error = ENOTTY;
                break;
        }
+
        return error;
-       return 0;
-
 }
 #endif /* _MODULE */
 



Home | Main Index | Thread Index | Old Index