Implemented a more reasonable solution for drive truncation with regular files

This commit is contained in:
2008-02-21 18:52:52 +00:00
parent c9067f4142
commit 4a27bf19e8
8 changed files with 59 additions and 17 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 "February 20, 2008"
.TH XORRISO 1 "February 21, 2008"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
@ -1289,8 +1289,9 @@ persists until things happen like -commit, -rollback, -dev, or end of xorriso.
If no output file was chosen before or during a "mkisofs" option list, then
standard output (-outdev "-") will get into effect before pathspecs get
added. If -o points to a regular file, then it will be truncated to 0 bytes
before "mkisofs" options are processed. Directories and symbolic links
are no valid -o targets.
when finally writing begins. This truncation does not happen if the drive
is chosen by xorriso options before or after -as mkisofs.
Directories and symbolic links are no valid -o targets.
.br
Writing to stdout is possible only if -as "mkisofs" was among the start
arguments or if other start arguments pointed the output drive to

View File

@ -6524,11 +6524,13 @@ int Xorriso_genisofs(struct XorrisO *xorriso, char *whom,
if(adr[0]) {
if(strncmp(adr, "stdio:", 6)==0 && strncmp(adr, "stdio:/dev/fd/", 14)!=0) {
ret= Sfile_type(adr+6, 1);
if(ret==-1)
if(ret==-1) {
/* ok */;
else if(ret==1) {
/* >>> would prefer to do this later ... or leave it to libburn */;
#ifdef NIX
} else if(ret==1) {
/* <<< is now done in libisoburn by bit4 of Xorriso_option_dev() */
ret= truncate(adr+6, (off_t) 0);
if(ret==-1) {
@ -6540,6 +6542,8 @@ int Xorriso_genisofs(struct XorrisO *xorriso, char *whom,
sprintf(xorriso->info_text, "-as %s: Truncated existing -o %s",
whom, Text_shellsafe(adr+6, sfe, 0));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
#endif /* NIX */
} else if(ret==2 || ret==3) {
sprintf(xorriso->info_text,
"-as %s: Cannot accept %s as target: -o %s",
@ -6548,7 +6552,8 @@ int Xorriso_genisofs(struct XorrisO *xorriso, char *whom,
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
}
}
ret= Xorriso_option_dev(xorriso, adr, 2|8); /* overwriteable as blank */
/* Regard overwriteable as blank, truncate regular files on write start */
ret= Xorriso_option_dev(xorriso, adr, 2|8|16);
if(ret<=0)
goto ex;
}
@ -7501,10 +7506,12 @@ int Xorriso_option_cut_out(struct XorrisO *xorriso, char *disk_path,
/* Options -dev , -indev, -outdev */
/** @param flag bit0=use as indev
/** @param flag bit0= use as indev
bit1= use as outdev
bit2= do not -reassure
bit3= regard overwriteable media as blank
bit4= if the drive is a regular disk file: truncate it to
the write start address
@return <=0 error , 1 success, 2 revoked by -reassure
*/
int Xorriso_option_dev(struct XorrisO *xorriso, char *in_adr, int flag)
@ -7564,7 +7571,7 @@ int Xorriso_option_dev(struct XorrisO *xorriso, char *in_adr, int flag)
}
ret= Xorriso_give_up_drive(xorriso, flag&3);
} else
ret= Xorriso_aquire_drive(xorriso, adr, (flag&3)|((flag&8)>>1));
ret= Xorriso_aquire_drive(xorriso, adr, (flag&3)|((flag&(8|16))>>1));
if(ret<=0)
return(ret);
return(1);

View File

@ -1 +1 @@
#define Xorriso_timestamP "2008.02.21.130047"
#define Xorriso_timestamP "2008.02.21.185203"

View File

@ -417,9 +417,11 @@ int Xorriso_create_empty_iso(struct XorrisO *xorriso, int flag)
}
/* @param flag bit0=aquire as isoburn input drive
bit1=aquire as libburn output drive (as isoburn drive if bit0)
bit2=regard overwriteable media as blank
/* @param flag bit0= aquire as isoburn input drive
bit1= aquire as libburn output drive (as isoburn drive if bit0)
bit2= regard overwriteable media as blank
bit3= if the drive is a regular disk file: truncate it to
the write start address
@return <=0 failure , 1= ok
2=success, but not writeable with bit1
3=success, but not blank and not ISO with bit0
@ -477,7 +479,7 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag)
}
if(dinfo==NULL) {
ret= isoburn_drive_aquire(&dinfo, libburn_adr, 1|((flag&4)>>1));
ret= isoburn_drive_aquire(&dinfo, libburn_adr, 1|((flag&(8|4))>>1));
Xorriso_process_msg_queues(xorriso,0);
if(ret<=0) {
sprintf(xorriso->info_text,"Cannot aquire drive '%s'", adr);