Date: Wed, 4 Jul 2007 17:04:26 +0200 From: "=?iso-8859-1?Q?david.chosrova@libertysurf.fr?=" <david.chosrova@libertysurf.fr> To: "=?iso-8859-1?Q?freebsd-hackers?=" <freebsd-hackers@freebsd.org> Subject: kernel dynamic references Message-ID: <JKNTVE$C5A4D26735C4FC1C6F888C434208B096@aliceadsl.fr>
next in thread | raw e-mail | index | archive | help
--_=__=_XaM3_.1183561466.2A.827234.42.26958.52.42.007.3152 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable =0D=0AHi,=0D=0A=0D=0A I'm new to Freebsd and interested in system program= ming. So I'have picked up a task from the project ideas list to start wit= h.=0D=0A (part of) the subject is : "This task is to define and implement= a general mechanism for tracking these references and use them in handli= ng module unload requests."=0D=0A=0D=0ASo, to do that, I'have added an "i= nt dynrefs" in struct module (kern_module.c), and functions to increase o= r decrease this count (module_add/remove_dynrefs(const char * modname) an= d module_updatedynrefs(const char * modname, int action) ) in kern_module= .c.=0D=0A=0D=0A To avoid unload of a module which has a dynrefs count !=3D= 0 , I have modified module_unload(), so that unload is process only if = dynrefs=3D0 or flag=3DLINKER_UNLOAD_FORCE.=0D=0A=0D=0A module_unload(modu= le_t mod, int flags)=0D=0A {=0D=0A int error;=0D=0A- error =3D MOD_EVENT= (mod, MOD_QUIESCE);=0D=0A+ MOD_SLOCK;=0D=0A+ (mod->dynrefs =3D=3D 0) ? (e= rror =3D MOD_EVENT(mod, MOD_QUIESCE)) : (error =3D EPERM);=0D=0A+ MOD_SUN= LOCK;=0D=0A=0D=0A=0D=0A=0D=0A I have compiled and tested. with a 6-2 RELE= ASE. For the test I'have used two dummy module, one adding a dynrefs on t= he other.=0D=0A=0D=0A Any comment are welcome=0D=0A=0D=0A David chosrova = =0D=0A=0D=0A=0D=0A=0D=0A=0A=0A------------------------ ALICE C'EST ENCORE= MIEUX AVEC CANAL+ LE BOUQUET ! ---------------=0AD=E9couvrez vite l'offr= e exclusive ALICEBOX et CANAL+ LE BOUQUET, en cliquant ici http://alicebo= x.fr=0ASoumis =E0 conditions.=0A --_=__=_XaM3_.1183561466.2A.827234.42.26958.52.42.007.3152 Content-Type: text/plain;name="module.diff"; name="module.diff" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="module.diff" LS0tIG1vZHVsZS5oLm9yaWcJV2VkIEp1bCAgNCAxMDoyOTo1MyAyMDA3CisrKyBtb2R1bGUu aAlXZWQgSnVsICA0IDEwOjIxOjQwIDIwMDcKQEAgLTE0Nyw3ICsxNDcsOCBAQAogaW50CW1v ZHVsZV9nZXRpZChtb2R1bGVfdCk7CiBtb2R1bGVfdAltb2R1bGVfZ2V0Zm5leHQobW9kdWxl X3QpOwogdm9pZAltb2R1bGVfc2V0c3BlY2lmaWMobW9kdWxlX3QsIG1vZHNwZWNpZmljX3Qg Kik7Ci0KK2ludAltb2R1bGVfYWRkX2R5bnJlZnMoY29uc3QgY2hhciAqKTsKK2ludAltb2R1 bGVfcmVtb3ZlX2R5bnJlZnMoY29uc3QgY2hhciAqKTsKIAogI2lmZGVmCU1PRF9ERUJVRwog ZXh0ZXJuIGludCBtb2RfZGVidWc7Cg== --_=__=_XaM3_.1183561466.2A.827234.42.26958.52.42.007.3152 Content-Type: text/plain;name="kern_module.diff"; name="kern_module.diff" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="kern_module.diff" LS0tIGtlcm5fbW9kdWxlLmMub3JpZwlXZWQgSnVsICA0IDEwOjMzOjA2IDIwMDcKKysrIGtl cm5fbW9kdWxlLmMJV2VkIEp1bCAgNCAxMDoyMToyOCAyMDA3CkBAIC01Miw2ICs1Miw3IEBA CiAJVEFJTFFfRU5UUlkobW9kdWxlKQlmbGluazsJLyogYWxsIG1vZHVsZXMgaW4gYSBmaWxl ICovCiAJc3RydWN0IGxpbmtlcl9maWxlCSpmaWxlOwkvKiBmaWxlIHdoaWNoIGNvbnRhaW5z IHRoaXMgbW9kdWxlICovCiAJaW50CQkJcmVmczsJLyogcmVmZXJlbmNlI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CBNT0RfUVVJ RVNDRSkpIDogKGVycm9yID0gRVBFUk0pOworCU1PRF9TVU5MT0NLOwogCWlmIChlcnJvciA9 PSBFT1BOT1RTVVBQIHx8IGVycm9yID09IEVJTlZBTCkKIAkJZXJyb3IgPSAwOwogCWlmIChm bGFncyA9PSBMSU5LRVJfVU5MT0FEX05PUk1BTCAmJiBlcnJvciAhPSAwKQpAQCAtMjYxLDYg KzI2NiwzNyBAQAogCiAJTU9EX1hMT0NLX0FTU0VSVDsKIAltb2QtPmRhdGEgPSAqZGF0YXA7 Cit9CisKK3N0YXRpYyBpbnQKK21vZHVsZV91cGRhdGVkeW5yZWZzKGNvbnN0IGNoYXIqIG1v ZG5hbWUsIGludCBhY3Rpb24pCit7CisJbW9kdWxlX3QgbW9kOworCQorCU1PRF9YTE9DSzsK Kwltb2QgPSBtb2R1bGVfbG9va3VwYnluYW1lKG1vZG5hbWUpOworCisJaWYobW9kID09IDAp IHsKKwkJTU9EX1hVTkxPQ0s7CisJCXJldHVybigtMSk7CisJfQorCisJKGFjdGlvbiA9PSAx KSA/IG1vZC0+ZHlucmVmcysrIDogbW9kLT5keW5yZWZzLS07CisJTU9EX1hVTkxPQ0s7CisJ cmV0dXJuICgwKTsKK30KKworaW50Cittb2R1bGVfYWRkX2R5bnJlZnMoY29uc3QgY2hhciAq bW9kbmFtZSkKK3sKKworCXJldHVybiAobW9kdWxlX3VwZGF0ZWR5bnJlZnMobW9kbmFtZSwx KSk7Cit9CisKK2ludAorbW9kdWxlX3JlbW92ZV9keW5yZWZzKGNvbnN0IGNoYXIgKiBtb2Ru YW1lKQoreworCXJldHVybiAobW9kdWxlX3VwZGF0ZWR5bnJlZnMobW9kbmFtZSwwKSk7CiB9 CiAKIC8qCQo= --_=__=_XaM3_.1183561466.2A.827234.42.26958.52.42.007.3152--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?JKNTVE$C5A4D26735C4FC1C6F888C434208B096>