FreeBSD/sbin/mdconfig/mdconfig.c
/*
 * List is comma separated list of MD disks. name is a
 * device name we look for.  Returns 1 if found and 0
 * otherwise.
 */
List is comma separated list of MD disks. name is a
device name we look for.  Returns 1 if found and 0
otherwise.
List is comma separated list of MD disks . name is a device name we look for . Returns 1 if found and 0 otherwise .
static int
md_find(const char *list, const char *name)
{
	int ret;
	char num[PATH_MAX];
	char *ptr, *p, *u;
	ret = 0;
	ptr = strdup(list);
	if (ptr == NULL)
		return (-1);
	for (p = ptr; (u = strsep(&p, ",")) != NULL;) {
		if (strncmp(u, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0)
			u += sizeof(_PATH_DEV) - 1;
		snprintf(num, sizeof(num), "%s%s", MD_NAME, u);
		if (strcmp(u, name) == 0 || strcmp(num, name) == 0) {
			ret = 1;
			break;
		}
	}
	free(ptr);
	return (ret);
}
static int md_find ( const char * list , const char * name ) { int ret ; char num [ PATH_MAX ] ; char * ptr , * p , * u ; ret = 0 ; ptr = strdup ( list ) ; if ( ptr == NULL ) return ( -1 ) ; for ( p = ptr ; ( u = strsep ( & p , " " ) ) != NULL ; ) { if ( strncmp ( u , _PATH_DEV , sizeof ( _PATH_DEV ) - 1 ) == 0 ) u += sizeof ( _PATH_DEV ) - 1 ; snprintf ( num , sizeof ( num ) , " " , MD_NAME , u ) ; if ( strcmp ( u , name ) == 0 || strcmp ( num , name ) == 0 ) { ret = 1 ; break ; } } free ( ptr ) ; return ( ret ) ; }
List is comma separated list of MD disks.
List is comma separated list of MD disks .
/* Just in case user specified number instead of full name */