memcpy(old_hdr.sense_buffer, srp->sense_b, sizeof (old_hdr.sense_buffer)); 
memcpy(old_hdr->sense_buffer, srp->sense_b, sizeof (old_hdr->sense_buffer)); 
sg_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos){	int res;	Sg_device *sdp;	Sg_fd *sfp;	Sg_request *srp;	int req_pack_id = -1;	struct sg_header old_hdr;	sg_io_hdr_t new_hdr;	sg_io_hdr_t *hp;	if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp)))		return -ENXIO;	SCSI_LOG_TIMEOUT(3, printk("sg_read: %s, count=%d\n",				   sdp->disk->disk_name, (int) count));	if (!access_ok(VERIFY_WRITE, buf, count))		return -EFAULT;	if (sfp->force_packid && (count >= SZ_SG_HEADER)) {		if (__copy_from_user(&old_hdr, buf, SZ_SG_HEADER))			return -EFAULT;		if (old_hdr.reply_len < 0) {			if (count >= SZ_SG_IO_HDR) {				if (__copy_from_user				    (&new_hdr, buf, SZ_SG_IO_HDR))					return -EFAULT;				req_pack_id = new_hdr.pack_id;			}		} else			req_pack_id = old_hdr.pack_id;	}	srp = sg_get_rq_mark(sfp, req_pack_id);	if (!srp) {		/* now wait on packet to arrive */		if (sdp->detached)			return -ENODEV;		if (filp->f_flags & O_NONBLOCK)			return -EAGAIN;		while (1) {			res = 0;	/* following is a macro that beats race condition */			__wait_event_interruptible(sfp->read_wait,				(sdp->detached || (srp = sg_get_rq_mark(sfp, req_pack_id))), 						   res);			if (sdp->detached)				return -ENODEV;			if (0 == res)				break;			return res;	/* -ERESTARTSYS because signal hit process */		}	}	if (srp->header.interface_id != '\0')		return sg_new_read(sfp, buf, count, srp);	hp = &srp->header;	memset(&old_hdr, 0, SZ_SG_HEADER);	old_hdr.reply_len = (int) hp->timeout;	old_hdr.pack_len = old_hdr.reply_len; /* very old, strange behaviour */	old_hdr.pack_id = hp->pack_id;	old_hdr.twelve_byte =	    ((srp->data.cmd_opcode >= 0xc0) && (12 == hp->cmd_len)) ? 1 : 0;	old_hdr.target_status = hp->masked_status;	old_hdr.host_status = hp->host_status;	old_hdr.driver_status = hp->driver_status;	if ((CHECK_CONDITION & hp->masked_status) ||	    (DRIVER_SENSE & hp->driver_status))		memcpy(old_hdr.sense_buffer, srp->sense_b,		       sizeof (old_hdr.sense_buffer));	switch (hp->host_status) {	/* This setup of 'result' is for backward compatibility and is best	   ignored by the user who should use target, host + driver status */	case DID_OK:	case DID_PASSTHROUGH:	case DID_SOFT_ERROR:		old_hdr.result = 0;		break;	case DID_NO_CONNECT:	case DID_BUS_BUSY:	case DID_TIME_OUT:		old_hdr.result = EBUSY;		break;	case DID_BAD_TARGET:	case DID_ABORT:	case DID_PARITY:	case DID_RESET:	case DID_BAD_INTR:		old_hdr.result = EIO;		break;	case DID_ERROR:		old_hdr.result = (srp->sense_b[0] == 0 && 				  hp->masked_status == GOOD) ? 0 : EIO;		break;	default:		old_hdr.result = EIO;		break;	}	/* Now copy the result back to the user buffer.  */	if (count >= SZ_SG_HEADER) {		if (__copy_to_user(buf, &old_hdr, SZ_SG_HEADER))			return -EFAULT;		buf += SZ_SG_HEADER;		if (count > old_hdr.reply_len)			count = old_hdr.reply_len;		if (count > SZ_SG_HEADER) {			if ((res =			     sg_read_oxfer(srp, buf, count - SZ_SG_HEADER)))				return -EFAULT;		}	} else		count = (old_hdr.result == 0) ? 0 : -EIO;	sg_finish_rem_req(srp);	return count;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/cb59e840838193957a84ad22f7e1465a06a7c10c/sg.c/clean/drivers/scsi/sg.c