New -format modes by_size_ and fast_by_size_
This commit is contained in:
parent
7618b01d1c
commit
22d8836f85
@ -10930,7 +10930,8 @@ 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, idx;
|
||||
int aq_ret, ret, aq_flag= 2, mode_flag= 0, as_needed= 0, idx;
|
||||
off_t size= 0;
|
||||
|
||||
if(flag&1)
|
||||
cmd= "-format";
|
||||
@ -10987,6 +10988,21 @@ unusable_index:;
|
||||
if(idx<0 || idx>255)
|
||||
goto unusable_index;
|
||||
mode_flag|= (idx<<8);
|
||||
} else if(strncmp(mode, "by_size_", 8) == 0 && (flag & 1)) {
|
||||
size= (off_t) Scanf_io_size(mode + 8, 0);
|
||||
if(size <= 0) {
|
||||
unusable_size:;
|
||||
sprintf(xorriso->info_text,
|
||||
"-format: mode '%s' provides unusable size value", mode);
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
||||
return(0);
|
||||
}
|
||||
mode_flag= 2;
|
||||
} else if(strncmp(mode, "fast_by_size_", 13) == 0 && (flag & 1)) {
|
||||
size= (off_t) Scanf_io_size(mode + 13, 0);
|
||||
if(size <= 0)
|
||||
goto unusable_size;
|
||||
mode_flag= 3;
|
||||
} else {
|
||||
sprintf(xorriso->info_text,
|
||||
"%s: Unknown %s mode '%s'",
|
||||
@ -10997,7 +11013,7 @@ unusable_index:;
|
||||
if(as_needed)
|
||||
ret= Xorriso_blank_as_needed(xorriso, (flag&1)<<2);
|
||||
else if(flag&1)
|
||||
ret= Xorriso_format_media(xorriso, mode_flag & 0xff81);
|
||||
ret= Xorriso_format_media(xorriso, size, mode_flag & 0xff83);
|
||||
else
|
||||
ret= Xorriso_blank_media(xorriso, mode_flag&3);
|
||||
if(ret==0)
|
||||
@ -12872,7 +12888,7 @@ 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 \"as_needed\"|\"full\"|\"fast\"|\"by_index_#\"|\"fast_by_index_#\"",
|
||||
" -format \"as_needed\"|\"full\"|\"fast\"|\"by_index_#\"|\"by_size_#\"",
|
||||
" Format BD-RE, DVD-RAM, DVD-RW, DVD+RW.",
|
||||
" -volid volume_id",
|
||||
" Specifies the volume ID text. (32 chars out of [A-Z0-9_])",
|
||||
|
@ -1 +1 @@
|
||||
#define Xorriso_timestamP "2008.12.11.072427"
|
||||
#define Xorriso_timestamP "2008.12.13.142726"
|
||||
|
@ -1014,7 +1014,7 @@ int Xorriso_auto_format(struct XorrisO *xorriso, int flag)
|
||||
"Unformatted %s media detected. Trying -format fast.",
|
||||
profile_name);
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
|
||||
ret= Xorriso_format_media(xorriso, 1 | 4);
|
||||
ret= Xorriso_format_media(xorriso, (off_t) 0, 1 | 4);
|
||||
if(ret<=0) {
|
||||
sprintf(xorriso->info_text, "Automatic formatting of %s failed",
|
||||
profile_name);
|
||||
@ -1054,42 +1054,6 @@ int Xorriso_write_session(struct XorrisO *xorriso, int flag)
|
||||
int profile_number;
|
||||
char profile_name[80];
|
||||
|
||||
#ifdef NIX
|
||||
|
||||
int profile, status, num_formats;
|
||||
off_t size;
|
||||
unsigned dummy;
|
||||
|
||||
ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
|
||||
"on attempt to write", 2);
|
||||
if(ret<=0)
|
||||
return(0);
|
||||
ret= burn_disc_get_profile(drive, &profile, profile_name);
|
||||
if(ret>0 && (!(flag&1)) &&
|
||||
(profile==0x12 || profile==0x43)) { /* DVD-RAM or BD-RE */
|
||||
ret= burn_disc_get_formats(drive, &status, &size, &dummy, &num_formats);
|
||||
if(ret>0 && status==BURN_FORMAT_IS_UNFORMATTED) {
|
||||
sprintf(xorriso->info_text,
|
||||
"Unformatted %s media detected. Trying -format fast.",
|
||||
profile_name);
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
|
||||
ret= Xorriso_format_media(xorriso, 1);
|
||||
if(ret<=0) {
|
||||
sprintf(xorriso->info_text, "Automatic formatting of %s failed",
|
||||
profile_name);
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
||||
return(ret);
|
||||
}
|
||||
ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
|
||||
"on attempt to write", 2);
|
||||
if(ret<=0)
|
||||
return(0);
|
||||
ret= burn_disc_get_profile(drive, &profile, profile_name);
|
||||
}
|
||||
}
|
||||
|
||||
#else /* NIX */
|
||||
|
||||
if(!(flag & 1)) {
|
||||
ret= Xorriso_auto_format(xorriso, 0);
|
||||
if(ret <=0 )
|
||||
@ -1099,9 +1063,6 @@ int Xorriso_write_session(struct XorrisO *xorriso, int flag)
|
||||
"on attempt to write", 2);
|
||||
if(ret<=0)
|
||||
return(0);
|
||||
|
||||
#endif /* ! NIX */
|
||||
|
||||
if(xorriso->out_drive_handle == xorriso->in_drive_handle) {
|
||||
source_drive= drive;
|
||||
} else {
|
||||
@ -4490,13 +4451,14 @@ int Xorriso_blank_media(struct XorrisO *xorriso, int flag)
|
||||
|
||||
|
||||
/* @param flag bit0= try to achieve faster formatting
|
||||
bit1= use parameter size (else use default size)
|
||||
bit2= do not re-aquire drive
|
||||
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 Xorriso_format_media(struct XorrisO *xorriso, off_t in_size, int flag)
|
||||
{
|
||||
int ret, mode_flag= 0, index, status, num_formats;
|
||||
unsigned dummy;
|
||||
@ -4515,7 +4477,11 @@ int Xorriso_format_media(struct XorrisO *xorriso, int flag)
|
||||
if(ret<=0)
|
||||
return(0);
|
||||
|
||||
if(flag & 2) {
|
||||
mode_flag= 0; /* format to given size */
|
||||
} else {
|
||||
mode_flag= 4; /* format to full size */
|
||||
}
|
||||
burn_disc_get_profile(drive, ¤t_profile, current_profile_name);
|
||||
|
||||
if(flag&128) { /* by_index */
|
||||
@ -4534,11 +4500,12 @@ int Xorriso_format_media(struct XorrisO *xorriso, int flag)
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
||||
return(0);
|
||||
}
|
||||
mode_flag= (flag & 0xff80) | 4; /* with size taken from descriptor */
|
||||
mode_flag|= (flag & 0xff80);
|
||||
if(flag&1)
|
||||
mode_flag|= (1<<6);
|
||||
|
||||
} else if(current_profile == 0x12) { /* DVD+RAM */
|
||||
if(!(flag & 2))
|
||||
mode_flag= 6; /* format to default payload size */
|
||||
if(flag&1)
|
||||
mode_flag|= (1<<6);
|
||||
@ -4552,7 +4519,7 @@ int Xorriso_format_media(struct XorrisO *xorriso, int flag)
|
||||
}
|
||||
|
||||
} else if(current_profile == 0x14) { /* DVD-RW sequential */
|
||||
if(flag&1) {
|
||||
if((flag & 3) == 1) {
|
||||
size= 128*1024*1024;
|
||||
mode_flag= 1; /* format to size, then write size of zeros */
|
||||
}
|
||||
@ -4566,11 +4533,13 @@ int Xorriso_format_media(struct XorrisO *xorriso, int flag)
|
||||
}
|
||||
|
||||
} else if(current_profile == 0x41) { /* BD-R SRM */
|
||||
if(!(flag & 2))
|
||||
mode_flag= 6; /* format to default payload size */
|
||||
if(flag&1)
|
||||
mode_flag|= (1<<6);
|
||||
|
||||
} else if(current_profile == 0x43) { /* BD-RE */
|
||||
if(!(flag & 2))
|
||||
mode_flag= 6; /* format to default payload size */
|
||||
if(flag&1)
|
||||
mode_flag|= (1<<6);
|
||||
@ -4594,6 +4563,8 @@ int Xorriso_format_media(struct XorrisO *xorriso, int flag)
|
||||
}
|
||||
sprintf(xorriso->info_text, "Beginning to format media.\n");
|
||||
Xorriso_info(xorriso, 0);
|
||||
if(flag & 2)
|
||||
size= in_size;
|
||||
burn_disc_format(drive, size, mode_flag);
|
||||
|
||||
start_time= time(0);
|
||||
@ -4675,19 +4646,19 @@ int Xorriso_blank_as_needed(struct XorrisO *xorriso, int flag)
|
||||
return(0);
|
||||
}
|
||||
if(!is_formatted) {
|
||||
ret= Xorriso_format_media(xorriso, (current_profile == 0x43));
|
||||
ret= Xorriso_format_media(xorriso, (off_t) 0, (current_profile == 0x43));
|
||||
if(ret <= 0)
|
||||
return(ret);
|
||||
did_work= (ret == 1);
|
||||
}
|
||||
} else if(current_profile == 0x14 && (flag&4)) { /* DVD-RW sequential */
|
||||
ret= Xorriso_format_media(xorriso, 0);
|
||||
ret= Xorriso_format_media(xorriso, (off_t) 0, 0);
|
||||
if(ret <= 0)
|
||||
return(ret);
|
||||
did_work= (ret == 1);
|
||||
} else if(current_profile == 0x41) { /* BD-R SRM */
|
||||
if(!is_formatted) {
|
||||
ret= Xorriso_format_media(xorriso, 1);
|
||||
ret= Xorriso_format_media(xorriso, (off_t) 0, 1);
|
||||
if(ret <= 0)
|
||||
return(ret);
|
||||
did_work= (ret == 1);
|
||||
|
@ -74,10 +74,14 @@ int Xorriso_tell_media_space(struct XorrisO *xorriso,
|
||||
int Xorriso_blank_media(struct XorrisO *xorriso, int flag);
|
||||
|
||||
/* @param flag bit0= try to achieve faster formatting
|
||||
bit1= use parameter size (else use default size)
|
||||
bit2= do not re-aquire drive
|
||||
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 Xorriso_format_media(struct XorrisO *xorriso, off_t size, int flag);
|
||||
|
||||
/* @return <=0 error, 1 success
|
||||
*/
|
||||
@ -365,6 +369,14 @@ int Xorriso_get_relax_text(struct XorrisO *xorriso, char mode[1024],
|
||||
int flag);
|
||||
|
||||
|
||||
/**
|
||||
@param flag bit0= print mount command to result channel rather than
|
||||
performing it
|
||||
*/
|
||||
int Xorriso_mount(struct XorrisO *xorriso, char *dev, int adr_mode,
|
||||
char *adr_value, char *cmd, int flag);
|
||||
|
||||
|
||||
/* A pseudo file type for El-Torito bootsectors as in man 2 stat :
|
||||
For now take the highest possible value.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user