From 9a96d6a17578d6a82a73c90f442b2b4bfaefef2a Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Thu, 25 Jun 2009 12:50:57 +0000 Subject: [PATCH] Bug fix: Copies of overwriteable media onto sequential were mistaken in ROM drives --- libisoburn/burn_wrap.c | 36 ++++++++++++++++++++++++++++++++---- xorriso/xorriso_timestamp.h | 2 +- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/libisoburn/burn_wrap.c b/libisoburn/burn_wrap.c index 17a94d4c..b6a3636b 100644 --- a/libisoburn/burn_wrap.c +++ b/libisoburn/burn_wrap.c @@ -275,6 +275,11 @@ static int isoburn_welcome_media(struct isoburn **o, struct burn_drive *d, struct burn_multi_caps *caps= NULL; struct isoburn_toc_entry *t; char profile_name[80]; + struct isoburn_toc_disc *disc= NULL; + struct isoburn_toc_session **sessions; + struct isoburn_toc_track **tracks; + int num_sessions= 0, num_tracks= 0, track_count= 0, session_no= 0; + char msg[80]; profile_name[0]= 0; ret= burn_disc_get_profile(d, &profile, profile_name); @@ -332,15 +337,38 @@ static int isoburn_welcome_media(struct isoburn **o, struct burn_drive *d, /* >>> recognize unsuitable media (but allow read-only media) */; if(readonly) { - /* This might be overwriteable media in a -ROM drive */ - if((flag & 16)) { - ret= 0; + /* This might be overwriteable media in a -ROM drive. + Pitfall: + Multi-session media which bear a xorriso image for overwriteables + in their first session would get a TOC of that first image rather + than of the media. + It is not possible to distinguish a BD-RE from a single session + BD-R with an image for overwriteables. But as soon as the media + bears 2 logical tracks it cannot be overwriteable. + So count the number of tracks first. + */ + disc= isoburn_toc_drive_get_disc(d); + if(disc != NULL) { + sessions= isoburn_toc_disc_get_sessions(disc, &num_sessions); + for(session_no= 0; session_no < num_sessions; session_no++) { + tracks= isoburn_toc_session_get_tracks(sessions[session_no], + &num_tracks); + track_count+= num_tracks; + } + isoburn_toc_disc_free(disc); + } + + sprintf(msg, "ROM media has libburn track count = %d", track_count); + isoburn_msgs_submit(*o, 0x00060000, msg, 0, "DEBUG", 0); + + if((flag & 16) || track_count >= 2) { + ret= 0; /* toc emulation off, or not overwriteable */ } else { ret= isoburn_emulate_toc(d, 1); if(ret<0) goto ex; } - if(ret==0 && profile !=0x08 && (flag&8)) { + if(ret == 0 && profile != 0x08 && (flag&8)) { /* This might also be multi-session media which do not get shown with a decent TOC. CD-R TOC (profile 0x08) can be trusted. Others not. diff --git a/xorriso/xorriso_timestamp.h b/xorriso/xorriso_timestamp.h index 527955e3..8043da1f 100644 --- a/xorriso/xorriso_timestamp.h +++ b/xorriso/xorriso_timestamp.h @@ -1 +1 @@ -#define Xorriso_timestamP "2009.06.24.133521" +#define Xorriso_timestamP "2009.06.25.125048"