From owner-freebsd-bugs@FreeBSD.ORG Mon Nov 17 03:00:38 2003 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DD8C116A4CE for ; Mon, 17 Nov 2003 03:00:37 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id AACA243FE9 for ; Mon, 17 Nov 2003 03:00:35 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id hAHB0ZFY081756 for ; Mon, 17 Nov 2003 03:00:35 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id hAHB0ZWq081755; Mon, 17 Nov 2003 03:00:35 -0800 (PST) (envelope-from gnats) Resent-Date: Mon, 17 Nov 2003 03:00:35 -0800 (PST) Resent-Message-Id: <200311171100.hAHB0ZWq081755@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Jens Rehsack Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5336E16A4CE; Mon, 17 Nov 2003 02:55:46 -0800 (PST) Received: from helo.liwing.de (helo.liwing.de [213.70.188.163]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7572F43FAF; Mon, 17 Nov 2003 02:55:44 -0800 (PST) (envelope-from root@helo.liwing.de) Received: from helo.liwing.de (localhost.liwing.de [127.0.0.1]) by helo.liwing.de (8.12.9p2/8.12.9) with ESMTP id hAHAtgUn058951; Mon, 17 Nov 2003 10:55:42 GMT (envelope-from root@helo.liwing.de) Received: (from root@localhost) by helo.liwing.de (8.12.9p2/8.12.9/Submit) id hAHAtfO6058950; Mon, 17 Nov 2003 10:55:41 GMT (envelope-from root) Message-Id: <200311171055.hAHAtfO6058950@helo.liwing.de> Date: Mon, 17 Nov 2003 10:55:41 GMT From: Jens Rehsack To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 cc: Jens Rehsack cc: current@FreeBSD.org cc: des@FreeBSD.org Subject: bin/59368: [PATCH] /usr/sbin/moused fails if ums is built into kernel X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Jens Rehsack List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Nov 2003 11:00:38 -0000 >Number: 59368 >Category: bin >Synopsis: [PATCH] /usr/sbin/moused fails if ums is built into kernel >Confidential: no >Severity: serious >Priority: high >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Nov 17 03:00:35 PST 2003 >Closed-Date: >Last-Modified: >Originator: Jens Rehsack >Release: FreeBSD 5.1-CURRENT i386 >Organization: LiWing IT-Services >Environment: System: FreeBSD statler 5.1-CURRENT FreeBSD 5.1-CURRENT #0: Sat Nov 15 14:11:24 GMT 2003 root@statler:/usr/obj/usr/src/sys/STATLER i386 >Description: If the device ums is built into the kernel and not as module, and the module is not build (eg. excluded by MODULES_OVERRIDE), moused fails with: 'unable to load USB mouse driver: No such file or directory' >How-To-Repeat: Build a -CURRENT kernel with ums, don't build the ums module, use an usb-mouse and reboot. >Fix: --- patch-usr.sbin::moused::moused.c begins here --- Index: usr.sbin/moused/moused.c =================================================================== diff -u usr.sbin/moused/moused.c.orig usr.sbin/moused/moused.c --- usr.sbin/moused/moused.c.orig Sat Nov 15 14:51:14 2003 +++ usr.sbin/moused/moused.c Sat Nov 15 15:08:10 2003 @@ -70,6 +70,9 @@ #include #include #include +#include +#include +#include #include #define MAX_CLICKTHRESHOLD 2000 /* 2 seconds */ @@ -495,6 +498,8 @@ static int kidspad(u_char rxc, mousestatus_t *act); +static int usbmodule(void); + int main(int argc, char *argv[]) { @@ -754,8 +759,7 @@ 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; } @@ -824,6 +828,43 @@ /* NOT REACHED */ exit(0); +} + +static int +usbmodule(void) +{ + int fileid, modid, loaded = 0; + struct kld_file_stat fstat; + struct module_stat mstat; + + for( fileid = kldnext(0); loaded == 0 && 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 --- patch-usr.sbin::moused::moused.c ends here --- >Release-Note: >Audit-Trail: >Unformatted: