New API calls isoburn_read_iso_head_v2(), isoburn_get_mount_params_v2()

This commit is contained in:
Thomas Schmitt 2024-03-09 21:49:26 +01:00
parent a86d1378ff
commit e7326e0e6c
4 changed files with 56 additions and 22 deletions

View File

@ -1304,7 +1304,8 @@ int isoburn_read_iso_head_v2(struct burn_drive *d, off_t lba,
off_t *image_blocks, char *info, int flag)
{
unsigned char *buffer= NULL;
int ret, info_mode, capacity, role;
int ret, info_mode, role;
off_t capacity;
off_t data_count, to_read;
struct isoburn *o;
@ -1324,14 +1325,14 @@ int isoburn_read_iso_head_v2(struct burn_drive *d, off_t lba,
/* >>> ??? return always 0 ? */
{ret= (-1*!!(flag&(1<<15))); goto ex;}
ret = burn_get_read_capacity(d, &capacity, 0);
ret = burn_get_read_capacity_v2(d, &capacity, 0);
if (ret <= 0 && (role == 2 || role == 4)) {
/* Might be a block device on a system where libburn cannot determine its
size. Try to read anyway. */
capacity = 0x7ffffff0;
capacity = 0x7fffffffffffffff;
ret = 1;
}
to_read= (off_t) capacity * ((off_t) 2048);
to_read= capacity * ((off_t) 2048);
if(ret > 0 && to_read >= (off_t) (36 * 1024)) {
ret= isoburn_find_emulator(&o, d, 0);
if(ret > 0)
@ -1339,7 +1340,7 @@ int isoburn_read_iso_head_v2(struct burn_drive *d, off_t lba,
{ret= (-1 * !!(flag & (1 << 15))); goto ex;}
if(to_read >= (off_t) (64 * 1024))
to_read= 64 * 1024;
ret = burn_read_data(d, ((off_t) lba) * (off_t) 2048, (char *) buffer,
ret = burn_read_data(d, lba * (off_t) 2048, (char *) buffer,
to_read, &data_count, 32); /* error messages as DEBUG */
} else
ret= 0;
@ -1372,17 +1373,13 @@ int isoburn_read_iso_head(struct burn_drive *d, int lba,
int *image_blocks, char *info, int flag)
{
int ret;
off_t long_lba, long_image_blocks;
off_t long_image_blocks;
long_lba= lba;
ret= isoburn_read_iso_head_v2(d, long_lba, &long_image_blocks, info, flag);
ret= isoburn_read_iso_head_v2(d, (off_t) lba, &long_image_blocks, info, flag);
if(ret <= 0)
return(ret);
if(long_image_blocks > 0x7fffffff) {
*image_blocks= 0x7fffffff;
return(0);
}
*image_blocks= long_image_blocks;
/* The old behavior was to return negative numbers on overflow */
*image_blocks= (int) long_image_blocks;
return(ret);
}
@ -2200,13 +2197,13 @@ ex:;
}
int isoburn_get_mount_params(struct burn_drive *d,
int adr_mode, char *adr_value,
int *lba, int *track, int *session,
char volid[33], int flag)
int isoburn_get_mount_params_v2(struct burn_drive *d,
int adr_mode, char *adr_value,
off_t *lba, int *track, int *session,
char volid[33], int flag)
{
int msc1_mem, ret, total_tracks, num_sessions, num_tracks, i, j, track_lba;
int size, is_iso= 0;
int ret, total_tracks, num_sessions, num_tracks, i, j, is_iso= 0;
off_t msc1_mem, track_lba, size;
struct isoburn *o;
struct isoburn_toc_disc *disc= NULL;
struct isoburn_toc_session **sessions= NULL;
@ -2236,14 +2233,14 @@ int isoburn_get_mount_params(struct burn_drive *d,
continue;
for(j= 0; j<num_tracks && *track < 0; j++) {
total_tracks++;
isoburn_get_track_lba(tracks[j], &track_lba, 0);
isoburn_get_track_lba_v2(tracks[j], &track_lba, 0);
if(track_lba == *lba) {
*track= total_tracks;
*session= i + 1;
}
}
}
ret= isoburn_read_iso_head(d, *lba, &size, volid, 1);
ret= isoburn_read_iso_head_v2(d, *lba, &size, volid, 1);
if(ret <= 0)
volid[0]= 0;
else
@ -2257,3 +2254,24 @@ ex:;
}
int isoburn_get_mount_params(struct burn_drive *d,
int adr_mode, char *adr_value,
int *lba, int *track, int *session,
char volid[33], int flag)
{
int ret;
off_t long_lba;
ret= isoburn_get_mount_params_v2(d, adr_mode, adr_value, &long_lba,
track, session, volid, flag);
if(ret <= 0)
return(ret);
if(long_lba > 0x7fffffff) {
*lba= 0x7fffffff;
ret= 0;
} else {
*lba= long_lba;
}
return(ret);
}

View File

@ -756,6 +756,12 @@ void isoburn_toc_disc_free(struct isoburn_toc_disc *disc);
int isoburn_read_iso_head(struct burn_drive *d, int lba,
int *image_blocks, char *info, int flag);
/** Like isoburn_read_iso_head() but with off_t block address and count.
@since 1.5.8
*/
int isoburn_read_iso_head_v2(struct burn_drive *d, off_t lba,
off_t *image_blocks, char *info, int flag);
/** Try to convert the given entity address into various entity addresses
which would describe it.
@ -785,6 +791,14 @@ int isoburn_get_mount_params(struct burn_drive *d,
int *lba, int *track, int *session,
char volid[33], int flag);
/** Like isoburn_get_mount_params() but with off_t block address type.
@since 1.5.8
*/
int isoburn_get_mount_params_v2(struct burn_drive *d,
int adr_mode, char *adr_value,
off_t *lba, int *track, int *session,
char volid[33], int flag);
/* ----------------------------------------------------------------------- */
/*

View File

@ -364,6 +364,8 @@ local: *;
};
LIBISOBURN1_1.5.8 {
isoburn_get_mount_params_v2;
isoburn_read_iso_head_v2;
isoburn_toc_disc_get_sectors_v2;
isoburn_toc_session_get_sectors_v2;
isoburn_toc_track_get_emul_v2;

View File

@ -1 +1 @@
#define Xorriso_timestamP "2024.03.09.183038"
#define Xorriso_timestamP "2024.03.09.204838"