New -blank and -format modes as_needed

This commit is contained in:
Thomas Schmitt 2008-05-12 19:36:23 +00:00
parent 9fec73b9d2
commit 8cecbb1699
5 changed files with 189 additions and 32 deletions

View File

@ -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 XORRISO 1 "May, 10, 2008"
.TH XORRISO 1 "May, 12, 2008"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
@ -918,18 +918,23 @@ Combined -commit and -eject. When writing has finished do not make
-indev and/or -outdev. Eventually give up any non-ejected drive.
.TP
\fB\-blank\fR mode
Blank media resp. invalidate ISO image on media if not -dummy
is activated.
Make media ready for writing from scratch (if not -dummy is activated).
.br
This affects only the -outdev not the -indev.
If both drives are the same and if the ISO image was altered
then this command leads to a FAILURE event.
Defined modes are:
fast, all, deformat, deformat_quickest
as_needed, fast, all, deformat, deformat_quickest
.br
"as_needed" cares for used CD-RW, DVD-RW and for used overwriteable media
by applying -blank "fast". It applies -format "full" to yet unformatted
DVD-RAM or BD-RE.
.br
"fast" and "all" make CD-RW and unformatted DVD-RW re-usable,
or invalidate overwriteable ISO images.
.br
"deformat" converts overwriteable DVD-RW into unformatted ones.
.br
"deformat_quickest" is a faster way to deformat or blank DVD-RW
but produces media which are only suitable for a single session.
xorriso will write onto them only if option -close is set to "on".
@ -940,9 +945,19 @@ reported percentages. Blanking was successful if no SORRY event or
worse occured.
.TP
\fB\-format\fR mode
Convert unformatted DVD-RW into overwriteable ones,
"de-ice" DVD+RW.
For now, mode should be the word "full".
Convert unformatted DVD-RW into overwriteable ones, "de-ice" DVD+RW, format
newly purchased BD-RE, re-format DVD-RAM or BD-RE.
.br
Defined modes are:
.br
as_needed, full, fast
.br
"as_needed" formats yet unformatted DVD-RW, DVD-RAM, BD-RE. Other media
are left untouched.
.br
"full" (re-)formats DVD-RW, DVD+RW, DVD-RAM, BD-RE.
.br
"fast" does the same as "full" but tries to be quicker.
.br
This action has no effect on media if -dummy is activated.
.br
@ -954,7 +969,6 @@ readable in some DVD players.
On the other hand unreliable DVD+RW can sometimes be repaired by
re-formatting.
.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

View File

@ -7712,8 +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;
int ret, aq_flag= 2, mode_flag;
int aq_ret, ret, aq_flag= 2, mode_flag, as_needed= 0;
if(flag&1)
cmd= "-format";
@ -7737,26 +7736,33 @@ int Xorriso_option_blank(struct XorrisO *xorriso, char *mode, int flag)
if(ret<=0)
return(2);
if(strcmp(mode, "all")==0 || strcmp(mode, "full")==0)
if(strcmp(mode, "as_needed")==0)
as_needed= 1;
else if(strcmp(mode, "all")==0 || strcmp(mode, "full")==0)
mode_flag= 0;
else if(strcmp(mode, "deformat")==0 || strcmp(mode, "deformat_sequential")==0)
else if((strcmp(mode, "deformat")==0 ||
strcmp(mode, "deformat_sequential")==0) && !(flag&1))
mode_flag= 2;
else if(strcmp(mode, "deformat_quickest")==0 ||
strcmp(mode, "deformat_sequential_quickest")==0)
else if((strcmp(mode, "deformat_quickest")==0 ||
strcmp(mode, "deformat_sequential_quickest")==0) && !(flag&1))
mode_flag= 3;
else if(strcmp(mode, "fast")==0 || mode[0]==0)
else if(strcmp(mode, "fast")==0)
mode_flag= 1;
else if(mode[0]==0)
mode_flag= !(flag&1);
else {
sprintf(xorriso->info_text,
"%s: Unknown %s mode '%s'",
cmd, ((flag&1) ? "format" : "blank"), mode);
cmd, ((flag&1) ? "-format" : "-blank"), mode);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
}
if(flag&1)
ret= Xorriso_format_media(xorriso, 0);
if(as_needed)
ret= Xorriso_blank_as_needed(xorriso, (flag&1)<<2);
else if(flag&1)
ret= Xorriso_format_media(xorriso, mode_flag&1);
else
ret= Xorriso_blank_media(xorriso, mode_flag);
ret= Xorriso_blank_media(xorriso, mode_flag&3);
if(ret==0)
return(ret);
strcpy(drive_name, xorriso->outdev);

View File

@ -1 +1 @@
#define Xorriso_timestamP "2008.05.12.193341"
#define Xorriso_timestamP "2008.05.12.193642"

View File

@ -558,8 +558,25 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag)
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
ret= 0; goto ex;
}
if(flag&1)
if(xorriso->image_start_mode&(1<<31)) /* used up setting */
xorriso->image_start_mode= 0; /* no need to perform auto setting */
}
drive= dinfo[0].drive;
if(flag&1) {
if(xorriso->image_start_mode&(1<<31)) /* used up setting */
xorriso->image_start_mode&= ~0xffff; /* perform auto setting */
if((xorriso->image_start_mode&(1<<30))) { /* if enabled at all */
ret= isoburn_set_msc1(drive, xorriso->image_start_mode & 0xffff,
xorriso->image_start_value, 0);
if(ret<=0)
goto ex;
if(xorriso->image_start_mode&(1<<31))
xorriso->image_start_mode= 0; /* disable msc1 setting completely */
else
xorriso->image_start_mode|= (1<<31); /* mark as used up */
}
}
state= isoburn_disc_get_status(drive);
Xorriso_process_msg_queues(xorriso,0);
if(flag&1) {
@ -2337,7 +2354,7 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag)
#ifdef Xorriso_new_toc_formaT
sprintf(respt, "TOC layout : %3s , %9s , %10s , %s\n",
"Idx", "sbsector=", "Size", "Volume Id");
"Idx", "sbsector", "Size", "Volume Id");
if(!(flag&1))
Xorriso_result(xorriso,0);
#endif
@ -2453,13 +2470,13 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag)
ret= 0;
else
ret= isoburn_read_iso_head(drive, lba, &image_blocks, volume_id, 1);
if(ret>0 && track_no==num_tracks-1) {
if(ret>0 && track_no==0) {
sprintf(respt, "ISO session : %3d , %9d , %9ds , %s\n",
session_no+1, lba, image_blocks , volume_id);
} else if(ret>0 && track_no==num_tracks-1) {
} else if(ret>0) {
sprintf(respt, "ISO track : %3d , %9d , %9ds , %s\n",
track_count, lba, image_blocks , volume_id);
} else if(track_no==num_tracks-1) {
} else if(track_no==0) {
sprintf(respt, "Other session: %3d , %9d , %9ds , \n",
session_no+1, lba, track_size);
} else {
@ -2659,8 +2676,6 @@ int Xorriso_blank_media(struct XorrisO *xorriso, int flag)
burn_disc_get_profile(drive, &current_profile, current_profile_name);
/* >>> */;
disc_state = isoburn_disc_get_status(drive);
if(current_profile == 0x13) { /* overwriteable DVD-RW */
/* Depending on flag bit1 formatted DVD-RW will get blanked to sequential
@ -2714,6 +2729,7 @@ int Xorriso_blank_media(struct XorrisO *xorriso, int flag)
isoburn_disc_erase(drive, (flag&1));
usleep(1000000);
while (burn_drive_get_status(drive, &p) != BURN_DRIVE_IDLE) {
Xorriso_process_msg_queues(xorriso,0);
if(p.sectors>0 && p.sector>=0) /* display 1 to 99 percent */
percent = 1.0 + ((double) p.sector+1.0) / ((double) p.sectors) * 98.0;
sprintf(xorriso->info_text, "Blanking ( %.1f%% done )", percent);
@ -2726,7 +2742,9 @@ int Xorriso_blank_media(struct XorrisO *xorriso, int flag)
return(1);
}
/* @return 0=failure, did not touch media , -1=failure, altered media
/* @param flag bit0= try to achieve faster formatting
@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)
@ -2734,24 +2752,56 @@ int Xorriso_format_media(struct XorrisO *xorriso, int flag)
int ret, mode_flag= 0;
struct burn_drive_info *dinfo;
struct burn_drive *drive;
struct burn_progress p;
double percent = 1.0;
int current_profile;
char current_profile_name[80];
off_t size= 0;
time_t start_time;
ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
"on attempt to -format", 2);
if(ret<=0)
return(0);
mode_flag= 4; /* format to full size */
burn_disc_get_profile(drive, &current_profile, current_profile_name);
if(current_profile == 0x14) { /* DVD-RW sequential */
size= 128*1024*1024;
mode_flag= 1;
if(current_profile == 0x12) { /* DVD+RAM */
mode_flag= 6; /* format to default payload size */
if(flag&1)
mode_flag|= (1<<6);
} else if(current_profile == 0x13) { /* DVD-RW */
if(flag&1) {
sprintf(xorriso->info_text,
"Detected formatted DVD-RW. Thus omitting desired fast format run.");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
return(2);
}
} else if(current_profile == 0x14) { /* DVD-RW sequential */
if(flag&1) {
size= 128*1024*1024;
mode_flag= 1; /* format to size, then write size of zeros */
}
} else if(current_profile == 0x1a) { /* DVD+RW */
mode_flag= 2;
if(flag&1) {
sprintf(xorriso->info_text,
"Detected DVD+RW. Thus omitting desired fast format run.");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
return(2);
}
} else if(current_profile == 0x43) { /* BD-RE */
mode_flag= 6; /* format to default payload size */
if(flag&1)
mode_flag|= (1<<6);
} else {
sprintf(xorriso->info_text,
"Can only -format DVD+RW and sequential DVD-RW");
"-format: Unsuitable media detected.");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
sprintf(xorriso->info_text,"Media current: %s (%4.4xh)",
current_profile_name, current_profile);
@ -2768,9 +2818,27 @@ int Xorriso_format_media(struct XorrisO *xorriso, int flag)
Xorriso_info(xorriso, 0);
burn_disc_format(drive, size, mode_flag);
#ifdef NIX
/* <<< too boring */
ret= Xorriso_pacifier_loop(xorriso, drive, 0);
if(ret<=0)
return(ret);
#else
start_time= time(0);
usleep(1000000);
while (burn_drive_get_status(drive, &p) != BURN_DRIVE_IDLE) {
Xorriso_process_msg_queues(xorriso,0);
if(p.sectors>0 && p.sector>=0) /* display 1 to 99 percent */
percent = 1.0 + ((double) p.sector+1.0) / ((double) p.sectors) * 98.0;
sprintf(xorriso->info_text, "Formatting ( %.1f%% done in %d seconds)",
percent, (int) (time(0) - start_time));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "UPDATE", 0);
usleep(1000000);
}
#endif /* ! NIX */
Xorriso_process_msg_queues(xorriso,0);
sprintf(xorriso->info_text, "Formatting done\n");
@ -2779,6 +2847,60 @@ int Xorriso_format_media(struct XorrisO *xorriso, int flag)
}
/* @param flag bit2= formatting rather than blanking
@return 0=failure, did not touch media , -1=failure, altered media
1=success, altered media , 2=success, did not touch media
*/
int Xorriso_blank_as_needed(struct XorrisO *xorriso, int flag)
{
int ret, is_formatted= -1, status, num_formats;
struct burn_drive_info *dinfo;
struct burn_drive *drive;
enum burn_disc_status disc_state;
unsigned dummy;
int current_profile;
char current_profile_name[80];
off_t size;
ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
"on attempt to blank or format", 2);
if(ret<=0)
return(0);
burn_disc_get_profile(drive, &current_profile, current_profile_name);
ret= burn_disc_get_formats(drive, &status, &size, &dummy, &num_formats);
if(ret>0 && status==BURN_FORMAT_IS_FORMATTED)
is_formatted= 1;
if(current_profile == 0x12 || current_profile == 0x43) { /* DVD+RAM , BD-RE */
if(is_formatted<0) {
sprintf(xorriso->info_text,
"-blank or -format: Unclear formatting status of %s",
current_profile_name);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
}
if(!is_formatted) {
ret= Xorriso_format_media(xorriso, 0);
return(ret);
}
} else if(current_profile == 0x14 && (flag&4)) { /* DVD-RW sequential */
ret= Xorriso_format_media(xorriso, 0);
return(ret);
}
disc_state = isoburn_disc_get_status(drive);
if(disc_state != BURN_DISC_BLANK && !(flag&4)) {
ret= Xorriso_blank_media(xorriso, 1);
return(ret);
}
sprintf(xorriso->info_text, "%s as_needed: no need for action detected",
(flag&4) ? "-format" : "-blank");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
return(2);
}
int Xorriso_cannot_create_iter(struct XorrisO *xorriso, int iso_error,int flag)
{
Xorriso_process_msg_queues(xorriso,0);

View File

@ -62,10 +62,25 @@ int Xorriso_show_devices(struct XorrisO *xorriso, int flag);
int Xorriso_tell_media_space(struct XorrisO *xorriso,
int *media_space, int *free_space, int flag);
/* @param flag bit0=fast , bit1=deformat
@return 0=failure, did not touch media , -1=failure, altered media
1=success, altered media , 2=success, did not touch media
*/
int Xorriso_blank_media(struct XorrisO *xorriso, int flag);
/* @param flag bit0= try to achieve faster formatting
@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);
/* @param flag bit2= formatting rather than blanking
@return 0=failure, did not touch media , -1=failure, altered media
1=success, altered media , 2=success, did not touch media
*/
int Xorriso_blank_as_needed(struct XorrisO *xorriso, int flag);
/* @param boss_iter Opaque internal handle. Use NULL outside xorrisoburn.c :
If not NULL then this is an iterator suitable for
iso_dir_iter_remove() which is then to be used instead