X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=include%2Fwimlib%2Flookup_table.h;h=f0cfb768f1e92410f022180c1c3393f9d1d04e62;hp=936163480c1f08f2524a92b2ada7cc86a52ad1bf;hb=7cfb9777313e1a2f60a49d6b9ef87910f27f1a51;hpb=465a630d28e93b09e55ca07b1a6cae8def3b42f5 diff --git a/include/wimlib/lookup_table.h b/include/wimlib/lookup_table.h index 93616348..f0cfb768 100644 --- a/include/wimlib/lookup_table.h +++ b/include/wimlib/lookup_table.h @@ -49,50 +49,50 @@ struct ntfs_location { * * If we open a WIM and read its lookup table, the location is set to * RESOURCE_IN_WIM since all the streams will initially be located in the WIM. - * However, to deal with problems such as image capture and image mount, we - * allow the actual location of the stream to be somewhere else, such as an - * external file. + * However, to handle situations such as image capture and image mount, we allow + * the actual location of the stream to be somewhere else, such as an external + * file. */ enum resource_location { - /* The lookup table entry does not correspond to a stream (this state - * should exist only temporarily) */ + /* The lookup table entry does not yet correspond to a stream; this is a + * temporary state only. */ RESOURCE_NONEXISTENT = 0, - /* The stream resource is located in a WIM file. The WIMStruct for the - * WIM file will be pointed to by the @wim member. The compression type - * of the resource will be cached in @compression_type, and the pipable - * status of the resource will be cached in @pipable. */ + /* The stream is located in a resource in a WIM file identified by the + * `struct wim_resource_spec' pointed to by @rspec. @offset_in_res + * identifies the offset at which this particular stream begins in the + * uncompressed data of the resource; this is normally 0, but in general + * a WIM resource may contain multiple streams. */ RESOURCE_IN_WIM, - /* The stream resource is located in an external file. The name of the - * file will be provided by @file_on_disk member. - * - * Note: On Windows @file_on_disk may actually specify a named data - * stream. */ + /* The stream is located in the external file named by @file_on_disk. + * On Windows, @file_on_disk may actually specify a named data stream. + */ RESOURCE_IN_FILE_ON_DISK, - /* The stream resource is directly attached in an in-memory buffer - * pointed to by @attached_buffer. */ + /* The stream is directly attached in the in-memory buffer pointed to by + * @attached_buffer. */ RESOURCE_IN_ATTACHED_BUFFER, #ifdef WITH_FUSE - /* The stream resource is located in an external file in the staging - * directory for a read-write mount. */ + /* The stream is located in the external file named by + * @staging_file_name, located in the staging directory for a read-write + * mount. */ RESOURCE_IN_STAGING_FILE, #endif #ifdef WITH_NTFS_3G - /* The stream resource is located in an NTFS volume. It is identified - * by volume, filename, data stream name, and by whether it is a reparse - * point or not. @ntfs_loc points to a structure containing this - * information. */ + /* The stream is located in an NTFS volume. It is identified by volume, + * filename, data stream name, and by whether it is a reparse point or + * not. @ntfs_loc points to a structure containing this information. + * */ RESOURCE_IN_NTFS_VOLUME, #endif #ifdef __WIN32__ - /* Windows only: the file is on disk in the file named @file_on_disk, - * but the file is encrypted and must be read using special functions. - * */ + /* Windows only: the stream is located in the external file named by + * @file_on_disk, but the file is encrypted and must be read using the + * appropriate Windows API. */ RESOURCE_WIN32_ENCRYPTED, #endif @@ -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; - - /* 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; + /* Uncompressed size of the stream. */ + u64 size; + + /* Stream flags (WIM_RESHDR_FLAG_*). */ + u16 flags : 8; /* One of the `enum resource_location' values documented above. */ u16 resource_location : 5; @@ -147,17 +134,6 @@ 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. */ @@ -209,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 @@ -254,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 { @@ -290,25 +263,15 @@ 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; -} - -static inline u64 -wim_resource_chunks(const struct wim_lookup_table_entry *lte) -{ - return DIV_ROUND_UP(wim_resource_size(lte), WIM_CHUNK_SIZE); -} + struct list_head wim_resource_list; +}; -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 +295,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 +322,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); @@ -403,23 +365,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->stream_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); @@ -504,6 +480,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); @@ -514,9 +493,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,