Do not believe libburn if it says a role 2 drive is empty

This commit is contained in:
Thomas Schmitt 2010-01-01 12:56:12 +00:00
parent 45277ed62b
commit ea9cb3ab4b
3 changed files with 28 additions and 10 deletions

View File

@ -6,7 +6,7 @@
*/
/* libburn wrappers for libisoburn
Copyright 2007 - 2009 Thomas Schmitt, <scdbackup@gmx.net>
Copyright 2007 - 2010 Thomas Schmitt, <scdbackup@gmx.net>
*/
/* <<< A70929 : hardcoded CD-RW with fabricated -msinfo
@ -1056,7 +1056,7 @@ int isoburn_read_iso_head(struct burn_drive *d, int lba,
int *image_blocks, char *info, int flag)
{
unsigned char buffer[64*1024];
int ret, info_mode, capacity;
int ret, info_mode, capacity, role;
off_t data_count;
info_mode= flag&255;
@ -1064,7 +1064,14 @@ int isoburn_read_iso_head(struct burn_drive *d, int lba,
if(flag&(1<<13)) {
memcpy(buffer, info, 64*1024);
} else {
role = burn_drive_get_drive_role(d);
ret = burn_get_read_capacity(d, &capacity, 0);
if (ret <= 0 && role == 2) {
/* Might be a block device on a system where libburn cannot determine its
size. Try to read anyway. */
capacity = 0x7ffffff0;
ret = 1;
}
if(ret > 0 && (off_t) capacity * (off_t) 2048 >= (off_t) (64 * 1024)) {
ret = burn_read_data(d, ((off_t) lba) * (off_t) 2048, (char *) buffer,
(off_t) 64*1024, &data_count, 2); /* no error messages */
@ -1130,7 +1137,7 @@ no_memory:;
int isoburn_emulate_toc(struct burn_drive *d, int flag)
{
int ret, image_size= 0, lba, track_blocks, session_count= 0, read_flag= 0;
int scan_start= 0, scan_count= 0, probe_minus_16= 0, growisofs_nwa;
int scan_start= 0, scan_count= 0, probe_minus_16= 0, growisofs_nwa, role;
int with_enclosure= 0, readable_blocks= -1;
struct isoburn *o;
char msg[160], size_text[80], *sev, volid[33], *volid_pt= NULL;
@ -1146,8 +1153,16 @@ int isoburn_emulate_toc(struct burn_drive *d, int flag)
return(0);
ret= burn_get_read_capacity(d, &readable_blocks, 0);
if(ret <= 0)
readable_blocks= -1;
if(ret <= 0) {
role = burn_drive_get_drive_role(d);
if (role == 2)
/* Might be a block device on a system where libburn cannot determine its
size. Try to read anyway. */
readable_blocks= 0x7ffffff0; /* try to read anyway */
else
readable_blocks= -1;
}
start_time= last_pacifier= time(NULL);
lba= 0;

View File

@ -6,7 +6,7 @@
/*
libisofs related functions of libisoburn.
Copyright 2007 - 2009 Vreixo Formoso Lopes <metalpain2002@yahoo.es>
Copyright 2007 - 2010 Vreixo Formoso Lopes <metalpain2002@yahoo.es>
Thomas Schmitt <scdbackup@gmx.net>
*/
@ -307,7 +307,7 @@ int isoburn_activate_session(struct burn_drive *drive)
*/
int isoburn_start_emulation(struct isoburn *o, int flag)
{
int ret, i, capacity = -1;
int ret, i, capacity = -1, role;
off_t data_count, to_read;
struct burn_drive *drive;
struct ecma119_pri_vol_desc *pvm;
@ -324,11 +324,14 @@ int isoburn_start_emulation(struct isoburn *o, int flag)
/* We can assume 0 as start block for image.
The data there point to the most recent session.
*/
role = burn_drive_get_drive_role(drive);
ret = burn_get_read_capacity(drive, &capacity, 0);
if (ret > 0 && capacity > 0) {
if ((ret > 0 && capacity > 0) || role == 2) {
/* Might be a block device on a system where libburn cannot determine its
size. Try to read anyway. */
memset(o->target_iso_head, 0, Libisoburn_target_head_sizE);
to_read = Libisoburn_target_head_sizE;
if((off_t) capacity * (off_t) 2048 < to_read)
if(capacity > 0 && (off_t) capacity * (off_t) 2048 < to_read)
to_read = (off_t) capacity * (off_t) 2048;
ret = burn_read_data(drive, (off_t) 0, (char*)o->target_iso_head,
to_read, &data_count, 2);

View File

@ -1 +1 @@
#define Xorriso_timestamP "2010.01.01.124622"
#define Xorriso_timestamP "2010.01.01.125742"