]> wimlib.net Git - wimlib/blob - include/wimlib/header.h
Refactor headers
[wimlib] / include / wimlib / header.h
1 #ifndef _WIMLIB_HEADER_H
2 #define _WIMLIB_HEADER_H
3
4 #include "wimlib/resource.h"
5 #include "wimlib/types.h"
6
7 #define WIM_MAGIC_LEN  8
8 #define WIM_GID_LEN    16
9 #define WIM_UNUSED_LEN 60
10
11 /* Length of the WIM header on disk. */
12 #define WIM_HEADER_DISK_SIZE (148 + WIM_UNUSED_LEN)
13
14 /* Compressed resources in the WIM are divided into separated compressed chunks
15  * of this size. */
16 #define WIM_CHUNK_SIZE 32768
17
18 /* Version of the WIM file.  There is an older version, but we don't support it
19  * yet.  The differences between the versions are undocumented. */
20 #define WIM_VERSION 0x10d00
21
22 /* Header at the very beginning of the WIM file. */
23 struct wim_header {
24         /* Identifies the file as WIM file. Must be exactly
25          * {'M', 'S', 'W', 'I', 'M', 0, 0, 0}  */
26         //u8  magic[WIM_MAGIC_LEN];
27
28         /* size of WIM header in bytes. */
29         //u32 hdr_size;
30
31         /* Version of the WIM file.  Microsoft provides no documentation about
32          * exactly what this field affects about the file format, other than the
33          * fact that more recent versions have a higher value. */
34         //u32 version;
35
36         /* Bitwise OR of one or more of the WIM_HDR_FLAG_* defined below. */
37         u32 flags;
38
39         /* The size of the pieces that the uncompressed files were split up into
40          * when they were compressed.  This should be the same as
41          * WIM_CHUNK_SIZE.  Microsoft incorrectly documents this as "the size of
42          * the compressed .wim file in bytes".*/
43         //u32 chunk_size;
44
45         /* A unique identifier for the WIM file. */
46         u8 guid[WIM_GID_LEN];
47
48         /* Part number of the WIM file in a spanned set. */
49         u16 part_number;
50
51         /* Total number of parts in a spanned set. */
52         u16 total_parts;
53
54         /* Number of images in the WIM file. */
55         u32 image_count;
56
57         /* Location, size, and flags of the lookup table of the WIM. */
58         struct resource_entry lookup_table_res_entry;
59
60         /* Location, size, and flags for the XML data of the WIM. */
61         struct resource_entry xml_res_entry;
62
63         /* Location, size, and flags for the boot metadata.  This means the
64          * metadata resource for the image specified by boot_idx below.  Should
65          * be zeroed out if boot_idx is 0. */
66         struct resource_entry boot_metadata_res_entry;
67
68         /* The index of the bootable image in the WIM file. If 0, there are no
69          * bootable images available. */
70         u32 boot_idx;
71
72         /* The location of the optional integrity table used to verify the
73          * integrity WIM.  Zeroed out if there is no integrity table.*/
74         struct resource_entry integrity;
75
76         /* Reserved for future disuse */
77         //u8 unused[WIM_UNUSED_LEN];
78 };
79
80 /* Flags for the `flags' field of the struct wim_header: */
81
82 /* Reserved for future use */
83 #define WIM_HDR_FLAG_RESERVED           0x00000001
84
85 /* Files and metadata in the WIM are compressed. */
86 #define WIM_HDR_FLAG_COMPRESSION        0x00000002
87
88 /* WIM is read-only (wimlib ignores this because it's pretty much pointless) */
89 #define WIM_HDR_FLAG_READONLY           0x00000004
90
91 /* Resource data specified by images in this WIM may be contained in a different
92  * WIM.  Or in other words, this WIM is part of a split WIM.  */
93 #define WIM_HDR_FLAG_SPANNED            0x00000008
94
95 /* The WIM contains resources only; no filesystem metadata.  wimlib ignores this
96  * flag, as it looks for resources in all the WIMs anyway. */
97 #define WIM_HDR_FLAG_RESOURCE_ONLY      0x00000010
98
99 /* The WIM contains metadata only.  wimlib ignores this flag.  Note that all the
100  * metadata resources for a split WIM should be in the first part. */
101 #define WIM_HDR_FLAG_METADATA_ONLY      0x00000020
102
103 /* Lock field to prevent multiple writers from writing the WIM concurrently.
104  * wimlib ignores this flag as it uses flock() to acquire a real lock on the
105  * file (if supported by the underlying filesystem). */
106 #define WIM_HDR_FLAG_WRITE_IN_PROGRESS  0x00000040
107
108 /* Reparse point fixup flag.  See docs for --rpfix and --norpfix in imagex, or
109  * WIMLIB_ADD_FLAG_{RPFIX,NORPFIX} in wimlib.h.  Note that
110  * WIM_HDR_FLAG_RP_FIX is a header flag and just sets the default behavior for
111  * the WIM; it can still be overridder on a per-image basis.  But there is no
112  * flag to set the default behavior for a specific image. */
113 #define WIM_HDR_FLAG_RP_FIX             0x00000080
114
115 /* Unused, reserved flag for another compression type */
116 #define WIM_HDR_FLAG_COMPRESS_RESERVED  0x00010000
117
118 /* Resources within the WIM are compressed using "XPRESS" compression, which is
119  * a LZ77-based compression algorithm. */
120 #define WIM_HDR_FLAG_COMPRESS_XPRESS    0x00020000
121
122 /* Resources within the WIM are compressed using "LZX" compression.  This is also
123  * a LZ77-based algorithm. */
124 #define WIM_HDR_FLAG_COMPRESS_LZX       0x00040000
125
126 #endif /* _WIMLIB_HEADER_H */