int target = SCpnt->device->id; 
int target = scmd_id(SCpnt); 
int scsi_debug_queuecommand(struct scsi_cmnd * SCpnt, done_funct_t done){	unsigned char *cmd = (unsigned char *) SCpnt->cmnd;	int block, upper_blk, num, k;	int errsts = 0;	int target = SCpnt->device->id;	struct sdebug_dev_info * devip = NULL;	int inj_recovered = 0;	if (done == NULL)		return 0;	/* assume mid level reprocessing command */	if ((SCSI_DEBUG_OPT_NOISE & scsi_debug_opts) && cmd) {		printk(KERN_INFO "scsi_debug: cmd ");		for (k = 0, num = SCpnt->cmd_len; k < num; ++k)			printk("%02x ", (int)cmd[k]);		printk("\n");	}        if(target == sdebug_driver_template.this_id) {		printk(KERN_INFO "scsi_debug: initiator's id used as "		       "target!\n");		return schedule_resp(SCpnt, NULL, done,				     DID_NO_CONNECT << 16, 0);        }	if (SCpnt->device->lun >= scsi_debug_max_luns)		return schedule_resp(SCpnt, NULL, done,				     DID_NO_CONNECT << 16, 0);	devip = devInfoReg(SCpnt->device);	if (NULL == devip)		return schedule_resp(SCpnt, NULL, done,				     DID_NO_CONNECT << 16, 0);        if ((scsi_debug_every_nth != 0) &&            (++scsi_debug_cmnd_count >= abs(scsi_debug_every_nth))) {                scsi_debug_cmnd_count = 0;		if (scsi_debug_every_nth < -1)			scsi_debug_every_nth = -1;		if (SCSI_DEBUG_OPT_TIMEOUT & scsi_debug_opts)			return 0; /* ignore command causing timeout */		else if (SCSI_DEBUG_OPT_RECOVERED_ERR & scsi_debug_opts)			inj_recovered = 1; /* to reads and writes below */        }	switch (*cmd) {	case INQUIRY:     /* mandatory, ignore unit attention */		errsts = resp_inquiry(SCpnt, target, devip);		break;	case REQUEST_SENSE:	/* mandatory, ignore unit attention */		errsts = resp_requests(SCpnt, devip);		break;	case REZERO_UNIT:	/* actually this is REWIND for SSC */	case START_STOP:		errsts = check_reset(SCpnt, devip);		break;	case ALLOW_MEDIUM_REMOVAL:		if ((errsts = check_reset(SCpnt, devip)))			break;		if (SCSI_DEBUG_OPT_NOISE & scsi_debug_opts)			printk(KERN_INFO "scsi_debug: Medium removal %s\n",			        cmd[4] ? "inhibited" : "enabled");		break;	case SEND_DIAGNOSTIC:     /* mandatory */		errsts = check_reset(SCpnt, devip);		break;	case TEST_UNIT_READY:     /* mandatory */		errsts = check_reset(SCpnt, devip);		break;        case RESERVE:		errsts = check_reset(SCpnt, devip);                break;        case RESERVE_10:		errsts = check_reset(SCpnt, devip);                break;        case RELEASE:		errsts = check_reset(SCpnt, devip);                break;        case RELEASE_10:		errsts = check_reset(SCpnt, devip);                break;	case READ_CAPACITY:		errsts = resp_readcap(SCpnt, devip);		break;	case READ_16:	case READ_12:	case READ_10:	case READ_6:		if ((errsts = check_reset(SCpnt, devip)))			break;		upper_blk = 0;		if ((*cmd) == READ_16) {			upper_blk = cmd[5] + (cmd[4] << 8) +				    (cmd[3] << 16) + (cmd[2] << 24);			block = cmd[9] + (cmd[8] << 8) +				(cmd[7] << 16) + (cmd[6] << 24);			num = cmd[13] + (cmd[12] << 8) +				(cmd[11] << 16) + (cmd[10] << 24);		} else if ((*cmd) == READ_12) {			block = cmd[5] + (cmd[4] << 8) +				(cmd[3] << 16) + (cmd[2] << 24);			num = cmd[9] + (cmd[8] << 8) +				(cmd[7] << 16) + (cmd[6] << 24);		} else if ((*cmd) == READ_10) {			block = cmd[5] + (cmd[4] << 8) +				(cmd[3] << 16) + (cmd[2] << 24);			num = cmd[8] + (cmd[7] << 8);		} else {			block = cmd[3] + (cmd[2] << 8) +				((cmd[1] & 0x1f) << 16);			num = cmd[4];		}		errsts = resp_read(SCpnt, upper_blk, block, num, devip);		if (inj_recovered && (0 == errsts)) {			mk_sense_buffer(devip, RECOVERED_ERROR,					THRESHHOLD_EXCEEDED, 0);			errsts = check_condition_result;		}		break;	case REPORT_LUNS:	/* mandatory, ignore unit attention */		errsts = resp_report_luns(SCpnt, devip);		break;	case VERIFY:		/* 10 byte SBC-2 command */		errsts = check_reset(SCpnt, devip);		break;	case WRITE_16:	case WRITE_12:	case WRITE_10:	case WRITE_6:		if ((errsts = check_reset(SCpnt, devip)))			break;		upper_blk = 0;		if ((*cmd) == WRITE_16) {			upper_blk = cmd[5] + (cmd[4] << 8) +				    (cmd[3] << 16) + (cmd[2] << 24);			block = cmd[9] + (cmd[8] << 8) +				(cmd[7] << 16) + (cmd[6] << 24);			num = cmd[13] + (cmd[12] << 8) +				(cmd[11] << 16) + (cmd[10] << 24);		} else if ((*cmd) == WRITE_12) {			block = cmd[5] + (cmd[4] << 8) +				(cmd[3] << 16) + (cmd[2] << 24);			num = cmd[9] + (cmd[8] << 8) +				(cmd[7] << 16) + (cmd[6] << 24);		} else if ((*cmd) == WRITE_10) {			block = cmd[5] + (cmd[4] << 8) +				(cmd[3] << 16) + (cmd[2] << 24);			num = cmd[8] + (cmd[7] << 8);		} else {			block = cmd[3] + (cmd[2] << 8) +				((cmd[1] & 0x1f) << 16);			num = cmd[4];		}		errsts = resp_write(SCpnt, upper_blk, block, num, devip);		if (inj_recovered && (0 == errsts)) {			mk_sense_buffer(devip, RECOVERED_ERROR,					THRESHHOLD_EXCEEDED, 0);			errsts = check_condition_result;		}		break;	case MODE_SENSE:	case MODE_SENSE_10:		errsts = resp_mode_sense(SCpnt, target, devip);		break;	case SYNCHRONIZE_CACHE:		errsts = check_reset(SCpnt, devip);		break;	default:		if (SCSI_DEBUG_OPT_NOISE & scsi_debug_opts)			printk(KERN_INFO "scsi_debug: Opcode: 0x%x not "			       "supported\n", *cmd);		if ((errsts = check_reset(SCpnt, devip)))			break;	/* Unit attention takes precedence */		mk_sense_buffer(devip, ILLEGAL_REQUEST, INVALID_OPCODE, 0);		errsts = check_condition_result;		break;	}	return schedule_resp(SCpnt, devip, done, errsts, scsi_debug_delay);}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/422c0d61d591cbfb70f029e13505fb437e169d68/scsi_debug.c/buggy/drivers/scsi/scsi_debug.c