static int nsmb_dev_load(module_t mod, int cmd, void *arg) { int error = 0; switch (cmd) { case MOD_LOAD: error = smb_sm_init(); if (error) break; error = smb_iod_init(); if (error) { smb_sm_done(); break; } cdevsw_add(&nsmb_cdevsw); nsmb_dev_tag = EVENTHANDLER_REGISTER(dev_clone, nsmb_dev_clone, 0, 1000); printf("netsmb_dev: loaded\n"); break; case MOD_UNLOAD: smb_iod_done(); error = smb_sm_done(); error = 0; EVENTHANDLER_DEREGISTER(dev_clone, nsmb_dev_tag); cdevsw_remove(&nsmb_cdevsw); printf("netsmb_dev: unloaded\n"); break; default: error = EINVAL; break; } return error; }
static int nsmb_dev_load(module_t mod, int cmd, void *arg) { int error = 0; switch (cmd) { case MOD_LOAD: error = smb_sm_init(); if (error) break; error = smb_iod_init(); if (error) { smb_sm_done(); break; } clone_setup(&nsmb_clones); nsmb_dev_tag = EVENTHANDLER_REGISTER(dev_clone, nsmb_dev_clone, 0, 1000); break; case MOD_UNLOAD: smb_iod_done(); error = smb_sm_done(); if (error) break; EVENTHANDLER_DEREGISTER(dev_clone, nsmb_dev_tag); drain_dev_clone_events(); clone_cleanup(&nsmb_clones); destroy_dev_drain(&nsmb_cdevsw); break; default: error = EINVAL; break; } return error; }
void netsmbattach(int num) { if (num <= 0) { #ifdef DIAGNOSTIC panic("netsmbattach: cound <= 0"); #endif return; } if (smb_sm_init()) { #ifdef DIAGNOSTIC panic("netsmbattach: smb_sm_init failed"); #endif return; } if (smb_iod_init()) { #ifdef DIAGNOSTIC panic("netsmbattach: smb_iod_init failed"); #endif smb_sm_done(); return; } }
int _init(void) { int error; (void) ddi_soft_state_init(&statep, sizeof (smb_dev_t), 1); /* Can initialize some mutexes also. */ mutex_init(&dev_lck, NULL, MUTEX_DRIVER, NULL); /* * Create a major name and number. */ nsmb_major = ddi_name_to_major(NSMB_NAME); nsmb_minor = 0; /* Connection data structures. */ (void) smb_sm_init(); /* Initialize password Key chain DB. */ smb_pkey_init(); /* Time conversion stuff. */ smb_time_init(); /* Initialize crypto mechanisms. */ smb_crypto_mech_init(); zone_key_create(&nsmb_zone_key, NULL, nsmb_zone_shutdown, nsmb_zone_destroy); /* * Install the module. Do this after other init, * to prevent entrances before we're ready. */ if ((error = mod_install((&nsmb_modlinkage))) != 0) { /* Same as 2nd half of _fini */ (void) zone_key_delete(nsmb_zone_key); smb_pkey_fini(); smb_sm_done(); mutex_destroy(&dev_lck); ddi_soft_state_fini(&statep); return (error); } return (0); }
int _fini(void) { int status; /* * Prevent unload if we have active VCs * or stored passwords */ if ((status = smb_sm_idle()) != 0) return (status); if ((status = smb_pkey_idle()) != 0) return (status); /* * Remove the module. Do this before destroying things, * to prevent new entrances while we're destorying. */ if ((status = mod_remove(&nsmb_modlinkage)) != 0) { return (status); } (void) zone_key_delete(nsmb_zone_key); /* Time conversion stuff. */ smb_time_fini(); /* Destroy password Key chain DB. */ smb_pkey_fini(); smb_sm_done(); mutex_destroy(&dev_lck); ddi_soft_state_fini(&statep); return (status); }