+static int allocate_lte_if_needed(struct dentry *dentry, void *arg)
+{
+ const WIMStruct *src_wim, *dest_wim;
+ struct list_head *lte_list_head;
+ struct inode *inode;
+
+ src_wim = ((struct wim_pair*)arg)->src_wim;
+ dest_wim = ((struct wim_pair*)arg)->dest_wim;
+ lte_list_head = &((struct wim_pair*)arg)->lte_list_head;
+ inode = dentry->d_inode;
+
+ wimlib_assert(!inode->resolved);
+
+ for (unsigned i = 0; i <= inode->num_ads; i++) {
+ struct lookup_table_entry *src_lte, *dest_lte;
+ src_lte = inode_stream_lte_unresolved(inode, i,
+ src_wim->lookup_table);
+
+ if (src_lte && ++src_lte->out_refcnt == 1) {
+ dest_lte = inode_stream_lte_unresolved(inode, i,
+ dest_wim->lookup_table);
+
+ if (!dest_lte) {
+ dest_lte = clone_lookup_table_entry(src_lte);
+ if (!dest_lte)
+ return WIMLIB_ERR_NOMEM;
+ list_add_tail(&dest_lte->list, lte_list_head);
+ }
+ }
+ }
+ return 0;
+}
+
+/*