FreeBSD/sys/cam/ctl/ctl.c
/*
 * SCSI VPD page 0x80, the Unit Serial Number page.
 */
SCSI VPD page 0x80, the Unit Serial Number page.
SCSI VPD page 0x80 the Unit Serial Number page .
static int
ctl_inquiry_evpd_serial(struct ctl_scsiio *ctsio, int alloc_len)
{
	struct scsi_vpd_unit_serial_number *sn_ptr;
	struct ctl_lun *lun;
	int data_len;
	lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr;
	data_len = 4 + CTL_SN_LEN;
	ctsio->kern_data_ptr = malloc(data_len, M_CTL, M_WAITOK | M_ZERO);
	sn_ptr = (struct scsi_vpd_unit_serial_number *)ctsio->kern_data_ptr;
	if (data_len < alloc_len) {
		ctsio->residual = alloc_len - data_len;
		ctsio->kern_data_len = data_len;
		ctsio->kern_total_len = data_len;
	} else {
		ctsio->residual = 0;
		ctsio->kern_data_len = alloc_len;
		ctsio->kern_total_len = alloc_len;
	}
	ctsio->kern_data_resid = 0;
	ctsio->kern_rel_offset = 0;
	ctsio->kern_sg_entries = 0;
	if (lun != NULL)
		sn_ptr->device = (SID_QUAL_LU_CONNECTED << 5) |
				  lun->be_lun->lun_type;
	else
		sn_ptr->device = (SID_QUAL_LU_OFFLINE << 5) | T_DIRECT;
	sn_ptr->page_code = SVPD_UNIT_SERIAL_NUMBER;
	sn_ptr->length = CTL_SN_LEN;
	if (lun != NULL) {
		strncpy((char *)sn_ptr->serial_num,
			(char *)lun->be_lun->serial_num, CTL_SN_LEN);
	} else
		memset(sn_ptr->serial_num, 0x20, CTL_SN_LEN);
	ctl_set_success(ctsio);
	ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED;
	ctsio->be_move_done = ctl_config_move_done;
	ctl_datamove((union ctl_io *)ctsio);
	return (CTL_RETVAL_COMPLETE);
}
static int ctl_inquiry_evpd_serial ( struct ctl_scsiio * ctsio , int alloc_len ) { struct scsi_vpd_unit_serial_number * sn_ptr ; struct ctl_lun * lun ; int data_len ; lun = ( struct ctl_lun * ) ctsio -> io_hdr . ctl_private [ CTL_PRIV_LUN ] . ptr ; data_len = 4 + CTL_SN_LEN ; ctsio -> kern_data_ptr = malloc ( data_len , M_CTL , M_WAITOK | M_ZERO ) ; sn_ptr = ( struct scsi_vpd_unit_serial_number * ) ctsio -> kern_data_ptr ; if ( data_len < alloc_len ) { ctsio -> residual = alloc_len - data_len ; ctsio -> kern_data_len = data_len ; ctsio -> kern_total_len = data_len ; } else { ctsio -> residual = 0 ; ctsio -> kern_data_len = alloc_len ; ctsio -> kern_total_len = alloc_len ; } ctsio -> kern_data_resid = 0 ; ctsio -> kern_rel_offset = 0 ; ctsio -> kern_sg_entries = 0 ; if ( lun != NULL ) sn_ptr -> device = ( SID_QUAL_LU_CONNECTED << 5 ) | lun -> be_lun -> lun_type ; else sn_ptr -> device = ( SID_QUAL_LU_OFFLINE << 5 ) | T_DIRECT ; sn_ptr -> page_code = SVPD_UNIT_SERIAL_NUMBER ; sn_ptr -> length = CTL_SN_LEN ; if ( lun != NULL ) { strncpy ( ( char * ) sn_ptr -> serial_num , ( char * ) lun -> be_lun -> serial_num , CTL_SN_LEN ) ; } else memset ( sn_ptr -> serial_num , 0x20 , CTL_SN_LEN ) ; ctl_set_success ( ctsio ) ; ctsio -> io_hdr . flags |= CTL_FLAG_ALLOCATED ; ctsio -> be_move_done = ctl_config_move_done ; ctl_datamove ( ( union ctl_io * ) ctsio ) ; return ( CTL_RETVAL_COMPLETE ) ; }
SCSI VPD page 0x80, the Unit Serial Number page.
SCSI VPD page 0x80 the Unit Serial Number page .
/*
	 * The control device is always connected.  The disk device, on the
	 * other hand, may not be online all the time.  Need to change this
	 * to figure out whether the disk device is actually online or not.
	 */ /*
	 * If we don't have a LUN, we just leave the serial number as
	 * all spaces.
	 */