From 132777bd31864bd8fc3bfe59218f96ad7699814b Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Sun, 3 Jul 2011 19:36:56 +0000 Subject: [PATCH] Enabled extraction of the boot catalog file to disk filesystem --- libisoburn/trunk/xorriso/iso_tree.c | 18 ++++++- libisoburn/trunk/xorriso/read_run.c | 53 +++++++++++++++----- libisoburn/trunk/xorriso/xorriso_timestamp.h | 2 +- 3 files changed, 58 insertions(+), 15 deletions(-) diff --git a/libisoburn/trunk/xorriso/iso_tree.c b/libisoburn/trunk/xorriso/iso_tree.c index cabb387e..10b4c56d 100644 --- a/libisoburn/trunk/xorriso/iso_tree.c +++ b/libisoburn/trunk/xorriso/iso_tree.c @@ -221,6 +221,10 @@ int Xorriso_fake_stbuf(struct XorrisO *xorriso, char *path, struct stat *stbuf, { int ret, min_hl, max_hl, node_idx, i; IsoImage *volume; + IsoBoot *bootcat; + uint32_t lba; + char *catcontent = NULL; + off_t catsize; memset((char *) stbuf, 0, sizeof(struct stat)); if(!(flag&1)) { @@ -270,7 +274,19 @@ int Xorriso_fake_stbuf(struct XorrisO *xorriso, char *path, struct stat *stbuf, if(LIBISO_ISREG(*node)) stbuf->st_size= iso_file_get_size((IsoFile *) *node)+ (2048 * !!(flag&2)); - else + else if(LIBISO_ISBOOT(*node)) { + ret= Xorriso_get_volume(xorriso, &volume, 0); + if(ret <= 0) + return(-1); + ret= iso_image_get_bootcat(volume, &bootcat, &lba, &catcontent, &catsize); + if(catcontent != NULL) + free(catcontent); + if(ret < 0) { + Xorriso_process_msg_queues(xorriso,0); + return(-1); + } + stbuf->st_size= catsize; + } else stbuf->st_size= 0; stbuf->st_blksize= 2048; diff --git a/libisoburn/trunk/xorriso/read_run.c b/libisoburn/trunk/xorriso/read_run.c index 7f71782f..4e9011ac 100644 --- a/libisoburn/trunk/xorriso/read_run.c +++ b/libisoburn/trunk/xorriso/read_run.c @@ -436,6 +436,11 @@ int Xorriso_tree_restore_node(struct XorrisO *xorriso, IsoNode *node, dev_t dev= 0; struct stat stbuf; struct utimbuf utime_buffer; + IsoImage *volume; + IsoBoot *bootcat; + uint32_t lba; + char *catcontent = NULL; + off_t catsize; Xorriso_alloc_meM(buf, char, buf_size); Xorriso_alloc_meM(temp_path, char, SfileadrL); @@ -445,12 +450,16 @@ int Xorriso_tree_restore_node(struct XorrisO *xorriso, IsoNode *node, ret= mkdir(disk_path, 0777); l_errno= errno; - } else if(LIBISO_ISREG(node)) { - what= "regular file"; - ret= Xorriso_iso_file_open(xorriso, img_path, (void *) node, &data_stream, - 1); - if(ret<=0) - goto ex; + } else if(LIBISO_ISREG(node) || ISO_NODE_IS_BOOTCAT(node)) { + if(ISO_NODE_IS_BOOTCAT(node)) { + what= "boot catalog"; + } else { + what= "regular file"; + ret= Xorriso_iso_file_open(xorriso, img_path, (void *) node, &data_stream, + 1); + if(ret<=0) + goto ex; + } open_path_pt= disk_path; ret= stat(open_path_pt, &stbuf); if(ret == -1 && errno == EACCES && (flag & 128)) @@ -497,7 +506,17 @@ int Xorriso_tree_restore_node(struct XorrisO *xorriso, IsoNode *node, if(write_fd==-1) goto cannot_restore; } - todo= size= iso_file_get_size((IsoFile *) node); + if(ISO_NODE_IS_BOOTCAT(node)) { + ret= Xorriso_get_volume(xorriso, &volume, 0); + if(ret<=0) + goto ex; + ret= iso_image_get_bootcat(volume, &bootcat, &lba, &catcontent, &catsize); + if(ret < 0) + goto ex; + todo= size= catsize; + } else { + todo= size= iso_file_get_size((IsoFile *) node); + } if(flag&2) { if(bytestodo) wanted= todo; - ret= Xorriso_iso_file_read(xorriso, data_stream, buf, wanted, 0); + if(ISO_NODE_IS_BOOTCAT(node)) { + ret= todo; + buf_pt= catcontent; + } else { + ret= Xorriso_iso_file_read(xorriso, data_stream, buf, wanted, 0); + buf_pt= buf; + } if(ret<=0) { if(xorriso->extract_error_mode == 0 && Xorriso_is_plain_image_file(xorriso, node, "", 0)) { @@ -547,13 +572,12 @@ int Xorriso_tree_restore_node(struct XorrisO *xorriso, IsoNode *node, break; } read_count+= ret; - buf_pt= buf; if(img_offset > read_count - ret) { /* skip the desired amount of bytes */ if(read_count <= img_offset) continue; - buf_pt= buf + (img_offset - (read_count - ret)); + buf_pt= buf_pt + (img_offset - (read_count - ret)); ret= read_count - img_offset; } @@ -584,7 +608,8 @@ int Xorriso_tree_restore_node(struct XorrisO *xorriso, IsoNode *node, unlink(open_path_pt); target_deleted= 1; } - Xorriso_iso_file_close(xorriso, &data_stream, 0); + if(! ISO_NODE_IS_BOOTCAT(node)) + Xorriso_iso_file_close(xorriso, &data_stream, 0); data_stream= NULL; if(temp_path==open_path_pt && !target_deleted) { ret= rename(temp_path, disk_path); @@ -663,11 +688,10 @@ probably_damaged:; goto ignored; } else { - if(ISO_NODE_IS_BOOTCAT(node)) - what= "boot catalog"; sprintf(xorriso->info_text, "Cannot restore file type '%s'", what); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); ret= 0; goto ex; + } if(ret == -1 && l_errno == EACCES && (flag & 128)) {ret= 4; goto ex;} @@ -695,8 +719,11 @@ ex:; } Xorriso_free_meM(buf); Xorriso_free_meM(temp_path); + if(catcontent != NULL) + free(catcontent); if(data_stream!=NULL) Xorriso_iso_file_close(xorriso, &data_stream, 0); + Xorriso_process_msg_queues(xorriso,0); return(ret); } diff --git a/libisoburn/trunk/xorriso/xorriso_timestamp.h b/libisoburn/trunk/xorriso/xorriso_timestamp.h index fc07bfdb..a1551758 100644 --- a/libisoburn/trunk/xorriso/xorriso_timestamp.h +++ b/libisoburn/trunk/xorriso/xorriso_timestamp.h @@ -1 +1 @@ -#define Xorriso_timestamP "2011.07.03.181840" +#define Xorriso_timestamP "2011.07.03.193627"