svn commit: r234199 - stable/8/sys/geom/part
Andrey V. Elsukov
ae at FreeBSD.org
Fri Apr 13 04:18:13 UTC 2012
Author: ae
Date: Fri Apr 13 04:18:12 2012
New Revision: 234199
URL: http://svn.freebsd.org/changeset/base/234199
Log:
MFC r233000:
Add MODULE_DEPEND() to geom_part modules.
MFC r233342:
Check that scheme is not already registered. This may happens when a
KLD is preloaded with loader(8) and leads to infinity loop.
Also do not return EEXIST error code from MOD_LOAD handler, because
we have undocumented(?) ability replace kernel's module with preloaded one.
And if we have so, then preloaded module will be initialized first.
Thus error in MOD_LOAD handler will be triggered for the kernel.
PR: kern/165573
Modified:
stable/8/sys/geom/part/g_part.c
stable/8/sys/geom/part/g_part.h
Directory Properties:
stable/8/sys/ (props changed)
Modified: stable/8/sys/geom/part/g_part.c
==============================================================================
--- stable/8/sys/geom/part/g_part.c Fri Apr 13 04:17:43 2012 (r234198)
+++ stable/8/sys/geom/part/g_part.c Fri Apr 13 04:18:12 2012 (r234199)
@@ -145,6 +145,7 @@ static struct g_class g_part_class = {
};
DECLARE_GEOM_CLASS(g_part_class, g_part);
+MODULE_VERSION(g_part, 0);
/*
* Support functions.
@@ -2135,23 +2136,32 @@ g_part_unload_event(void *arg, int flag)
int
g_part_modevent(module_t mod, int type, struct g_part_scheme *scheme)
{
+ struct g_part_scheme *iter;
uintptr_t arg;
int error;
+ error = 0;
switch (type) {
case MOD_LOAD:
- TAILQ_INSERT_TAIL(&g_part_schemes, scheme, scheme_list);
-
- error = g_retaste(&g_part_class);
- if (error)
- TAILQ_REMOVE(&g_part_schemes, scheme, scheme_list);
+ TAILQ_FOREACH(iter, &g_part_schemes, scheme_list) {
+ if (scheme == iter) {
+ printf("GEOM_PART: scheme %s is already "
+ "registered!\n", scheme->name);
+ break;
+ }
+ }
+ if (iter == NULL) {
+ TAILQ_INSERT_TAIL(&g_part_schemes, scheme,
+ scheme_list);
+ g_retaste(&g_part_class);
+ }
break;
case MOD_UNLOAD:
arg = (uintptr_t)scheme;
error = g_waitfor_event(g_part_unload_event, &arg, M_WAITOK,
NULL);
- if (!error)
- error = (arg == (uintptr_t)scheme) ? EDOOFUS : arg;
+ if (error == 0)
+ error = arg;
break;
default:
error = EOPNOTSUPP;
Modified: stable/8/sys/geom/part/g_part.h
==============================================================================
--- stable/8/sys/geom/part/g_part.h Fri Apr 13 04:17:43 2012 (r234198)
+++ stable/8/sys/geom/part/g_part.h Fri Apr 13 04:18:12 2012 (r234199)
@@ -208,6 +208,7 @@ int g_part_modevent(module_t, int, struc
name##_modevent, \
&name##_scheme \
}; \
- DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_ANY)
+ DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_ANY); \
+ MODULE_DEPEND(name, g_part, 0, 0, 0)
#endif /* !_GEOM_PART_H_ */
More information about the svn-src-stable-8
mailing list