Source-Changes-HG archive

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

[src/trunk]: src/sys/fs/autofs fix module attachment and cdevsw



details:   https://anonhg.NetBSD.org/src/rev/5c9d64ad142a
branches:  trunk
changeset: 828908:5c9d64ad142a
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Jan 09 16:19:39 2018 +0000

description:
fix module attachment and cdevsw

diffstat:

 sys/fs/autofs/autofs.c        |  41 ++++++++++++++++++++++++++++-------------
 sys/fs/autofs/autofs_vfsops.c |  33 +++++++++++++--------------------
 2 files changed, 41 insertions(+), 33 deletions(-)

diffs (184 lines):

diff -r 319cb99753c5 -r 5c9d64ad142a sys/fs/autofs/autofs.c
--- a/sys/fs/autofs/autofs.c    Tue Jan 09 16:18:35 2018 +0000
+++ b/sys/fs/autofs/autofs.c    Tue Jan 09 16:19:39 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: autofs.c,v 1.2 2018/01/09 13:56:00 martin Exp $        */
+/*     $NetBSD: autofs.c,v 1.3 2018/01/09 16:19:39 christos Exp $      */
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -68,23 +68,33 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autofs.c,v 1.2 2018/01/09 13:56:00 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autofs.c,v 1.3 2018/01/09 16:19:39 christos Exp $");
 
 #include "autofs.h"
 
+#include "ioconf.h"
+
 #include <sys/atomic.h>
 #include <sys/queue.h>
 #include <sys/signalvar.h>
 
-static int     autofs_open(dev_t dev, int flags, int mode, struct lwp *l);
-static int     autofs_close(dev_t dev, int flags, int mode, struct lwp *l);
-static int     autofs_ioctl(dev_t dev, const u_long cmd, void *data, int flag,
-    struct lwp *l);
+dev_type_open(autofs_open);
+dev_type_close(autofs_close);
+dev_type_ioctl(autofs_ioctl);
 
-struct cdevsw autofs_ops = {
-       .d_open         = autofs_open,
-       .d_close        = autofs_close,
-       .d_ioctl        = autofs_ioctl,
+const struct cdevsw autofs_cdevsw = {
+       .d_open = autofs_open,
+       .d_close = autofs_close,
+       .d_read = noread,
+       .d_write = nowrite,
+       .d_ioctl = autofs_ioctl,
+       .d_stop = nostop,
+       .d_tty = notty,
+       .d_poll = nopoll,
+       .d_mmap = nommap,
+       .d_kqfilter = nokqfilter,
+       .d_discard = nodiscard,
+       .d_flag = D_OTHER,
 };
 
 /*
@@ -111,6 +121,11 @@
 int autofs_retry_delay = 1;
 int autofs_interruptible = 1;
 
+void
+autofsattach(int n)
+{
+}
+
 static int
 autofs_node_cmp(const struct autofs_node *a, const struct autofs_node *b)
 {
@@ -504,7 +519,7 @@
        return 0;
 }
 
-static int
+int
 autofs_open(dev_t dev, int flags, int mode, struct lwp *l)
 {
 
@@ -528,7 +543,7 @@
        return 0;
 }
 
-static int
+int
 autofs_close(dev_t dev, int flags, int mode, struct lwp *l)
 {
 
@@ -540,7 +555,7 @@
        return 0;
 }
 
-static int
+int
 autofs_ioctl(dev_t dev, const u_long cmd, void *data, int flag, struct lwp *l)
 {
 
diff -r 319cb99753c5 -r 5c9d64ad142a sys/fs/autofs/autofs_vfsops.c
--- a/sys/fs/autofs/autofs_vfsops.c     Tue Jan 09 16:18:35 2018 +0000
+++ b/sys/fs/autofs/autofs_vfsops.c     Tue Jan 09 16:19:39 2018 +0000
@@ -33,7 +33,7 @@
  *
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autofs_vfsops.c,v 1.1 2018/01/09 03:31:14 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autofs_vfsops.c,v 1.2 2018/01/09 16:19:39 christos Exp $");
 
 
 #include "autofs.h"
@@ -46,6 +46,7 @@
 MODULE(MODULE_CLASS_VFS, autofs, NULL);
 
 static int     autofs_statvfs(struct mount *, struct statvfs *);
+static int     autofs_sysctl_create(void);
 
 static void
 autofs_init(void)
@@ -64,6 +65,10 @@
        cv_init(&autofs_softc->sc_cv, "autofscv");
        mutex_init(&autofs_softc->sc_lock, MUTEX_DEFAULT, IPL_NONE);
        autofs_softc->sc_dev_opened = false;
+
+       autofs_sysctl_create();
+       workqueue_create(&autofs_tmo_wq, "autofstmo",
+           autofs_timeout_wq, NULL, 0, 0, WQ_MPSAFE);
 }
 
 static void
@@ -72,6 +77,8 @@
        KASSERT(autofs_softc);
        KASSERT(!autofs_softc->sc_dev_opened);
 
+       workqueue_destroy(autofs_tmo_wq);
+
        struct autofs_softc *sc = autofs_softc;
        autofs_softc = NULL;
 
@@ -437,6 +444,8 @@
        return error;
 }
 
+extern const struct cdevsw autofs_cdevsw;
+
 static int
 autofs_modcmd(modcmd_t cmd, void *arg)
 {
@@ -451,30 +460,16 @@
                if (error)
                        break;
 #ifdef _MODULE
-               error = devsw_attach("autofs", NULL, &bmajor, &autofs_ops,
+               error = devsw_attach("autofs", NULL, &bmajor, &autofs_cdevsw,
                    &cmajor);
                if (error) {
                        vfs_detach(&autofs_vfsops);
                        break;
                }
 #endif
-               error = workqueue_create(&autofs_tmo_wq, "autofstmo",
-                   autofs_timeout_wq, NULL, 0, 0, WQ_MPSAFE);
-               if (error) {
-                       devsw_detach(NULL, &autofs_ops);
-                       vfs_detach(&autofs_vfsops);
-                       break;
-               }
-
-               error = autofs_sysctl_create();
-               if (error) {
-                       workqueue_destroy(autofs_tmo_wq);
-                       devsw_detach(NULL, &autofs_ops);
-                       vfs_detach(&autofs_vfsops);
-                       break;
-               }
                break;
        case MODULE_CMD_FINI:
+#ifdef _MODULE
                KASSERT(autofs_softc);
                mutex_enter(&autofs_softc->sc_lock);
                if (autofs_softc->sc_dev_opened) {
@@ -484,9 +479,7 @@
                }
                mutex_exit(&autofs_softc->sc_lock);
 
-               workqueue_destroy(autofs_tmo_wq);
-#ifdef _MODULE
-               error = devsw_detach(NULL, &autofs_ops);
+               error = devsw_detach(NULL, &autofs_cdevsw);
                if (error)
                        break;
 #endif



Home | Main Index | Thread Index | Old Index