From 0a3b34d9c133969fd02741bcc7b386e09e8348b6 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Sun, 9 Jan 2011 13:59:19 +0000 Subject: [PATCH] Refusing to burn if foreseeable size exceeds media capacity --- cdrskin/cdrskin.1 | 5 ++++- cdrskin/cdrskin.c | 40 ++++++++++++++++++++++++++----------- cdrskin/cdrskin_timestamp.h | 2 +- 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/cdrskin/cdrskin.1 b/cdrskin/cdrskin.1 index 0b4df82..31d36dc 100644 --- a/cdrskin/cdrskin.1 +++ b/cdrskin/cdrskin.1 @@ -2,7 +2,7 @@ .\" First parameter, NAME, should be all caps .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" other parameters are allowed: see man(7), man(1) -.TH CDRSKIN 1 "Aug 21, 2010" +.TH CDRSKIN 1 "Jan 09, 2011" .\" Please adjust this date whenever revising the manpage. .\" .\" Some roff macros, for reference: @@ -554,6 +554,9 @@ which appear to be in the desired blank or format state already. This option enables a burn run with option -dummy even if libburn believes that drive and media will not simulate the write mode but will write for real. .br +It enables a burn run where cdrskin expects to exceed the available media +capacity. +.br .B Caution: Use this only when in urgent need. .TP diff --git a/cdrskin/cdrskin.c b/cdrskin/cdrskin.c index 196c0df..e76b81a 100644 --- a/cdrskin/cdrskin.c +++ b/cdrskin/cdrskin.c @@ -1,6 +1,6 @@ /* - cdrskin.c , Copyright 2006-2010 Thomas Schmitt + cdrskin.c , Copyright 2006-2011 Thomas Schmitt Provided under GPL version 2 or later. A cdrecord compatible command line interface for libburn. @@ -7081,6 +7081,10 @@ int Cdrskin_burn(struct CdrskiN *skin, int flag) double put_counter, get_counter, empty_counter, full_counter; int total_min_fill, fifo_percent; #endif +#ifdef Cdrskin_libburn_has_get_spacE + off_t free_space; + char msg[80]; +#endif if(skin->tell_media_space) doing= "estimating"; @@ -7324,17 +7328,12 @@ burn_failed:; /* write capacity estimation and return without actual burning */ #ifdef Cdrskin_libburn_has_get_spacE - { - off_t free_space; - char msg[80]; - - free_space= burn_disc_available_space(drive,o); - sprintf(msg,"%d\n",(int) (free_space/(off_t) 2048)); - if(skin->preskin->result_fd>=0) { - write(skin->preskin->result_fd,msg,strlen(msg)); - } else - printf("%s",msg); - } + free_space= burn_disc_available_space(drive,o); + sprintf(msg,"%d\n",(int) (free_space/(off_t) 2048)); + if(skin->preskin->result_fd>=0) { + write(skin->preskin->result_fd,msg,strlen(msg)); + } else + printf("%s",msg); #endif /* Cdrskin_libburn_has_get_spacE */ if(skin->track_counter>0) @@ -7344,6 +7343,23 @@ burn_failed:; {ret= 1; goto ex;} } + +#ifdef Cdrskin_libburn_has_get_spacE + if(skin->fixed_size > 0 && !skin->force_is_set) { + free_space= burn_disc_available_space(drive,o); + if(skin->fixed_size > free_space && free_space > 0) { + fprintf(stderr, + "cdrskin: FATAL : predicted session size %lus does not fit on media (%lus)\n", + (unsigned long) ((skin->fixed_size + 2047.0) / 2048.0), + (unsigned long) ((free_space + 2047) / 2048)); + ClN(fprintf(stderr, + "cdrskin: HINT : This test may be disabled by option -force\n");) + {ret= 0; goto ex;} + } + } +#endif /* Cdrskin_libburn_has_get_spacE */ + + Cdrskin_adjust_speed(skin,0); #ifndef Cdrskin_extra_leaN diff --git a/cdrskin/cdrskin_timestamp.h b/cdrskin/cdrskin_timestamp.h index 9661961..3073f63 100644 --- a/cdrskin/cdrskin_timestamp.h +++ b/cdrskin/cdrskin_timestamp.h @@ -1 +1 @@ -#define Cdrskin_timestamP "2011.01.03.195125" +#define Cdrskin_timestamP "2011.01.09.135915"