X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=src%2Flookup_table.c;h=302b1750ece3335c0dfda989c036efeb552e7d38;hp=37d701a1e49403efc7c6387c537c13d05bf62fdd;hb=acfc301115f69877a634f3141908747a54f678a0;hpb=b072e7cbca1ccb874e22aa94e3efae37ce211939 diff --git a/src/lookup_table.c b/src/lookup_table.c index 37d701a1..302b1750 100644 --- a/src/lookup_table.c +++ b/src/lookup_table.c @@ -75,8 +75,10 @@ new_lookup_table_entry(void) lte = CALLOC(1, sizeof(struct wim_lookup_table_entry)); if (lte) { - lte->part_number = 1; - lte->refcnt = 1; + lte->part_number = 1; + lte->refcnt = 1; + BUILD_BUG_ON(RESOURCE_NONEXISTENT != 0); + BUILD_BUG_ON(WIMLIB_COMPRESSION_TYPE_NONE != 0); } else { ERROR("Out of memory (tried to allocate %zu bytes for " "lookup table entry)", @@ -334,6 +336,9 @@ cmp_streams_by_sequential_order(const void *p1, const void *p2) return 1; return 0; case RESOURCE_IN_FILE_ON_DISK: +#ifdef WITH_FUSE + case RESOURCE_IN_STAGING_FILE: +#endif #ifdef __WIN32__ case RESOURCE_WIN32_ENCRYPTED: #endif @@ -678,7 +683,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; @@ -710,10 +716,13 @@ write_wim_lookup_table_from_stream_list(struct list_head *stream_list, WIM_RESHDR_FLAG_METADATA, out_fd, WIMLIB_COMPRESSION_TYPE_NONE, + 0, out_res_entry, NULL, - write_resource_flags); + write_resource_flags, + comp_ctx); FREE(table_buf); + DEBUG("ret=%d", ret); return ret; } @@ -803,7 +812,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 +1037,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 +1176,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 +1239,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 +1254,7 @@ inode_unnamed_stream_hash(const struct wim_inode *inode) return hash; } } - return NULL; + return zero_hash; }