1 /*
2  * The file header definition of a sparse VMware Virtual Disk (VMDK) file
3  *
4  * Copyright (C) 2009-2021, Joachim Metz <joachim.metz@gmail.com>
5  *
6  * Refer to AUTHORS for acknowledgements.
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20  */
21 
22 #if !defined( _VMDK_SPARSE_FILE_HEADER_H )
23 #define _VMDK_SPARSE_FILE_HEADER_H
24 
25 #include <common.h>
26 #include <types.h>
27 
28 #if defined( __cplusplus )
29 extern "C" {
30 #endif
31 
32 typedef struct vmdk_sparse_file_header vmdk_sparse_file_header_t;
33 
34 struct vmdk_sparse_file_header
35 {
36 	/* The signature
37 	 * Consists of 4 bytes
38 	 * Contains: "KDMV"
39 	 */
40 	uint8_t signature[ 4 ];
41 
42 	/* The version
43 	 * Consists of 4 bytes
44 	 */
45 	uint8_t version[ 4 ];
46 
47 	/* The flags
48 	 * Consists of 4 bytes
49 	 */
50 	uint8_t flags[ 4 ];
51 
52 	/* The maximum data number of sectors (capacity)
53 	 * Consists of 8 bytes
54 	 * Contains a value in sectors
55 	 */
56 	uint8_t maximum_data_number_of_sectors[ 8 ];
57 
58 	/* The grain number of sectors
59 	 * Consists of 8 bytes
60 	 * Contains a value in sectors
61 	 */
62 	uint8_t grain_number_of_sectors[ 8 ];
63 
64 	/* The descriptor sector number
65 	 * Consists of 8 bytes
66 	 * Contains a value in sectors
67 	 */
68 	uint8_t descriptor_sector_number[ 8 ];
69 
70 	/* The descriptor number of sectors
71 	 * Consists of 8 bytes
72 	 * Contains a value in sectors
73 	 */
74 	uint8_t descriptor_number_of_sectors[ 8 ];
75 
76 	/* The number of grain table entries
77 	 * Consists of 4 bytes
78 	 */
79 	uint8_t number_of_grain_table_entries[ 4 ];
80 
81 	/* The secondary grain directory sector number
82 	 * Consists of 8 bytes
83 	 * Contains a value in sectors
84 	 */
85 	uint8_t secondary_grain_directory_sector_number[ 8 ];
86 
87 	/* The primary grain directory sector number
88 	 * Consists of 8 bytes
89 	 * Contains a value in sectors
90 	 */
91 	uint8_t primary_grain_directory_sector_number[ 8 ];
92 
93 	/* The metadata (overhead) number of sectors
94 	 * Consists of 8 bytes
95 	 * Contains a value in sectors
96 	 */
97 	uint8_t metadata_number_of_sectors[ 8 ];
98 
99 	/* Value to indicate the VMDK was cleanly closed
100 	 * Consists of 1 byte
101 	 */
102 	uint8_t is_dirty;
103 
104 	/* The single end of line character
105 	 * Consists of 1 byte
106 	 * Contains: '\n'
107 	 */
108 	uint8_t single_end_of_line_character;
109 
110 	/* A non end of line character
111 	 * Consists of 1 byte
112 	 * Contains: ' '
113 	 */
114 	uint8_t non_end_of_line_character;
115 
116 	/* The first double end of line character
117 	 * Consists of 1 byte
118 	 * Contains: '\r'
119 	 */
120 	uint8_t first_double_end_of_line_character;
121 
122 	/* The second double end of line character
123 	 * Consists of 1 byte
124 	 * Contains: '\n'
125 	 */
126 	uint8_t second_double_end_of_line_character;
127 
128 	/* The compression method
129 	 * Consists of 2 bytes
130 	 */
131 	uint8_t compression_method[ 2 ];
132 
133 	/* Padding
134 	 * Consists of 433 bytes
135 	 */
136 	uint8_t padding[ 433 ];
137 };
138 
139 #if defined( __cplusplus )
140 }
141 #endif
142 
143 #endif /* !defined( _VMDK_SPARSE_FILE_HEADER_H ) */
144 
145