Enabled extraction of the boot catalog file to disk filesystem

This commit is contained in:
Thomas Schmitt 2011-07-03 19:36:56 +00:00
parent 44904069a4
commit d76591cc47
3 changed files with 58 additions and 15 deletions

View File

@ -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;

View File

@ -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)) {
} 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;
}
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(bytes<size)
todo= size= bytes;
@ -516,7 +535,13 @@ int Xorriso_tree_restore_node(struct XorrisO *xorriso, IsoNode *node,
wanted= buf_size;
if(wanted>todo)
wanted= todo;
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,6 +608,7 @@ int Xorriso_tree_restore_node(struct XorrisO *xorriso, IsoNode *node,
unlink(open_path_pt);
target_deleted= 1;
}
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) {
@ -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);
}

View File

@ -1 +1 @@
#define Xorriso_timestamP "2011.07.03.181840"
#define Xorriso_timestamP "2011.07.03.193627"