|
|
|
@ -64,6 +64,20 @@ struct isoburn_cached_drive { |
|
|
|
|
struct burn_drive *drive; |
|
|
|
|
struct isoburn_cache_tile tiles[Libisoburn_cache_tileS]; |
|
|
|
|
int current_age; |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Offset to be applied to all block addresses to compensate for an |
|
|
|
|
eventual displacement of the block addresses relative to the image |
|
|
|
|
start block address that was assumed when the image was created. |
|
|
|
|
E.g. if track number 2 gets copied into a disk file and shall then |
|
|
|
|
be loaded as ISO filesystem. |
|
|
|
|
If displacement_sign is 1 then the displacement number will be |
|
|
|
|
added to .read_block() addresses, if -1 it will be subtracted. |
|
|
|
|
Else it will be ignored. |
|
|
|
|
*/ |
|
|
|
|
uint32_t displacement; |
|
|
|
|
int displacement_sign; |
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
#define Libisoburn_max_agE 2000000000 |
|
|
|
@ -105,6 +119,19 @@ int ds_read_block(IsoDataSource *src, uint32_t lba, uint8_t *buffer) |
|
|
|
|
|
|
|
|
|
tiles = (struct isoburn_cache_tile *) icd->tiles; |
|
|
|
|
|
|
|
|
|
if(icd->displacement_sign == 1) { |
|
|
|
|
if(lba + icd->displacement < lba) { |
|
|
|
|
address_rollover:; |
|
|
|
|
return ISO_DISPLACE_ROLLOVER; |
|
|
|
|
} else |
|
|
|
|
lba += icd->displacement; |
|
|
|
|
} else if(icd->displacement_sign == -1) { |
|
|
|
|
if(lba < icd->displacement ) |
|
|
|
|
goto address_rollover; |
|
|
|
|
else |
|
|
|
|
lba -= icd->displacement; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
aligned_lba= lba & ~(Libisoburn_tile_blockS - 1); |
|
|
|
|
|
|
|
|
|
for(i=0; i<Libisoburn_cache_tileS; i++) { |
|
|
|
@ -151,30 +178,10 @@ int ds_read_block(IsoDataSource *src, uint32_t lba, uint8_t *buffer) |
|
|
|
|
if (ret > 0) |
|
|
|
|
return 1; |
|
|
|
|
tiles[oldest].last_error_lba = lba; |
|
|
|
|
|
|
|
|
|
#ifdef ISO_DATA_SOURCE_MISHAP |
|
|
|
|
ret= ISO_DATA_SOURCE_MISHAP; |
|
|
|
|
#else |
|
|
|
|
/* <<< pre libisofs-0.6.7 */ |
|
|
|
|
/* It is not required by the specs of libisofs but implicitely assumed
|
|
|
|
|
... |
|
|
|
|
But it is not possible to ignore FAILURE. |
|
|
|
|
libisofs insists in original error codes, i.e. libisoburn cannot |
|
|
|
|
change severity FAILURE associated with ISO_FILE_READ_ERROR. |
|
|
|
|
So ISO_FILE_READ_ERROR is not an option and libisoburn has to |
|
|
|
|
misuse ISO_FILE_CANT_WRITE, which is actually for image generation |
|
|
|
|
and not for image reading. |
|
|
|
|
This is quite wrong, although the error message text is unclear |
|
|
|
|
enough to make it appear plausible. |
|
|
|
|
*/ |
|
|
|
|
ret= ISO_FILE_CANT_WRITE; |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
if(ret >= 0) |
|
|
|
|
ret = -1; |
|
|
|
|
sprintf(msg, "ds_read_block(%lu) returns %d", (unsigned long) lba, ret); |
|
|
|
|
sprintf(msg, "ds_read_block(%lu) returns %lX", |
|
|
|
|
(unsigned long) lba, (unsigned long) ret); |
|
|
|
|
isoburn_msgs_submit(NULL, 0x00060000, msg, 0, "DEBUG", 0); |
|
|
|
|
return ret;
|
|
|
|
|
return ISO_DATA_SOURCE_MISHAP; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#ifdef Libisoburn_read_cache_reporT |
|
|
|
@ -226,7 +233,8 @@ int isoburn_data_source_shutdown(IsoDataSource *src, int flag) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IsoDataSource *isoburn_data_source_new(struct burn_drive *d) |
|
|
|
|
IsoDataSource *isoburn_data_source_new(struct burn_drive *d, |
|
|
|
|
uint32_t displacement, int displacement_sign) |
|
|
|
|
{ |
|
|
|
|
IsoDataSource *ret; |
|
|
|
|
struct isoburn_cached_drive *icd= NULL; |
|
|
|
@ -238,6 +246,7 @@ IsoDataSource *isoburn_data_source_new(struct burn_drive *d) |
|
|
|
|
icd = calloc(1,sizeof(struct isoburn_cached_drive)); |
|
|
|
|
if (ret == NULL || icd == NULL) |
|
|
|
|
return NULL; |
|
|
|
|
ret->version = 0; |
|
|
|
|
ret->refcount = 1; |
|
|
|
|
ret->read_block = ds_read_block; |
|
|
|
|
ret->open = ds_open; |
|
|
|
@ -253,6 +262,8 @@ IsoDataSource *isoburn_data_source_new(struct burn_drive *d) |
|
|
|
|
icd->tiles[i].last_aligned_error_lba = 0xffffffff; |
|
|
|
|
icd->tiles[i].age= 0; |
|
|
|
|
} |
|
|
|
|
icd->displacement = displacement; |
|
|
|
|
icd->displacement_sign = displacement_sign; |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|