Lines Matching defs:module

38 static mutex_t mod_lock;	/* protects module list */
91 * This is determined at runtime when filesys module register
114 * call unregister() entry point to allow module to unregister for
118 module_detach(module_t *module)
120 struct rcm_mod_ops *ops = module->modops;
122 rcm_log_message(RCM_TRACE2, "module_detach(name=%s)\n", module->name);
124 ops->rcmop_unregister(module->rcmhandle);
129 * call register() entry point to allow module to register for resources
132 module_attach(module_t *module)
134 struct rcm_mod_ops *ops = module->modops;
136 rcm_log_message(RCM_TRACE2, "module_attach(name=%s)\n", module->name);
138 if (ops->rcmop_register(module->rcmhandle) != RCM_SUCCESS) {
140 gettext("module %s register() failed\n"), module->name);
145 module_init(module_t *module)
147 if (module->dlhandle)
148 /* rcm module */
149 return (module->init());
152 return (script_init(module));
156 * call rmc_mod_info() entry of module
159 module_info(module_t *module)
161 if (module->dlhandle)
162 /* rcm module */
163 return (module->info());
166 return (script_info(module));
170 module_fini(module_t *module)
172 if (module->dlhandle)
173 /* rcm module */
174 return (module->fini());
177 return (script_fini(module));
181 * call rmc_mod_fini() entry of module, dlclose module, and free memory
184 module_unload(module_t *module)
186 int version = module->modops->version;
188 rcm_log_message(RCM_DEBUG, "module_unload(name=%s)\n", module->name);
190 (void) module_fini(module);
192 rcm_handle_free(module->rcmhandle);
193 free(module->name);
200 free(module->modops);
208 if (module->dlhandle)
209 rcm_module_close(module->dlhandle);
211 free(module);
215 * Locate the module, execute rcm_mod_init() and check ops vector version
220 module_t *module;
225 * dlopen the module
227 module = s_calloc(1, sizeof (*module));
228 module->name = s_strdup(modname);
229 module->modops = NULL;
230 rcm_init_queue(&module->client_q);
233 /* rcm module */
234 module->dlhandle = rcm_module_open(modname);
236 if (module->dlhandle == NULL) {
238 gettext("cannot open module %s\n"), modname);
245 module->init = (struct rcm_mod_ops *(*)())dlsym(
246 module->dlhandle, "rcm_mod_init");
247 module->fini = (int (*)())dlsym(
248 module->dlhandle, "rcm_mod_fini");
249 module->info = (const char *(*)())dlsym(module->dlhandle,
251 if (module->init == NULL || module->fini == NULL ||
252 module->info == NULL) {
254 gettext("missing entries in module %s\n"), modname);
260 module->dlhandle = NULL;
261 module->init = (struct rcm_mod_ops *(*)()) NULL;
262 module->fini = (int (*)()) NULL;
263 module->info = (const char *(*)()) NULL;
266 if ((module->modops = module_init(module)) == NULL) {
267 if (module->dlhandle)
269 gettext("cannot init module %s\n"), modname);
276 switch (module->modops->version) {
278 module->modops = modops_from_v1((void *)module->modops);
286 gettext("module %s rejected: version %d not supported\n"),
287 modname, module->modops->version);
288 (void) module_fini(module);
295 if ((module->modops->rcmop_register == NULL) ||
296 (module->modops->rcmop_unregister == NULL) ||
297 (module->modops->rcmop_get_info == NULL) ||
298 (module->modops->rcmop_request_suspend == NULL) ||
299 (module->modops->rcmop_notify_resume == NULL) ||
300 (module->modops->rcmop_request_offline == NULL) ||
301 (module->modops->rcmop_notify_online == NULL) ||
302 (module->modops->rcmop_notify_remove == NULL)) {
304 gettext("module %s rejected: has NULL ops fields\n"),
306 (void) module_fini(module);
310 module->rcmhandle = rcm_handle_alloc(module);
311 return (module);
314 if (module->modops && module->modops->version == RCM_MOD_OPS_V1)
315 free(module->modops);
317 if (module->dlhandle)
318 rcm_module_close(module->dlhandle);
320 free(module->name);
321 free(module);
326 * add one to module hold count. load the module if not loaded
331 module_t *module;
336 module = module_head;
337 while (module) {
338 if (strcmp(module->name, modname) == 0) {
341 module = module->next;
344 if (module) {
345 module->ref_count++;
347 return (module);
353 if ((module = module_load(modname)) == NULL) {
359 * Hold module and link module into module list
361 module->ref_count = MOD_REFCNT_INIT;
362 module->next = module_head;
363 module_head = module;
367 return (module);
371 * decrement module hold count. Unload it if no reference
374 cli_module_rele(module_t *module)
378 rcm_log_message(RCM_TRACE3, "cli_module_rele(name=%s)\n", module->name);
381 if (--(module->ref_count) != 0) {
386 rcm_log_message(RCM_TRACE2, "unloading module %s\n", module->name);
389 * Unlink the module from list
391 while (curr && (curr != module)) {
397 gettext("Unexpected error: module %s not found.\n"),
398 module->name);
406 module_unload(module);
511 /* Allocate rsrc_client_t structure. Load module if necessary. */
529 client->module = mod;
553 strcmp(modname, client->module->name) == 0) {
566 client->alias, client->module->name, client->pid);
579 client->alias, client->module->name, client->pid);
614 if (client->module) {
615 cli_module_rele(client->module);
640 struct rcm_mod_ops *ops = client->module->modops;
645 client->module->name, cmd, targ->flag);
649 * know if a module uses this handle to callback into rcm_daemon.
651 hdl = rcm_handle_alloc(client->module);
694 * Process the operation via a callback to the client module.
908 targ->seq_num, client->module->name, info, error,
1256 "client not registered: module=%s, pid=%d, dev=%s\n"),
1402 * the filesystem root to avoid infinite recursion on filesystem module.
1404 * N.B. Such request should only come from filesystem RCM module.
1419 * The filesys module should have taken care of
1516 * Get the list of currently loaded module
1566 module_t *module;
1573 /* rcm module */
1581 module = cli_module_hold(entp->d_name);
1582 if (module == NULL) {
1590 if (module->ref_count == MOD_REFCNT_INIT) {
1592 * ask module to register for resource 1st time
1594 module_attach(module);
1596 cli_module_rele(module);
1624 * Hold module by incrementing ref count and release
1777 user->module->name, user->pid, user->alias);
1805 * Allocate handle from calling into each RCM module
1808 rcm_handle_alloc(module_t *module)
1814 hdl->modname = module->name;
1817 hdl->module = module;
1892 /* call a module's getinfo routine; detects v1 ops and adjusts the call */