]> wimlib.net Git - wimlib/blob - include/wimlib/metadata.h
inode/blob cleanups
[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 #ifdef WITH_NTFS_3G
9 struct _ntfs_volume;
10 #endif
11
12 /* Metadata for a WIM image  */
13 struct wim_image_metadata {
14
15         /* Number of WIMStruct's that are sharing this image metadata (from
16          * calls to wimlib_export_image().) */
17         unsigned long refcnt;
18
19         /* Pointer to the root dentry of the image. */
20         struct wim_dentry *root_dentry;
21
22         /* Pointer to the security data of the image. */
23         struct wim_security_data *security_data;
24
25         /* Pointer to the blob descriptor for this image's metadata resource */
26         struct blob_descriptor *metadata_blob;
27
28         /* Linked list of 'struct wim_inode's for this image. */
29         struct list_head inode_list;
30
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;
37
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. */
41         u8 modified : 1;
42
43 #ifdef WITH_NTFS_3G
44         struct _ntfs_volume *ntfs_vol;
45 #endif
46 };
47
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)
52 {
53         return wim->image_metadata[wim->current_image - 1];
54 }
55
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)
60 {
61         return wim_get_current_image_metadata(wim)->root_dentry;
62 }
63
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)
68 {
69         return wim_get_current_image_metadata(wim)->security_data;
70 }
71
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)
75
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)
79
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)
84
85 extern void
86 put_image_metadata(struct wim_image_metadata *imd, struct blob_table *table);
87
88 extern int
89 append_image_metadata(WIMStruct *wim, struct wim_image_metadata *imd);
90
91 extern struct wim_image_metadata *
92 new_image_metadata(void) _malloc_attribute;
93
94 #endif /* _WIMLIB_METADATA_H */