/*
 * rootfnnodep is allocated here.  Its sole purpose is to provide
 * read/write locking for top level fnnodes.  This object is
 * persistent and will not be deallocated until the zone is destroyed.
 *
 * The current zone is implied as the zone of interest, since we will be
 * calling zthread_create() which must be called from the correct zone.
 */
struct autofs_globals *
autofs_zone_init(void)
{
	char rootname[sizeof ("root_fnnode_zone_") + ZONEID_WIDTH];
	struct autofs_globals *fngp;
	zoneid_t zoneid = getzoneid();

	fngp = kmem_zalloc(sizeof (*fngp), KM_SLEEP);
	(void) snprintf(rootname, sizeof (rootname), "root_fnnode_zone_%d",
	    zoneid);
	fngp->fng_rootfnnodep = auto_makefnnode(VNON, NULL, rootname, CRED(),
	    fngp);
	/*
	 * Don't need to hold fng_rootfnnodep as it's never really used for
	 * anything.
	 */
	fngp->fng_fnnode_count = 1;
	fngp->fng_printed_not_running_msg = 0;
	fngp->fng_zoneid = zoneid;
	mutex_init(&fngp->fng_unmount_threads_lock, NULL, MUTEX_DEFAULT,
	    NULL);
	fngp->fng_unmount_threads = 0;

	mutex_init(&fngp->fng_autofs_daemon_lock, NULL, MUTEX_DEFAULT, NULL);

	/*
	 * Start the unmounter thread for this zone.
	 */
	(void) zthread_create(NULL, 0, auto_do_unmount, fngp, 0, minclsyspri);
	return (fngp);
}
Beispiel #2
0
void
nfsauth_init(void)
{
	/*
	 * mountd can be restarted by smf(5). We need to make sure
	 * the updated door handle will safely make it to mountd_dh
	 */
	mutex_init(&mountd_lock, NULL, MUTEX_DEFAULT, NULL);

	mutex_init(&refreshq_lock, NULL, MUTEX_DEFAULT, NULL);
	list_create(&refreshq_queue, sizeof (refreshq_exi_node_t),
	    offsetof(refreshq_exi_node_t, ren_node));

	cv_init(&refreshq_cv, NULL, CV_DEFAULT, NULL);

	/*
	 * Allocate nfsauth cache handle
	 */
	exi_cache_handle = kmem_cache_create("exi_cache_handle",
	    sizeof (struct auth_cache), 0, NULL, NULL,
	    exi_cache_reclaim, NULL, NULL, 0);

	refreshq_thread_state = REFRESHQ_THREAD_RUNNING;
	(void) zthread_create(NULL, 0, nfsauth_refresh_thread,
	    NULL, 0, minclsyspri);
}
Beispiel #3
0
void ztst_thrctl(){
  int i = 0;
  zthr_id_t id;
  zthr_t attr;
  sprintf(attr.name, "thr[0]");
  ZDBG("testing ztst_thrctl()...");
  zthread_create(&id, zproc_thr1, (void*)&attr);
  // main loop
  for(i=0; i< 10; i++){
    ZDBG("main loop %d...", i);
    zsleepms(500);
  }
  // cancel thread
  zthread_cancel(&id);
  zthread_join(&id);
}