FreeBSD/sys/cam/ctl/ctl.c
/*
 * Returns the match type in the case of a match, or CTL_LUN_PAT_NONE if
 * there is no match.
 */
Returns the match type in the case of a match, or CTL_LUN_PAT_NONE if
there is no match.
Returns the match type in the case of a match or CTL_LUN_PAT_NONE if there is no match .
static ctl_lun_error_pattern
ctl_cmd_pattern_match(struct ctl_scsiio *ctsio, struct ctl_error_desc *desc)
{
	const struct ctl_cmd_entry *entry;
	ctl_lun_error_pattern filtered_pattern, pattern;
	pattern = desc->error_pattern;
	if (pattern & CTL_LUN_PAT_CMD)
		return (CTL_LUN_PAT_CMD);
	if ((pattern & CTL_LUN_PAT_MASK) == CTL_LUN_PAT_ANY)
		return (CTL_LUN_PAT_ANY);
	entry = ctl_get_cmd_entry(ctsio, NULL);
	filtered_pattern = entry->pattern & pattern;
	if ((filtered_pattern & ~CTL_LUN_PAT_MASK) !=
	     (pattern & ~CTL_LUN_PAT_MASK))
		return (CTL_LUN_PAT_NONE);
	if (filtered_pattern & CTL_LUN_PAT_RANGE) {
		uint64_t lba1;
		uint64_t len1;
		ctl_action action;
		int retval;
		retval = ctl_get_lba_len((union ctl_io *)ctsio, &lba1, &len1);
		if (retval != 0)
			return (CTL_LUN_PAT_NONE);
		action = ctl_extent_check_lba(lba1, len1, desc->lba_range.lba,
					      desc->lba_range.len, FALSE);
		if (action == CTL_ACTION_PASS)
			return (CTL_LUN_PAT_NONE);
	}
	return (filtered_pattern);
}
static ctl_lun_error_pattern ctl_cmd_pattern_match ( struct ctl_scsiio * ctsio , struct ctl_error_desc * desc ) { const struct ctl_cmd_entry * entry ; ctl_lun_error_pattern filtered_pattern , pattern ; pattern = desc -> error_pattern ; if ( pattern & CTL_LUN_PAT_CMD ) return ( CTL_LUN_PAT_CMD ) ; if ( ( pattern & CTL_LUN_PAT_MASK ) == CTL_LUN_PAT_ANY ) return ( CTL_LUN_PAT_ANY ) ; entry = ctl_get_cmd_entry ( ctsio , NULL ) ; filtered_pattern = entry -> pattern & pattern ; if ( ( filtered_pattern & ~ CTL_LUN_PAT_MASK ) != ( pattern & ~ CTL_LUN_PAT_MASK ) ) return ( CTL_LUN_PAT_NONE ) ; if ( filtered_pattern & CTL_LUN_PAT_RANGE ) { uint64_t lba1 ; uint64_t len1 ; ctl_action action ; int retval ; retval = ctl_get_lba_len ( ( union ctl_io * ) ctsio , & lba1 , & len1 ) ; if ( retval != 0 ) return ( CTL_LUN_PAT_NONE ) ; action = ctl_extent_check_lba ( lba1 , len1 , desc -> lba_range . lba , desc -> lba_range . len , FALSE ) ; if ( action == CTL_ACTION_PASS ) return ( CTL_LUN_PAT_NONE ) ; } return ( filtered_pattern ) ; }
Returns the match type in the case of a match, or CTL_LUN_PAT_NONE if
 there is no match.
Returns the match type in the case of a match or CTL_LUN_PAT_NONE if there is no match .
/*
	 * XXX KDM we need more data passed into this function to match a
	 * custom pattern, and we actually need to implement custom pattern
	 * matching.
	 */ /*
	 * If the user requested specific flags in the pattern (e.g.
	 * CTL_LUN_PAT_RANGE), make sure the command supports all of those
	 * flags.
	 *
	 * If the user did not specify any flags, it doesn't matter whether
	 * or not the command supports the flags.
	 */ /*
	 * If the user asked for a range check, see if the requested LBA
	 * range overlaps with this command's LBA range.
	 */ /*
		 * A "pass" means that the LBA ranges don't overlap, so
		 * this doesn't match the user's range criteria.
		 */