Date: Fri, 19 Feb 2010 00:26:01 GMT From: Peter Wemm <peter@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 174840 for review Message-ID: <201002190026.o1J0Q1qP092750@repoman.freebsd.org>
index | next in thread | raw e-mail
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); }help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201002190026.o1J0Q1qP092750>
