From owner-p4-projects@FreeBSD.ORG Fri Feb 19 00:26:01 2010 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 8082E1065679; Fri, 19 Feb 2010 00:26:01 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 44FEE106566B for ; Fri, 19 Feb 2010 00:26:01 +0000 (UTC) (envelope-from peter@wemm.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 32D898FC13 for ; Fri, 19 Feb 2010 00:26:01 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id o1J0Q1gp092752 for ; Fri, 19 Feb 2010 00:26:01 GMT (envelope-from peter@wemm.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id o1J0Q1qP092750 for perforce@freebsd.org; Fri, 19 Feb 2010 00:26:01 GMT (envelope-from peter@wemm.org) Date: Fri, 19 Feb 2010 00:26:01 GMT Message-Id: <201002190026.o1J0Q1qP092750@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to peter@wemm.org using -f From: Peter Wemm To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 174840 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Feb 2010 00:26:01 -0000 http://p4web.freebsd.org/chv.cgi?CH=174840 Change 174840 by peter@peter_daintree on 2010/02/19 00:25:45 Replace a fragile, abi-sensative chunk of needlessly complicated code with the two syscalls that it should be making. Bonus: works in 32 bit environments on 64 bit hosts now. Affected files ... .. //depot/projects/hammer/lib/libutil/kld.c#3 edit Differences ... ==== //depot/projects/hammer/lib/libutil/kld.c#3 (text) ==== @@ -38,32 +38,8 @@ int kld_isloaded(const char *name) { - struct kld_file_stat fstat; - struct module_stat mstat; - const char *ko; - int fid, mid; - - for (fid = kldnext(0); fid > 0; fid = kldnext(fid)) { - fstat.version = sizeof(fstat); - if (kldstat(fid, &fstat) != 0) - continue; - /* check if the file name matches the supplied name */ - if (strcmp(fstat.name, name) == 0) - return (1); - /* strip .ko and try again */ - if ((ko = strstr(fstat.name, ".ko")) != NULL && - strlen(name) == (size_t)(ko - fstat.name) && - strncmp(fstat.name, name, ko - fstat.name) == 0) - return (1); - /* look for a matching module within the file */ - for (mid = kldfirstmod(fid); mid > 0; mid = modfnext(mid)) { - mstat.version = sizeof(mstat); - if (modstat(mid, &mstat) != 0) - continue; - if (strcmp(mstat.name, name) == 0) - return (1); - } - } + if (modstat(name) != -1 || kldfind(name) != -1) + return (1); return (0); }