From d8cfe78f4fbbcaf2c6f9e14b88629d6463e32f87 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Tue, 5 Feb 2008 16:27:10 +0000 Subject: [PATCH] New option -padding --- xorriso/xorriso.1 | 9 +++++ xorriso/xorriso.c | 31 +++++++++++++++++- xorriso/xorriso.h | 9 +++-- xorriso/xorriso_private.h | 2 ++ xorriso/xorriso_timestamp.h | 2 +- xorriso/xorrisoburn.c | 65 ++++++++++++++++++++----------------- 6 files changed, 84 insertions(+), 34 deletions(-) diff --git a/xorriso/xorriso.1 b/xorriso/xorriso.1 index 1da5912b..26d920ff 100644 --- a/xorriso/xorriso.1 +++ b/xorriso/xorriso.1 @@ -935,6 +935,15 @@ any more (if possible at all with the given type of target media). This is the contrary of cdrecord, wodim, cdrskin option -multi, and is one aspect of growisofs option -dvd-compat. .TP +\fB\-padding\fR number["k"|"m"] +Append the given number of extra bytes to the image stream. +This is a traditional remedy for a traditional bug in block +device read drivers. Needed only for CD recordings in TAO mode. +Since one can hardly predict on what media an image might end up, +xorriso adds the traditional 300k of padding by default to all images. +.br +For images which will never get to a CD it is safe to use -padding 0 . +.TP .B Exception processing: .TP \fB\-abort_on\fR severity diff --git a/xorriso/xorriso.c b/xorriso/xorriso.c index 1fd9d242..16e25bb2 100644 --- a/xorriso/xorriso.c +++ b/xorriso/xorriso.c @@ -2878,6 +2878,7 @@ int Xorriso_new(struct XorrisO ** xorriso,char *progname, int flag) m->do_close= 0; m->speed= 0; m->fs= 4*512; /* 4 MiB */ + m->padding= 300*1024; m->allow_graft_points= 0; m->dialog= 0; m->search_mode= 0; @@ -3920,7 +3921,7 @@ int Xorriso_status(struct XorrisO *xorriso, char *filter, FILE *fp, int flag) if((xorriso->temp_mem_limit/1024/1024)*1024*1024==xorriso->temp_mem_limit) sprintf(line,"-temp_mem_limit %dm\n", xorriso->temp_mem_limit/1024/1024); else - sprintf(line,"-fs %dk\n", xorriso->temp_mem_limit/1024); + sprintf(line,"-temp_mem_limit %dk\n", xorriso->temp_mem_limit/1024); if(!(is_default && no_defaults)) Xorriso_status_result(xorriso,filter,fp,flag&2); @@ -4042,6 +4043,11 @@ int Xorriso_status(struct XorrisO *xorriso, char *filter, FILE *fp, int flag) if(!(is_default && no_defaults)) Xorriso_status_result(xorriso,filter,fp,flag&2); + is_default= (xorriso->padding==300*1024); + sprintf(line,"-padding %dk\n", xorriso->padding/1024); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + is_default= (strcmp(xorriso->report_about_text,"UPDATE")==0); sprintf(line,"-report_about %s\n",xorriso->report_about_text); if(!(is_default && no_defaults)) @@ -7797,6 +7803,25 @@ int Xorriso_option_overwrite(struct XorrisO *xorriso, char *mode, int flag) } +/* Option -padding */ +int Xorriso_option_padding(struct XorrisO *xorriso, char *size, int flag) +{ + double num; + + num= Scanf_io_size(size, 0); + if(num < 0 || num > 1024.0 * 1024.0 * 1024.0) { + sprintf(xorriso->info_text, "-padding: wrong size %.f (allowed: %.f - %.f)", + num, 0.0, 1024.0 * 1024.0 * 1024.0); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + xorriso->padding= num; + if(xorriso->padding/2048 != num/2048.0) + xorriso->padding++; + return(1); +} + + /* Option -page */ int Xorriso_option_page(struct XorrisO *xorriso, int len, int width, int flag) { @@ -8593,6 +8618,10 @@ next_command:; (*idx)++; ret= Xorriso_option_dev(xorriso, arg1, 2); + } else if(strcmp(cmd,"padding")==0) { + (*idx)++; + ret= Xorriso_option_padding(xorriso, arg1, 0); + } else if(strcmp(cmd,"page")==0) { (*idx)+= 2; num1= num2= 0; diff --git a/xorriso/xorriso.h b/xorriso/xorriso.h index 350b709f..1d537618 100644 --- a/xorriso/xorriso.h +++ b/xorriso/xorriso.h @@ -258,9 +258,6 @@ int Xorriso_option_fs(struct XorrisO *xorriso, char *size, int flag); /* Option -gid */ int Xorriso_option_gid(struct XorrisO *xorriso, char *gid, int flag); -/* Option -pathspecs */ -int Xorriso_option_pathspecs(struct XorrisO *xorriso, char *mode, int flag); - /* Option -help and part of -prog_help */ int Xorriso_option_help(struct XorrisO *xorriso, int flag); @@ -316,12 +313,18 @@ int Xorriso_option_options_from_file(struct XorrisO *xorriso, char *adr, /* Option -overwrite "on"|"nondir"|"off" */ int Xorriso_option_overwrite(struct XorrisO *xorriso, char *mode, int flag); +/* Option -padding */ +int Xorriso_option_padding(struct XorrisO *xorriso, char *size, int flag); + /* Option -page */ int Xorriso_option_page(struct XorrisO *xorriso, int len, int width, int flag); /* Option -path-list */ int Xorriso_option_path_list(struct XorrisO *xorriso, char *adr, int flag); +/* Option -pathspecs */ +int Xorriso_option_pathspecs(struct XorrisO *xorriso, char *mode, int flag); + /* Option -pkt_output */ int Xorriso_option_pkt_output(struct XorrisO *xorriso, char *mode, int flag); diff --git a/xorriso/xorriso_private.h b/xorriso/xorriso_private.h index aafb61e2..23605a09 100644 --- a/xorriso/xorriso_private.h +++ b/xorriso/xorriso_private.h @@ -106,6 +106,8 @@ struct XorrisO { /* the global context of xorriso */ int do_close; int speed; /* in libburn units : 1000 bytes/second , 0 = Max, -1 = Min */ int fs; /* fifo size in 2048 byte chunks : at most 1 GB */ + int padding; /* number of bytes to add after ISO 9660 image */ + /* XORRISO options */ int allow_graft_points; diff --git a/xorriso/xorriso_timestamp.h b/xorriso/xorriso_timestamp.h index 5791a58e..00ec02af 100644 --- a/xorriso/xorriso_timestamp.h +++ b/xorriso/xorriso_timestamp.h @@ -1 +1 @@ -#define Xorriso_timestamP "2008.02.04.214133" +#define Xorriso_timestamP "2008.02.05.162621" diff --git a/xorriso/xorrisoburn.c b/xorriso/xorrisoburn.c index e08c245d..65c929b6 100644 --- a/xorriso/xorrisoburn.c +++ b/xorriso/xorrisoburn.c @@ -70,8 +70,8 @@ int Xorriso_pacifier_loop(struct XorrisO *xorriso, struct burn_drive *drive, #define LIBISO_ISSOCK(node) (iso_node_get_type(node) == LIBISO_SPECIAL && \ S_ISSOCK(iso_node_get_mode(node))) - -#define Xorriso_min_track_sizE 300 +/* CD specs say one shall not write tracks < 600 kiB */ +#define Xorriso_cd_min_track_sizE 300 /* ------------------------------------------------------------------------ */ @@ -678,7 +678,8 @@ int Xorriso_make_write_options( */ int Xorriso_write_session(struct XorrisO *xorriso, int flag) { - int ret, media_space, img_sectors; + int ret, media_space, img_sectors, padding= 0, profile= 0; + char profile_name[80]; struct isoburn_imgen_opts *sopts= NULL; struct burn_drive_info *dinfo, *source_dinfo; struct burn_drive *drive, *source_drive; @@ -772,40 +773,46 @@ int Xorriso_write_session(struct XorrisO *xorriso, int flag) if(flag&1) goto ex; + sessions= burn_disc_get_sessions(disc, &num_sessions); + if(sessions==NULL || num_sessions < 1) { +no_track:; + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text,"Program error : no track in prepared disc"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + isoburn_cancel_prepared_write(source_drive, drive, 0); + {ret= -1; goto ex;} + } + tracks= burn_session_get_tracks(sessions[0], &num_tracks); + if(tracks==NULL || num_tracks < 1) + goto no_track; + + padding= 0; + ret= burn_disc_get_profile(drive, &profile, profile_name); + padding= xorriso->padding / 2048; + if(xorriso->padding > padding * 2048) + padding++; + if(profile==0x09 || profile==0x0a) { /* CD-R , CD-RW */ + if(img_sectors + padding < Xorriso_cd_min_track_sizE) { + padding= Xorriso_cd_min_track_sizE - img_sectors; + sprintf(xorriso->info_text, + "Expanded track to minimum size of %d sectors", + Xorriso_cd_min_track_sizE); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + } + } + burn_track_define_data(tracks[0], 0, padding * 2048, 0, BURN_MODE1); + Xorriso_process_msg_queues(xorriso,0); + media_space= burn_disc_available_space(drive, burn_options) / (off_t) 2048; - if(media_space < img_sectors || media_space < Xorriso_min_track_sizE) { + if(media_space < img_sectors + padding) { Xorriso_process_msg_queues(xorriso,0); sprintf(xorriso->info_text,"Image size %ds exceeds free space on media %ds", - (img_sectors < Xorriso_min_track_sizE ? Xorriso_min_track_sizE - : img_sectors ), - media_space); + img_sectors + padding, media_space); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); isoburn_cancel_prepared_write(source_drive, drive, 0); {ret= 0; goto ex;} } - if(img_sectors < Xorriso_min_track_sizE) { - sessions= burn_disc_get_sessions(disc, &num_sessions); - if(sessions==NULL || num_sessions < 1) { -no_track:; - Xorriso_process_msg_queues(xorriso,0); - sprintf(xorriso->info_text,"Program error : no track in prepared disc"); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); - isoburn_cancel_prepared_write(source_drive, drive, 0); - {ret= -1; goto ex;} - } - tracks= burn_session_get_tracks(sessions[0], &num_tracks); - if(tracks==NULL || num_tracks < 1) - goto no_track; - burn_track_define_data(tracks[0], 0, - (Xorriso_min_track_sizE - img_sectors) * 2048, - 0, BURN_MODE1); - Xorriso_process_msg_queues(xorriso,0); - sprintf(xorriso->info_text, "Expanded track to minimum size of %d sectors", - Xorriso_min_track_sizE); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); - } - isoburn_disc_write(burn_options, disc); burn_write_opts_free(burn_options);