From owner-freebsd-hackers Mon Jan 18 20:52:05 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id UAA13371 for freebsd-hackers-outgoing; Mon, 18 Jan 1999 20:52:05 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from whistle.com (s205m131.whistle.com [207.76.205.131]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id UAA13357 for ; Mon, 18 Jan 1999 20:52:01 -0800 (PST) (envelope-from archie@whistle.com) Received: (from smap@localhost) by whistle.com (8.7.5/8.6.12) id UAA11042; Mon, 18 Jan 1999 20:51:53 -0800 (PST) Received: from bubba.whistle.com( 207.76.205.7) by whistle.com via smap (V2.0) id xma011040; Mon, 18 Jan 99 20:51:51 -0800 Received: (from archie@localhost) by bubba.whistle.com (8.8.7/8.6.12) id UAA07575; Mon, 18 Jan 1999 20:51:51 -0800 (PST) From: Archie Cobbs Message-Id: <199901190451.UAA07575@bubba.whistle.com> Subject: Re: Loading KLD from the kernel In-Reply-To: from Doug Rabson at "Jan 18, 99 10:44:19 am" To: dfr@nlsystems.com (Doug Rabson) Date: Mon, 18 Jan 1999 20:51:51 -0800 (PST) Cc: freebsd-hackers@FreeBSD.ORG, julian@whistle.com (Julian Elischer) X-Mailer: ELM [version 2.4ME+ PL38 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Doug Rabson writes: > > What's the correct way to request loading of a KLD module from within > > the kernel (but not from an interrupt handler). I see the kldload() > > syscall function.. should I just call it directly? > > > > Same question for unloading a KLD module... > > The right thing to do is to call linker_load_file() like this: > > linker_file_t lf; > int error = linker_load_file(filename, &lf); > if (error) > ...; Thanks!! That works great. Now I have another much more minor question.. when kldload() loads a module, it increments "lf->userrefs" .. I assume this field is for the "client" code to use (eg, kld syscalls or other kernel entity). If this field is zero, you can't unload the module from root shell: linkerunload: attempt to unload file which was not loaded by user I'm trying to understand the exact semantics of userrefs, and how we can allow root to unload a KLD from the shell that was loaded from the kernel (after checking that it's safe, of course)? I tried simply incrementing lf->userrefs after loading the module from the kernel, but somehow it went back to zero (?) Thanks, -Archie ___________________________________________________________________________ Archie Cobbs * Whistle Communications, Inc. * http://www.whistle.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message