Do a pass over all modules in the kernel and make them return EOPNOTSUPP

for unknown events.

A number of modules return EINVAL in this instance, and I have left
those alone for now and instead taught MOD_QUIESCE to accept this
as "didn't do anything".
This commit is contained in:
phk 2004-07-15 08:26:07 +00:00
parent 953f0781f4
commit 803ccd11bd
59 changed files with 101 additions and 20 deletions

View File

@ -274,6 +274,7 @@ linux_elf_modevent(module_t mod, int type, void *data)
printf("Could not deinstall ELF interpreter entry\n");
break;
default:
return (EOPNOTSUPP);
break;
}
return error;

View File

@ -53,6 +53,8 @@ void periphdriver_register(void *);
case MOD_UNLOAD: \
printf(#name " module unload - not possible for this module type\n"); \
return EINVAL; \
default: \
return EOPNOTSUPP; \
} \
return 0; \
} \

View File

@ -1348,6 +1348,8 @@ cam_module_event_handler(module_t mod, int what, void *arg)
xpt_init(NULL);
} else if (what == MOD_UNLOAD) {
return EBUSY;
} else {
return EOPNOTSUPP;
}
return 0;

View File

@ -90,9 +90,9 @@ codadev_modevent(module_t mod, int type, void *data)
case MOD_LOAD:
break;
case MOD_UNLOAD:
break;
return (EBUSY);
default:
break;
return (EOPNOTSUPP);
}
return 0;
}

View File

@ -411,6 +411,7 @@ svr4_elf_modevent(module_t mod, int type, void *data)
printf("svr4 ELF exec handler removed\n");
break;
default:
return (EOPNOTSUPP);
break;
}
return error;

View File

@ -1540,6 +1540,7 @@ static int
ahd_modevent(module_t mod, int type, void *data)
{
/* XXX Deal with busy status on unload. */
/* XXX Deal with unknown events */
return 0;
}

View File

@ -1663,6 +1663,7 @@ static int
ahc_modevent(module_t mod, int type, void *data)
{
/* XXX Deal with busy status on unload. */
/* XXX Deal with unknown events */
return 0;
}

View File

@ -88,6 +88,7 @@ bktr_mem_modevent(module_t mod, int type, void *unused){
printf("bktr_mem: memory holder cannot be unloaded\n");
return EBUSY;
default:
return EOPNOTSUPP;
break;
}
return (0);

View File

@ -651,6 +651,9 @@ dcons_modevent(module_t mode, int type, void *data)
break;
case MOD_SHUTDOWN:
break;
default:
err = EOPNOTSUPP;
break;
}
return(err);
}

View File

@ -386,6 +386,8 @@ fb_modevent(module_t mod, int type, void *data)
case MOD_UNLOAD:
printf("fb module unload - not possible for this module type\n");
return EINVAL;
default:
return EOPNOTSUPP;
}
return 0;
}

View File

@ -55,6 +55,7 @@ typedef struct image_decoder scrn_saver_t;
case MOD_UNLOAD: \
return splash_unregister(&sw); \
default: \
return EOPNOTSUPP; \
break; \
} \
return 0; \
@ -76,6 +77,7 @@ typedef struct image_decoder scrn_saver_t;
case MOD_UNLOAD: \
return splash_unregister(&sw); \
default: \
return EOPNOTSUPP; \
break; \
} \
return 0; \

View File

@ -2273,6 +2273,8 @@ fw_modevent(module_t mode, int type, void *data)
break;
case MOD_SHUTDOWN:
break;
default:
return (EOPNOTSUPP);
}
return (err);
}

View File

@ -646,6 +646,8 @@ harp_modevent(module_t mod, int event, void *data)
uma_zdestroy(harp_vcc_zone);
break;
default:
return (EOPNOTSUPP);
}
return (0);
}

View File

@ -451,6 +451,7 @@ hfa_modevent (module_t mod, int type, void *data)
break;
default:
return (EOPNOTSUPP);
break;
}

View File

@ -164,6 +164,7 @@ isp_module_handler(module_t mod, int what, void *arg)
}
break;
default:
return (EOPNOTSUPP);
break;
}
return (0);

View File

@ -1237,6 +1237,7 @@ md_modevent(module_t mod, int type, void *data)
status_dev = 0;
break;
default:
return (EOPNOTSUPP);
break;
}
return (0);

View File

@ -135,6 +135,8 @@ null_modevent(module_t mod __unused, int type, void *data __unused)
case MOD_SHUTDOWN:
break;
default:
return (EOPNOTSUPP);
}
return (0);

View File

@ -215,7 +215,7 @@ openprom_modevent(module_t mode, int type, void *data)
destroy_dev(openprom_dev);
return (0);
default:
return (0);
return (EOPNOTSUPP);
}
}

View File

@ -220,6 +220,10 @@ random_modevent(module_t mod __unused, int type, void *data __unused)
case MOD_SHUTDOWN:
break;
default:
error = EOPNOTSUPP;
break;
}
return (error);
}

View File

@ -650,6 +650,7 @@ snp_modevent(mod, type, data)
ldisc_deregister(snooplinedisc);
break;
default:
return (EOPNOTSUPP);
break;
}
return (0);

View File

@ -38,6 +38,7 @@ snd_modevent(module_t mod, int type, void *data)
case MOD_UNLOAD:
break;
default:
return (EOPNOTSUPP);
break;
}
return 0;

View File

@ -165,6 +165,7 @@ streams_modevent(module_t mod, int type, void *unused)
return 0;
default:
return EOPNOTSUPP;
break;
}
return 0;

View File

@ -391,6 +391,7 @@ typedef struct sc_term_sw {
return EBUSY; \
return sc_term_remove(&sw); \
default: \
return EOPNOTSUPP; \
break; \
} \
return 0; \
@ -462,6 +463,7 @@ typedef struct sc_renderer {
} \
break; \
default: \
return EOPNOTSUPP; \
break; \
} \
return error; \

View File

@ -1550,6 +1550,8 @@ utopia_mod_init(module_t mod, int what, void *arg)
UTP_WUNLOCK_LIST();
mtx_destroy(&utopia_list_mtx);
break;
default:
return (EOPNOTSUPP);
}
return (0);
}

View File

@ -318,6 +318,7 @@ vinum_modevent(module_t mod, modeventtype_t type, void *unused)
EVENTHANDLER_DEREGISTER(dev_clone, dev_clone_tag);
return 0;
default:
return EOPNOTSUPP;
break;
}
return 0;

View File

@ -90,9 +90,9 @@ codadev_modevent(module_t mod, int type, void *data)
case MOD_LOAD:
break;
case MOD_UNLOAD:
break;
return (EBUSY);
default:
break;
return (EOPNOTSUPP);
}
return 0;
}

View File

@ -394,7 +394,7 @@ pfs_modevent(module_t mod, int evt, void *arg)
pfs_fileno_unload();
break;
default:
printf("pseudofs: unexpected event type %d\n", evt);
return EOPNOTSUPP;
break;
}
return 0;

View File

@ -1363,6 +1363,7 @@ union_modevent(module_t mod, int type, void *data)
union_dircheckp = NULL;
break;
default:
return EOPNOTSUPP;
break;
}
return 0;

View File

@ -635,6 +635,7 @@ g_gate_modevent(module_t mod, int type, void *data)
destroy_dev(status_dev);
break;
default:
return (EOPNOTSUPP);
break;
}

View File

@ -116,7 +116,7 @@ ibcs2_modevent(module_t mod, int type, void *unused)
}
sx_sunlock(&allproc_lock);
default:
/* do not care */
return (EOPNOTSUPP);
break;
}
return (rval);

View File

@ -1652,7 +1652,7 @@ vesa_mod_event(module_t mod, int type, void *data)
case MOD_UNLOAD:
return vesa_unload();
default:
break;
return EOPNOTSUPP;
}
return 0;
}

View File

@ -960,7 +960,7 @@ linux_elf_modevent(module_t mod, int type, void *data)
printf("Could not deinstall ELF interpreter entry\n");
break;
default:
break;
return EOPNOTSUPP;
}
return error;
}

View File

@ -57,6 +57,8 @@
case MOD_UNLOAD: \
printf(#name " module unload - not possible for this module type\n"); \
return EINVAL; \
default: \
return EOPNOTSUPP; \
} \
return 0; \
} \

View File

@ -359,6 +359,7 @@ mac_policy_modevent(module_t mod, int type, void *data)
error = 0;
break;
default:
error = EOPNOTSUPP;
break;
}

View File

@ -228,7 +228,7 @@ module_unload(module_t mod, int flags)
int error;
error = MOD_EVENT(mod, MOD_QUIESCE);
if (error == EOPNOTSUPP)
if (error == EOPNOTSUPP || error == EINVAL)
error = 0;
if (flags == LINKER_UNLOAD_NORMAL && error != 0)
return (error);

View File

@ -115,6 +115,9 @@ syscall_module_handler(struct module *mod, int what, void *arg)
}
error = syscall_deregister(data->offset, &data->old_sysent);
return error;
default :
return EOPNOTSUPP;
}
if (data->chainevh)

View File

@ -2535,6 +2535,8 @@ root_bus_module_handler(module_t mod, int what, void* arg)
case MOD_SHUTDOWN:
device_shutdown(root_bus);
return (0);
default:
return (EOPNOTSUPP);
}
return (0);
@ -2612,6 +2614,9 @@ driver_module_handler(module_t mod, int what, void *arg)
if (!error && dmd->dmd_chainevh)
error = dmd->dmd_chainevh(mod,what,dmd->dmd_chainarg);
break;
default:
error = EOPNOTSUPP;
break;
}
return (error);

View File

@ -528,7 +528,8 @@ vfs_modevent(module_t mod, int type, void *data)
if (vfc)
error = vfs_unregister(vfc);
break;
default: /* including MOD_SHUTDOWN */
default:
error = EOPNOTSUPP;
break;
}
return (error);

View File

@ -155,6 +155,8 @@ disc_modevent(module_t mod, int type, void *data)
mtx_unlock(&disc_mtx);
mtx_destroy(&disc_mtx);
break;
default:
return (EOPNOTSUPP);
}
return (0);
}

View File

@ -584,7 +584,7 @@ if_ef_modevent(module_t mod, int type, void *data)
case MOD_UNLOAD:
return ef_unload();
default:
break;
return EOPNOTSUPP;
}
return 0;
}

View File

@ -145,6 +145,8 @@ faithmodevent(mod, type, data)
mtx_unlock(&faith_mtx);
mtx_destroy(&faith_mtx);
break;
default:
return EOPNOTSUPP;
}
return 0;
}

View File

@ -255,6 +255,8 @@ gifmodevent(mod, type, data)
ip6_gif_hlim = 0;
#endif
break;
default:
return EOPNOTSUPP;
}
return 0;
}

View File

@ -767,6 +767,8 @@ gremodevent(module_t mod, int type, void *data)
mtx_unlock(&gre_mtx);
mtx_destroy(&gre_mtx);
break;
default:
return EOPNOTSUPP;
}
return 0;
}

View File

@ -172,6 +172,8 @@ loop_modevent(module_t mod, int type, void *data)
case MOD_UNLOAD:
printf("loop module unload - not possible for this module type\n");
return EINVAL;
default:
return EOPNOTSUPP;
}
return 0;
}

View File

@ -294,6 +294,8 @@ ppp_modevent(module_t mod, int type, void *data)
}
PPP_LIST_LOCK_DESTROY();
break;
default:
return EOPNOTSUPP;
}
return 0;
}

View File

@ -210,6 +210,8 @@ sl_modevent(module_t mod, int type, void *data)
ldisc_deregister(SLIPDISC);
printf("if_sl module unload - not possible for this module type\n");
return EINVAL;
default:
return EOPNOTSUPP;
}
return 0;
}

View File

@ -484,9 +484,8 @@ sppp_modevent(module_t mod, int type, void *unused)
break;
case MOD_UNLOAD:
return EACCES;
break;
default:
break;
return EOPNOTSUPP;
}
return 0;
}

View File

@ -301,6 +301,8 @@ stfmodevent(mod, type, data)
mtx_unlock(&stf_mtx);
mtx_destroy(&stf_mtx);
break;
default:
return (EOPNOTSUPP);
}
return (0);

View File

@ -204,6 +204,8 @@ tunmodevent(module_t mod, int type, void *data)
clone_cleanup(&tunclones);
mtx_destroy(&tunmtx);
break;
default:
return EOPNOTSUPP;
}
return 0;
}

View File

@ -248,6 +248,8 @@ vlan_modevent(module_t mod, int type, void *data)
&LIST_FIRST(&ifv_list)->ifv_if);
VLAN_LOCK_DESTROY();
break;
default:
return (EOPNOTSUPP);
}
return (0);
}

View File

@ -2954,7 +2954,7 @@ ng_mod_event(module_t mod, int event, void *data)
if (type->mod_event != NULL)
error = (*type->mod_event)(mod, event, data);
else
error = 0; /* XXX ? */
error = EOPNOTSUPP; /* XXX ? */
break;
}
return (error);

View File

@ -2080,6 +2080,7 @@ dummynet_modevent(module_t mod, int type, void *data)
#endif
break ;
default:
return EOPNOTSUPP;
break ;
}
return 0 ;

View File

@ -3441,6 +3441,7 @@ ipfw_modevent(module_t mod, int type, void *unused)
err = 0;
break;
default:
return EOPNOTSUPP;
break;
}
return err;

View File

@ -3421,6 +3421,8 @@ ip_mroute_modevent(module_t mod, int type, void *unused)
MFC_LOCK_DESTROY();
mtx_destroy(&mrouter_mtx);
break;
default:
return EOPNOTSUPP;
}
return 0;
}

View File

@ -1293,6 +1293,7 @@ ip6fw_modevent(module_t mod, int type, void *unused)
printf("IPv6 firewall unloaded\n");
return 0;
default:
return EOPNOTSUPP;
break;
}
return 0;

View File

@ -521,9 +521,9 @@ static const short *nfsrv_v3errmap[] = {
static int
nfsrv_modevent(module_t mod, int type, void *data)
{
int error = 0;
NET_LOCK_GIANT();
switch (type) {
case MOD_LOAD:
mtx_init(&nfsd_mtx, "nfsd_mtx", NULL, MTX_DEF);
@ -556,10 +556,10 @@ nfsrv_modevent(module_t mod, int type, void *data)
sysent[SYS_nfssvc].sy_call = (sy_call_t *)nfssvc;
break;
case MOD_UNLOAD:
case MOD_UNLOAD:
if (nfsrv_numnfsd != 0) {
NET_UNLOCK_GIANT();
return EBUSY;
error = EBUSY;
break;
}
callout_stop(&nfsrv_callout);
@ -567,9 +567,12 @@ nfsrv_modevent(module_t mod, int type, void *data)
sysent[SYS_nfssvc].sy_call = nfs_prev_nfssvc_sy_call;
mtx_destroy(&nfsd_mtx);
break;
default:
error = EOPNOTSUPP;
break;
}
NET_UNLOCK_GIANT();
return 0;
return error;
}
static moduledata_t nfsserver_mod = {
"nfsserver",

View File

@ -359,6 +359,7 @@ mac_policy_modevent(module_t mod, int type, void *data)
error = 0;
break;
default:
error = EOPNOTSUPP;
break;
}

View File

@ -359,6 +359,7 @@ mac_policy_modevent(module_t mod, int type, void *data)
error = 0;
break;
default:
error = EOPNOTSUPP;
break;
}

View File

@ -105,6 +105,7 @@ int exec_unregister(const struct execsw *);
printf(__XSTRING(name) " unregister failed\n");\
break; \
default: \
error = EOPNOTSUPP; \
break; \
} \
return error; \