]> wimlib.net Git - wimlib/blob - include/wimlib/metadata.h
wimlib.h: Fix typo
[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 static inline struct wim_image_metadata *
50 wim_get_current_image_metadata(WIMStruct *w)
51 {
52         return w->image_metadata[w->current_image - 1];
53 }
54
55 static inline const struct wim_image_metadata *
56 wim_get_const_current_image_metadata(const WIMStruct *w)
57 {
58         return w->image_metadata[w->current_image - 1];
59 }
60
61 static inline struct wim_dentry *
62 wim_root_dentry(WIMStruct *w)
63 {
64         return wim_get_current_image_metadata(w)->root_dentry;
65 }
66
67 static inline struct wim_security_data *
68 wim_security_data(WIMStruct *w)
69 {
70         return wim_get_current_image_metadata(w)->security_data;
71 }
72
73 static inline const struct wim_security_data *
74 wim_const_security_data(const WIMStruct *w)
75 {
76         return wim_get_const_current_image_metadata(w)->security_data;
77 }
78
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)
82
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)
86
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)
91
92 extern void
93 destroy_image_metadata(struct wim_image_metadata *imd,
94                        struct wim_lookup_table *table,
95                        bool free_metadata_lte);
96
97 extern void
98 put_image_metadata(struct wim_image_metadata *imd,
99                    struct wim_lookup_table *table);
100
101 extern int
102 append_image_metadata(WIMStruct *w, struct wim_image_metadata *imd);
103
104 extern struct wim_image_metadata *
105 new_image_metadata(void);
106
107 extern struct wim_image_metadata **
108 new_image_metadata_array(unsigned num_images);
109
110
111 #endif /* _WIMLIB_METADATA_H */