X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=include%2Fwimlib%2Flookup_table.h;h=9f6e3ea38008a15e271460c4a091e5ad819ddd6b;hb=0ac1c0afd3f1b4341409e66cb31c94053d1b8988;hp=a2feebf7e8b7959ee87adc11c0d25bd5945725a0;hpb=8d51112e66e90048a944dcc58b01ab6b76e4c02c;p=wimlib diff --git a/include/wimlib/lookup_table.h b/include/wimlib/lookup_table.h index a2feebf7..9f6e3ea3 100644 --- a/include/wimlib/lookup_table.h +++ b/include/wimlib/lookup_table.h @@ -28,8 +28,7 @@ enum resource_location { RESOURCE_IN_WIM, /* 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 - * (file path, then colon, then name of the stream). */ + */ RESOURCE_IN_FILE_ON_DISK, /* The stream is directly attached in the in-memory buffer pointed to by @@ -52,6 +51,11 @@ enum resource_location { #endif #ifdef __WIN32__ + /* Windows only: the stream is located in the external file named by + * @file_on_disk, which is in the Windows NT namespace and may specify a + * named data stream. */ + RESOURCE_IN_WINNT_FILE_ON_DISK, + /* 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. */ @@ -59,6 +63,11 @@ enum resource_location { #endif }; +struct stream_owner { + struct wim_inode *inode; + const utf16lechar *stream_name; +}; + /* Specification for a stream, which may be the contents of a file (unnamed data * stream), a named data stream, reparse point data, or a WIM metadata resource. * @@ -97,6 +106,11 @@ struct wim_lookup_table_entry { * need this.) */ u32 dont_check_metadata_hash : 1; + u32 may_send_done_with_file : 1; + + /* Only used by wimlib_export_image() */ + u32 was_exported : 1; + union { /* (On-disk field) SHA1 message digest of the stream referenced * by this lookup table entry. */ @@ -123,20 +137,25 @@ struct wim_lookup_table_entry { /* Number of times this lookup table entry is referenced by dentries in * the WIM. When a WIM's lookup table is read, this field is - * initialized from a corresponding entry; while it should be correct, - * in general it may not be. wim_recalculate_refcnts() recalculates the - * reference counts for all streams and is run before doing any - * deletions. */ + * initialized from a corresponding entry. + * + * However, see lte_decrement_refcnt() for information about the + * limitations of this field. */ u32 refcnt; /* When a WIM file is written, this is set to the number of references * (by dentries) to this stream in the output WIM file. * - * During extraction, this is set to the number of times the stream must - * be extracted. + * During extraction, this is the number of slots in stream_owners (or + * inline_stream_owners) that have been filled. * * During image export, this is set to the number of references of this - * stream that originated from the source WIM. */ + * stream that originated from the source WIM. + * + * When mounting a WIM image read-write, this is set to the number of + * extra references to this stream preemptively taken to allow later + * saving the modified image as a new image and leaving the original + * image alone. */ u32 out_refcnt; #ifdef WITH_FUSE @@ -152,10 +171,16 @@ struct wim_lookup_table_entry { struct wim_resource_spec *rspec; u64 offset_in_res; }; - tchar *file_on_disk; + struct { + tchar *file_on_disk; + struct wim_inode *file_inode; + }; void *attached_buffer; #ifdef WITH_FUSE - tchar *staging_file_name; + struct { + char *staging_file_name; + int staging_dir_fd; + }; #endif #ifdef WITH_NTFS_3G struct ntfs_location *ntfs_loc; @@ -167,12 +192,6 @@ struct wim_lookup_table_entry { */ struct list_head rspec_node; - /* This field is used during the hardlink and symlink image extraction - * modes. In these modes, all identical files are linked together, and - * @extracted_file will be set to the filename of the first extracted - * file containing this stream. */ - tchar *extracted_file; - /* Temporary fields */ union { /* Fields used temporarily during WIM file writing. */ @@ -188,6 +207,7 @@ struct wim_lookup_table_entry { struct { u64 out_res_offset_in_wim; u64 out_res_size_in_wim; + u64 out_res_uncompressed_size; }; }; @@ -199,20 +219,18 @@ struct wim_lookup_table_entry { struct wim_reshdr out_reshdr; }; - /* Used temporarily during extraction */ + /* Used temporarily during extraction. This is an array of + * pointers to the inodes being extracted that use this stream. + */ union { - /* Dentries to extract that reference this stream. + /* Inodes to extract that reference this stream. * out_refcnt tracks the number of slots filled. */ - struct wim_dentry *inline_lte_dentries[7]; + struct stream_owner inline_stream_owners[3]; struct { - struct wim_dentry **lte_dentries; - size_t alloc_lte_dentries; + struct stream_owner *stream_owners; + u32 alloc_stream_owners; }; }; - - /* Actual reference count to this stream (only used while - * verifying an image). */ - u32 real_refcnt; }; /* Temporary list fields. */ @@ -225,6 +243,9 @@ struct wim_lookup_table_entry { /* Links streams being exported. */ struct list_head export_stream_list; + + /* Links original list of streams in the read-write mounted image. */ + struct list_head orig_stream_list; }; /* Links streams that are still unhashed after being been added to a @@ -324,12 +345,6 @@ sort_stream_list_by_sequential_order(struct list_head *stream_list, extern int lte_zero_out_refcnt(struct wim_lookup_table_entry *lte, void *ignore); -extern int -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); - static inline bool lte_is_partial(const struct wim_lookup_table_entry * lte) { @@ -337,17 +352,13 @@ lte_is_partial(const struct wim_lookup_table_entry * lte) lte->size != lte->rspec->uncompressed_size; } -static inline bool -lte_filename_valid(const struct wim_lookup_table_entry *lte) +static inline const struct stream_owner * +stream_owners(struct wim_lookup_table_entry *stream) { - return lte->resource_location == RESOURCE_IN_FILE_ON_DISK - #ifdef __WIN32__ - || lte->resource_location == RESOURCE_WIN32_ENCRYPTED - #endif - #ifdef WITH_FUSE - || lte->resource_location == RESOURCE_IN_STAGING_FILE - #endif - ; + if (stream->out_refcnt <= ARRAY_LEN(stream->inline_stream_owners)) + return stream->inline_stream_owners; + else + return stream->stream_owners; } static inline void