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 c403b15b47
commit 132777bd31
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; int ret, min_hl, max_hl, node_idx, i;
IsoImage *volume; IsoImage *volume;
IsoBoot *bootcat;
uint32_t lba;
char *catcontent = NULL;
off_t catsize;
memset((char *) stbuf, 0, sizeof(struct stat)); memset((char *) stbuf, 0, sizeof(struct stat));
if(!(flag&1)) { if(!(flag&1)) {
@ -270,7 +274,19 @@ int Xorriso_fake_stbuf(struct XorrisO *xorriso, char *path, struct stat *stbuf,
if(LIBISO_ISREG(*node)) if(LIBISO_ISREG(*node))
stbuf->st_size= iso_file_get_size((IsoFile *) *node)+ (2048 * !!(flag&2)); 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_size= 0;
stbuf->st_blksize= 2048; stbuf->st_blksize= 2048;

View File

@ -436,6 +436,11 @@ int Xorriso_tree_restore_node(struct XorrisO *xorriso, IsoNode *node,
dev_t dev= 0; dev_t dev= 0;
struct stat stbuf; struct stat stbuf;
struct utimbuf utime_buffer; 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(buf, char, buf_size);
Xorriso_alloc_meM(temp_path, char, SfileadrL); 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); ret= mkdir(disk_path, 0777);
l_errno= errno; l_errno= errno;
} else if(LIBISO_ISREG(node)) { } else if(LIBISO_ISREG(node) || ISO_NODE_IS_BOOTCAT(node)) {
what= "regular file"; if(ISO_NODE_IS_BOOTCAT(node)) {
ret= Xorriso_iso_file_open(xorriso, img_path, (void *) node, &data_stream, what= "boot catalog";
1); } else {
if(ret<=0) what= "regular file";
goto ex; ret= Xorriso_iso_file_open(xorriso, img_path, (void *) node, &data_stream,
1);
if(ret<=0)
goto ex;
}
open_path_pt= disk_path; open_path_pt= disk_path;
ret= stat(open_path_pt, &stbuf); ret= stat(open_path_pt, &stbuf);
if(ret == -1 && errno == EACCES && (flag & 128)) 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) if(write_fd==-1)
goto cannot_restore; 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(flag&2) {
if(bytes<size) if(bytes<size)
todo= size= bytes; todo= size= bytes;
@ -516,7 +535,13 @@ int Xorriso_tree_restore_node(struct XorrisO *xorriso, IsoNode *node,
wanted= buf_size; wanted= buf_size;
if(wanted>todo) if(wanted>todo)
wanted= todo; 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(ret<=0) {
if(xorriso->extract_error_mode == 0 && if(xorriso->extract_error_mode == 0 &&
Xorriso_is_plain_image_file(xorriso, node, "", 0)) { Xorriso_is_plain_image_file(xorriso, node, "", 0)) {
@ -547,13 +572,12 @@ int Xorriso_tree_restore_node(struct XorrisO *xorriso, IsoNode *node,
break; break;
} }
read_count+= ret; read_count+= ret;
buf_pt= buf;
if(img_offset > read_count - ret) { if(img_offset > read_count - ret) {
/* skip the desired amount of bytes */ /* skip the desired amount of bytes */
if(read_count <= img_offset) if(read_count <= img_offset)
continue; continue;
buf_pt= buf + (img_offset - (read_count - ret)); buf_pt= buf_pt + (img_offset - (read_count - ret));
ret= read_count - img_offset; ret= read_count - img_offset;
} }
@ -584,7 +608,8 @@ int Xorriso_tree_restore_node(struct XorrisO *xorriso, IsoNode *node,
unlink(open_path_pt); unlink(open_path_pt);
target_deleted= 1; 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; data_stream= NULL;
if(temp_path==open_path_pt && !target_deleted) { if(temp_path==open_path_pt && !target_deleted) {
ret= rename(temp_path, disk_path); ret= rename(temp_path, disk_path);
@ -663,11 +688,10 @@ probably_damaged:;
goto ignored; goto ignored;
} else { } else {
if(ISO_NODE_IS_BOOTCAT(node))
what= "boot catalog";
sprintf(xorriso->info_text, "Cannot restore file type '%s'", what); sprintf(xorriso->info_text, "Cannot restore file type '%s'", what);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
ret= 0; goto ex; ret= 0; goto ex;
} }
if(ret == -1 && l_errno == EACCES && (flag & 128)) if(ret == -1 && l_errno == EACCES && (flag & 128))
{ret= 4; goto ex;} {ret= 4; goto ex;}
@ -695,8 +719,11 @@ ex:;
} }
Xorriso_free_meM(buf); Xorriso_free_meM(buf);
Xorriso_free_meM(temp_path); Xorriso_free_meM(temp_path);
if(catcontent != NULL)
free(catcontent);
if(data_stream!=NULL) if(data_stream!=NULL)
Xorriso_iso_file_close(xorriso, &data_stream, 0); Xorriso_iso_file_close(xorriso, &data_stream, 0);
Xorriso_process_msg_queues(xorriso,0);
return(ret); return(ret);
} }

View File

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