X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=include%2Fwimlib%2Flookup_table.h;h=a22ed3d1b0c4c490221b8b815fe1dc4d65b0a43b;hb=3ffb2cde078ae8f62d542ab89166e1059c13d758;hp=746d744965718a9dc5090374cb8e74769a5600a3;hpb=da295f258b60e1593de305385c0669eac4b76644;p=wimlib diff --git a/include/wimlib/lookup_table.h b/include/wimlib/lookup_table.h index 746d7449..a22ed3d1 100644 --- a/include/wimlib/lookup_table.h +++ b/include/wimlib/lookup_table.h @@ -114,24 +114,11 @@ struct wim_lookup_table_entry { /* List of lookup table entries in this hash bucket */ struct hlist_node hash_list; - /* Location and size of the stream in the WIM, whether it is compressed - * or not, and whether it's a metadata resource or not. This is an - * on-disk field. */ - struct resource_entry resource_entry; + /* Uncompressed size of the stream. */ + u64 size; - /* Specifies which part of the split WIM the resource is located in. - * This is on on-disk field. - * - * In stand-alone WIMs, this must be 1. - * - * In split WIMs, every split WIM part has its own lookup table, and in - * read_lookup_table() it's currently expected that the part number of - * each lookup table entry in a split WIM part's lookup table is the - * same as the part number of that split WIM part. So this makes this - * field redundant since we store a pointer to the corresponding - * WIMStruct in the lookup table entry anyway. - */ - u16 part_number; + /* Stream flags (WIM_RESHDR_FLAG_*). */ + u16 flags : 8; /* One of the `enum resource_location' values documented above. */ u16 resource_location : 5; @@ -147,22 +134,17 @@ struct wim_lookup_table_entry { u16 no_progress : 1; - /* If resource_location == RESOURCE_IN_WIM, this will be a cached value - * that specifies the compression type of this stream as one of - * WIMLIB_COMPRESSION_TYPE_*. Otherwise this will be 0, which is the - * same as WIMLIB_COMPRESSION_TYPE_NONE. */ - u16 compression_type : 2; - - /* If resource_location == RESOURCE_IN_WIM, this flag will be set if the - * WIM is pipable and therefore the stream is in a slightly different - * format. See comment above write_pipable_wim(). */ - u16 is_pipable : 1; - /* Set to 1 when a metadata entry has its checksum changed; in such * cases the hash is no longer valid to verify the data if the metadata * resource is read again. */ u16 dont_check_metadata_hash : 1; + /* Only used during WIM write. Normal value is 0 (resource not + * filtered). */ + u16 filtered : 2; +#define FILTERED_SAME_WIM 0x1 /* Resource already in same WIM */ +#define FILTERED_EXTERNAL_WIM 0x2 /* Resource already in external WIM */ + /* (On-disk field) * Number of times this lookup table entry is referenced by dentries. * Unfortunately, this field is not always set correctly in Microsoft's @@ -203,7 +185,10 @@ struct wim_lookup_table_entry { /* Pointers to somewhere where the stream is actually located. See the * comments for the @resource_location field above. */ union { - WIMStruct *wim; + struct { + struct wim_resource_spec *rspec; + u64 offset_in_res; + }; tchar *file_on_disk; void *attached_buffer; #ifdef WITH_FUSE @@ -248,15 +233,9 @@ struct wim_lookup_table_entry { struct list_head being_compressed_list; }; - /* When a WIM file is written, @output_resource_entry is filled - * in with the resource entry for the output WIM. This will not - * necessarily be the same as the @resource_entry since: - * - The stream may have a different offset in the new WIM - * - The stream may have a different compressed size in the new - * WIM if the compression type changed - */ - struct resource_entry output_resource_entry; - + /* When a WIM file is written, @output_reshdr is filled in with + * the resource header for the output WIM. */ + struct wim_reshdr out_reshdr; /* Used temporarily during extraction */ union { @@ -284,31 +263,34 @@ struct wim_lookup_table_entry { /* Links streams that are still unhashed after being been added * to a WIM. */ struct list_head unhashed_list; -}; -static inline u64 -wim_resource_size(const struct wim_lookup_table_entry *lte) -{ - return lte->resource_entry.original_size; -} + struct list_head wim_resource_list; +}; -static inline u64 -wim_resource_chunks(const struct wim_lookup_table_entry *lte) +static inline int +lte_ctype(const struct wim_lookup_table_entry *lte) { - return DIV_ROUND_UP(wim_resource_size(lte), WIM_CHUNK_SIZE); + if (lte->resource_location == RESOURCE_IN_WIM) + return lte->rspec->ctype; + else + return WIMLIB_COMPRESSION_TYPE_NONE; } -static inline u64 -wim_resource_compressed_size(const struct wim_lookup_table_entry *lte) +static inline u32 +lte_cchunk_size(const struct wim_lookup_table_entry * lte) { - return lte->resource_entry.size; + if (lte->resource_location == RESOURCE_IN_WIM && + lte->rspec->ctype != WIMLIB_COMPRESSION_TYPE_NONE) + return lte->rspec->cchunk_size; + else + return 32768; } -static inline int -wim_resource_compression_type(const struct wim_lookup_table_entry *lte) +static inline bool +lte_is_partial(const struct wim_lookup_table_entry * lte) { - BUILD_BUG_ON(WIMLIB_COMPRESSION_TYPE_NONE != 0); - return lte->compression_type; + return lte->resource_location == RESOURCE_IN_WIM && + lte->size != lte->rspec->uncompressed_size; } static inline bool @@ -332,7 +314,7 @@ read_wim_lookup_table(WIMStruct *wim); extern int write_wim_lookup_table(WIMStruct *wim, int image, int write_flags, - struct resource_entry *out_res_entry, + struct wim_reshdr *out_reshdr, struct list_head *stream_list_override); extern void @@ -359,8 +341,7 @@ clone_lookup_table_entry(const struct wim_lookup_table_entry *lte) _malloc_attribute; extern void -print_lookup_table_entry(const struct wim_lookup_table_entry *entry, - FILE *out); +print_lookup_table_entry(const struct wim_lookup_table_entry *lte, FILE *out); extern void free_lookup_table_entry(struct wim_lookup_table_entry *lte); @@ -385,12 +366,14 @@ for_lookup_table_entry_pos_sorted(struct wim_lookup_table *table, void *arg); extern struct wim_lookup_table_entry * -__lookup_resource(const struct wim_lookup_table *table, const u8 hash[]); +lookup_resource(const struct wim_lookup_table *table, const u8 hash[]); extern int -lookup_resource(WIMStruct *wim, const tchar *path, - int lookup_flags, struct wim_dentry **dentry_ret, - struct wim_lookup_table_entry **lte_ret, u16 *stream_idx_ret); +wim_pathname_to_stream(WIMStruct *wim, const tchar *path, + int lookup_flags, + struct wim_dentry **dentry_ret, + struct wim_lookup_table_entry **lte_ret, + u16 *stream_idx_ret); extern void lte_decrement_refcnt(struct wim_lookup_table_entry *lte, @@ -401,23 +384,37 @@ lte_decrement_num_opened_fds(struct wim_lookup_table_entry *lte); #endif extern int -lte_zero_out_refcnt(struct wim_lookup_table_entry *entry, void *ignore); +lte_zero_out_refcnt(struct wim_lookup_table_entry *lte, void *ignore); extern int -lte_zero_real_refcnt(struct wim_lookup_table_entry *entry, void *ignore); +lte_zero_real_refcnt(struct wim_lookup_table_entry *lte, void *ignore); extern int lte_free_extracted_file(struct wim_lookup_table_entry *lte, void *ignore); -extern void -lte_init_wim(struct wim_lookup_table_entry *lte, WIMStruct *wim); +static inline void +lte_bind_wim_resource_spec(struct wim_lookup_table_entry *lte, + struct wim_resource_spec *rspec) +{ + lte->resource_location = RESOURCE_IN_WIM; + lte->rspec = rspec; + list_add_tail(<e->wim_resource_list, &rspec->lte_list); +} + +static inline void +lte_unbind_wim_resource_spec(struct wim_lookup_table_entry *lte) +{ + list_del(<e->wim_resource_list); + lte->rspec = NULL; + lte->resource_location = RESOURCE_NONEXISTENT; +} extern int inode_resolve_ltes(struct wim_inode *inode, struct wim_lookup_table *table, bool force); extern int -resource_not_found_error(struct wim_inode *inode, const u8 *hash); +resource_not_found_error(const struct wim_inode *inode, const u8 *hash); extern void inode_unresolve_ltes(struct wim_inode *inode); @@ -442,9 +439,9 @@ inode_stream_lte_unresolved(const struct wim_inode *inode, unsigned stream_idx, if (!table) return NULL; if (stream_idx == 0) - return __lookup_resource(table, inode->i_hash); + return lookup_resource(table, inode->i_hash); else - return __lookup_resource(table, + return lookup_resource(table, inode->i_ads_entries[ stream_idx - 1].hash); } @@ -502,6 +499,9 @@ inode_stream_name_nbytes(const struct wim_inode *inode, unsigned stream_idx) return inode->i_ads_entries[stream_idx - 1].stream_name_nbytes; } +extern struct wim_lookup_table_entry * +inode_unnamed_stream_resolved(const struct wim_inode *inode, u16 *stream_idx_ret); + extern struct wim_lookup_table_entry * inode_unnamed_lte_resolved(const struct wim_inode *inode); @@ -512,9 +512,8 @@ inode_unnamed_lte_unresolved(const struct wim_inode *inode, extern struct wim_lookup_table_entry * inode_unnamed_lte(const struct wim_inode *inode, const struct wim_lookup_table *table); -extern u64 -lookup_table_total_stream_size(struct wim_lookup_table *table); - +extern const u8 * +inode_unnamed_stream_hash(const struct wim_inode *inode); static inline void lookup_table_insert_unhashed(struct wim_lookup_table *table,