1 #ifndef _WIMLIB_RESOURCE_H
2 #define _WIMLIB_RESOURCE_H
4 #include "wimlib/types.h"
5 #include "wimlib/callback.h"
7 struct wim_lookup_table_entry;
8 struct wim_image_metadata;
10 /* Metadata for a resource in a WIM file. */
11 struct resource_entry {
12 /* Size, in bytes, of the resource in the WIM file. */
15 /* Bitwise or of one or more of the WIM_RESHDR_FLAG_* flags. */
18 /* Offset, in bytes, of the resource in the WIM file. */
21 /* Uncompressed size of the resource in the WIM file. Is the same as
22 * @size if the resource is uncompressed. */
27 /* Flags for the `flags' field of the struct resource_entry structure. */
29 /* I haven't seen this flag used in any of the WIMs I have examined. I assume
30 * it means that there are no references to the stream, so the space is free.
31 * However, even after deleting files from a WIM mounted with `imagex.exe
32 * /mountrw', I could not see this flag being used. Either way, we don't
33 * actually use this flag for anything. */
34 #define WIM_RESHDR_FLAG_FREE 0x01
36 /* Indicates that the stream is a metadata resource for a WIM image. */
37 #define WIM_RESHDR_FLAG_METADATA 0x02
39 /* Indicates that the stream is compressed. */
40 #define WIM_RESHDR_FLAG_COMPRESSED 0x04
42 /* I haven't seen this flag used in any of the WIMs I have examined. Perhaps it
43 * means that a stream could possibly be split among multiple split WIM parts.
44 * However, `imagex.exe /split' does not seem to create any WIMs like this.
45 * Either way, we don't actually use this flag for anything. */
46 #define WIM_RESHDR_FLAG_SPANNED 0x08
48 /* Nonzero if a struct resource_entry indicates a compressed resource. */
50 resource_is_compressed(const struct resource_entry *entry)
52 return (entry->flags & WIM_RESHDR_FLAG_COMPRESSED);
56 # define copy_resource_entry(dst, src) memcpy(dst, src, sizeof(struct resource_entry))
57 # define zero_resource_entry(entry) memset(entry, 0, sizeof(struct resource_entry))
60 copy_resource_entry(struct resource_entry *dst,
61 const struct resource_entry *src)
63 BUILD_BUG_ON(sizeof(struct resource_entry) != 24);
64 ((u64*)dst)[0] = ((u64*)src)[0];
65 ((u64*)dst)[1] = ((u64*)src)[1];
66 ((u64*)dst)[2] = ((u64*)src)[2];
70 zero_resource_entry(struct resource_entry *entry)
72 BUILD_BUG_ON(sizeof(struct resource_entry) != 24);
79 #define WIMLIB_RESOURCE_FLAG_RAW 0x1
80 #define WIMLIB_RESOURCE_FLAG_RECOMPRESS 0x2
83 read_resource_prefix(const struct wim_lookup_table_entry *lte,
84 u64 size, consume_data_callback_t cb, void *ctx_or_buf,
88 get_resource_entry(const void *p, struct resource_entry *entry);
91 put_resource_entry(void *p, const struct resource_entry *entry);
94 read_partial_wim_resource_into_buf(const struct wim_lookup_table_entry *lte,
95 size_t size, u64 offset, void *buf);
97 read_full_resource_into_buf(const struct wim_lookup_table_entry *lte, void *buf);
100 write_wim_resource(struct wim_lookup_table_entry *lte, int out_fd,
101 int out_ctype, struct resource_entry *out_res_entry,
105 extract_wim_resource(const struct wim_lookup_table_entry *lte,
107 consume_data_callback_t extract_chunk,
108 void *extract_chunk_arg);
111 extract_wim_resource_to_fd(const struct wim_lookup_table_entry *lte,
115 sha1_resource(struct wim_lookup_table_entry *lte);
118 copy_resource(struct wim_lookup_table_entry *lte, void *w);
121 read_metadata_resource(WIMStruct *w,
122 struct wim_image_metadata *image_metadata);
125 write_metadata_resource(WIMStruct *w);
127 #endif /* _WIMLIB_RESOURCE_H */