Bug 114291 - [RFE] [modules] [patch] add dynamic module references
Summary: [RFE] [modules] [patch] add dynamic module references
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: Unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs mailing list
Depends on:
Reported: 2007-07-04 16:20 UTC by david chosrova
Modified: 2017-12-31 22:32 UTC (History)
0 users

See Also:

file.diff (1.75 KB, patch)
2007-07-04 16:20 UTC, david chosrova
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description david chosrova 2007-07-04 16:20:03 UTC

I'm new to Freebsd and interested in system programming. So I'have picked
up a task from the project ideas list to start with.

(part of) the subject is : "This task is to define and implement a general
mechanism for tracking these references and use them in handling module
unload requests."

So, to do that, I've added an "int dynrefs" in struct module
(kern_module.c), and functions to increase or decrease this count
(module_add/remove_dynrefs(const char * modname) and
module_updatedynrefs(const char * modname, int action) ) in kern_module.c.

To avoid unload of a module which has a dynrefs count != 0 , I have
modified module_unload(), so that unload is process only if dynrefs=0

 module_unload(module_t mod, int flags)
 	int error;
-	error = MOD_EVENT(mod, MOD_QUIESCE);
+	(mod->dynrefs == 0) ? (error = MOD_EVENT(mod, MOD_QUIESCE)) : (error = EPERM);

I have compiled and tested. with a 6-2 RELEASE. For the test I'have used
two dummy module, one adding a dynrefs on the other.

Any comment are welcome

David chosrova

Fix: Patch attached with submission follows:
Comment 1 david chosrova 2007-07-04 16:48:41 UTC

 It is quite a long time. What was in fact needed  ?


david Chosrova
Comment 2 K. Macy freebsd_committer 2007-11-16 18:20:28 UTC
Responsible Changed
From-To: freebsd-bugs->kmacy

Need to see if this is something that we in fact want.
Comment 3 Gavin Atkinson freebsd_committer freebsd_triage 2011-06-01 21:41:37 UTC
Responsible Changed
From-To: kmacy->freebsd-bugs

kmacy has asked for all of his PRs to be reassigned, put back into the 

To submitter: I'm afraid that I don't know the status of this idea -  
it may be worth posting to freebsd-hackers to give your patch a 
larger audience.
Comment 4 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 07:59:52 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped