1 #ifndef _WIMLIB_METADATA_H
2 #define _WIMLIB_METADATA_H
4 #include "wimlib/list.h"
5 #include "wimlib/types.h"
6 #include "wimlib/wim.h"
8 /* Metadata for a WIM image */
9 struct wim_image_metadata {
11 /* Number of WIMStruct's that are sharing this image metadata (from
12 * calls to wimlib_export_image().) */
15 /* Pointer to the root dentry of the image. */
16 struct wim_dentry *root_dentry;
18 /* Pointer to the security data of the image. */
19 struct wim_security_data *security_data;
21 /* Pointer to the blob descriptor for this image's metadata resource */
22 struct blob_descriptor *metadata_blob;
24 /* Linked list of 'struct wim_inode's for this image. */
25 struct hlist_head inode_list;
27 /* Linked list of 'struct blob_descriptor's for blobs that are
28 * referenced by this image's dentry tree, but have not had their SHA-1
29 * message digests calculated yet and therefore have not been inserted
30 * into the WIMStruct's blob table. This list is appended to when files
31 * are scanned for inclusion in this WIM image. */
32 struct list_head unhashed_blobs;
34 /* 1 iff the dentry tree has been modified from the original stored in
35 * the WIM file. If this is the case, the memory for the dentry tree
36 * should not be freed when switching to a different WIM image. */
40 /* Retrieve the metadata of the image in @wim currently selected with
41 * select_wim_image(). */
42 static inline struct wim_image_metadata *
43 wim_get_current_image_metadata(WIMStruct *wim)
45 return wim->image_metadata[wim->current_image - 1];
48 /* Retrieve the root dentry of the image in @wim currently selected with
49 * select_wim_image(). */
50 static inline struct wim_dentry *
51 wim_get_current_root_dentry(WIMStruct *wim)
53 return wim_get_current_image_metadata(wim)->root_dentry;
56 /* Retrieve the security data of the image in @wim currently selected with
57 * select_wim_image(). */
58 static inline struct wim_security_data *
59 wim_get_current_security_data(WIMStruct *wim)
61 return wim_get_current_image_metadata(wim)->security_data;
64 /* Iterate over each inode in a WIM image */
65 #define image_for_each_inode(inode, imd) \
66 hlist_for_each_entry(inode, &(imd)->inode_list, i_hlist_node)
68 /* Iterate over each inode in a WIM image (safe against inode removal) */
69 #define image_for_each_inode_safe(inode, tmp, imd) \
70 hlist_for_each_entry_safe(inode, tmp, &(imd)->inode_list, i_hlist_node)
72 /* Iterate over each blob in a WIM image that has not yet been hashed */
73 #define image_for_each_unhashed_blob(blob, imd) \
74 list_for_each_entry(blob, &(imd)->unhashed_blobs, unhashed_list)
76 /* Iterate over each blob in a WIM image that has not yet been hashed (safe
77 * against blob removal) */
78 #define image_for_each_unhashed_blob_safe(blob, tmp, imd) \
79 list_for_each_entry_safe(blob, tmp, &(imd)->unhashed_blobs, unhashed_list)
82 put_image_metadata(struct wim_image_metadata *imd, struct blob_table *table);
85 append_image_metadata(WIMStruct *wim, struct wim_image_metadata *imd);
87 extern struct wim_image_metadata *
88 new_image_metadata(void) _malloc_attribute;
90 #endif /* _WIMLIB_METADATA_H */