Adopting next development step of libisofs

This commit is contained in:
Thomas Schmitt 2008-08-26 16:33:55 +00:00
parent 615eb60115
commit 847a54f423
6 changed files with 248 additions and 29 deletions

View File

@ -147,6 +147,10 @@ int ds_read_block(IsoDataSource *src, uint32_t lba, uint8_t *buffer)
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.
@ -159,6 +163,8 @@ int ds_read_block(IsoDataSource *src, uint32_t lba, uint8_t *buffer)
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);

View File

@ -200,7 +200,7 @@ void isoburn_version(int *major, int *minor, int *micro);
*/
#define isoburn_libisofs_req_major 0
#define isoburn_libisofs_req_minor 6
#define isoburn_libisofs_req_micro 6
#define isoburn_libisofs_req_micro 7
/** The minimum version of libburn to be used with this version of libisoburn
at compile time.

View File

@ -16,7 +16,7 @@ AC_SUBST(BURN_MICRO_VERSION)
LIBISOFS_MAJOR_VERSION=0
LIBISOFS_MINOR_VERSION=6
LIBISOFS_MICRO_VERSION=6
LIBISOFS_MICRO_VERSION=7
AC_SUBST(LIBISOFS_MAJOR_VERSION)
AC_SUBST(LIBISOFS_MINOR_VERSION)
AC_SUBST(LIBISOFS_MICRO_VERSION)

View File

@ -1900,7 +1900,7 @@ struct FindjoB {
19= empty_iso_dir iso_rr_equiv
20= is_full_in_iso iso_rr_equiv
21= report_damage
>>>22= report_lba
22= report_lba
*/
int action;
char *target;
@ -11347,7 +11347,9 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
" min_lba=blockadr , max_lba=blockadr ,",
" abort_file=path , time_limit=seconds , item_limit=number ,",
" retry=on|off|default , data_to=filepath ,",
" sector_map=filepath , map_with_volid=on|off",
" sector_map=filepath , map_with_volid=on|off ,",
" patch_lba0=on|off|force|blockadr[:force] ,",
" report=blocks|files|blocks_files",
"",
"Compatibility emulation (argument list may be ended by --):",
" -as mkisofs [-help|-version|-o|-R|-J|-V|-P|-f|-m|-exclude-list|-no-pad|",
@ -12967,7 +12969,8 @@ bd_speed:;
int Xorriso_option_split_size(struct XorrisO *xorriso, char *size, int flag)
{
double num;
static off_t limit= ((off_t) 4) * ((off_t) 1024*1024*1024) - (off_t) 1;
/* At most: 100 extents with 4 GB - 2 kB each = 400 GB - 800 kB */
static off_t limit= ((off_t) 400) * ((off_t) 1024*1024*1024) - (off_t) 819200;
num= Scanf_io_size(size, 0);
if(num > limit) {

View File

@ -1 +1 @@
#define Xorriso_timestamP "2008.08.24.173217"
#define Xorriso_timestamP "2008.08.26.163254"

View File

@ -74,6 +74,8 @@ int Xorriso_findi_iter(struct XorrisO *xorriso, IsoDir *dir_node, off_t *mem,
IsoNode ***node_array, int *node_count, int *node_idx,
IsoNode **iterated_node, int flag);
int Xorriso__file_start_lba(IsoNode *node, int *lba, int flag);
#define LIBISO_ISDIR(node) (iso_node_get_type(node) == LIBISO_DIR)
#define LIBISO_ISREG(node) (iso_node_get_type(node) == LIBISO_FILE)
@ -91,6 +93,10 @@ int Xorriso_findi_iter(struct XorrisO *xorriso, IsoDir *dir_node, off_t *mem,
#define Xorriso_cd_min_track_sizE 300
/* >>> transitional macro */
#define Xorriso_libisofs_0_6_7 yes
/* ------------------------------------------------------------------------ */
@ -920,7 +926,7 @@ int Xorriso_write_session(struct XorrisO *xorriso, int flag)
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
}
}
isoburn_igopt_set_level(sopts, 2);
isoburn_igopt_set_level(sopts, 3);
isoburn_igopt_set_extensions(sopts, 1|((!!xorriso->do_joliet)<<1));
isoburn_igopt_set_relaxed(sopts, isoburn_igopt_allow_deep_paths);
isoburn_igopt_set_sort_files(sopts, 1);
@ -1653,7 +1659,8 @@ int Xorriso_tree_graft_node(struct XorrisO *xorriso, IsoImage *volume,
struct stat stbuf;
char sfe[5*SfileadrL];
off_t size= 0;
static off_t limit= ((off_t) 4) * ((off_t) 1024*1024*1024) - (off_t) 1;
/* At most: 100 extents with 4 GB - 2 kB each = 400 GB - 800 kB */
static off_t limit= ((off_t) 400) * ((off_t) 1024*1024*1024) - (off_t) 819200;
if(flag&8) {
if(cut_size > limit) {
@ -2364,12 +2371,17 @@ int Xorriso_restore_is_identical(struct XorrisO *xorriso, void *in_node,
unsigned int fs_id;
dev_t dev_id;
ino_t ino_id;
uint32_t dummy;
IsoStream *stream;
IsoImage *volume;
IsoNode *node;
struct stat stbuf;
#ifdef Xorriso_libisofs_0_6_7
int dummy;
#else
uint32_t dummy;
#endif
memset(type_text, 0, 5);
if(!xorriso->volset_change_pending)
return(0);
@ -2384,9 +2396,20 @@ int Xorriso_restore_is_identical(struct XorrisO *xorriso, void *in_node,
return(-1);
}
#ifdef Xorriso_libisofs_0_6_7
ret= Xorriso__file_start_lba(node, &dummy, 0);
if(ret != 0)
return(0);
#else /* Xorriso_libisofs_0_6_7 */
ret= iso_node_get_old_image_lba(node, &dummy, 0);
if(ret!=0)
return(0);
#endif /* ! Xorriso_libisofs_0_6_7 */
if(!LIBISO_ISREG(node))
return(0);
stream= iso_file_get_stream((IsoFile *) node);
@ -4159,15 +4182,32 @@ int Xorriso_cannot_create_iter(struct XorrisO *xorriso, int iso_error,int flag)
int Xorriso__node_lba_cmp(const void *node1, const void *node2)
{
uint32_t lba1= 0, lba2= 0;
int ret;
#ifdef Xorriso_libisofs_0_6_7
int lba1= 0, lba2= 0;
ret= Xorriso__file_start_lba(*((IsoNode **) node1), &lba1, 0);
if(ret!=1)
lba1= 0;
ret= Xorriso__file_start_lba(*((IsoNode **) node2), &lba2, 0);
if(ret!=1)
lba2= 0;
#else /* Xorriso_libisofs_0_6_7 */
uint32_t lba1= 0, lba2= 0;
ret = iso_node_get_old_image_lba(*((IsoNode **) node1), &lba1, 0);
if(ret!=1)
lba1= 0;
ret = iso_node_get_old_image_lba(*((IsoNode **) node2), &lba2, 0);
if(ret!=1)
lba2= 0;
#endif /* ! Xorriso_libisofs_0_6_7 */
return(lba1-lba2);
}
@ -5541,6 +5581,159 @@ int Xorriso_set_time(struct XorrisO *xorriso, char *in_path, time_t t,
}
#ifdef Xorriso_libisofs_0_6_7
int Xorriso__start_end_lbas(IsoNode *node,
int *lba_count, int **start_lbas, int **end_lbas,
off_t *size, int flag)
{
int section_count= 0, ret, i;
struct iso_file_section *sections= NULL;
*lba_count= 0;
*start_lbas= *end_lbas= NULL;
*size= 0;
if(!LIBISO_ISREG(node))
return(0);
*size= iso_file_get_size((IsoFile *) node);
ret= iso_file_get_old_image_sections((IsoFile *) node, &section_count,
&sections, 0);
if(ret < 0)
{ret= -1; goto ex;}
if(ret != 1 || section_count <= 0)
{ret= 0; goto ex;}
*start_lbas= calloc(section_count, sizeof(int));
*end_lbas= calloc(section_count, sizeof(int));
if(*start_lbas == NULL || *end_lbas == NULL)
{ret= -1; goto ex;}
for(i= 0; i < section_count; i++) {
(*start_lbas)[i]= sections[i].block;
(*end_lbas)[i]= sections[i].block + sections[i].size / 2048 - 1;
if(sections[i].size % 2048)
(*end_lbas)[i]++;
}
*lba_count= section_count;
ret= 1;
ex:;
if(sections != NULL)
free((char *) sections);
if(ret <= 0) {
if((*start_lbas) != NULL)
free((char *) *start_lbas);
if((*end_lbas) != NULL)
free((char *) *end_lbas);
*start_lbas= *end_lbas= NULL;
*lba_count= 0;
}
return(ret);
}
int Xorriso__file_start_lba(IsoNode *node,
int *lba, int flag)
{
int *start_lbas= NULL, *end_lbas= NULL, lba_count= 0, i, ret;
off_t size;
*lba= -1;
ret= Xorriso__start_end_lbas(node, &lba_count, &start_lbas, &end_lbas,
&size, 0);
if(ret <= 0)
return(ret);
for(i= 0; i < lba_count; i++) {
if(*lba < 0 || start_lbas[i] < *lba)
*lba= start_lbas[i];
}
if(start_lbas != NULL)
free((char *) start_lbas);
if(end_lbas != NULL)
free((char *) end_lbas);
if(*lba < 0)
return(0);
return(1);
}
/* @param damage_start Returns first damaged byte address
@param damage_end Returns first byte address after last damaged byte
@return <0 error, 0=undamaged , 1=damaged
*/
int Xorriso_file_eval_damage(struct XorrisO *xorriso, IsoNode *node,
off_t *damage_start, off_t *damage_end,
int flag)
{
int *start_lbas= NULL, *end_lbas= NULL, lba_count= 0, sect;
int i, sectors, sector_size, ret;
off_t sect_base= 0, size= 0, byte;
struct SectorbitmaP *map;
*damage_start= *damage_end= -1;
map= xorriso->in_sector_map;
if(map == NULL)
return(0);
Sectorbitmap_get_layout(map, &sectors, &sector_size, 0);
sector_size/= 2048;
ret= Xorriso__start_end_lbas(node, &lba_count, &start_lbas, &end_lbas,
&size, 0);
if(ret <= 0)
return(ret);
for(sect= 0; sect < lba_count; sect++) {
for(i= start_lbas[sect]; i <= end_lbas[sect]; i+= sector_size) {
if(Sectorbitmap_is_set(map, i / sector_size, 0) == 0) {
byte= ((off_t) 2048) * ((off_t) (i - start_lbas[sect])) + sect_base;
if(*damage_start < 0 || byte < *damage_start)
*damage_start= byte;
if(byte + (off_t) 2048 > *damage_end)
*damage_end= byte + (off_t) 2048;
}
}
sect_base+= ((off_t) 2048) *
((off_t) (end_lbas[sect] - start_lbas[sect] + 1));
}
if(*damage_end > size)
*damage_end= size;
if(start_lbas != NULL)
free((char *) start_lbas);
if(end_lbas != NULL)
free((char *) end_lbas);
if(*damage_start < 0)
return(0);
return(1);
}
int Xorriso_report_lba(struct XorrisO *xorriso, char *show_path,
IsoNode *node, int flag)
{
int ret, *start_lbas= NULL, *end_lbas= NULL, lba_count, i;
off_t size;
char sfe[5*SfileadrL];
ret= Xorriso__start_end_lbas(node, &lba_count, &start_lbas, &end_lbas,
&size, 0);
if(ret < 0)
{ret= -1; goto ex;}
if(ret == 0)
{ret= 1; goto ex;} /* it is ok to ignore other types */
for(i= 0; i < lba_count; i++) {
sprintf(xorriso->result_line,
"File data lba: %2d , %8d , %8d , %8.f , %s\n",
i, start_lbas[i], end_lbas[i] + 1 - start_lbas[i], (double) size,
Text_shellsafe(show_path, sfe, 0));
Xorriso_result(xorriso, 0);
}
ret= 1;
ex:;
if(start_lbas != NULL)
free((char *) start_lbas);
if(end_lbas != NULL)
free((char *) end_lbas);
return(ret);
}
#else /* Xorriso_libisofs_0_6_7 */
int Xorriso_start_end_lba(struct XorrisO *xorriso, IsoNode *node,
int *start_lba, int *end_lba, off_t *size, int flag)
{
@ -5574,6 +5767,7 @@ int Xorriso_file_eval_damage(struct XorrisO *xorriso, IsoNode *node,
{
int start_lba, end_lba, i, sectors, sector_size, damaged= 0, ret;
int next_good_lba= -1, first_bad_lba= -1;
int i, sectors, sector_size, ret;
off_t size= 0;
struct SectorbitmaP *map;
@ -5581,12 +5775,11 @@ int Xorriso_file_eval_damage(struct XorrisO *xorriso, IsoNode *node,
map= xorriso->in_sector_map;
if(map == NULL)
return(0);
Sectorbitmap_get_layout(map, &sectors, &sector_size, 0);
sector_size/= 2048;
ret= Xorriso_start_end_lba(xorriso, node, &start_lba, &end_lba, &size, 0);
if(ret <= 0)
return(ret);
Sectorbitmap_get_layout(map, &sectors, &sector_size, 0);
sector_size/= 2048;
for(i= start_lba; i <= end_lba; i+= sector_size)
if(Sectorbitmap_is_set(map, i / sector_size, 0) == 0) {
damaged= 1;
@ -5594,7 +5787,6 @@ int Xorriso_file_eval_damage(struct XorrisO *xorriso, IsoNode *node,
first_bad_lba= i;
next_good_lba= (i / sector_size + 1) * sector_size;
}
if(damaged) {
*damage_start= (first_bad_lba - start_lba) * 2048;
*damage_end= (next_good_lba - start_lba) * 2048;
@ -5625,6 +5817,8 @@ int Xorriso_report_lba(struct XorrisO *xorriso, char *show_path,
return(1);
}
#endif /* ! Xorriso_libisofs_0_6_7 */
int Xorriso_report_damage(struct XorrisO *xorriso, char *show_path,
IsoNode *node, int flag)
@ -5745,8 +5939,13 @@ int Xorriso_findi_test(struct XorrisO *xorriso, struct FindjoB *job,
struct stat *boss_stbuf, struct stat *stbuf,
int depth, int flag)
{
int ret, start_lba, end_lba, damage_filter, file_end_lba, file_start_lba;
int ret, start_lba, end_lba, damage_filter;
off_t damage_start, damage_end, size;
#ifdef Xorriso_libisofs_0_6_7
int lba_count, *file_end_lbas= NULL, *file_start_lbas= NULL, i;
#else
int file_end_lba, file_start_lba;
#endif
ret= Findjob_test(job, name, boss_stbuf, stbuf, depth, 0);
if(ret<=0)
@ -5761,6 +5960,28 @@ int Xorriso_findi_test(struct XorrisO *xorriso, struct FindjoB *job,
return(0);
}
#ifdef Xorriso_libisofs_0_6_7
if(start_lba >= 0 && end_lba >= 0) {
ret= Xorriso__start_end_lbas(node, &lba_count,
&file_start_lbas, &file_end_lbas, &size, 0);
if(ret <= 0)
goto ex;
for(i= 0; i < lba_count; i++) {
if(file_end_lbas[i] < start_lba || file_start_lbas[i] > end_lba)
{ret= 0; goto ex;}
}
}
ret= 1;
ex:;
if(file_start_lbas != NULL)
free((char *) file_start_lbas);
if(file_end_lbas != NULL)
free((char *) file_end_lbas);
return(ret);
#else /* Xorriso_libisofs_0_6_7 */
if(start_lba >= 0 && end_lba >= 0) {
ret= Xorriso_start_end_lba(xorriso, node, &file_start_lba, &file_end_lba,
&size, 0);
@ -5770,6 +5991,9 @@ int Xorriso_findi_test(struct XorrisO *xorriso, struct FindjoB *job,
return(0);
}
return(1);
#endif /* ! Xorriso_libisofs_0_6_7 */
}
@ -6623,13 +6847,6 @@ int Xorriso_iso_file_open(struct XorrisO *xorriso, char *pathname,
IsoFile *filenode= NULL;
IsoStream *iso_stream= NULL;
/* for debugging
#define Libisofs_lba_tesT yes
*/
#ifdef Libisofs_lba_tesT
uint32_t lba;
#endif
*stream= NULL;
if(flag&1) {
node= (IsoNode *) node_pt;
@ -6645,13 +6862,6 @@ int Xorriso_iso_file_open(struct XorrisO *xorriso, char *pathname,
return(0);
}
#ifdef Libisofs_lba_tesT
ret = iso_node_get_old_image_lba(node, &lba, 0);
sprintf(xorriso->info_text, "%s : ret= %d , LBA= %lx",
pathname, ret, (unsigned long) lba);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
#endif
filenode= (IsoFile *) node;
iso_stream= iso_file_get_stream(filenode);
if(iso_stream==NULL) {