]> wimlib.net Git - wimlib/blobdiff - src/lookup_table.c
xml.c: Fix writing <WINDOWS> element
[wimlib] / src / lookup_table.c
index 37d701a1e49403efc7c6387c537c13d05bf62fdd..553cf33b1c413f4dbfa430291b8439b85abec869 100644 (file)
@@ -678,7 +678,8 @@ static int
 write_wim_lookup_table_from_stream_list(struct list_head *stream_list,
                                        struct filedes *out_fd,
                                        struct resource_entry *out_res_entry,
-                                       int write_resource_flags)
+                                       int write_resource_flags,
+                                       struct wimlib_lzx_context **comp_ctx)
 {
        size_t table_size;
        struct wim_lookup_table_entry *lte;
@@ -712,8 +713,10 @@ write_wim_lookup_table_from_stream_list(struct list_head *stream_list,
                                             WIMLIB_COMPRESSION_TYPE_NONE,
                                             out_res_entry,
                                             NULL,
-                                            write_resource_flags);
+                                            write_resource_flags,
+                                            comp_ctx);
        FREE(table_buf);
+       DEBUG("ret=%d", ret);
        return ret;
 }
 
@@ -803,7 +806,8 @@ write_wim_lookup_table(WIMStruct *wim, int image, int write_flags,
        return write_wim_lookup_table_from_stream_list(stream_list,
                                                       &wim->out_fd,
                                                       out_res_entry,
-                                                      write_resource_flags);
+                                                      write_resource_flags,
+                                                      &wim->lzx_context);
 }
 
 
@@ -1027,8 +1031,7 @@ wim_pathname_to_stream(WIMStruct *wim,
                        return -ENOENT;
                }
        } else {
-               lte = inode->i_lte;
-               stream_idx = 0;
+               lte = inode_unnamed_stream_resolved(inode, &stream_idx);
        }
 out:
        if (dentry_ret)
@@ -1167,19 +1170,28 @@ inode_stream_lte(const struct wim_inode *inode, unsigned stream_idx,
 }
 
 struct wim_lookup_table_entry *
-inode_unnamed_lte_resolved(const struct wim_inode *inode)
+inode_unnamed_stream_resolved(const struct wim_inode *inode, u16 *stream_idx_ret)
 {
        wimlib_assert(inode->i_resolved);
        for (unsigned i = 0; i <= inode->i_num_ads; i++) {
                if (inode_stream_name_nbytes(inode, i) == 0 &&
                    !is_zero_hash(inode_stream_hash_resolved(inode, i)))
                {
+                       *stream_idx_ret = i;
                        return inode_stream_lte_resolved(inode, i);
                }
        }
+       *stream_idx_ret = 0;
        return NULL;
 }
 
+struct wim_lookup_table_entry *
+inode_unnamed_lte_resolved(const struct wim_inode *inode)
+{
+       u16 stream_idx;
+       return inode_unnamed_stream_resolved(inode, &stream_idx);
+}
+
 struct wim_lookup_table_entry *
 inode_unnamed_lte_unresolved(const struct wim_inode *inode,
                             const struct wim_lookup_table *table)
@@ -1221,6 +1233,9 @@ inode_unnamed_lte(const struct wim_inode *inode,
                return inode_unnamed_lte_unresolved(inode, table);
 }
 
+/* Returns the SHA1 message digest of the unnamed data stream of a WIM inode, or
+ * 'zero_hash' if the unnamed data stream is missing has all zeroes in its SHA1
+ * message digest field.  */
 const u8 *
 inode_unnamed_stream_hash(const struct wim_inode *inode)
 {
@@ -1233,7 +1248,7 @@ inode_unnamed_stream_hash(const struct wim_inode *inode)
                                return hash;
                }
        }
-       return NULL;
+       return zero_hash;
 }