FreeBSD/sys/kern/imgact_binmisc.c
/*
 * sysctl() handler for munipulating interpretor table.
 * Not MP safe (locked by sysctl).
 */
sysctl() handler for munipulating interpretor table.
Not MP safe (locked by sysctl).
sysctl () handler for munipulating interpretor table . Not MP safe ( locked by sysctl ) .
static int
sysctl_kern_binmisc(SYSCTL_HANDLER_ARGS)
{
	ximgact_binmisc_entry_t xbe;
	int error = 0;
	switch(arg2) {
	case IBC_ADD:
		error = SYSCTL_IN(req, &xbe, sizeof(xbe));
		if (error)
			return (error);
		if (IBE_VERSION != xbe.xbe_version)
			return (EINVAL);
		if (interp_list_entry_count == IBE_MAX_ENTRIES)
			return (ENOSPC);
		error = imgact_binmisc_add_entry(&xbe);
		break;
	case IBC_REMOVE:
		error = SYSCTL_IN(req, &xbe, sizeof(xbe));
		if (error)
			return (error);
		if (IBE_VERSION != xbe.xbe_version)
			return (EINVAL);
		error = imgact_binmisc_remove_entry(xbe.xbe_name);
		break;
	case IBC_DISABLE:
		error = SYSCTL_IN(req, &xbe, sizeof(xbe));
		if (error)
			return (error);
		if (IBE_VERSION != xbe.xbe_version)
			return (EINVAL);
		error = imgact_binmisc_disable_entry(xbe.xbe_name);
		break;
	case IBC_ENABLE:
		error = SYSCTL_IN(req, &xbe, sizeof(xbe));
		if (error)
			return (error);
		if (IBE_VERSION != xbe.xbe_version)
			return (EINVAL);
		error = imgact_binmisc_enable_entry(xbe.xbe_name);
		break;
	case IBC_LOOKUP:
		error = SYSCTL_IN(req, &xbe, sizeof(xbe));
		if (error)
			return (error);
		if (IBE_VERSION != xbe.xbe_version)
			return (EINVAL);
		error = imgact_binmisc_lookup_entry(xbe.xbe_name, &xbe);
		if (!error)
			error = SYSCTL_OUT(req, &xbe, sizeof(xbe));
		break;
	case IBC_LIST:
		if (!req->oldptr) {
			error = SYSCTL_OUT(req, 0, interp_list_entry_count *
			    sizeof(ximgact_binmisc_entry_t));
			return (error);
		} else
			if (!req->oldlen)
				return (EINVAL);
		error = imgact_binmisc_get_all_entries(req);
		break;
	default:
		return (EINVAL);
	}
	return (error);
}
static int sysctl_kern_binmisc ( SYSCTL_HANDLER_ARGS ) { ximgact_binmisc_entry_t xbe ; int error = 0 ; switch ( arg2 ) { case IBC_ADD : error = SYSCTL_IN ( req , & xbe , sizeof ( xbe ) ) ; if ( error ) return ( error ) ; if ( IBE_VERSION != xbe . xbe_version ) return ( EINVAL ) ; if ( interp_list_entry_count == IBE_MAX_ENTRIES ) return ( ENOSPC ) ; error = imgact_binmisc_add_entry ( & xbe ) ; break ; case IBC_REMOVE : error = SYSCTL_IN ( req , & xbe , sizeof ( xbe ) ) ; if ( error ) return ( error ) ; if ( IBE_VERSION != xbe . xbe_version ) return ( EINVAL ) ; error = imgact_binmisc_remove_entry ( xbe . xbe_name ) ; break ; case IBC_DISABLE : error = SYSCTL_IN ( req , & xbe , sizeof ( xbe ) ) ; if ( error ) return ( error ) ; if ( IBE_VERSION != xbe . xbe_version ) return ( EINVAL ) ; error = imgact_binmisc_disable_entry ( xbe . xbe_name ) ; break ; case IBC_ENABLE : error = SYSCTL_IN ( req , & xbe , sizeof ( xbe ) ) ; if ( error ) return ( error ) ; if ( IBE_VERSION != xbe . xbe_version ) return ( EINVAL ) ; error = imgact_binmisc_enable_entry ( xbe . xbe_name ) ; break ; case IBC_LOOKUP : error = SYSCTL_IN ( req , & xbe , sizeof ( xbe ) ) ; if ( error ) return ( error ) ; if ( IBE_VERSION != xbe . xbe_version ) return ( EINVAL ) ; error = imgact_binmisc_lookup_entry ( xbe . xbe_name , & xbe ) ; if ( ! error ) error = SYSCTL_OUT ( req , & xbe , sizeof ( xbe ) ) ; break ; case IBC_LIST : if ( ! req -> oldptr ) { error = SYSCTL_OUT ( req , 0 , interp_list_entry_count * sizeof ( ximgact_binmisc_entry_t ) ) ; return ( error ) ; } else if ( ! req -> oldlen ) return ( EINVAL ) ; error = imgact_binmisc_get_all_entries ( req ) ; break ; default : return ( EINVAL ) ; } return ( error ) ; }
sysctl() handler for munipulating interpretor table.
sysctl () handler for munipulating interpretor table .
/* Add an entry. Limited to IBE_MAX_ENTRIES. */ /* Remove an entry. */ /* Disable an entry. */ /* Enable an entry. */ /* Lookup an entry. */ /* Return a snapshot of the interpretor list. */ /* No pointer then just return the list size. */