+/* WIM alternate data stream entry (on-disk format) */
+struct wim_ads_entry_on_disk {
+ /* Length of the entry, in bytes. This apparently includes all
+ * fixed-length fields, plus the stream name and null terminator if
+ * present, and the padding up to an 8 byte boundary. wimlib is a
+ * little less strict when reading the entries, and only requires that
+ * the number of bytes from this field is at least as large as the size
+ * of the fixed length fields and stream name without null terminator.
+ * */
+ le64 length;
+
+ le64 reserved;
+
+ /* SHA1 message digest of the uncompressed stream; or, alternatively,
+ * can be all zeroes if the stream has zero length. */
+ u8 hash[SHA1_HASH_SIZE];
+
+ /* Length of the stream name, in bytes. 0 if the stream is unnamed. */
+ le16 stream_name_nbytes;
+
+ /* Stream name in UTF-16LE. It is @stream_name_nbytes bytes long,
+ * excluding the the null terminator. There is a null terminator
+ * character if @stream_name_nbytes != 0; i.e., if this stream is named.
+ * */
+ utf16lechar stream_name[];
+} _packed_attribute;
+
+#define WIM_ADS_ENTRY_DISK_SIZE 38
+
+/* WIM directory entry (on-disk format) */
+struct wim_dentry_on_disk {
+ le64 length;
+ le32 attributes;
+ sle32 security_id;
+ le64 subdir_offset;
+ le64 unused_1;
+ le64 unused_2;
+ le64 creation_time;
+ le64 last_access_time;
+ le64 last_write_time;
+ u8 unnamed_stream_hash[SHA1_HASH_SIZE];
+ union {
+ struct {
+ le32 rp_unknown_1;
+ le32 reparse_tag;
+ le16 rp_unknown_2;
+ le16 not_rpfixed;
+ } _packed_attribute reparse;
+ struct {
+ le32 rp_unknown_1;
+ le64 hard_link_group_id;
+ } _packed_attribute nonreparse;
+ };
+ le16 num_alternate_data_streams;
+ le16 short_name_nbytes;
+ le16 file_name_nbytes;
+
+ /* Follewed by variable length file name, if file_name_nbytes != 0 */
+ utf16lechar file_name[];
+
+ /* Followed by variable length short name, if short_name_nbytes != 0 */
+ /*utf16lechar short_name[];*/
+} _packed_attribute;
+
+#define WIM_DENTRY_DISK_SIZE 102
+
+/* Calculates the unaligned length, in bytes, of an on-disk WIM dentry that has
+ * a file name and short name that take the specified numbers of bytes. This
+ * excludes any alternate data stream entries that may follow the dentry. */
+static u64
+_dentry_correct_length_unaligned(u16 file_name_nbytes, u16 short_name_nbytes)