From ea9cb3ab4b5cef82d42974282a7a1cfd6a262a76 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Fri, 1 Jan 2010 12:56:12 +0000 Subject: [PATCH] Do not believe libburn if it says a role 2 drive is empty --- libisoburn/burn_wrap.c | 25 ++++++++++++++++++++----- libisoburn/isofs_wrap.c | 11 +++++++---- xorriso/xorriso_timestamp.h | 2 +- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/libisoburn/burn_wrap.c b/libisoburn/burn_wrap.c index 7e26491f..5c353435 100644 --- a/libisoburn/burn_wrap.c +++ b/libisoburn/burn_wrap.c @@ -6,7 +6,7 @@ */ /* libburn wrappers for libisoburn - Copyright 2007 - 2009 Thomas Schmitt, + Copyright 2007 - 2010 Thomas Schmitt, */ /* <<< 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; diff --git a/libisoburn/isofs_wrap.c b/libisoburn/isofs_wrap.c index 5ec083f3..219f47ba 100644 --- a/libisoburn/isofs_wrap.c +++ b/libisoburn/isofs_wrap.c @@ -6,7 +6,7 @@ /* libisofs related functions of libisoburn. - Copyright 2007 - 2009 Vreixo Formoso Lopes + Copyright 2007 - 2010 Vreixo Formoso Lopes Thomas Schmitt */ @@ -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); diff --git a/xorriso/xorriso_timestamp.h b/xorriso/xorriso_timestamp.h index 294ae848..e7970139 100644 --- a/xorriso/xorriso_timestamp.h +++ b/xorriso/xorriso_timestamp.h @@ -1 +1 @@ -#define Xorriso_timestamP "2010.01.01.124622" +#define Xorriso_timestamP "2010.01.01.125742"