Source-Changes-HG archive

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

[src/trunk]: src Update to use newstyle rump_module interfaces.



details:   https://anonhg.NetBSD.org/src/rev/cb93020ed8ee
branches:  trunk
changeset: 752751:cb93020ed8ee
user:      pooka <pooka%NetBSD.org@localhost>
date:      Fri Mar 05 18:49:30 2010 +0000

description:
Update to use newstyle rump_module interfaces.

diffstat:

 lib/libukfs/ukfs.c             |  12 +++++++-----
 tests/rump/rumpkern/t_modcmd.c |  31 +++++++++++++++++++++++--------
 2 files changed, 30 insertions(+), 13 deletions(-)

diffs (93 lines):

diff -r 0ae8ae8724fc -r cb93020ed8ee lib/libukfs/ukfs.c
--- a/lib/libukfs/ukfs.c        Fri Mar 05 18:47:49 2010 +0000
+++ b/lib/libukfs/ukfs.c        Fri Mar 05 18:49:30 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ukfs.c,v 1.47 2009/12/13 20:52:36 pooka Exp $  */
+/*     $NetBSD: ukfs.c,v 1.48 2010/03/05 18:49:30 pooka Exp $  */
 
 /*
  * Copyright (c) 2007, 2008, 2009  Antti Kantee.  All Rights Reserved.
@@ -1097,7 +1097,7 @@
 ukfs_modload(const char *fname)
 {
        void *handle;
-       struct modinfo **mi;
+       const struct modinfo *const *mi_start, *const *mi_end;
        int error;
 
        handle = dlopen(fname, RTLD_LAZY|RTLD_GLOBAL);
@@ -1110,9 +1110,11 @@
                return -1;
        }
 
-       mi = dlsym(handle, "__start_link_set_modules");
-       if (mi) {
-               error = rump_pub_module_init(*mi, NULL);
+       mi_start = dlsym(handle, "__start_link_set_modules");
+       mi_end = dlsym(handle, "__stop_link_set_modules");
+       if (mi_start && mi_end) {
+               error = rump_pub_module_init(mi_start,
+                   (size_t)(mi_end-mi_start));
                if (error)
                        goto errclose;
                return 1;
diff -r 0ae8ae8724fc -r cb93020ed8ee tests/rump/rumpkern/t_modcmd.c
--- a/tests/rump/rumpkern/t_modcmd.c    Fri Mar 05 18:47:49 2010 +0000
+++ b/tests/rump/rumpkern/t_modcmd.c    Fri Mar 05 18:49:30 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_modcmd.c,v 1.4 2009/11/06 15:26:54 pooka Exp $       */
+/*     $NetBSD: t_modcmd.c,v 1.5 2010/03/05 18:49:30 pooka Exp $       */
 
 /*
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -63,9 +63,9 @@
 ATF_TC_BODY(cmsg_modcmd, tc)
 {
        struct tmpfs_args args;
-       struct modinfo **mi;
+       const struct modinfo *const *mi_start, *const *mi_end;
        void *handle;
-       int rv;
+       int i, rv, loop = 0;
 
        rump_init();
        memset(&args, 0, sizeof(args));
@@ -82,18 +82,33 @@
                const char *dlmsg = dlerror();
                atf_tc_fail("cannot open %s: %s", TMPFSMODULE, dlmsg);
        }
-       mi = dlsym(handle, "__start_link_set_modules");
-       if (mi == NULL)
+
+ again:
+       mi_start = dlsym(handle, "__start_link_set_modules");
+       mi_end = dlsym(handle, "__stop_link_set_modules");
+       if (mi_start == NULL || mi_end == NULL)
                atf_tc_fail("cannot find module info");
-       if ((rv = rump_pub_module_init(*mi, NULL)) != 0)
+       if ((rv = rump_pub_module_init(mi_start, (size_t)(mi_end-mi_start)))!=0)
                atf_tc_fail("module init failed: %d (%s)", rv, strerror(rv));
+       if ((rv = rump_pub_module_init(mi_start, (size_t)(mi_end-mi_start)))==0)
+               atf_tc_fail("module double init succeeded");
 
        if (rump_sys_mount(MOUNT_TMPFS, "/mp", 0, &args, sizeof(args)) == -1)
                atf_tc_fail_errno("still cannot mount");
        if (rump_sys_unmount("/mp", 0) == -1)
                atf_tc_fail("cannot unmount");
-       if ((rv = rump_pub_module_fini(*mi)) != 0)
-               atf_tc_fail("module fini failed: %d (%s)", rv, strerror(rv));
+       for (i = 0; i < (int)(mi_end-mi_start); i++) {
+               if ((rv = rump_pub_module_fini(mi_start[i])) != 0)
+                       atf_tc_fail("module fini failed: %d (%s)",
+                           rv, strerror(rv));
+       }
+       for (i = 0; i < (int)(mi_end-mi_start); i++) {
+               if ((rv = rump_pub_module_fini(mi_start[i])) == 0)
+                       atf_tc_fail("module double fini succeeded");
+       }
+       if (loop++ == 0)
+               goto again;
+
        if (dlclose(handle)) {
                const char *dlmsg = dlerror();
                atf_tc_fail("cannot close %s: %s", TMPFSMODULE, dlmsg);



Home | Main Index | Thread Index | Old Index