1 /*
2  * Grain table functions
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( _LIBVMDK_GRAIN_TABLE_H )
23 #define _LIBVMDK_GRAIN_TABLE_H
24 
25 #include <common.h>
26 #include <types.h>
27 
28 #include "libvmdk_extent_table.h"
29 #include "libvmdk_grain_data.h"
30 #include "libvmdk_io_handle.h"
31 #include "libvmdk_libbfio.h"
32 #include "libvmdk_libcerror.h"
33 #include "libvmdk_libfcache.h"
34 #include "libvmdk_libfdata.h"
35 
36 #if defined( __cplusplus )
37 extern "C" {
38 #endif
39 
40 typedef struct libvmdk_grain_table libvmdk_grain_table_t;
41 
42 struct libvmdk_grain_table
43 {
44 	/* The IO handle
45 	 */
46 	libvmdk_io_handle_t *io_handle;
47 
48 	/* The previous last grain offset that was filled
49 	 */
50 	int previous_last_grain_offset_filled;
51 
52 	/* The last grain offset that was filled
53 	 */
54 	int last_grain_offset_filled;
55 
56 	/* The last grain offset that was compared
57 	 */
58 	int last_grain_offset_compared;
59 };
60 
61 int libvmdk_grain_table_initialize(
62      libvmdk_grain_table_t **grain_table,
63      libvmdk_io_handle_t *io_handle,
64      libcerror_error_t **error );
65 
66 int libvmdk_grain_table_free(
67      libvmdk_grain_table_t **grain_table,
68      libcerror_error_t **error );
69 
70 int libvmdk_grain_table_clone(
71      libvmdk_grain_table_t **destination_grain_table,
72      libvmdk_grain_table_t *source_grain_table,
73      libcerror_error_t **error );
74 
75 int libvmdk_grain_table_grain_is_sparse_at_offset(
76      libvmdk_grain_table_t *grain_table,
77      uint64_t grain_index,
78      libbfio_pool_t *file_io_pool,
79      libvmdk_extent_table_t *extent_table,
80      off64_t offset,
81      libcerror_error_t **error );
82 
83 int libvmdk_grain_table_get_grain_data_at_offset(
84      libvmdk_grain_table_t *grain_table,
85      uint64_t grain_index,
86      libbfio_pool_t *file_io_pool,
87      libvmdk_extent_table_t *extent_table,
88      libfcache_cache_t *grains_cache,
89      off64_t offset,
90      libvmdk_grain_data_t **grain_data,
91      off64_t *grain_data_offset,
92      libcerror_error_t **error );
93 
94 #if defined( __cplusplus )
95 }
96 #endif
97 
98 #endif /* !defined( _LIBVMDK_GRAIN_TABLE_H ) */
99 
100