]> wimlib.net Git - wimlib/blob - include/wimlib/metadata.h
win32_capture.c: adjust loading stream info from encrypted files
[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 lookup table entry for this image's metadata resource
26          */
27         struct wim_lookup_table_entry *metadata_lte;
28
29         /* Linked list of 'struct wim_inode's for this image. */
30         struct list_head inode_list;
31
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;
38
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. */
42         u8 modified : 1;
43
44 #ifdef WITH_NTFS_3G
45         struct _ntfs_volume *ntfs_vol;
46 #endif
47 };
48
49 /* Retrieve the metadata of the image in @wim currently selected with
50  * select_wim_image().  */
51 static inline struct wim_image_metadata *
52 wim_get_current_image_metadata(WIMStruct *wim)
53 {
54         return wim->image_metadata[wim->current_image - 1];
55 }
56
57 /* Retrieve the root dentry of the image in @wim currently selected with
58  * select_wim_image().  */
59 static inline struct wim_dentry *
60 wim_get_current_root_dentry(WIMStruct *wim)
61 {
62         return wim_get_current_image_metadata(wim)->root_dentry;
63 }
64
65 /* Retrieve the security data of the image in @wim currently selected with
66  * select_wim_image().  */
67 static inline struct wim_security_data *
68 wim_get_current_security_data(WIMStruct *wim)
69 {
70         return wim_get_current_image_metadata(wim)->security_data;
71 }
72
73 /* Iterate over each inode in a WIM image  */
74 #define image_for_each_inode(inode, imd) \
75         list_for_each_entry(inode, &(imd)->inode_list, i_list)
76
77 /* Iterate over each stream in a WIM image that has not yet been hashed */
78 #define image_for_each_unhashed_stream(lte, imd) \
79         list_for_each_entry(lte, &(imd)->unhashed_streams, unhashed_list)
80
81 /* Iterate over each stream in a WIM image that has not yet been hashed (safe
82  * against stream removal) */
83 #define image_for_each_unhashed_stream_safe(lte, tmp, imd) \
84         list_for_each_entry_safe(lte, tmp, &(imd)->unhashed_streams, unhashed_list)
85
86 extern void
87 put_image_metadata(struct wim_image_metadata *imd,
88                    struct wim_lookup_table *table);
89
90 extern int
91 append_image_metadata(WIMStruct *wim, struct wim_image_metadata *imd);
92
93 extern struct wim_image_metadata *
94 new_image_metadata(void) _malloc_attribute;
95
96 #endif /* _WIMLIB_METADATA_H */