X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Fwrite.c;h=a431871b43792b557c2d6796ead0e16874aa98e7;hb=31e7d901124217da4e02717f6b59ee437d15aef3;hp=e7f6966760c465f8b832765af70836f1c47b1291;hpb=9a23ab0c8f362ca68a45e8b4a9a973b418972cb6;p=wimlib diff --git a/src/write.c b/src/write.c index e7f69667..a431871b 100644 --- a/src/write.c +++ b/src/write.c @@ -1341,16 +1341,17 @@ static int write_stream_list(struct list_head *stream_list, FILE *out_fp, struct lte_overwrite_prepare_args { WIMStruct *wim; - struct list_head *stream_list; off_t end_offset; + struct list_head *stream_list; }; static int lte_overwrite_prepare(struct lookup_table_entry *lte, void *arg) { struct lte_overwrite_prepare_args *args = arg; - if (lte->resource_entry.offset + - lte->resource_entry.size > args->end_offset) + if (lte->resource_location == RESOURCE_IN_WIM && + lte->wim == args->wim && + lte->resource_entry.offset + lte->resource_entry.size > args->end_offset) { ERROR("The following resource is after the XML data:"); print_lookup_table_entry(lte); @@ -1372,33 +1373,43 @@ static int wim_find_new_streams(WIMStruct *wim, off_t end_offset, struct list_head *stream_list) { struct lte_overwrite_prepare_args args = { - .wim = wim, + .wim = wim, + .end_offset = end_offset, .stream_list = stream_list, - .end_offset = end_offset, }; return for_lookup_table_entry(wim->lookup_table, lte_overwrite_prepare, &args); } -static int dentry_find_streams_to_write(struct dentry *dentry, - void *wim) +static int inode_find_streams_to_write(struct inode *inode, + struct lookup_table *table, + struct list_head *stream_list) { - WIMStruct *w = wim; - struct list_head *stream_list = w->private; struct lookup_table_entry *lte; - for (unsigned i = 0; i <= dentry->d_inode->num_ads; i++) { - lte = inode_stream_lte(dentry->d_inode, i, w->lookup_table); - if (lte && ++lte->out_refcnt == 1) - list_add_tail(<e->staging_list, stream_list); + for (unsigned i = 0; i <= inode->num_ads; i++) { + lte = inode_stream_lte(inode, i, table); + if (lte) { + if (lte->out_refcnt == 0) + list_add_tail(<e->staging_list, stream_list); + lte->out_refcnt += inode->link_count; + } } return 0; } static int image_find_streams_to_write(WIMStruct *w) { - return for_dentry_in_tree(wim_root_dentry(w), - dentry_find_streams_to_write, w); + struct inode *inode; + struct hlist_node *cur; + struct hlist_head *inode_list; + + inode_list = &wim_get_current_image_metadata(w)->inode_list; + hlist_for_each_entry(inode, cur, inode_list, hlist) { + inode_find_streams_to_write(inode, w->lookup_table, + (struct list_head*)w->private); + } + return 0; } static int write_wim_streams(WIMStruct *w, int image, int write_flags,