]> wimlib.net Git - wimlib/blobdiff - src/lookup_table.h
Save original xml_data only when needed
[wimlib] / src / lookup_table.h
index ab545f2d3ea94cd38b139af34ab7fee4bdbcaaa9..e5241f8068498ce0504145589551c8cffd8b57b8 100644 (file)
@@ -40,7 +40,7 @@ struct ntfs_location {
        tchar *path;
        utf16lechar *stream_name;
        u16 stream_name_nchars;
-       struct _ntfs_volume **ntfs_vol_p;
+       struct _ntfs_volume *ntfs_vol;
        bool is_reparse_point;
 };
 #endif
@@ -135,8 +135,18 @@ struct wim_lookup_table_entry {
         */
        u16 part_number;
 
-       /* See enum resource_location above */
-       u16 resource_location;
+       /* One of the `enum resource_location' values documented above. */
+       u16 resource_location : 5;
+
+       /* 1 if this stream is a unique size (only set while writing streams). */
+       u8 unique_size : 1;
+
+       /* 1 if this stream had a SHA1-message digest calculated for it yet? */
+       u8 unhashed : 1;
+       
+       u8 deferred : 1;
+
+       u8 no_progress : 1;
 
        /* (On-disk field)
         * Number of times this lookup table entry is referenced by dentries.
@@ -156,45 +166,56 @@ struct wim_lookup_table_entry {
                 * the full 20 byte hash just to insert the entry in a hash
                 * table. */
                size_t hash_short;
-       };
-
-       union {
-               #ifdef WITH_FUSE
-               u16 num_opened_fds;
-               #endif
 
-               /* This field is used for the special hardlink or symlink image
-                * extraction mode.   In these mode, 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;
+               /* Unhashed entries only (unhashed == 1): these variables make
+                * it possible to find the pointer to this 'struct
+                * wim_lookup_table_entry' contained in either 'struct
+                * wim_ads_entry' or 'struct wim_inode'.  There can be at most 1
+                * such pointer, as we can only join duplicate streams after
+                * they have been hashed.  */
+               struct {
+                       struct wim_inode *back_inode;
+                       u32 back_stream_id;
+               };
        };
 
+       /* When a WIM file is written, out_refcnt starts at 0 and is incremented
+        * whenever the stream pointed to by this lookup table entry needs to be
+        * written.  The stream only need to be written when out_refcnt is
+        * nonzero, since otherwise it is not referenced by any dentries. */
+       u32 out_refcnt;
+
        /* Pointers to somewhere where the stream is actually located.  See the
         * comments for the @resource_location field above. */
        union {
                WIMStruct *wim;
                tchar *file_on_disk;
-               tchar *staging_file_name;
                void *attached_buffer;
+       #ifdef WITH_FUSE
+               tchar *staging_file_name;
+       #endif
        #ifdef WITH_NTFS_3G
                struct ntfs_location *ntfs_loc;
        #endif
        };
 
-       /* Pointer to inode that contains the opened file descriptors to
-        * this stream (valid iff resource_location ==
-        * RESOURCE_IN_STAGING_FILE) */
-       struct wim_inode *lte_inode;
+       /* Actual reference count to this stream (only used while
+        * verifying an image). */
+       u32 real_refcnt;
 
-       /* When a WIM file is written, out_refcnt starts at 0 and is incremented
-        * whenever the file resource pointed to by this lookup table entry
-        * needs to be written.  The file resource only need to be written when
-        * out_refcnt is nonzero, since otherwise it is not referenced by any
-        * dentries. */
-       u32 out_refcnt;
+       union {
+       #ifdef WITH_FUSE
+               /* Number of times this stream has been opened (used only during
+                * mounting) */
+               u16 num_opened_fds;
+       #endif
 
-       u32 real_refcnt;
+               /* This field is used for the special hardlink or symlink image
+                * extraction mode.   In these mode, 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;
+       };
 
        union {
                /* When a WIM file is written, @output_resource_entry is filled
@@ -206,17 +227,26 @@ struct wim_lookup_table_entry {
                 */
                struct resource_entry output_resource_entry;
 
-               struct list_head msg_list;
+               struct {
+                       struct list_head msg_list;
+                       struct list_head being_compressed_list;
+               };
                struct list_head inode_list;
+
+               struct {
+                       struct hlist_node hash_list_2;
+
+                       struct list_head write_streams_list;
+               };
        };
 
-       /* List of lookup table entries that correspond to streams that have
-        * been extracted to the staging directory when modifying a read-write
-        * mounted WIM.
-        *
-        * This field is also used to make other lists of lookup table entries.
-        * */
-       struct list_head staging_list;
+       /* Temporary list fields */
+       union {
+               struct list_head unhashed_list;
+               struct list_head swm_stream_list;
+               struct list_head extraction_list;
+               struct list_head export_stream_list;
+       };
 };
 
 static inline u64
@@ -283,6 +313,7 @@ lookup_table_insert(struct wim_lookup_table *table, struct wim_lookup_table_entr
 static inline void
 lookup_table_unlink(struct wim_lookup_table *table, struct wim_lookup_table_entry *lte)
 {
+       wimlib_assert(!lte->unhashed);
        hlist_del(&lte->hash_list);
        wimlib_assert(table->num_entries != 0);
        table->num_entries--;
@@ -307,7 +338,7 @@ for_lookup_table_entry(struct wim_lookup_table *table,
                       void *arg);
 
 extern int
-sort_stream_list_by_wim_position(struct list_head *stream_list);
+cmp_streams_by_wim_position(const void *p1, const void *p2);
 
 extern int
 for_lookup_table_entry_pos_sorted(struct wim_lookup_table *table,
@@ -349,13 +380,6 @@ inode_unresolve_ltes(struct wim_inode *inode);
 extern int
 write_lookup_table_entry(struct wim_lookup_table_entry *lte, void *__out);
 
-static inline struct resource_entry*
-wim_metadata_resource_entry(WIMStruct *w)
-{
-       return &w->image_metadata[
-                       w->current_image - 1].metadata_lte->resource_entry;
-}
-
 static inline struct wim_lookup_table_entry *
 inode_stream_lte_resolved(const struct wim_inode *inode, unsigned stream_idx)
 {
@@ -474,12 +498,22 @@ lookup_table_total_stream_size(struct wim_lookup_table *table);
 
 static inline void
 lookup_table_insert_unhashed(struct wim_lookup_table *table,
-                            struct wim_lookup_table_entry *lte)
+                            struct wim_lookup_table_entry *lte,
+                            struct wim_inode *back_inode,
+                            u32 back_stream_id)
 {
-       list_add_tail(&lte->staging_list, table->unhashed_streams);
+       lte->unhashed = 1;
+       lte->back_inode = back_inode;
+       lte->back_stream_id = back_stream_id;
+       list_add_tail(&lte->unhashed_list, table->unhashed_streams);
 }
 
-extern void
-lookup_table_free_unhashed_streams(struct wim_lookup_table *table);
+extern int
+hash_unhashed_stream(struct wim_lookup_table_entry *lte,
+                    struct wim_lookup_table *lookup_table,
+                    struct wim_lookup_table_entry **lte_ret);
+
+extern struct wim_lookup_table_entry **
+retrieve_lte_pointer(struct wim_lookup_table_entry *lte);
 
 #endif