FreeBSD/sys/kern/imgact_binmisc.c
/*
 * Add the given interpreter if it doesn't already exist.  Return EEXIST
 * if the name already exist in the interpreter list.
 */
Add the given interpreter if it doesn't already exist.  Return EEXIST
if the name already exist in the interpreter list.
Add the given interpreter if it doesn ' t already exist . Return EEXIST if the name already exist in the interpreter list .
static int
imgact_binmisc_add_entry(ximgact_binmisc_entry_t *xbe)
{
	imgact_binmisc_entry_t *ibe;
	char *p;
	int cnt;
	if (xbe->xbe_msize > IBE_MAGIC_MAX)
		return (EINVAL);
	for(cnt = 0, p = xbe->xbe_name; *p != 0; cnt++, p++)
		if (cnt >= IBE_NAME_MAX || !isascii((int)*p))
			return (EINVAL);
	for(cnt = 0, p = xbe->xbe_interpreter; *p != 0; cnt++, p++)
		if (cnt >= IBE_INTERP_LEN_MAX || !isascii((int)*p))
			return (EINVAL);
	p = xbe->xbe_interpreter;
	while (1) {
		p = strchr(p, '#');
		if (!p)
			break;
		p++;
		switch(*p) {
		case ISM_POUND:
			p++;
			break;
		case ISM_OLD_ARGV0:
			p++;
			break;
		case 0:
		default:
			return (EINVAL);
		}
	}
	sx_xlock(&interp_list_sx);
	if (imgact_binmisc_find_entry(xbe->xbe_name) != NULL) {
		sx_xunlock(&interp_list_sx);
		return (EEXIST);
	}
	ibe = imgact_binmisc_new_entry(xbe);
	SLIST_INSERT_HEAD(&interpreter_list, ibe, link);
	interp_list_entry_count++;
	sx_xunlock(&interp_list_sx);
	return (0);
}
static int imgact_binmisc_add_entry ( ximgact_binmisc_entry_t * xbe ) { imgact_binmisc_entry_t * ibe ; char * p ; int cnt ; if ( xbe -> xbe_msize > IBE_MAGIC_MAX ) return ( EINVAL ) ; for ( cnt = 0 , p = xbe -> xbe_name ; * p != 0 ; cnt ++ , p ++ ) if ( cnt >= IBE_NAME_MAX || ! isascii ( ( int ) * p ) ) return ( EINVAL ) ; for ( cnt = 0 , p = xbe -> xbe_interpreter ; * p != 0 ; cnt ++ , p ++ ) if ( cnt >= IBE_INTERP_LEN_MAX || ! isascii ( ( int ) * p ) ) return ( EINVAL ) ; p = xbe -> xbe_interpreter ; while ( 1 ) { p = strchr ( p , ' ' ) ; if ( ! p ) break ; p ++ ; switch ( * p ) { case ISM_POUND : p ++ ; break ; case ISM_OLD_ARGV0 : p ++ ; break ; case 0 : default : return ( EINVAL ) ; } } sx_xlock ( & interp_list_sx ) ; if ( imgact_binmisc_find_entry ( xbe -> xbe_name ) != NULL ) { sx_xunlock ( & interp_list_sx ) ; return ( EEXIST ) ; } ibe = imgact_binmisc_new_entry ( xbe ) ; SLIST_INSERT_HEAD ( & interpreter_list , ibe , link ) ; interp_list_entry_count ++ ; sx_xunlock ( & interp_list_sx ) ; return ( 0 ) ; }
Add the given interpreter if it doesn't already exist.
Add the given interpreter if it doesn ' t already exist .
/* Make sure we don't have any invalid #'s. */ /* "##" */ /* "#a" */ /* Anything besides the above is invalid. */ /* Preallocate a new entry. */