FreeBSD/sys/cam/cam_xpt.c
/*
 * Match a single peripheral against any number of match patterns.
 */
Match a single peripheral against any number of match patterns.
Match a single peripheral against any number of match patterns .
static dev_match_ret
xptperiphmatch(struct dev_match_pattern *patterns, u_int num_patterns,
	       struct cam_periph *periph)
{
	dev_match_ret retval;
	u_int i;
	if (periph == NULL)
		return(DM_RET_ERROR);
	if ((patterns == NULL) || (num_patterns == 0))
		return(DM_RET_STOP | DM_RET_COPY);
	retval = DM_RET_STOP;
	for (i = 0; i < num_patterns; i++) {
		struct periph_match_pattern *cur_pattern;
		if (patterns[i].type != DEV_MATCH_PERIPH)
			continue;
		cur_pattern = &patterns[i].pattern.periph_pattern;
		if (cur_pattern->flags == PERIPH_MATCH_ANY) {
			retval |= DM_RET_COPY;
			return(retval);
		}
		if (cur_pattern->flags == PERIPH_MATCH_NONE)
			continue;
		if (((cur_pattern->flags & PERIPH_MATCH_PATH) != 0)
		 && (cur_pattern->path_id != periph->path->bus->path_id))
			continue;
		if (((cur_pattern->flags & PERIPH_MATCH_TARGET) != 0)
		 && ((periph->path->target == NULL)
		 ||(cur_pattern->target_id != periph->path->target->target_id)))
			continue;
		if (((cur_pattern->flags & PERIPH_MATCH_LUN) != 0)
		 && ((periph->path->device == NULL)
		 || (cur_pattern->target_lun != periph->path->device->lun_id)))
			continue;
		if (((cur_pattern->flags & PERIPH_MATCH_UNIT) != 0)
		 && (cur_pattern->unit_number != periph->unit_number))
			continue;
		if (((cur_pattern->flags & PERIPH_MATCH_NAME) != 0)
		 && (strncmp(cur_pattern->periph_name, periph->periph_name,
			     DEV_IDLEN) != 0))
			continue;
		retval |= DM_RET_COPY;
		return(retval);
	}
	return(retval);
}
static dev_match_ret xptperiphmatch ( struct dev_match_pattern * patterns , u_int num_patterns , struct cam_periph * periph ) { dev_match_ret retval ; u_int i ; if ( periph == NULL ) return ( DM_RET_ERROR ) ; if ( ( patterns == NULL ) || ( num_patterns == 0 ) ) return ( DM_RET_STOP | DM_RET_COPY ) ; retval = DM_RET_STOP ; for ( i = 0 ; i < num_patterns ; i ++ ) { struct periph_match_pattern * cur_pattern ; if ( patterns [ i ] . type != DEV_MATCH_PERIPH ) continue ; cur_pattern = & patterns [ i ] . pattern . periph_pattern ; if ( cur_pattern -> flags == PERIPH_MATCH_ANY ) { retval |= DM_RET_COPY ; return ( retval ) ; } if ( cur_pattern -> flags == PERIPH_MATCH_NONE ) continue ; if ( ( ( cur_pattern -> flags & PERIPH_MATCH_PATH ) != 0 ) && ( cur_pattern -> path_id != periph -> path -> bus -> path_id ) ) continue ; if ( ( ( cur_pattern -> flags & PERIPH_MATCH_TARGET ) != 0 ) && ( ( periph -> path -> target == NULL ) || ( cur_pattern -> target_id != periph -> path -> target -> target_id ) ) ) continue ; if ( ( ( cur_pattern -> flags & PERIPH_MATCH_LUN ) != 0 ) && ( ( periph -> path -> device == NULL ) || ( cur_pattern -> target_lun != periph -> path -> device -> lun_id ) ) ) continue ; if ( ( ( cur_pattern -> flags & PERIPH_MATCH_UNIT ) != 0 ) && ( cur_pattern -> unit_number != periph -> unit_number ) ) continue ; if ( ( ( cur_pattern -> flags & PERIPH_MATCH_NAME ) != 0 ) && ( strncmp ( cur_pattern -> periph_name , periph -> periph_name , DEV_IDLEN ) != 0 ) ) continue ; retval |= DM_RET_COPY ; return ( retval ) ; } return ( retval ) ; }
Match a single peripheral against any number of match patterns.
Match a single peripheral against any number of match patterns .
/*
	 * If we aren't given something to match against, that's an error.
	 */ /*
	 * If there are no match entries, then this peripheral matches no
	 * matter what.
	 */ /*
	 * There aren't any nodes below a peripheral node, so there's no
	 * reason to descend the tree any further.
	 */ /*
		 * If the pattern in question isn't for a peripheral, we
		 * aren't interested.
		 */ /*
		 * If they want to match on anything, then we will do so.
		 */ /* set the copy flag */ /*
			 * We've already set the return action to stop,
			 * since there are no nodes below peripherals in
			 * the tree.
			 */ /*
		 * Not sure why someone would do this...
		 */ /*
		 * For the target and lun id's, we have to make sure the
		 * target and lun pointers aren't NULL.  The xpt peripheral
		 * has a wildcard target and device.
		 */ /*
		 * If we get to this point, the user definitely wants
		 * information on this peripheral.  So tell the caller to
		 * copy the data out.
		 */ /*
		 * The return action has already been set to stop, since
		 * peripherals don't have any nodes below them in the EDT.
		 */ /*
	 * If we get to this point, the peripheral that was passed in
	 * doesn't match any of the patterns.
	 */