user/scsi.c
/*XXX should keep track of free blocks here */
XXX should keep track of free blocks here
XXX should keep track of free blocks here
static void
mmc_read_track_information(target_data_t *td, lun_data_t *ld, unsigned char *cdb, unsigned char *data, int *data_size, unsigned char *status)
{
	unsigned char address;
	unsigned short alloc_len;
	unsigned long lba;
	off_t total_size;
	long blocks;
	address=cdb[1]&0x03;
	lba=ntohl( *((long *)(cdb+2)) );
	alloc_len=ntohs( *((short *)(cdb+7)) );
if((address!=1)||(!lba)){
*status=2;return;
}
	memset(data, 0, alloc_len);
	switch(ld->current_profile){
	case 0x0011:	
		data[0]=0x00;		
		data[1]=0x22;
		data[2]=0x01;		
		data[32]=0x00;		
		data[3]=0x01;		
		data[33]=0x00;
		data[4]=0x00;		
		data[5]=0x04;		
		data[6]=0x61;
		data[7]=0x03;
		data[8]=0x00;		
		data[9]=0x00;		
		data[10]=0x00;		
		data[11]=0x00;		
		data[12]=0x00;		
		data[13]=0x00;		
		data[14]=0x00;		
		data[15]=0x00;		
		data[16]=0x00;		
		data[17]=0x23;		
		data[18]=0x10;		
		data[19]=0x20;		
		data[20]=0x00;		
		data[21]=0x00;		
		data[22]=0x00;		
		data[23]=0x10;		
		data[24]=0x00;		
		data[25]=0x23;		
		data[26]=0x10;		
		data[27]=0x20;		
		data[28]=0x00;
		data[29]=0x00;
		data[30]=0x00;
		data[31]=0x00;
		break;
	case 0x0010:	
		data[0]=0x00;		
		data[1]=0x22;
		data[2]=0x01;		
		data[32]=0x00;		
		data[3]=0x01;		
		data[33]=0x00;
		data[4]=0x00;		
		data[5]=0x04;		
		data[6]=0x01;
		data[7]=0x00;
		data[8]=0x00;		
		data[9]=0x00;		
		data[10]=0x00;		
		data[11]=0x00;		
		data[12]=0x00;		
		data[13]=0x00;		
		data[14]=0x00;		
		data[15]=0x00;		
		data[16]=0x00;		
		data[17]=0x00;		
		data[18]=0x00;		
		data[19]=0x00;		
		data[20]=0x00;		
		data[21]=0x00;		
		data[22]=0x00;		
		data[23]=0x10;		
		total_size=ftello(ld->lun_fh);
		blocks=total_size/ld->block_size;
		if((total_size/ld->block_size)!=blocks){
			blocks--; 
		}
		data[24]=(blocks>>24)&0xff;
		data[25]=(blocks>>16)&0xff;
		data[26]=(blocks>> 8)&0xff;
		data[27]=(blocks    )&0xff;
		data[28]=0x00;
		data[29]=0x00;
		data[30]=0x00;
		data[31]=0x00;
		break;
	}
	*data_size=alloc_len;
	*status=0;
}
static void mmc_read_track_information ( target_data_t * td , lun_data_t * ld , unsigned char * cdb , unsigned char * data , int * data_size , unsigned char * status ) { unsigned char address ; unsigned short alloc_len ; unsigned long lba ; off_t total_size ; long blocks ; address = cdb [ 1 ] & 0x03 ; lba = ntohl ( * ( ( long * ) ( cdb + 2 ) ) ) ; alloc_len = ntohs ( * ( ( short * ) ( cdb + 7 ) ) ) ; if ( ( address != 1 ) || ( ! lba ) ) { * status = 2 ; return ; } memset ( data , 0 , alloc_len ) ; switch ( ld -> current_profile ) { case 0x0011 : data [ 0 ] = 0x00 ; data [ 1 ] = 0x22 ; data [ 2 ] = 0x01 ; data [ 32 ] = 0x00 ; data [ 3 ] = 0x01 ; data [ 33 ] = 0x00 ; data [ 4 ] = 0x00 ; data [ 5 ] = 0x04 ; data [ 6 ] = 0x61 ; data [ 7 ] = 0x03 ; data [ 8 ] = 0x00 ; data [ 9 ] = 0x00 ; data [ 10 ] = 0x00 ; data [ 11 ] = 0x00 ; data [ 12 ] = 0x00 ; data [ 13 ] = 0x00 ; data [ 14 ] = 0x00 ; data [ 15 ] = 0x00 ; data [ 16 ] = 0x00 ; data [ 17 ] = 0x23 ; data [ 18 ] = 0x10 ; data [ 19 ] = 0x20 ; data [ 20 ] = 0x00 ; data [ 21 ] = 0x00 ; data [ 22 ] = 0x00 ; data [ 23 ] = 0x10 ; data [ 24 ] = 0x00 ; data [ 25 ] = 0x23 ; data [ 26 ] = 0x10 ; data [ 27 ] = 0x20 ; data [ 28 ] = 0x00 ; data [ 29 ] = 0x00 ; data [ 30 ] = 0x00 ; data [ 31 ] = 0x00 ; break ; case 0x0010 : data [ 0 ] = 0x00 ; data [ 1 ] = 0x22 ; data [ 2 ] = 0x01 ; data [ 32 ] = 0x00 ; data [ 3 ] = 0x01 ; data [ 33 ] = 0x00 ; data [ 4 ] = 0x00 ; data [ 5 ] = 0x04 ; data [ 6 ] = 0x01 ; data [ 7 ] = 0x00 ; data [ 8 ] = 0x00 ; data [ 9 ] = 0x00 ; data [ 10 ] = 0x00 ; data [ 11 ] = 0x00 ; data [ 12 ] = 0x00 ; data [ 13 ] = 0x00 ; data [ 14 ] = 0x00 ; data [ 15 ] = 0x00 ; data [ 16 ] = 0x00 ; data [ 17 ] = 0x00 ; data [ 18 ] = 0x00 ; data [ 19 ] = 0x00 ; data [ 20 ] = 0x00 ; data [ 21 ] = 0x00 ; data [ 22 ] = 0x00 ; data [ 23 ] = 0x10 ; total_size = ftello ( ld -> lun_fh ) ; blocks = total_size / ld -> block_size ; if ( ( total_size / ld -> block_size ) != blocks ) { blocks -- ; } data [ 24 ] = ( blocks >> 24 ) & 0xff ; data [ 25 ] = ( blocks >> 16 ) & 0xff ; data [ 26 ] = ( blocks >> 8 ) & 0xff ; data [ 27 ] = ( blocks ) & 0xff ; data [ 28 ] = 0x00 ; data [ 29 ] = 0x00 ; data [ 30 ] = 0x00 ; data [ 31 ] = 0x00 ; break ; } * data_size = alloc_len ; * status = 0 ; }
XXX should keep track of free blocks here
XXX should keep track of free blocks here
/* DVD-R */ /* data length */ /* track number */ /* session number */ /* reserved */ /* no damage, not a copy, track mode:data */ /* all ecc blocks are blank, mode 1 iso/iec 10149 */ /* lra_v:1 nwa_v:1 */ /* track start address */ /* next writeable address */ /* free blocks */ /* fixed packet size/blocking factor */ /* track size */ /* last recorded address */ /* DVD-ROM */ /* data length */ /* track number */ /* session number */ /* reserved */ /* no damage, not a copy, track mode:data */ /* mode 1 iso/iec 10149 */ /* lra_v:0 nwa_v:0 */ /* track start address */ /* next writeable address */ /* free blocks */ /* fixed packet size/blocking factor */ /* track size */ /* round down to nearest block size */ /* last recorded address */