From cf2bf625cf6da332d79d96b8b8c60372a1b63971 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Wed, 14 May 2008 11:45:28 +0000 Subject: [PATCH] New -format types by_index and fast_by_index --- libisoburn/trunk/xorriso/xorriso.1 | 36 ++++++++++++++------ libisoburn/trunk/xorriso/xorriso.c | 35 +++++++++++++++---- libisoburn/trunk/xorriso/xorriso_timestamp.h | 2 +- libisoburn/trunk/xorriso/xorrisoburn.c | 29 ++++++++++++++-- 4 files changed, 80 insertions(+), 22 deletions(-) diff --git a/libisoburn/trunk/xorriso/xorriso.1 b/libisoburn/trunk/xorriso/xorriso.1 index 455e5911..386ebe8a 100644 --- a/libisoburn/trunk/xorriso/xorriso.1 +++ b/libisoburn/trunk/xorriso/xorriso.1 @@ -954,7 +954,7 @@ newly purchased BD-RE, re-format DVD-RAM or BD-RE. .br Defined modes are: .br - as_needed, full, fast + as_needed, full, fast, by_index_, fast_by_index_ .br "as_needed" formats yet unformatted DVD-RW, DVD-RAM, BD-RE. Other media are left untouched. @@ -963,26 +963,40 @@ are left untouched. .br "fast" does the same as "full" but tries to be quicker. .br -This action has no effect on media if -dummy is activated. +"by_index_" selects a format out of the descriptor list issued by option +-list_formats. The index number from that list is to be appended to the +mode word. E.g: "by_index_3". .br -Be warned that re-formatting DVD+RW is considered to be risky -to the media's health. DVD+RW get formatted as far as needed -during writing, but an entirely formatted media might be better -readable in some DVD players. +"fast_by_index_" does the same as "by_index_" but tries to be quicker. .br -On the other hand unreliable DVD+RW can sometimes be repaired by -re-formatting. +The formatting action has no effect on media if -dummy is activated. +.br +Formatting is normally needed only once during the lifetime of a media, +if ever. But it is a reason for re-formatting if: +.br + DVD-RW was deformatted by -blank, +.br + DVD+RW has read failures (re-formatting might help or not), +.br + DVD-RAM or BD-RE shall change their amount of defect reserve. .br The progress reports issued by some drives while formatting are quite unrealistic. Do not conclude success or failure from the reported percentages. Formatting was successful if no SORRY event -or worse occured. +or worse occured. Be patient with apparently frozen progress. .TP \fB\-list_formats\fR Put out a list of format descriptors as reported by the output drive for -the current media. The list gives a "Format idx" number, a MMC profile -code (like "00h" or "26h"), the announced size in blocks (like "2236704s") +the current media. The list gives the index number after "Format idx", +a MMC format code, the announced size in blocks (like "2236704s") and the same size in MiB. +.br +MMC format codes are manifold. Most important are: +"00h" general formatting, "01h" increases reserve space for DVD-RAM, +"26h" for DVD+RW, "30h" for BD-RE with reserve space, +"31h" for BD-RE without reserve space. +.br +Smaller format size with DVD-RAM or BD-RE means more reserve space. .TP .B Settings for data insertion: .TP diff --git a/libisoburn/trunk/xorriso/xorriso.c b/libisoburn/trunk/xorriso/xorriso.c index cd32b914..f29c9f00 100644 --- a/libisoburn/trunk/xorriso/xorriso.c +++ b/libisoburn/trunk/xorriso/xorriso.c @@ -7712,7 +7712,7 @@ int Xorriso_option_ban_stdio_write(struct XorrisO *xorriso, int flag) int Xorriso_option_blank(struct XorrisO *xorriso, char *mode, int flag) { char drive_name[SfileadrL], *cmd= "-blank"; - int aq_ret, ret, aq_flag= 2, mode_flag, as_needed= 0; + int aq_ret, ret, aq_flag= 2, mode_flag, as_needed= 0, idx; if(flag&1) cmd= "-format"; @@ -7741,14 +7741,35 @@ int Xorriso_option_blank(struct XorrisO *xorriso, char *mode, int flag) else if(strcmp(mode, "all")==0 || strcmp(mode, "full")==0) mode_flag= 0; else if((strcmp(mode, "deformat")==0 || - strcmp(mode, "deformat_sequential")==0) && !(flag&1)) + strcmp(mode, "deformat_sequential")==0) && !(flag&1)) mode_flag= 2; else if((strcmp(mode, "deformat_quickest")==0 || - strcmp(mode, "deformat_sequential_quickest")==0) && !(flag&1)) + strcmp(mode, "deformat_sequential_quickest")==0) && !(flag&1)) mode_flag= 3; else if(strcmp(mode, "fast")==0) mode_flag= 1; - else if(mode[0]==0) + else if(strncmp(mode, "by_index_", 9)==0 && (flag&1)) { + mode_flag= 128; + idx= -1; + if(strlen(mode)>9) + sscanf(mode+9, "%d", &idx); + if(idx<0 || idx>255) { +unusable_index:; + sprintf(xorriso->info_text, + "-format: mode '%s' provides unusable index number", mode); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + mode_flag|= (idx<<8); + } else if(strncmp(mode, "fast_by_index_", 14)==0 && (flag&1)) { + mode_flag= 1 | 128; + idx= -1; + if(strlen(mode)>14) + sscanf(mode+14, "%d", &idx); + if(idx<0 || idx>255) + goto unusable_index; + mode_flag|= (idx<<8); + } else if(mode[0]==0) mode_flag= !(flag&1); else { sprintf(xorriso->info_text, @@ -7760,7 +7781,7 @@ int Xorriso_option_blank(struct XorrisO *xorriso, char *mode, int flag) if(as_needed) ret= Xorriso_blank_as_needed(xorriso, (flag&1)<<2); else if(flag&1) - ret= Xorriso_format_media(xorriso, mode_flag&1); + ret= Xorriso_format_media(xorriso, mode_flag & 0xff81); else ret= Xorriso_blank_media(xorriso, mode_flag&3); if(ret==0) @@ -9020,8 +9041,8 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag) " Allow for writing only the usage of optical drives.", " -blank \"fast\"|\"all\"|\"deformat\"|\"deformat_quickest\"", " Blank media resp. invalidate ISO image on media.", -" -format \"full\"", -" Format DVD-RW to overwriteable state or de-ice DVD+RW.", +" -format \"as_needed\"|\"full\"|\"fast\"|\"by_index_#\"|\"fast_by_index_#\"", +" Format BD-RE, DVD-RAM, DVD-RW, DVD+RW.", " -volid volume_id", " Specifies the volume ID text. (32 chars out of [A-Z0-9_])", " -publisher name", diff --git a/libisoburn/trunk/xorriso/xorriso_timestamp.h b/libisoburn/trunk/xorriso/xorriso_timestamp.h index 0acb405e..c6e39360 100644 --- a/libisoburn/trunk/xorriso/xorriso_timestamp.h +++ b/libisoburn/trunk/xorriso/xorriso_timestamp.h @@ -1 +1 @@ -#define Xorriso_timestamP "2008.05.13.180912" +#define Xorriso_timestamP "2008.05.14.114548" diff --git a/libisoburn/trunk/xorriso/xorrisoburn.c b/libisoburn/trunk/xorriso/xorrisoburn.c index e99026e1..6fc5a6f1 100644 --- a/libisoburn/trunk/xorriso/xorrisoburn.c +++ b/libisoburn/trunk/xorriso/xorrisoburn.c @@ -2753,12 +2753,15 @@ int Xorriso_blank_media(struct XorrisO *xorriso, int flag) /* @param flag bit0= try to achieve faster formatting + bit7= by_index mode: + bit8 to bit15 contain the index of the format to use. @return 0=failure, did not touch media , -1=failure, altered media 1=success, altered media , 2=success, did not touch media */ int Xorriso_format_media(struct XorrisO *xorriso, int flag) { - int ret, mode_flag= 0; + int ret, mode_flag= 0, index, status, num_formats; + unsigned dummy; struct burn_drive_info *dinfo; struct burn_drive *drive; struct burn_progress p; @@ -2776,7 +2779,27 @@ int Xorriso_format_media(struct XorrisO *xorriso, int flag) mode_flag= 4; /* format to full size */ burn_disc_get_profile(drive, ¤t_profile, current_profile_name); - if(current_profile == 0x12) { /* DVD+RAM */ + if(flag&128) { /* by_index */ + index= (flag>>8) & 0xff; + ret= burn_disc_get_formats(drive, &status, &size, &dummy, &num_formats); + if(ret<=0) + num_formats= 0; + if(ret<=0 || index<0 || index>=num_formats) { + if(num_formats>0) + sprintf(xorriso->info_text, + "-format by_index_%d: format descriptors range from index 0 to %d", + index, num_formats-1); + else + sprintf(xorriso->info_text, + "-format by_index_%d: no format descriptors available", index); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + mode_flag= (flag & 0xff80) | 4; /* with size taken from descriptor */ + if(flag&1) + mode_flag|= (1<<6); + + } else if(current_profile == 0x12) { /* DVD+RAM */ mode_flag= 6; /* format to default payload size */ if(flag&1) mode_flag|= (1<<6); @@ -2815,7 +2838,7 @@ int Xorriso_format_media(struct XorrisO *xorriso, int flag) sprintf(xorriso->info_text,"Media current: %s (%4.4xh)", current_profile_name, current_profile); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); - return 0; + return(0); } if(xorriso->do_dummy) {