- lte = inode->i_lte;
- stream_idx = 0;
- }
-out:
- if (dentry_ret)
- *dentry_ret = dentry;
- if (lte_ret)
- *lte_ret = lte;
- if (stream_idx_ret)
- *stream_idx_ret = stream_idx;
- return 0;
-}
-#endif
-
-/*
- * XXX Probably should store the compression type directly in the lookup table
- * entry
- */
-int
-wim_resource_compression_type(const struct wim_lookup_table_entry *lte)
-{
- if (!(lte->resource_entry.flags & WIM_RESHDR_FLAG_COMPRESSED)
- || lte->resource_location != RESOURCE_IN_WIM)
- return WIMLIB_COMPRESSION_TYPE_NONE;
- return wimlib_get_compression_type(lte->wim);
-}
-
-/* Resolve an inode's lookup table entries
- *
- * This replaces the SHA1 hash fields (which are used to lookup an entry in the
- * lookup table) with pointers directly to the lookup table entries. A circular
- * linked list of streams sharing the same lookup table entry is created.
- *
- * This function always succeeds; unresolved lookup table entries are given a
- * NULL pointer.
- */
-int
-inode_resolve_ltes(struct wim_inode *inode, struct wim_lookup_table *table)
-{
- int ret;
- const u8 *hash;
-
- if (!inode->i_resolved) {
- struct wim_lookup_table_entry *lte, *ads_lte;
-
- /* Resolve the default file stream */
- lte = NULL;
- hash = inode->i_hash;
- if (!is_zero_hash(hash)) {
- lte = __lookup_resource(table, hash);
- if (unlikely(!lte))
- goto resource_not_found;
- }
-
- /* Resolve the alternate data streams */
- struct wim_lookup_table_entry *ads_ltes[inode->i_num_ads];
- for (u16 i = 0; i < inode->i_num_ads; i++) {
- struct wim_ads_entry *cur_entry;
-
- ads_lte = NULL;
- cur_entry = &inode->i_ads_entries[i];
- hash = cur_entry->hash;
- if (!is_zero_hash(hash)) {
- ads_lte = __lookup_resource(table, hash);
- if (unlikely(!ads_lte))
- goto resource_not_found;
- }
- ads_ltes[i] = ads_lte;
- }
- inode->i_lte = lte;
- for (u16 i = 0; i < inode->i_num_ads; i++)
- inode->i_ads_entries[i].lte = ads_ltes[i];
- inode->i_resolved = 1;
- }
- return 0;
-resource_not_found:
- if (wimlib_print_errors) {
- ERROR("\"%"TS"\": resource not found", inode_first_full_path(inode));
- tfprintf(stderr, T(" SHA-1 message digest of missing resource:\n "));
- print_hash(hash, stderr);
- tputc(T('\n'), stderr);
- }
- return WIMLIB_ERR_RESOURCE_NOT_FOUND;
-}
-
-void
-inode_unresolve_ltes(struct wim_inode *inode)
-{
- if (inode->i_resolved) {
- if (inode->i_lte)
- copy_hash(inode->i_hash, inode->i_lte->hash);
- else
- zero_out_hash(inode->i_hash);
-
- for (u16 i = 0; i < inode->i_num_ads; i++) {
- if (inode->i_ads_entries[i].lte)
- copy_hash(inode->i_ads_entries[i].hash,
- inode->i_ads_entries[i].lte->hash);
- else
- zero_out_hash(inode->i_ads_entries[i].hash);
- }
- inode->i_resolved = 0;
- }
-}
-
-/*
- * Returns the lookup table entry for stream @stream_idx of the inode, where
- * stream_idx = 0 means the default un-named file stream, and stream_idx >= 1
- * corresponds to an alternate data stream.
- *
- * This works for both resolved and un-resolved inodes.
- */
-struct wim_lookup_table_entry *
-inode_stream_lte(const struct wim_inode *inode, unsigned stream_idx,
- const struct wim_lookup_table *table)
-{
- if (inode->i_resolved)
- return inode_stream_lte_resolved(inode, stream_idx);
- else
- return inode_stream_lte_unresolved(inode, stream_idx, table);
-}
-
-struct wim_lookup_table_entry *
-inode_unnamed_lte_resolved(const struct wim_inode *inode)
-{
- 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)))
- {
- return inode_stream_lte_resolved(inode, i);
- }
- }
- return NULL;
-}
-
-struct wim_lookup_table_entry *
-inode_unnamed_lte_unresolved(const struct wim_inode *inode,
- const struct wim_lookup_table *table)
-{
- 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_unresolved(inode, i)))
- {
- return inode_stream_lte_unresolved(inode, i, table);