aboutsummaryrefslogtreecommitdiff
path: root/sbin/mdconfig
diff options
context:
space:
mode:
Diffstat (limited to 'sbin/mdconfig')
-rw-r--r--sbin/mdconfig/mdconfig.c39
1 files changed, 12 insertions, 27 deletions
diff --git a/sbin/mdconfig/mdconfig.c b/sbin/mdconfig/mdconfig.c
index e3ca148d7fa9..03747aa13058 100644
--- a/sbin/mdconfig/mdconfig.c
+++ b/sbin/mdconfig/mdconfig.c
@@ -334,32 +334,17 @@ query(const int fd, const int unit)
void
mdmaybeload(void)
{
- struct module_stat mstat;
- int fileid, modid;
- const char *name;
- char *cp;
+ char name1[64], name2[64];
- name = MD_MODNAME;
- /* scan files in kernel */
- mstat.version = sizeof(struct module_stat);
- for (fileid = kldnext(0); fileid > 0; fileid = kldnext(fileid)) {
- /* scan modules in file */
- for (modid = kldfirstmod(fileid); modid > 0;
- modid = modfnext(modid)) {
- if (modstat(modid, &mstat) < 0)
- continue;
- /* strip bus name if present */
- if ((cp = strchr(mstat.name, '/')) != NULL) {
- cp++;
- } else {
- cp = mstat.name;
- }
- /* already loaded? */
- if (!strcmp(name, cp))
- return;
- }
- }
- /* not present, we should try to load it */
- kldload(name);
+ snprintf(name1, sizeof(name1), "g_%s", MD_NAME);
+ snprintf(name2, sizeof(name2), "geom_%s", MD_NAME);
+ if (modfind(name1) == -1) {
+ /* Not present in kernel, try loading it. */
+ if (kldload(name2) == -1 || modfind(name1) == -1) {
+ if (errno != EEXIST) {
+ errx(EXIT_FAILURE,
+ "%s module not available!", name2);
+ }
+ }
+ }
}
-