diff --git a/libisoburn/trunk/xorriso/xorriso.1 b/libisoburn/trunk/xorriso/xorriso.1 index 52d70d69..2a8a25cf 100644 --- a/libisoburn/trunk/xorriso/xorriso.1 +++ b/libisoburn/trunk/xorriso/xorriso.1 @@ -586,6 +586,30 @@ exist, then iso_rr_path gets deleted. addressing: Its semantics is similar to -add and thus avoids the pitfalls inherited from cp -r behavior. Its syntax resembles cp, though. .TP +\fB\-cut_out\fR disk_path byte_offset byte_count iso_rr_path +WARNING: This option is fewly tested. +Especially it is not coordinated with -compare_r and -update_r. +.br +Map a byte interval of a regular disk file into a regular file in the ISO +image. +This may be necessary if the disk file is larger than a single media, or if +it exceeds the traditional limit of 2 GiB - 2 kiB for old operating systems, +or the limit of 4 GiB - 2 kiB for newer ones. +.br +The clumsy remedy for this limit is to backup file pieces and to concatenate +them at restore time. A well tested chopping size is 2047m. +It is permissible to request a higher byte_count than available. The +resulting file will be truncated to the correct size of a final piece. +To request a byte_offset higher than available yields no file in +the ISO image but a SORRY event. +E.g: +.br +-cut_out disk_file 0 2047m iso_rr_part1 +.br +-cut_out disk_file 2047m 2047m iso_rr_part2 +.br +-cut_out disk_file 4094m 2047m iso_rr_part3 +.TP \fB\-rm\fR iso_rr_path [***] Delete the given files from the ISO image. .br diff --git a/libisoburn/trunk/xorriso/xorriso.c b/libisoburn/trunk/xorriso/xorriso.c index 29c8580b..34ec2769 100644 --- a/libisoburn/trunk/xorriso/xorriso.c +++ b/libisoburn/trunk/xorriso/xorriso.c @@ -7159,7 +7159,7 @@ int Xorriso_update_interpreter(struct XorrisO *xorriso, void *boss_iter, if(ret>0) { deleted= 1; ret= Xorriso_graft_in(xorriso, boss_iter, disk_path, iso_rr_path, - 2|(flag&4)); + (off_t) 0, (off_t) 0, 2|(flag&4)); } sprintf(xorriso->info_text, "Deleted and re-added "); @@ -7173,7 +7173,7 @@ int Xorriso_update_interpreter(struct XorrisO *xorriso, void *boss_iter, /* iso_adr not existing, size, cannot open iso file, early eof of iso file content bytes differ */ ret= Xorriso_graft_in(xorriso, boss_iter, disk_path, iso_rr_path, - 2|(flag&4)); + (off_t) 0, (off_t) 0, 2|(flag&4)); sprintf(xorriso->info_text, "Added/overwrote "); } else if(compare_result&(4|16|32|256|512|1024)) { @@ -7288,7 +7288,7 @@ int Xorriso_option_add(struct XorrisO *xorriso, int argc, char **argv, goto problem_handler; strcpy(source, eff_path); - ret= Xorriso_graft_in(xorriso, NULL, source, target, 0); + ret= Xorriso_graft_in(xorriso, NULL, source, target, (off_t)0, (off_t)0, 0); if(ret<=0 || xorriso->request_to_abort) goto problem_handler; sprintf(xorriso->info_text, "Added to ISO image: %s '%s'='%s'\n", @@ -8052,7 +8052,8 @@ int Xorriso_option_cpri(struct XorrisO *xorriso, int argc, char **argv, goto problem_handler; } } - ret= Xorriso_graft_in(xorriso, NULL, eff_origin, eff_dest, 0); + ret= Xorriso_graft_in(xorriso, NULL, eff_origin, eff_dest, + (off_t) 0, (off_t) 0, 0); if(ret<=0 || xorriso->request_to_abort) goto problem_handler; sprintf(xorriso->info_text, "Added to ISO image: %s '%s'='%s'\n", @@ -8079,15 +8080,37 @@ ex:; /* Option -cut_out */ int Xorriso_option_cut_out(struct XorrisO *xorriso, char *disk_path, - off_t startbyte, off_t bytecount, char *iso_rr_path, int flag) + char *start, char *count, char *iso_rr_path, int flag) { + int ret; + double num; + off_t startbyte, bytecount; - fprintf(stderr, - ">>> LIBISOFS : would cut out from %s , byte %.f to %.f, and graft as %s", + num= Scanf_io_size(start, 0); + if(num<0 || num > 1.0e18) { /* 10^18 = 10^3 ^ 6 < 2^10 ^ 6 = 2^60 */ + sprintf(xorriso->info_text, + "-cut_out: startbyte address negative or much too large (%s)", start); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + startbyte= num; + num= Scanf_io_size(count, 0); + if(num<=0 || num > 1.0e18) { + sprintf(xorriso->info_text, + "-cut_out: bytecount zero, negative or much too large (%s)", count); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + bytecount= num; + sprintf(xorriso->info_text, + "-cut_out from %s , byte %.f to %.f, and graft as %s", disk_path, (double) startbyte, (double) (startbyte+bytecount), iso_rr_path); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); - return(1); + ret= Xorriso_cut_out(xorriso, disk_path, startbyte, bytecount, + iso_rr_path, 0); + return(ret); } @@ -10258,8 +10281,7 @@ return: { int ret, was_dashed, end_ret; int num1, num2; - double d1, d2; - char *cmd, *arg1, *arg2, *arg4; + char *cmd, *arg1, *arg2; if(xorriso==NULL) return(0); @@ -10386,17 +10408,15 @@ next_command:; ret= Xorriso_option_cpri(xorriso, argc, argv, idx, 0); } else if(strcmp(cmd,"cut_out")==0) { - (*idx)+= 2; - d1= d2= -1; - sscanf(arg2,"%lf", &d1); - if((*idx)argc) { + sprintf(xorriso->info_text, + "-cut_out: Not enough arguments. Needed are: disk_path start count so_rr_path"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; + } else + ret= Xorriso_option_cut_out(xorriso, arg1, arg2, + argv[(*idx)-2], argv[(*idx)-1], 0); } else if(strcmp(cmd,"dev")==0) { (*idx)++; diff --git a/libisoburn/trunk/xorriso/xorriso.h b/libisoburn/trunk/xorriso/xorriso.h index 79446951..44cf9aae 100644 --- a/libisoburn/trunk/xorriso/xorriso.h +++ b/libisoburn/trunk/xorriso/xorriso.h @@ -233,11 +233,9 @@ int Xorriso_option_compare(struct XorrisO *xorriso, char *disk_path, int Xorriso_option_cpri( struct XorrisO *xorriso, int argc, char **argv, int *idx, int flag); -/* >>> not yet implemented - / * Option -cut_out * / - int Xorriso_option_cut_out(struct XorrisO *xorriso, char *disk_path, - off_t startbyte, off_t bytecount, char *iso_rr_path, int flag); -*/ +/* Option -cut_out */ +int Xorriso_option_cut_out(struct XorrisO *xorriso, char *disk_path, + char *start, char *count, char *iso_rr_path, int flag); /* Options -dev , -indev, -outdev */ /* @param flag bit0=use as indev , bit1= use as outdev diff --git a/libisoburn/trunk/xorriso/xorriso_private.h b/libisoburn/trunk/xorriso/xorriso_private.h index 039a7dbc..74273d86 100644 --- a/libisoburn/trunk/xorriso/xorriso_private.h +++ b/libisoburn/trunk/xorriso/xorriso_private.h @@ -368,6 +368,9 @@ char *Text_shellsafe(char *in_text, char *out_text, int flag); int Sort_argv(int argc, char **argv, int flag); +/* @param flag bit0= single letters */ +char *Ftypetxt(mode_t st_mode, int flag); + struct DirseQ; int Dirseq_new(struct DirseQ **o, char *adr, int flag); diff --git a/libisoburn/trunk/xorriso/xorriso_timestamp.h b/libisoburn/trunk/xorriso/xorriso_timestamp.h index e53edaad..39b5580f 100644 --- a/libisoburn/trunk/xorriso/xorriso_timestamp.h +++ b/libisoburn/trunk/xorriso/xorriso_timestamp.h @@ -1 +1 @@ -#define Xorriso_timestamP "2008.03.08.104231" +#define Xorriso_timestamP "2008.03.09.142200" diff --git a/libisoburn/trunk/xorriso/xorrisoburn.c b/libisoburn/trunk/xorriso/xorrisoburn.c index 545b11a7..5d27cb12 100644 --- a/libisoburn/trunk/xorriso/xorrisoburn.c +++ b/libisoburn/trunk/xorriso/xorrisoburn.c @@ -1433,10 +1433,14 @@ int Xorriso_transfer_properties(struct XorrisO *xorriso, struct stat *stbuf, } -/* Ticket 132 : Workaround for missing feature iso_tree_add_new_node() */ +/* Ticket 132 : Former workaround for missing feature iso_tree_add_new_node() + which is now available and gets used here. + @param flag bit3= cut_out_node: offset and size are valid +*/ int Xorriso_tree_graft_node(struct XorrisO *xorriso, IsoImage *volume, IsoDir *dir, char *disk_path, char *img_name, char *nominal_source, char *nominal_target, + off_t offset, off_t cut_size, IsoNode **node, int flag) { int ret; @@ -1473,7 +1477,11 @@ int Xorriso_tree_graft_node(struct XorrisO *xorriso, IsoImage *volume, #else /* Xorriso_workaround_ticket_132 */ - ret= iso_tree_add_new_node(volume, dir, img_name, disk_path, node); + if(flag&8) + ret= iso_tree_add_new_cut_out_node(volume, dir, img_name, disk_path, + offset, cut_size, node); + else + ret= iso_tree_add_new_node(volume, dir, img_name, disk_path, node); #endif /* Xorriso_workaround_ticket_132 */ @@ -1691,13 +1699,13 @@ cannot_lstat:; #ifdef NIX ret= iso_tree_add_node(volume, dir, srcpt, &node); if(ret<0) { - Xorriso_report_iso_error(xorriso, stbuf_src, ret, + Xorriso_report_iso_error(xorriso, "", ret, "Cannot add node to tree", 0, "FAILURE", 1|2); goto was_problem; } #else ret= Xorriso_tree_graft_node(xorriso, volume, dir, srcpt, img_name, - stbuf_src, img_path, + "", img_path, (off_t) 0, (off_t) 0, &node, 0); #endif } @@ -1835,10 +1843,12 @@ int Xorriso_copy_properties(struct XorrisO *xorriso, @param flag bit0= mkdir: graft in as empty directory, not as copy from disk bit1= do not report added files bit2= -follow: this is not a command parameter + bit3= use offset and cut_size for cut_out_node @return <=0 = error , 1 = added simple node , 2 = added directory */ int Xorriso_graft_in(struct XorrisO *xorriso, void *boss_iter, - char *disk_path, char *img_path, int flag) + char *disk_path, char *img_path, + off_t offset, off_t cut_size, int flag) { IsoImage *volume; char path[SfileadrL], *apt, *npt, *cpt, sfe[5*SfileadrL], sfe2[5*SfileadrL]; @@ -2014,11 +2024,6 @@ handle_path_node:; } if(done) { attach_source:; - xorriso->pacifier_count++; - if(xorriso->pacifier_count%100 && !(flag&2)) - Xorriso_pacifier_callback(xorriso, "files added", - xorriso->pacifier_count, - xorriso->pacifier_total, "", 0); if(flag&1) { /* directory node was created above */; @@ -2051,9 +2056,9 @@ attach_source:; } #else ret= Xorriso_tree_graft_node(xorriso, volume, dir, disk_path_pt, apt, - disk_path, img_path, &node, 0); + disk_path, img_path, + offset, cut_size, &node, flag&8); if(ret<0) { - Xorriso_msgs_submit(xorriso, 0, disk_path, 0, "ERRFILE", 0); sprintf(xorriso->info_text, "Grafting failed: %s = %s", Text_shellsafe(img_path,sfe,0), Text_shellsafe(disk_path,sfe2,0)); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); @@ -2062,6 +2067,12 @@ attach_source:; #endif xorriso->volset_change_pending= 1; iso_node_set_name(node, apt); + + xorriso->pacifier_count++; + if(xorriso->pacifier_count%100 && !(flag&2)) + Xorriso_pacifier_callback(xorriso, "files added", + xorriso->pacifier_count, + xorriso->pacifier_total, "", 0); } } else *npt= '/'; @@ -2071,6 +2082,69 @@ attach_source:; } +/* @param flag bit0= -follow: disk_path is not a command parameter +*/ +int Xorriso_cut_out(struct XorrisO *xorriso, char *disk_path, + off_t startbyte, off_t bytecount, char *iso_rr_path, int flag) +{ + int ret; + char eff_source[SfileadrL], eff_dest[SfileadrL], sfe[SfileadrL*5]; + struct stat stbuf; + + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, disk_path, eff_source, + 2|4); + if(ret<=0) + return(ret); + + if(lstat(eff_source, &stbuf)==-1) { + Xorriso_msgs_submit(xorriso, 0, eff_source, 0, "ERRFILE", 0); + sprintf(xorriso->info_text, "-cut_out: Cannot determine type of %s", + Text_shellsafe(eff_source, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0); + return(0); + } + + if((stbuf.st_mode&S_IFMT) == S_IFLNK) { + if(!(xorriso->do_follow_links || (xorriso->do_follow_param && !(flag&1)))) + goto unsupported_type; + if(stat(eff_source, &stbuf)==-1) { + Xorriso_msgs_submit(xorriso, 0, eff_source, 0, "ERRFILE", 0); + sprintf(xorriso->info_text, + "-cut_out: Cannot determine link target type of %s", + Text_shellsafe(eff_source, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE",0); + return(0); + } + } + if(S_ISREG(stbuf.st_mode)) { + if(stbuf.st_sizeinfo_text, + "-cut_out: Byte offset %.f larger than file size %.f", + (double) startbyte, (double) stbuf.st_size); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "SORRY", 0); + return(0); + } + } else { +unsupported_type:; + Xorriso_msgs_submit(xorriso, 0, eff_source, 0, "ERRFILE", 0); + sprintf(xorriso->info_text, "-cut_out: Unsupported file type %s with %s", + Ftypetxt(stbuf.st_mode, 0), Text_shellsafe(eff_source, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0); + return(0); + } + + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, iso_rr_path, eff_dest, + 2|((flag&1)<<2)); + if(ret<=0) + return(ret); + + ret= Xorriso_graft_in(xorriso, NULL, eff_source, eff_dest, + startbyte, bytecount, 8); + return(ret); +} + + int Xorriso_process_msg_queues(struct XorrisO *xorriso, int flag) { int ret, error_code= 0, os_errno= 0, count= 0, pass, imgid, tunneled; @@ -3643,7 +3717,8 @@ int Xorriso_rename(struct XorrisO *xorriso, void *boss_iter, cpt= dir_adr+strlen(dir_adr); *cpt= 0; if(dir_adr[0]!=0) { - ret= Xorriso_graft_in(xorriso, boss_iter, NULL, dir_adr, 1); + ret= Xorriso_graft_in(xorriso, boss_iter, NULL, dir_adr, + (off_t) 0, (off_t) 0, 1); if(ret<=0) return(ret); } @@ -3731,7 +3806,7 @@ int Xorriso_mkdir(struct XorrisO *xorriso, char *path, int flag) ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, path, eff_path, 2); if(ret<0) return(-2); - ret= Xorriso_graft_in(xorriso, NULL, NULL, eff_path, 1); + ret= Xorriso_graft_in(xorriso, NULL, NULL, eff_path, (off_t) 0, (off_t) 0, 1); if(ret<=0) return(-2); if(!(flag&1)) { diff --git a/libisoburn/trunk/xorriso/xorrisoburn.h b/libisoburn/trunk/xorriso/xorrisoburn.h index 7ce4aa56..f4dafdc9 100644 --- a/libisoburn/trunk/xorriso/xorrisoburn.h +++ b/libisoburn/trunk/xorriso/xorrisoburn.h @@ -47,7 +47,8 @@ int Xorriso_write_session(struct XorrisO *xorriso, int flag); @return <=0 = error , 1 = added simple node , 2 = added directory */ int Xorriso_graft_in(struct XorrisO *xorriso, void *boss_iter, - char *disk_path, char *img_path, int flag); + char *disk_path, char *img_path, + off_t offset, off_t cut_size, int flag); int Xorriso__text_to_sev(char *severity_name, int *severity_number,int flag); @@ -191,5 +192,8 @@ int Xorriso_iso_file_close(struct XorrisO *xorriso, void **stream, int flag); int Xorriso_copy_properties(struct XorrisO *xorriso, char *disk_path, char *img_path, int flag); +int Xorriso_cut_out(struct XorrisO *xorriso, char *disk_path, + off_t startbyte, off_t bytecount, char *iso_rr_path, int flag); + #endif /* Xorrisoburn_includeD */