]> wimlib.net Git - wimlib/blob - include/wimlib/metadata.h
NTFS-3g capture: use reference-counted NTFS volumes
[wimlib] / include / wimlib / metadata.h
1 #ifndef _WIMLIB_METADATA_H
2 #define _WIMLIB_METADATA_H
3
4 #include "wimlib/list.h"
5 #include "wimlib/types.h"
6 #include "wimlib/wim.h"
7
8 /* Metadata for a WIM image  */
9 struct wim_image_metadata {
10
11         /* Number of WIMStruct's that are sharing this image metadata (from
12          * calls to wimlib_export_image().) */
13         unsigned long refcnt;
14
15         /* Pointer to the root dentry of the image. */
16         struct wim_dentry *root_dentry;
17
18         /* Pointer to the security data of the image. */
19         struct wim_security_data *security_data;
20
21         /* Pointer to the blob descriptor for this image's metadata resource */
22         struct blob_descriptor *metadata_blob;
23
24         /* Linked list of 'struct wim_inode's for this image. */
25         struct hlist_head inode_list;
26
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;
33
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. */
37         u8 modified : 1;
38 };
39
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)
44 {
45         return wim->image_metadata[wim->current_image - 1];
46 }
47
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)
52 {
53         return wim_get_current_image_metadata(wim)->root_dentry;
54 }
55
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)
60 {
61         return wim_get_current_image_metadata(wim)->security_data;
62 }
63
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)
67
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)
71
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)
75
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)
80
81 extern void
82 put_image_metadata(struct wim_image_metadata *imd, struct blob_table *table);
83
84 extern int
85 append_image_metadata(WIMStruct *wim, struct wim_image_metadata *imd);
86
87 extern struct wim_image_metadata *
88 new_image_metadata(void) _malloc_attribute;
89
90 #endif /* _WIMLIB_METADATA_H */