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"
12 /* Metadata for a WIM image */
13 struct wim_image_metadata {
15 /* Number of WIMStruct's that are sharing this image metadata (from
16 * calls to wimlib_export_image().) */
19 /* Pointer to the root dentry of the image. */
20 struct wim_dentry *root_dentry;
22 /* Pointer to the security data of the image. */
23 struct wim_security_data *security_data;
25 /* Pointer to the blob descriptor for this image's metadata resource */
26 struct blob_descriptor *metadata_blob;
28 /* Linked list of 'struct wim_inode's for this image. */
29 struct list_head inode_list;
31 /* Linked list of 'struct blob_descriptor's for blobs that are
32 * referenced by this image's dentry tree, but have not had their SHA-1
33 * message digests calculated yet and therefore have not been inserted
34 * into the WIMStruct's blob table. This list is appended to when files
35 * are scanned for inclusion in this WIM image. */
36 struct list_head unhashed_blobs;
38 /* 1 iff the dentry tree has been modified from the original stored in
39 * the WIM file. If this is the case, the memory for the dentry tree
40 * should not be freed when switching to a different WIM image. */
44 struct _ntfs_volume *ntfs_vol;
48 /* Retrieve the metadata of the image in @wim currently selected with
49 * select_wim_image(). */
50 static inline struct wim_image_metadata *
51 wim_get_current_image_metadata(WIMStruct *wim)
53 return wim->image_metadata[wim->current_image - 1];
56 /* Retrieve the root dentry of the image in @wim currently selected with
57 * select_wim_image(). */
58 static inline struct wim_dentry *
59 wim_get_current_root_dentry(WIMStruct *wim)
61 return wim_get_current_image_metadata(wim)->root_dentry;
64 /* Retrieve the security data of the image in @wim currently selected with
65 * select_wim_image(). */
66 static inline struct wim_security_data *
67 wim_get_current_security_data(WIMStruct *wim)
69 return wim_get_current_image_metadata(wim)->security_data;
72 /* Iterate over each inode in a WIM image */
73 #define image_for_each_inode(inode, imd) \
74 list_for_each_entry(inode, &(imd)->inode_list, i_list)
76 /* Iterate over each blob in a WIM image that has not yet been hashed */
77 #define image_for_each_unhashed_blob(blob, imd) \
78 list_for_each_entry(blob, &(imd)->unhashed_blobs, unhashed_list)
80 /* Iterate over each blob in a WIM image that has not yet been hashed (safe
81 * against blob removal) */
82 #define image_for_each_unhashed_blob_safe(blob, tmp, imd) \
83 list_for_each_entry_safe(blob, tmp, &(imd)->unhashed_blobs, unhashed_list)
86 put_image_metadata(struct wim_image_metadata *imd, struct blob_table *table);
89 append_image_metadata(WIMStruct *wim, struct wim_image_metadata *imd);
91 extern struct wim_image_metadata *
92 new_image_metadata(void) _malloc_attribute;
94 #endif /* _WIMLIB_METADATA_H */