1 /*
2  * Index functions
3  *
4  * Copyright (C) 2010-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( _LIBFSNTFS_INDEX_H )
23 #define _LIBFSNTFS_INDEX_H
24 
25 #include <common.h>
26 #include <types.h>
27 
28 #include "libfsntfs_bitmap_values.h"
29 #include "libfsntfs_index_node.h"
30 #include "libfsntfs_index_root_header.h"
31 #include "libfsntfs_index_value.h"
32 #include "libfsntfs_io_handle.h"
33 #include "libfsntfs_libbfio.h"
34 #include "libfsntfs_libcerror.h"
35 #include "libfsntfs_libfcache.h"
36 #include "libfsntfs_libfdata.h"
37 #include "libfsntfs_mft_attribute.h"
38 #include "libfsntfs_mft_entry.h"
39 
40 #if defined( __cplusplus )
41 extern "C" {
42 #endif
43 
44 typedef struct libfsntfs_index libfsntfs_index_t;
45 
46 struct libfsntfs_index
47 {
48 	/* The IO handle
49 	 */
50 	libfsntfs_io_handle_t *io_handle;
51 
52 	/* The name
53 	 */
54 	uint8_t *name;
55 
56 	/* The name size
57 	 */
58 	size_t name_size;
59 
60 	/* The flags
61 	 */
62 	uint32_t flags;
63 
64 	/* The root header
65 	 */
66 	libfsntfs_index_root_header_t *root_header;
67 
68 	/* The root node
69 	 */
70 	libfsntfs_index_node_t *root_node;
71 
72 	/* The index entry vector
73 	 */
74 	libfdata_vector_t *index_entry_vector;
75 
76 	/* The index node cache
77 	 */
78 	libfcache_cache_t *index_node_cache;
79 
80 	/* The bitmap values
81 	 */
82 	libfsntfs_bitmap_values_t *bitmap_values;
83 };
84 
85 int libfsntfs_index_initialize(
86      libfsntfs_index_t **index,
87      libfsntfs_io_handle_t *io_handle,
88      const uint8_t *name,
89      size_t name_size,
90      libcerror_error_t **error );
91 
92 int libfsntfs_index_free(
93      libfsntfs_index_t **index,
94      libcerror_error_t **error );
95 
96 int libfsntfs_index_read(
97      libfsntfs_index_t *index,
98      libbfio_handle_t *file_io_handle,
99      libfsntfs_mft_entry_t *mft_entry,
100      uint8_t flags,
101      libcerror_error_t **error );
102 
103 int libfsntfs_index_read_root_header(
104      libfsntfs_index_t *index,
105      libfsntfs_mft_attribute_t *index_root_attribute,
106      libcerror_error_t **error );
107 
108 int libfsntfs_index_read_root_node(
109      libfsntfs_index_t *index,
110      libfsntfs_mft_attribute_t *index_root_attribute,
111      libcerror_error_t **error );
112 
113 int libfsntfs_index_read_bitmap(
114      libfsntfs_index_t *index,
115      libbfio_handle_t *file_io_handle,
116      libfsntfs_mft_attribute_t *bitmap_attribute,
117      uint8_t flags,
118      libcerror_error_t **error );
119 
120 int libfsntfs_index_get_index_entry_size(
121      libfsntfs_index_t *index,
122      uint32_t *index_entry_size,
123      libcerror_error_t **error );
124 
125 int libfsntfs_index_get_attribute_type(
126      libfsntfs_index_t *index,
127      uint32_t *attribute_type,
128      libcerror_error_t **error );
129 
130 int libfsntfs_index_get_collation_type(
131      libfsntfs_index_t *index,
132      uint32_t *collation_type,
133      libcerror_error_t **error );
134 
135 int libfsntfs_index_sub_node_is_allocated(
136      libfsntfs_index_t *index,
137      int sub_node_vcn,
138      libcerror_error_t **error );
139 
140 int libfsntfs_index_get_sub_node(
141      libfsntfs_index_t *index,
142      libbfio_handle_t *file_io_handle,
143      libfcache_cache_t *index_node_cache,
144      off64_t index_entry_offset,
145      int sub_node_vcn,
146      libfsntfs_index_node_t **index_node,
147      libcerror_error_t **error );
148 
149 #if defined( __cplusplus )
150 }
151 #endif
152 
153 #endif /* !defined( _LIBFSNTFS_INDEX_H ) */
154 
155