Beispiel #1
0
static int
ippctl_action_create(
	char		*modname,
	char		*aname,
	nvlist_t	*nvlp,
	ipp_flags_t	flags)
{
	int		ipp_rc;
	int		rc;
	ipp_mod_id_t	mid;
	ipp_action_id_t	aid;

	/*
	 * Look up the module id from the name and create the new
	 * action.
	 */

	mid = ipp_mod_lookup(modname);
	FREE_TEXT(modname);

	ipp_rc = ipp_action_create(mid, aname, &nvlp, flags, &aid);
	FREE_TEXT(aname);

	/*
	 * Add an nvlist containing the kernel return code to the
	 * set of nvlists to pass back to libipp.
	 */

	if ((rc = ippctl_set_rc(ipp_rc)) != 0) {
		if (nvlp != NULL) {
			nvlist_free(nvlp);
			if (ipp_action_destroy(aid, 0) != 0) {
				cmn_err(CE_PANIC,
				    "ippctl: unrecoverable error (aid = %d)",
				    aid);
				/*NOTREACHED*/
			}
		}
		return (rc);
	}

	/*
	 * If the module passed back an nvlist, add this as
	 * well.
	 */

	if (nvlp != NULL) {
		rc = ippctl_callback(nvlp, NULL);
		nvlist_free(nvlp);
	} else
		rc = 0;

	return (rc);
}
Beispiel #2
0
/*ARGSUSED*/
static int
mod_infoipp(struct modlipp *modl, struct modlinkage *modlp, int *p0)
{
	struct modctl *mcp = mod_getctl(modlp);
	ipp_mod_id_t mid;

	if (mcp == NULL) {
		*p0 = -1;
		return (0);	/* module is not yet installed */
	}

	mid = ipp_mod_lookup(mcp->mod_modname);

	*p0 = mid;
	return (0);
}
Beispiel #3
0
/*ARGSUSED*/
static int
mod_removeipp(struct modlipp *modl, struct modlinkage *modlp)
{
	struct modctl *mcp = mod_getctl(modlp);
	extern kthread_id_t mod_aul_thread;
	ipp_mod_id_t mid;

	ASSERT(mcp != NULL);

	if ((moddebug & MODDEBUG_NOAUL_IPP) && (mod_aul_thread == curthread))
		return (EBUSY);

	mid = ipp_mod_lookup(mcp->mod_modname);
	ASSERT(mid != IPP_MOD_INVAL);

	return (ipp_mod_unregister(mid));
}
Beispiel #4
0
static int
ippctl_mod_list_actions(
	char		*modname)
{
	ipp_mod_id_t	mid;
	nvlist_t	*nvlp;
	int		ipp_rc;
	int		rc = 0;
	ipp_action_id_t	*aid_array;
	char		**aname_array = NULL;
	int		nelt;
	int		length;
	int		i;

	/*
	 * Get the module id.
	 */

	mid = ipp_mod_lookup(modname);
	FREE_TEXT(modname);

	/*
	 * Get a list of all the action ids for the module. If that succeeds,
	 * translate the ids into names.
	 *
	 * NOTE: This translation may fail if an action is
	 * destroyed during this operation. If this occurs, EAGAIN
	 * will be passed back to libipp note that a transient
	 * problem occured.
	 */

	if ((ipp_rc = ipp_mod_list_actions(mid, &aid_array, &nelt)) == 0) {

		/*
		 * It is possible that there are no actions defined.
		 * (This is unlikely though as the module would normally
		 * be auto-unloaded fairly quickly)
		 */

		if (nelt > 0) {
			length = nelt * sizeof (char *);
			aname_array = kmem_zalloc(length, KM_SLEEP);

			for (i = 0; i < nelt; i++) {
				if (ipp_action_name(aid_array[i],
				    &aname_array[i]) != 0) {
					kmem_free(aid_array, nelt *
					    sizeof (ipp_action_id_t));
					FREE_TEXT_ARRAY(aname_array, nelt);
					ipp_rc = EAGAIN;
					goto done;
				}
			}

			kmem_free(aid_array, nelt * sizeof (ipp_action_id_t));

			if ((rc = nvlist_alloc(&nvlp, NV_UNIQUE_NAME,
			    KM_SLEEP)) != 0) {
				FREE_TEXT_ARRAY(aname_array, nelt);
				return (rc);
			}

			if ((rc = ippctl_attach_aname_array(nvlp, aname_array,
			    nelt)) != 0) {
				FREE_TEXT_ARRAY(aname_array, nelt);
				nvlist_free(nvlp);
				return (rc);
			}

			FREE_TEXT_ARRAY(aname_array, nelt);

			if ((rc = ippctl_callback(nvlp, NULL)) != 0) {
				nvlist_free(nvlp);
				return (rc);
			}

			nvlist_free(nvlp);
		}
	}

done:
	/*
	 * Add an nvlist containing the kernel return code to the
	 * set of nvlists to pass back to libipp.
	 */

	if ((rc = ippctl_set_rc(ipp_rc)) != 0)
		return (rc);

	return (0);
}