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 lookup table entry for this image's metadata resource
27 struct wim_lookup_table_entry *metadata_lte;
29 /* Linked list of 'struct wim_inode's for this image. */
30 struct list_head inode_list;
32 /* Linked list of 'struct wim_lookup_table_entry's for this image that
33 * are referred to in the dentry tree, but have not had a SHA1 message
34 * digest calculated yet and therefore have not been inserted into the
35 * WIM's lookup table. This list is added to during wimlib_add_image()
36 * and wimlib_mount_image() (read-write only). */
37 struct list_head unhashed_streams;
39 /* 1 iff the dentry tree has been modified. If this is the case, the
40 * memory for the dentry tree should not be freed when switching to a
41 * different WIM image. */
45 struct _ntfs_volume *ntfs_vol;
49 static inline struct wim_image_metadata *
50 wim_get_current_image_metadata(WIMStruct *wim)
52 return wim->image_metadata[wim->current_image - 1];
55 static inline const struct wim_image_metadata *
56 wim_get_const_current_image_metadata(const WIMStruct *wim)
58 return wim->image_metadata[wim->current_image - 1];
61 static inline struct wim_dentry *
62 wim_root_dentry(WIMStruct *wim)
64 return wim_get_current_image_metadata(wim)->root_dentry;
67 static inline struct wim_security_data *
68 wim_security_data(WIMStruct *wim)
70 return wim_get_current_image_metadata(wim)->security_data;
73 static inline const struct wim_security_data *
74 wim_const_security_data(const WIMStruct *wim)
76 return wim_get_const_current_image_metadata(wim)->security_data;
79 /* Iterate over each inode in a WIM image that has not yet been hashed */
80 #define image_for_each_inode(inode, imd) \
81 list_for_each_entry(inode, &imd->inode_list, i_list)
83 /* Iterate over each stream in a WIM image that has not yet been hashed */
84 #define image_for_each_unhashed_stream(lte, imd) \
85 list_for_each_entry(lte, &imd->unhashed_streams, unhashed_list)
87 /* Iterate over each stream in a WIM image that has not yet been hashed (safe
88 * against stream removal) */
89 #define image_for_each_unhashed_stream_safe(lte, tmp, imd) \
90 list_for_each_entry_safe(lte, tmp, &imd->unhashed_streams, unhashed_list)
93 destroy_image_metadata(struct wim_image_metadata *imd,
94 struct wim_lookup_table *table,
95 bool free_metadata_lte);
98 put_image_metadata(struct wim_image_metadata *imd,
99 struct wim_lookup_table *table);
102 append_image_metadata(WIMStruct *wim, struct wim_image_metadata *imd);
104 extern struct wim_image_metadata *
105 new_image_metadata(void) _malloc_attribute;
107 extern struct wim_image_metadata **
108 new_image_metadata_array(unsigned num_images) _malloc_attribute;
110 #endif /* _WIMLIB_METADATA_H */