binmiscctl should use modfind instead of kldfind

kldfind() only matches kernel modules, so if you link imgact_binmisc directly
into the kernel, binmiscctl can't find it, tries to load it, and errors
out with:
  Can't load imgact_binmisc kernel module: File exists

A quick search of other base commands shows that the correct procedure is to
call modfind(), and then try kldload() if that fails.

PR:		218593
Submitted by:	Dan Nelson <dnelson_1901@yahoo.com>
MFC after:	1 week
This commit is contained in:
Sean Bruno 2017-07-28 18:11:53 +00:00
parent d00ed7642f
commit 4b5e2f8ea0
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=321658

View File

@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <sys/imgact_binmisc.h>
#include <sys/linker.h>
#include <sys/module.h>
#include <sys/sysctl.h>
enum cmd {
@ -401,7 +402,7 @@ main(int argc, char **argv)
size_t xbe_out_sz = 0, *xbe_out_szp = NULL;
uint32_t i;
if (kldfind(KMOD_NAME) == -1) {
if (modfind(KMOD_NAME) == -1) {
if (kldload(KMOD_NAME) == -1)
fatal("Can't load %s kernel module: %s",
KMOD_NAME, strerror(errno));