diff options
| author | Dag-Erling Smørgrav <des@FreeBSD.org> | 2003-11-17 11:08:28 +0000 |
|---|---|---|
| committer | Dag-Erling Smørgrav <des@FreeBSD.org> | 2003-11-17 11:08:28 +0000 |
| commit | 3bdc98d7120a603bb3f7292db51138d0cb703cdf (patch) | |
| tree | f9de9a76be21fa75065e7d158a1b516a57923d7c /usr.sbin/moused | |
| parent | ef3c5c90153ab935e6fbc132440ad5433890e4ac (diff) | |
Notes
Diffstat (limited to 'usr.sbin/moused')
| -rw-r--r-- | usr.sbin/moused/moused.c | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/usr.sbin/moused/moused.c b/usr.sbin/moused/moused.c index e1c848efa3da..b77e82a6f2f7 100644 --- a/usr.sbin/moused/moused.c +++ b/usr.sbin/moused/moused.c @@ -70,6 +70,9 @@ static const char rcsid[] = #include <sys/socket.h> #include <sys/stat.h> #include <sys/un.h> +#include <sys/param.h> +#include <sys/linker.h> +#include <sys/module.h> #include <unistd.h> #define MAX_CLICKTHRESHOLD 2000 /* 2 seconds */ @@ -495,6 +498,8 @@ static void mremote_clientchg(int add); static int kidspad(u_char rxc, mousestatus_t *act); +static int usbmodule(void); + int main(int argc, char *argv[]) { @@ -754,8 +759,7 @@ main(int argc, char *argv[]) retry = 1; if (strncmp(rodent.portname, "/dev/ums", 8) == 0) { - if (kldload("ums") == -1 && errno != EEXIST) - logerr(1, "unable to load USB mouse driver"); + usbmodule(); retry = 5; } @@ -826,6 +830,38 @@ main(int argc, char *argv[]) exit(0); } +static int +usbmodule(void) +{ + struct kld_file_stat fstat; + struct module_stat mstat; + int fileid, modid; + int loaded; + + for (loaded = 0, fileid = kldnext(0); !loaded && fileid > 0; + fileid = kldnext(fileid)) { + fstat.version = sizeof(fstat); + if (kldstat(fileid, &fstat) < 0) + continue; + if (strncmp(fstat.name, "uhub/ums", 8) == 0) { + loaded = 1; + break; + } + for (modid = kldfirstmod(fileid); modid > 0; + modid = modfnext(modid)) { + mstat.version = sizeof(mstat); + if (modstat(modid, &mstat) < 0) + continue; + if (strncmp(mstat.name, "uhub/ums", 8) == 0) { + loaded = 1; + break; + } + } + } + if (!loaded && kldload("ums") == -1 && errno != EEXIST) + logerr(1, "unable to load USB mouse driver"); +} + static void moused(void) { |
