Avoid known unknown if the kernel presents us with an unknown
unknown for module class and/or source. related to PR kern/43014
This commit is contained in:
parent
8058413106
commit
23d5534a55
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: main.c,v 1.9 2010/03/05 10:27:16 pooka Exp $ */
|
/* $NetBSD: main.c,v 1.10 2010/03/19 16:25:33 pooka Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||||
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
__RCSID("$NetBSD: main.c,v 1.9 2010/03/05 10:27:16 pooka Exp $");
|
__RCSID("$NetBSD: main.c,v 1.10 2010/03/19 16:25:33 pooka Exp $");
|
||||||
#endif /* !lint */
|
#endif /* !lint */
|
||||||
|
|
||||||
#include <sys/module.h>
|
#include <sys/module.h>
|
||||||
@ -51,12 +51,14 @@ static const char *classes[] = {
|
|||||||
"exec",
|
"exec",
|
||||||
"secmodel",
|
"secmodel",
|
||||||
};
|
};
|
||||||
|
const unsigned int class_max = __arraycount(classes);
|
||||||
|
|
||||||
static const char *sources[] = {
|
static const char *sources[] = {
|
||||||
"builtin",
|
"builtin",
|
||||||
"boot",
|
"boot",
|
||||||
"filesys",
|
"filesys",
|
||||||
};
|
};
|
||||||
|
const unsigned int source_max = __arraycount(sources);
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
@ -104,6 +106,9 @@ main(int argc, char **argv)
|
|||||||
len = iov.iov_len / sizeof(modstat_t);
|
len = iov.iov_len / sizeof(modstat_t);
|
||||||
qsort(iov.iov_base, len, sizeof(modstat_t), modstatcmp);
|
qsort(iov.iov_base, len, sizeof(modstat_t), modstatcmp);
|
||||||
for (ms = iov.iov_base; len != 0; ms++, len--) {
|
for (ms = iov.iov_base; len != 0; ms++, len--) {
|
||||||
|
const char *class;
|
||||||
|
const char *source;
|
||||||
|
|
||||||
if (name != NULL && strcmp(ms->ms_name, name) != 0) {
|
if (name != NULL && strcmp(ms->ms_name, name) != 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -117,9 +122,18 @@ main(int argc, char **argv)
|
|||||||
} else {
|
} else {
|
||||||
snprintf(sbuf, sizeof(sbuf), "%u", ms->ms_size);
|
snprintf(sbuf, sizeof(sbuf), "%u", ms->ms_size);
|
||||||
}
|
}
|
||||||
|
if (ms->ms_class <= class_max)
|
||||||
|
class = classes[ms->ms_class];
|
||||||
|
else
|
||||||
|
class = "UNKNOWN";
|
||||||
|
if (ms->ms_source < source_max)
|
||||||
|
source = sources[ms->ms_source];
|
||||||
|
else
|
||||||
|
source = "UNKNOWN";
|
||||||
|
|
||||||
printf("%-16s %-10s %-10s %-5d %-8s %s\n",
|
printf("%-16s %-10s %-10s %-5d %-8s %s\n",
|
||||||
ms->ms_name, classes[ms->ms_class], sources[ms->ms_source],
|
ms->ms_name, class, source, ms->ms_refcnt, sbuf,
|
||||||
ms->ms_refcnt, sbuf, ms->ms_required);
|
ms->ms_required);
|
||||||
}
|
}
|
||||||
|
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
@ -143,4 +157,3 @@ modstatcmp(const void *a, const void *b)
|
|||||||
|
|
||||||
return strcmp(msa->ms_name, msb->ms_name);
|
return strcmp(msa->ms_name, msb->ms_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user