Source-Changes-HG archive

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

[src/pgoyette-compat]: src/tests/modules Update the check for module existenc...



details:   https://anonhg.NetBSD.org/src/rev/1f846c45a0b1
branches:  pgoyette-compat
changeset: 830612:1f846c45a0b1
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Wed Sep 05 08:58:03 2018 +0000

description:
Update the check for module existence via modctl(3) to use the new
format of returned data.

diffstat:

 tests/modules/t_modctl.c |  16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diffs (53 lines):

diff -r 9887dead31f7 -r 1f846c45a0b1 tests/modules/t_modctl.c
--- a/tests/modules/t_modctl.c  Tue Sep 04 11:53:46 2018 +0000
+++ b/tests/modules/t_modctl.c  Wed Sep 05 08:58:03 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_modctl.c,v 1.12 2012/08/20 08:07:52 martin Exp $     */
+/*     $NetBSD: t_modctl.c,v 1.12.30.1 2018/09/05 08:58:03 pgoyette Exp $      */
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: t_modctl.c,v 1.12 2012/08/20 08:07:52 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: t_modctl.c,v 1.12.30.1 2018/09/05 08:58:03 pgoyette Exp $");
 
 #include <sys/module.h>
 #include <sys/sysctl.h>
@@ -84,11 +84,12 @@
 {
        bool found;
        size_t len;
+       int count;
        struct iovec iov;
        modstat_t *ms;
 
        check_permission();
-       for (len = 4096; ;) {
+       for (len = 8192; ;) {
                iov.iov_base = malloc(len);
                iov.iov_len = len;
 
@@ -107,14 +108,17 @@
        }
 
        found = false;
-       len = iov.iov_len / sizeof(modstat_t);
-       for (ms = (modstat_t *)iov.iov_base; len != 0 && !found;
-           ms++, len--) {
+       count = *(int *)iov.iov_base;
+       ms = (modstat_t *)((char *)iov.iov_base + sizeof(int));
+       while ( count ) {
                if (strcmp(ms->ms_name, name) == 0) {
                        if (msdest != NULL)
                                *msdest = *ms;
                        found = true;
+                       break;
                }
+               ms++;
+               count--;
        }
 
        free(iov.iov_base);



Home | Main Index | Thread Index | Old Index