/src/libfsntfs/libfsntfs/libfsntfs_attribute.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Attribute functions |
3 | | * |
4 | | * Copyright (C) 2010-2023, 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 | | #include <common.h> |
23 | | #include <memory.h> |
24 | | #include <types.h> |
25 | | |
26 | | #include "libfsntfs_attribute.h" |
27 | | #include "libfsntfs_bitmap_values.h" |
28 | | #include "libfsntfs_data_run.h" |
29 | | #include "libfsntfs_debug.h" |
30 | | #include "libfsntfs_definitions.h" |
31 | | #include "libfsntfs_file_name_values.h" |
32 | | #include "libfsntfs_io_handle.h" |
33 | | #include "libfsntfs_libbfio.h" |
34 | | #include "libfsntfs_libcdata.h" |
35 | | #include "libfsntfs_libcerror.h" |
36 | | #include "libfsntfs_libcnotify.h" |
37 | | #include "libfsntfs_libcthreads.h" |
38 | | #include "libfsntfs_logged_utility_stream_values.h" |
39 | | #include "libfsntfs_mft_attribute.h" |
40 | | #include "libfsntfs_object_identifier_values.h" |
41 | | #include "libfsntfs_path_hint.h" |
42 | | #include "libfsntfs_reparse_point_values.h" |
43 | | #include "libfsntfs_security_descriptor_values.h" |
44 | | #include "libfsntfs_standard_information_values.h" |
45 | | #include "libfsntfs_txf_data_values.h" |
46 | | #include "libfsntfs_types.h" |
47 | | #include "libfsntfs_unused.h" |
48 | | #include "libfsntfs_volume_information_values.h" |
49 | | #include "libfsntfs_volume_name_values.h" |
50 | | |
51 | | /* Creates an attribute |
52 | | * Make sure the value attribute is referencing, is set to NULL |
53 | | * Returns 1 if successful or -1 on error |
54 | | */ |
55 | | int libfsntfs_attribute_initialize( |
56 | | libfsntfs_attribute_t **attribute, |
57 | | libfsntfs_mft_attribute_t *mft_attribute, |
58 | | libcerror_error_t **error ) |
59 | 0 | { |
60 | 0 | libfsntfs_internal_attribute_t *internal_attribute = NULL; |
61 | 0 | static char *function = "libfsntfs_attribute_initialize"; |
62 | |
|
63 | 0 | if( attribute == NULL ) |
64 | 0 | { |
65 | 0 | libcerror_error_set( |
66 | 0 | error, |
67 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
68 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
69 | 0 | "%s: invalid attribute.", |
70 | 0 | function ); |
71 | |
|
72 | 0 | return( -1 ); |
73 | 0 | } |
74 | 0 | if( *attribute != NULL ) |
75 | 0 | { |
76 | 0 | libcerror_error_set( |
77 | 0 | error, |
78 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
79 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET, |
80 | 0 | "%s: invalid attribute value already set.", |
81 | 0 | function ); |
82 | |
|
83 | 0 | return( -1 ); |
84 | 0 | } |
85 | 0 | if( mft_attribute == NULL ) |
86 | 0 | { |
87 | 0 | libcerror_error_set( |
88 | 0 | error, |
89 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
90 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
91 | 0 | "%s: invalid MFT attribute.", |
92 | 0 | function ); |
93 | |
|
94 | 0 | return( -1 ); |
95 | 0 | } |
96 | 0 | internal_attribute = memory_allocate_structure( |
97 | 0 | libfsntfs_internal_attribute_t ); |
98 | |
|
99 | 0 | if( internal_attribute == NULL ) |
100 | 0 | { |
101 | 0 | libcerror_error_set( |
102 | 0 | error, |
103 | 0 | LIBCERROR_ERROR_DOMAIN_MEMORY, |
104 | 0 | LIBCERROR_MEMORY_ERROR_INSUFFICIENT, |
105 | 0 | "%s: unable to create attribute.", |
106 | 0 | function ); |
107 | |
|
108 | 0 | goto on_error; |
109 | 0 | } |
110 | 0 | if( memory_set( |
111 | 0 | internal_attribute, |
112 | 0 | 0, |
113 | 0 | sizeof( libfsntfs_internal_attribute_t ) ) == NULL ) |
114 | 0 | { |
115 | 0 | libcerror_error_set( |
116 | 0 | error, |
117 | 0 | LIBCERROR_ERROR_DOMAIN_MEMORY, |
118 | 0 | LIBCERROR_MEMORY_ERROR_SET_FAILED, |
119 | 0 | "%s: unable to clear attribute.", |
120 | 0 | function ); |
121 | |
|
122 | 0 | memory_free( |
123 | 0 | internal_attribute ); |
124 | |
|
125 | 0 | return( -1 ); |
126 | 0 | } |
127 | 0 | #if defined( HAVE_LIBFSNTFS_MULTI_THREAD_SUPPORT ) |
128 | 0 | if( libcthreads_read_write_lock_initialize( |
129 | 0 | &( internal_attribute->read_write_lock ), |
130 | 0 | error ) != 1 ) |
131 | 0 | { |
132 | 0 | libcerror_error_set( |
133 | 0 | error, |
134 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
135 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
136 | 0 | "%s: unable to initialize read/write lock.", |
137 | 0 | function ); |
138 | |
|
139 | 0 | goto on_error; |
140 | 0 | } |
141 | 0 | #endif |
142 | 0 | internal_attribute->mft_attribute = mft_attribute; |
143 | |
|
144 | 0 | *attribute = (libfsntfs_attribute_t *) internal_attribute; |
145 | |
|
146 | 0 | return( 1 ); |
147 | | |
148 | 0 | on_error: |
149 | 0 | if( internal_attribute != NULL ) |
150 | 0 | { |
151 | 0 | memory_free( |
152 | 0 | internal_attribute ); |
153 | 0 | } |
154 | 0 | return( -1 ); |
155 | 0 | } |
156 | | |
157 | | /* Frees an attribute |
158 | | * Returns 1 if successful or -1 on error |
159 | | */ |
160 | | int libfsntfs_attribute_free( |
161 | | libfsntfs_attribute_t **attribute, |
162 | | libcerror_error_t **error ) |
163 | 0 | { |
164 | 0 | static char *function = "libfsntfs_attribute_free"; |
165 | |
|
166 | 0 | if( attribute == NULL ) |
167 | 0 | { |
168 | 0 | libcerror_error_set( |
169 | 0 | error, |
170 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
171 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
172 | 0 | "%s: invalid attribute.", |
173 | 0 | function ); |
174 | |
|
175 | 0 | return( -1 ); |
176 | 0 | } |
177 | 0 | if( *attribute != NULL ) |
178 | 0 | { |
179 | 0 | *attribute = NULL; |
180 | 0 | } |
181 | 0 | return( 1 ); |
182 | 0 | } |
183 | | |
184 | | /* Frees an attribute |
185 | | * Returns 1 if successful or -1 on error |
186 | | */ |
187 | | int libfsntfs_internal_attribute_free( |
188 | | libfsntfs_internal_attribute_t **internal_attribute, |
189 | | libcerror_error_t **error ) |
190 | 0 | { |
191 | 0 | static char *function = "libfsntfs_internal_attribute_free"; |
192 | 0 | int result = 1; |
193 | |
|
194 | 0 | if( internal_attribute == NULL ) |
195 | 0 | { |
196 | 0 | libcerror_error_set( |
197 | 0 | error, |
198 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
199 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
200 | 0 | "%s: invalid attribute.", |
201 | 0 | function ); |
202 | |
|
203 | 0 | return( -1 ); |
204 | 0 | } |
205 | 0 | if( *internal_attribute != NULL ) |
206 | 0 | { |
207 | | /* The mft_attribute reference is freed elsewhere |
208 | | */ |
209 | 0 | #if defined( HAVE_LIBFSNTFS_MULTI_THREAD_SUPPORT ) |
210 | 0 | if( libcthreads_read_write_lock_free( |
211 | 0 | &( ( *internal_attribute )->read_write_lock ), |
212 | 0 | error ) != 1 ) |
213 | 0 | { |
214 | 0 | libcerror_error_set( |
215 | 0 | error, |
216 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
217 | 0 | LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED, |
218 | 0 | "%s: unable to free read/write lock.", |
219 | 0 | function ); |
220 | |
|
221 | 0 | result = -1; |
222 | 0 | } |
223 | 0 | #endif |
224 | 0 | if( ( *internal_attribute )->path_hint != NULL ) |
225 | 0 | { |
226 | 0 | if( libfsntfs_path_hint_free( |
227 | 0 | &( ( *internal_attribute )->path_hint ), |
228 | 0 | error ) != 1 ) |
229 | 0 | { |
230 | 0 | libcerror_error_set( |
231 | 0 | error, |
232 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
233 | 0 | LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED, |
234 | 0 | "%s: unable to free attribute path hint.", |
235 | 0 | function ); |
236 | |
|
237 | 0 | result = -1; |
238 | 0 | } |
239 | 0 | } |
240 | 0 | if( ( *internal_attribute )->value != NULL ) |
241 | 0 | { |
242 | 0 | if( ( *internal_attribute )->free_value != NULL ) |
243 | 0 | { |
244 | 0 | if( ( *internal_attribute )->free_value( |
245 | 0 | &( ( *internal_attribute )->value ), |
246 | 0 | error ) != 1 ) |
247 | 0 | { |
248 | 0 | libcerror_error_set( |
249 | 0 | error, |
250 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
251 | 0 | LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED, |
252 | 0 | "%s: unable to free attribute value.", |
253 | 0 | function ); |
254 | |
|
255 | 0 | result = -1; |
256 | 0 | } |
257 | 0 | } |
258 | 0 | } |
259 | 0 | memory_free( |
260 | 0 | *internal_attribute ); |
261 | |
|
262 | 0 | *internal_attribute = NULL; |
263 | 0 | } |
264 | 0 | return( result ); |
265 | 0 | } |
266 | | |
267 | | /* Reads the attribute value |
268 | | * Returns 1 if successful or -1 on error |
269 | | */ |
270 | | int libfsntfs_internal_attribute_read_value( |
271 | | libfsntfs_internal_attribute_t *internal_attribute, |
272 | | libfsntfs_io_handle_t *io_handle, |
273 | | libbfio_handle_t *file_io_handle, |
274 | | uint8_t flags, |
275 | | libcerror_error_t **error ) |
276 | 0 | { |
277 | 0 | static char *function = "libfsntfs_internal_attribute_read_value"; |
278 | 0 | uint32_t attribute_type = 0; |
279 | 0 | int result = 0; |
280 | |
|
281 | 0 | if( internal_attribute == NULL ) |
282 | 0 | { |
283 | 0 | libcerror_error_set( |
284 | 0 | error, |
285 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
286 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
287 | 0 | "%s: invalid attribute.", |
288 | 0 | function ); |
289 | |
|
290 | 0 | return( -1 ); |
291 | 0 | } |
292 | 0 | if( internal_attribute->value != NULL ) |
293 | 0 | { |
294 | 0 | libcerror_error_set( |
295 | 0 | error, |
296 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
297 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET, |
298 | 0 | "%s: invalid attribute - value already set.", |
299 | 0 | function ); |
300 | |
|
301 | 0 | return( -1 ); |
302 | 0 | } |
303 | 0 | if( libfsntfs_internal_attribute_get_type( |
304 | 0 | internal_attribute, |
305 | 0 | &attribute_type, |
306 | 0 | error ) != 1 ) |
307 | 0 | { |
308 | 0 | libcerror_error_set( |
309 | 0 | error, |
310 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
311 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
312 | 0 | "%s: unable to retrieve type from attribute.", |
313 | 0 | function ); |
314 | |
|
315 | 0 | goto on_error; |
316 | 0 | } |
317 | 0 | switch( attribute_type ) |
318 | 0 | { |
319 | 0 | case LIBFSNTFS_ATTRIBUTE_TYPE_BITMAP: |
320 | 0 | internal_attribute->free_value = (int (*)(intptr_t **, libcerror_error_t **)) &libfsntfs_bitmap_values_free; |
321 | |
|
322 | 0 | if( libfsntfs_bitmap_values_initialize( |
323 | 0 | (libfsntfs_bitmap_values_t **) &( internal_attribute->value ), |
324 | 0 | error ) != 1 ) |
325 | 0 | { |
326 | 0 | libcerror_error_set( |
327 | 0 | error, |
328 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
329 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
330 | 0 | "%s: unable to create bitmap values.", |
331 | 0 | function ); |
332 | |
|
333 | 0 | goto on_error; |
334 | 0 | } |
335 | 0 | if( libfsntfs_bitmap_values_read_from_mft_attribute( |
336 | 0 | (libfsntfs_bitmap_values_t *) internal_attribute->value, |
337 | 0 | internal_attribute->mft_attribute, |
338 | 0 | io_handle, |
339 | 0 | file_io_handle, |
340 | 0 | io_handle->cluster_block_size, |
341 | 0 | flags, |
342 | 0 | error ) != 1 ) |
343 | 0 | { |
344 | 0 | libcerror_error_set( |
345 | 0 | error, |
346 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
347 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
348 | 0 | "%s: unable to read bitmap values.", |
349 | 0 | function ); |
350 | |
|
351 | 0 | goto on_error; |
352 | 0 | } |
353 | 0 | break; |
354 | | |
355 | 0 | case LIBFSNTFS_ATTRIBUTE_TYPE_FILE_NAME: |
356 | 0 | internal_attribute->free_value = (int (*)(intptr_t **, libcerror_error_t **)) &libfsntfs_file_name_values_free; |
357 | |
|
358 | 0 | if( libfsntfs_file_name_values_initialize( |
359 | 0 | (libfsntfs_file_name_values_t **) &( internal_attribute->value ), |
360 | 0 | error ) != 1 ) |
361 | 0 | { |
362 | 0 | libcerror_error_set( |
363 | 0 | error, |
364 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
365 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
366 | 0 | "%s: unable to create file name values.", |
367 | 0 | function ); |
368 | |
|
369 | 0 | goto on_error; |
370 | 0 | } |
371 | 0 | if( libfsntfs_file_name_values_read_from_mft_attribute( |
372 | 0 | (libfsntfs_file_name_values_t *) internal_attribute->value, |
373 | 0 | internal_attribute->mft_attribute, |
374 | 0 | error ) != 1 ) |
375 | 0 | { |
376 | 0 | libcerror_error_set( |
377 | 0 | error, |
378 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
379 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
380 | 0 | "%s: unable to read file name values.", |
381 | 0 | function ); |
382 | |
|
383 | 0 | goto on_error; |
384 | 0 | } |
385 | 0 | break; |
386 | | |
387 | 0 | case LIBFSNTFS_ATTRIBUTE_TYPE_LOGGED_UTILITY_STREAM: |
388 | 0 | result = libfsntfs_mft_attribute_compare_name_with_utf8_string( |
389 | 0 | internal_attribute->mft_attribute, |
390 | 0 | (uint8_t *) "$TXF_DATA", |
391 | 0 | 9, |
392 | 0 | error ); |
393 | |
|
394 | 0 | if( result == -1 ) |
395 | 0 | { |
396 | 0 | libcerror_error_set( |
397 | 0 | error, |
398 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
399 | 0 | LIBCERROR_RUNTIME_ERROR_GENERIC, |
400 | 0 | "%s: unable to compare UTF-8 string with attribute name.", |
401 | 0 | function ); |
402 | |
|
403 | 0 | goto on_error; |
404 | 0 | } |
405 | 0 | else if( result != 0 ) |
406 | 0 | { |
407 | 0 | internal_attribute->free_value = (int (*)(intptr_t **, libcerror_error_t **)) &libfsntfs_txf_data_values_free; |
408 | |
|
409 | 0 | if( libfsntfs_txf_data_values_initialize( |
410 | 0 | (libfsntfs_txf_data_values_t **) &( internal_attribute->value ), |
411 | 0 | error ) != 1 ) |
412 | 0 | { |
413 | 0 | libcerror_error_set( |
414 | 0 | error, |
415 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
416 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
417 | 0 | "%s: unable to create TxF data values.", |
418 | 0 | function ); |
419 | |
|
420 | 0 | goto on_error; |
421 | 0 | } |
422 | 0 | if( libfsntfs_txf_data_values_read_from_mft_attribute( |
423 | 0 | (libfsntfs_txf_data_values_t *) internal_attribute->value, |
424 | 0 | internal_attribute->mft_attribute, |
425 | 0 | error ) != 1 ) |
426 | 0 | { |
427 | 0 | libcerror_error_set( |
428 | 0 | error, |
429 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
430 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
431 | 0 | "%s: unable to read TxF data values.", |
432 | 0 | function ); |
433 | |
|
434 | 0 | goto on_error; |
435 | 0 | } |
436 | 0 | } |
437 | 0 | else |
438 | 0 | { |
439 | 0 | internal_attribute->free_value = (int (*)(intptr_t **, libcerror_error_t **)) &libfsntfs_logged_utility_stream_values_free; |
440 | |
|
441 | 0 | if( libfsntfs_logged_utility_stream_values_initialize( |
442 | 0 | (libfsntfs_logged_utility_stream_values_t **) &( internal_attribute->value ), |
443 | 0 | error ) != 1 ) |
444 | 0 | { |
445 | 0 | libcerror_error_set( |
446 | 0 | error, |
447 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
448 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
449 | 0 | "%s: unable to create logged utility stream values.", |
450 | 0 | function ); |
451 | |
|
452 | 0 | goto on_error; |
453 | 0 | } |
454 | 0 | if( libfsntfs_logged_utility_stream_values_read_from_mft_attribute( |
455 | 0 | (libfsntfs_logged_utility_stream_values_t *) internal_attribute->value, |
456 | 0 | internal_attribute->mft_attribute, |
457 | 0 | error ) != 1 ) |
458 | 0 | { |
459 | 0 | libcerror_error_set( |
460 | 0 | error, |
461 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
462 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
463 | 0 | "%s: unable to read logged utility stream values.", |
464 | 0 | function ); |
465 | |
|
466 | 0 | goto on_error; |
467 | 0 | } |
468 | 0 | } |
469 | 0 | break; |
470 | | |
471 | 0 | case LIBFSNTFS_ATTRIBUTE_TYPE_OBJECT_IDENTIFIER: |
472 | 0 | internal_attribute->free_value = (int (*)(intptr_t **, libcerror_error_t **)) &libfsntfs_object_identifier_values_free; |
473 | |
|
474 | 0 | if( libfsntfs_object_identifier_values_initialize( |
475 | 0 | (libfsntfs_object_identifier_values_t **) &( internal_attribute->value ), |
476 | 0 | error ) != 1 ) |
477 | 0 | { |
478 | 0 | libcerror_error_set( |
479 | 0 | error, |
480 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
481 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
482 | 0 | "%s: unable to create object identifier values.", |
483 | 0 | function ); |
484 | |
|
485 | 0 | goto on_error; |
486 | 0 | } |
487 | 0 | if( libfsntfs_object_identifier_values_read_from_mft_attribute( |
488 | 0 | (libfsntfs_object_identifier_values_t *) internal_attribute->value, |
489 | 0 | internal_attribute->mft_attribute, |
490 | 0 | error ) != 1 ) |
491 | 0 | { |
492 | 0 | libcerror_error_set( |
493 | 0 | error, |
494 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
495 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
496 | 0 | "%s: unable to read object identifier values.", |
497 | 0 | function ); |
498 | |
|
499 | 0 | goto on_error; |
500 | 0 | } |
501 | 0 | break; |
502 | | |
503 | 0 | case LIBFSNTFS_ATTRIBUTE_TYPE_REPARSE_POINT: |
504 | 0 | internal_attribute->free_value = (int (*)(intptr_t **, libcerror_error_t **)) &libfsntfs_reparse_point_values_free; |
505 | |
|
506 | 0 | if( libfsntfs_reparse_point_values_initialize( |
507 | 0 | (libfsntfs_reparse_point_values_t **) &( internal_attribute->value ), |
508 | 0 | error ) != 1 ) |
509 | 0 | { |
510 | 0 | libcerror_error_set( |
511 | 0 | error, |
512 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
513 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
514 | 0 | "%s: unable to create reparse point values.", |
515 | 0 | function ); |
516 | |
|
517 | 0 | goto on_error; |
518 | 0 | } |
519 | 0 | if( libfsntfs_reparse_point_values_read_from_mft_attribute( |
520 | 0 | (libfsntfs_reparse_point_values_t *) internal_attribute->value, |
521 | 0 | internal_attribute->mft_attribute, |
522 | 0 | error ) != 1 ) |
523 | 0 | { |
524 | 0 | libcerror_error_set( |
525 | 0 | error, |
526 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
527 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
528 | 0 | "%s: unable to read reparse point values.", |
529 | 0 | function ); |
530 | |
|
531 | 0 | goto on_error; |
532 | 0 | } |
533 | 0 | break; |
534 | | |
535 | 0 | case LIBFSNTFS_ATTRIBUTE_TYPE_SECURITY_DESCRIPTOR: |
536 | 0 | internal_attribute->free_value = (int (*)(intptr_t **, libcerror_error_t **)) &libfsntfs_security_descriptor_values_free; |
537 | |
|
538 | 0 | if( libfsntfs_security_descriptor_values_initialize( |
539 | 0 | (libfsntfs_security_descriptor_values_t **) &( internal_attribute->value ), |
540 | 0 | error ) != 1 ) |
541 | 0 | { |
542 | 0 | libcerror_error_set( |
543 | 0 | error, |
544 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
545 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
546 | 0 | "%s: unable to create security descriptor values.", |
547 | 0 | function ); |
548 | |
|
549 | 0 | goto on_error; |
550 | 0 | } |
551 | 0 | if( libfsntfs_security_descriptor_values_read_from_mft_attribute( |
552 | 0 | (libfsntfs_security_descriptor_values_t *) internal_attribute->value, |
553 | 0 | internal_attribute->mft_attribute, |
554 | 0 | io_handle, |
555 | 0 | file_io_handle, |
556 | 0 | flags, |
557 | 0 | error ) != 1 ) |
558 | 0 | { |
559 | 0 | libcerror_error_set( |
560 | 0 | error, |
561 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
562 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
563 | 0 | "%s: unable to read security descriptor values.", |
564 | 0 | function ); |
565 | |
|
566 | 0 | goto on_error; |
567 | 0 | } |
568 | 0 | break; |
569 | | |
570 | 0 | case LIBFSNTFS_ATTRIBUTE_TYPE_STANDARD_INFORMATION: |
571 | 0 | internal_attribute->free_value = (int (*)(intptr_t **, libcerror_error_t **)) &libfsntfs_standard_information_values_free; |
572 | |
|
573 | 0 | if( libfsntfs_standard_information_values_initialize( |
574 | 0 | (libfsntfs_standard_information_values_t **) &( internal_attribute->value ), |
575 | 0 | error ) != 1 ) |
576 | 0 | { |
577 | 0 | libcerror_error_set( |
578 | 0 | error, |
579 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
580 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
581 | 0 | "%s: unable to create standard information values.", |
582 | 0 | function ); |
583 | |
|
584 | 0 | goto on_error; |
585 | 0 | } |
586 | 0 | if( libfsntfs_standard_information_values_read_from_mft_attribute( |
587 | 0 | (libfsntfs_standard_information_values_t *) internal_attribute->value, |
588 | 0 | internal_attribute->mft_attribute, |
589 | 0 | error ) != 1 ) |
590 | 0 | { |
591 | 0 | libcerror_error_set( |
592 | 0 | error, |
593 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
594 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
595 | 0 | "%s: unable to read standard information values.", |
596 | 0 | function ); |
597 | |
|
598 | 0 | goto on_error; |
599 | 0 | } |
600 | 0 | break; |
601 | | |
602 | 0 | case LIBFSNTFS_ATTRIBUTE_TYPE_VOLUME_INFORMATION: |
603 | 0 | internal_attribute->free_value = (int (*)(intptr_t **, libcerror_error_t **)) &libfsntfs_volume_information_values_free; |
604 | |
|
605 | 0 | if( libfsntfs_volume_information_values_initialize( |
606 | 0 | (libfsntfs_volume_information_values_t **) &( internal_attribute->value ), |
607 | 0 | error ) != 1 ) |
608 | 0 | { |
609 | 0 | libcerror_error_set( |
610 | 0 | error, |
611 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
612 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
613 | 0 | "%s: unable to create volume information values.", |
614 | 0 | function ); |
615 | |
|
616 | 0 | goto on_error; |
617 | 0 | } |
618 | 0 | if( libfsntfs_volume_information_values_read_from_mft_attribute( |
619 | 0 | (libfsntfs_volume_information_values_t *) internal_attribute->value, |
620 | 0 | internal_attribute->mft_attribute, |
621 | 0 | error ) != 1 ) |
622 | 0 | { |
623 | 0 | libcerror_error_set( |
624 | 0 | error, |
625 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
626 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
627 | 0 | "%s: unable to read volume information values.", |
628 | 0 | function ); |
629 | |
|
630 | 0 | goto on_error; |
631 | 0 | } |
632 | 0 | break; |
633 | | |
634 | 0 | case LIBFSNTFS_ATTRIBUTE_TYPE_VOLUME_NAME: |
635 | 0 | internal_attribute->free_value = (int (*)(intptr_t **, libcerror_error_t **)) &libfsntfs_volume_name_values_free; |
636 | |
|
637 | 0 | if( libfsntfs_volume_name_values_initialize( |
638 | 0 | (libfsntfs_volume_name_values_t **) &( internal_attribute->value ), |
639 | 0 | error ) != 1 ) |
640 | 0 | { |
641 | 0 | libcerror_error_set( |
642 | 0 | error, |
643 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
644 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
645 | 0 | "%s: unable to create volume name values.", |
646 | 0 | function ); |
647 | |
|
648 | 0 | goto on_error; |
649 | 0 | } |
650 | 0 | if( libfsntfs_volume_name_values_read_from_mft_attribute( |
651 | 0 | (libfsntfs_volume_name_values_t *) internal_attribute->value, |
652 | 0 | internal_attribute->mft_attribute, |
653 | 0 | error ) != 1 ) |
654 | 0 | { |
655 | 0 | libcerror_error_set( |
656 | 0 | error, |
657 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
658 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
659 | 0 | "%s: unable to read volume name values.", |
660 | 0 | function ); |
661 | |
|
662 | 0 | goto on_error; |
663 | 0 | } |
664 | 0 | break; |
665 | | |
666 | 0 | case LIBFSNTFS_ATTRIBUTE_TYPE_INDEX_ALLOCATION: |
667 | 0 | case LIBFSNTFS_ATTRIBUTE_TYPE_INDEX_ROOT: |
668 | 0 | default: |
669 | 0 | break; |
670 | 0 | } |
671 | 0 | return( 1 ); |
672 | | |
673 | 0 | on_error: |
674 | 0 | if( ( internal_attribute->value != NULL ) |
675 | 0 | && ( internal_attribute->free_value != NULL ) ) |
676 | 0 | { |
677 | 0 | internal_attribute->free_value( |
678 | 0 | &( internal_attribute->value ), |
679 | 0 | NULL ); |
680 | 0 | } |
681 | 0 | return( -1 ); |
682 | 0 | } |
683 | | |
684 | | /* Retrieves the type |
685 | | * Returns 1 if successful or -1 on error |
686 | | */ |
687 | | int libfsntfs_internal_attribute_get_type( |
688 | | libfsntfs_internal_attribute_t *internal_attribute, |
689 | | uint32_t *type, |
690 | | libcerror_error_t **error ) |
691 | 0 | { |
692 | 0 | static char *function = "libfsntfs_internal_attribute_get_type"; |
693 | |
|
694 | 0 | if( internal_attribute == NULL ) |
695 | 0 | { |
696 | 0 | libcerror_error_set( |
697 | 0 | error, |
698 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
699 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
700 | 0 | "%s: invalid attribute.", |
701 | 0 | function ); |
702 | |
|
703 | 0 | return( -1 ); |
704 | 0 | } |
705 | 0 | if( libfsntfs_mft_attribute_get_type( |
706 | 0 | internal_attribute->mft_attribute, |
707 | 0 | type, |
708 | 0 | error ) != 1 ) |
709 | 0 | { |
710 | 0 | libcerror_error_set( |
711 | 0 | error, |
712 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
713 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
714 | 0 | "%s: unable to retrieve type from MFT attribute.", |
715 | 0 | function ); |
716 | |
|
717 | 0 | return( -1 ); |
718 | 0 | } |
719 | 0 | return( 1 ); |
720 | 0 | } |
721 | | |
722 | | /* Retrieves the type |
723 | | * Returns 1 if successful or -1 on error |
724 | | */ |
725 | | int libfsntfs_attribute_get_type( |
726 | | libfsntfs_attribute_t *attribute, |
727 | | uint32_t *type, |
728 | | libcerror_error_t **error ) |
729 | 0 | { |
730 | 0 | libfsntfs_internal_attribute_t *internal_attribute = NULL; |
731 | 0 | static char *function = "libfsntfs_attribute_get_type"; |
732 | 0 | int result = 1; |
733 | |
|
734 | 0 | if( attribute == NULL ) |
735 | 0 | { |
736 | 0 | libcerror_error_set( |
737 | 0 | error, |
738 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
739 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
740 | 0 | "%s: invalid attribute.", |
741 | 0 | function ); |
742 | |
|
743 | 0 | return( -1 ); |
744 | 0 | } |
745 | 0 | internal_attribute = (libfsntfs_internal_attribute_t *) attribute; |
746 | |
|
747 | 0 | #if defined( HAVE_LIBFSNTFS_MULTI_THREAD_SUPPORT ) |
748 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
749 | 0 | internal_attribute->read_write_lock, |
750 | 0 | error ) != 1 ) |
751 | 0 | { |
752 | 0 | libcerror_error_set( |
753 | 0 | error, |
754 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
755 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
756 | 0 | "%s: unable to grab read/write lock for reading.", |
757 | 0 | function ); |
758 | |
|
759 | 0 | return( -1 ); |
760 | 0 | } |
761 | 0 | #endif |
762 | 0 | if( libfsntfs_internal_attribute_get_type( |
763 | 0 | internal_attribute, |
764 | 0 | type, |
765 | 0 | error ) != 1 ) |
766 | 0 | { |
767 | 0 | libcerror_error_set( |
768 | 0 | error, |
769 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
770 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
771 | 0 | "%s: unable to retrieve type.", |
772 | 0 | function ); |
773 | |
|
774 | 0 | result = -1; |
775 | 0 | } |
776 | 0 | #if defined( HAVE_LIBFSNTFS_MULTI_THREAD_SUPPORT ) |
777 | 0 | if( libcthreads_read_write_lock_release_for_read( |
778 | 0 | internal_attribute->read_write_lock, |
779 | 0 | error ) != 1 ) |
780 | 0 | { |
781 | 0 | libcerror_error_set( |
782 | 0 | error, |
783 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
784 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
785 | 0 | "%s: unable to release read/write lock for reading.", |
786 | 0 | function ); |
787 | |
|
788 | 0 | return( -1 ); |
789 | 0 | } |
790 | 0 | #endif |
791 | 0 | return( result ); |
792 | 0 | } |
793 | | |
794 | | /* Retrieves the data flags |
795 | | * Returns 1 if successful or -1 on error |
796 | | */ |
797 | | int libfsntfs_attribute_get_data_flags( |
798 | | libfsntfs_attribute_t *attribute, |
799 | | uint16_t *data_flags, |
800 | | libcerror_error_t **error ) |
801 | 0 | { |
802 | 0 | libfsntfs_internal_attribute_t *internal_attribute = NULL; |
803 | 0 | static char *function = "libfsntfs_attribute_get_data_flags"; |
804 | 0 | uint16_t safe_data_flags = 0; |
805 | 0 | int result = 1; |
806 | |
|
807 | 0 | if( attribute == NULL ) |
808 | 0 | { |
809 | 0 | libcerror_error_set( |
810 | 0 | error, |
811 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
812 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
813 | 0 | "%s: invalid attribute.", |
814 | 0 | function ); |
815 | |
|
816 | 0 | return( -1 ); |
817 | 0 | } |
818 | 0 | internal_attribute = (libfsntfs_internal_attribute_t *) attribute; |
819 | |
|
820 | 0 | if( data_flags == NULL ) |
821 | 0 | { |
822 | 0 | libcerror_error_set( |
823 | 0 | error, |
824 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
825 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
826 | 0 | "%s: invalid data flags.", |
827 | 0 | function ); |
828 | |
|
829 | 0 | return( -1 ); |
830 | 0 | } |
831 | 0 | #if defined( HAVE_LIBFSNTFS_MULTI_THREAD_SUPPORT ) |
832 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
833 | 0 | internal_attribute->read_write_lock, |
834 | 0 | error ) != 1 ) |
835 | 0 | { |
836 | 0 | libcerror_error_set( |
837 | 0 | error, |
838 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
839 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
840 | 0 | "%s: unable to grab read/write lock for reading.", |
841 | 0 | function ); |
842 | |
|
843 | 0 | return( -1 ); |
844 | 0 | } |
845 | 0 | #endif |
846 | 0 | if( internal_attribute->mft_attribute != NULL ) |
847 | 0 | { |
848 | 0 | if( libfsntfs_mft_attribute_get_data_flags( |
849 | 0 | internal_attribute->mft_attribute, |
850 | 0 | &safe_data_flags, |
851 | 0 | error ) != 1 ) |
852 | 0 | { |
853 | 0 | libcerror_error_set( |
854 | 0 | error, |
855 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
856 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
857 | 0 | "%s: unable to retrieve data flags from MFT attribute.", |
858 | 0 | function ); |
859 | |
|
860 | 0 | result = -1; |
861 | 0 | } |
862 | 0 | } |
863 | 0 | #if defined( HAVE_LIBFSNTFS_MULTI_THREAD_SUPPORT ) |
864 | 0 | if( libcthreads_read_write_lock_release_for_read( |
865 | 0 | internal_attribute->read_write_lock, |
866 | 0 | error ) != 1 ) |
867 | 0 | { |
868 | 0 | libcerror_error_set( |
869 | 0 | error, |
870 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
871 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
872 | 0 | "%s: unable to release read/write lock for reading.", |
873 | 0 | function ); |
874 | |
|
875 | 0 | return( -1 ); |
876 | 0 | } |
877 | 0 | #endif |
878 | 0 | if( result == 1 ) |
879 | 0 | { |
880 | 0 | *data_flags = safe_data_flags; |
881 | 0 | } |
882 | 0 | return( result ); |
883 | 0 | } |
884 | | |
885 | | /* Retrieves the value |
886 | | * Returns 1 if successful or -1 on error |
887 | | */ |
888 | | int libfsntfs_internal_attribute_get_value( |
889 | | libfsntfs_internal_attribute_t *internal_attribute, |
890 | | intptr_t **value, |
891 | | libcerror_error_t **error ) |
892 | 0 | { |
893 | 0 | static char *function = "libfsntfs_internal_attribute_get_value"; |
894 | |
|
895 | 0 | if( internal_attribute == NULL ) |
896 | 0 | { |
897 | 0 | libcerror_error_set( |
898 | 0 | error, |
899 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
900 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
901 | 0 | "%s: invalid attribute.", |
902 | 0 | function ); |
903 | |
|
904 | 0 | return( -1 ); |
905 | 0 | } |
906 | 0 | if( value == NULL ) |
907 | 0 | { |
908 | 0 | libcerror_error_set( |
909 | 0 | error, |
910 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
911 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
912 | 0 | "%s: invalid value.", |
913 | 0 | function ); |
914 | |
|
915 | 0 | return( -1 ); |
916 | 0 | } |
917 | 0 | *value = internal_attribute->value; |
918 | |
|
919 | 0 | return( 1 ); |
920 | 0 | } |
921 | | |
922 | | /* Retrieves the size of the UTF-8 encoded name |
923 | | * The returned size includes the end of string character |
924 | | * Returns 1 if successful or -1 on error |
925 | | */ |
926 | | int libfsntfs_attribute_get_utf8_name_size( |
927 | | libfsntfs_attribute_t *attribute, |
928 | | size_t *utf8_string_size, |
929 | | libcerror_error_t **error ) |
930 | 0 | { |
931 | 0 | libfsntfs_internal_attribute_t *internal_attribute = NULL; |
932 | 0 | static char *function = "libfsntfs_attribute_get_utf8_name_size"; |
933 | 0 | int result = 1; |
934 | |
|
935 | 0 | if( attribute == NULL ) |
936 | 0 | { |
937 | 0 | libcerror_error_set( |
938 | 0 | error, |
939 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
940 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
941 | 0 | "%s: invalid attribute.", |
942 | 0 | function ); |
943 | |
|
944 | 0 | return( -1 ); |
945 | 0 | } |
946 | 0 | internal_attribute = (libfsntfs_internal_attribute_t *) attribute; |
947 | |
|
948 | 0 | #if defined( HAVE_LIBFSNTFS_MULTI_THREAD_SUPPORT ) |
949 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
950 | 0 | internal_attribute->read_write_lock, |
951 | 0 | error ) != 1 ) |
952 | 0 | { |
953 | 0 | libcerror_error_set( |
954 | 0 | error, |
955 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
956 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
957 | 0 | "%s: unable to grab read/write lock for reading.", |
958 | 0 | function ); |
959 | |
|
960 | 0 | return( -1 ); |
961 | 0 | } |
962 | 0 | #endif |
963 | 0 | if( libfsntfs_mft_attribute_get_utf8_name_size( |
964 | 0 | internal_attribute->mft_attribute, |
965 | 0 | utf8_string_size, |
966 | 0 | error ) != 1 ) |
967 | 0 | { |
968 | 0 | libcerror_error_set( |
969 | 0 | error, |
970 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
971 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
972 | 0 | "%s: unable to retrieve UTF-8 name size from MFT attribute.", |
973 | 0 | function ); |
974 | |
|
975 | 0 | result = -1; |
976 | 0 | } |
977 | 0 | #if defined( HAVE_LIBFSNTFS_MULTI_THREAD_SUPPORT ) |
978 | 0 | if( libcthreads_read_write_lock_release_for_read( |
979 | 0 | internal_attribute->read_write_lock, |
980 | 0 | error ) != 1 ) |
981 | 0 | { |
982 | 0 | libcerror_error_set( |
983 | 0 | error, |
984 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
985 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
986 | 0 | "%s: unable to release read/write lock for reading.", |
987 | 0 | function ); |
988 | |
|
989 | 0 | return( -1 ); |
990 | 0 | } |
991 | 0 | #endif |
992 | 0 | return( result ); |
993 | 0 | } |
994 | | |
995 | | /* Retrieves the UTF-8 encoded name |
996 | | * The size should include the end of string character |
997 | | * Returns 1 if successful or -1 on error |
998 | | */ |
999 | | int libfsntfs_attribute_get_utf8_name( |
1000 | | libfsntfs_attribute_t *attribute, |
1001 | | uint8_t *utf8_string, |
1002 | | size_t utf8_string_size, |
1003 | | libcerror_error_t **error ) |
1004 | 0 | { |
1005 | 0 | libfsntfs_internal_attribute_t *internal_attribute = NULL; |
1006 | 0 | static char *function = "libfsntfs_attribute_get_utf8_name"; |
1007 | 0 | int result = 1; |
1008 | |
|
1009 | 0 | if( attribute == NULL ) |
1010 | 0 | { |
1011 | 0 | libcerror_error_set( |
1012 | 0 | error, |
1013 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1014 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1015 | 0 | "%s: invalid attribute.", |
1016 | 0 | function ); |
1017 | |
|
1018 | 0 | return( -1 ); |
1019 | 0 | } |
1020 | 0 | internal_attribute = (libfsntfs_internal_attribute_t *) attribute; |
1021 | |
|
1022 | 0 | #if defined( HAVE_LIBFSNTFS_MULTI_THREAD_SUPPORT ) |
1023 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
1024 | 0 | internal_attribute->read_write_lock, |
1025 | 0 | error ) != 1 ) |
1026 | 0 | { |
1027 | 0 | libcerror_error_set( |
1028 | 0 | error, |
1029 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1030 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1031 | 0 | "%s: unable to grab read/write lock for reading.", |
1032 | 0 | function ); |
1033 | |
|
1034 | 0 | return( -1 ); |
1035 | 0 | } |
1036 | 0 | #endif |
1037 | 0 | if( libfsntfs_mft_attribute_get_utf8_name( |
1038 | 0 | internal_attribute->mft_attribute, |
1039 | 0 | utf8_string, |
1040 | 0 | utf8_string_size, |
1041 | 0 | error ) != 1 ) |
1042 | 0 | { |
1043 | 0 | libcerror_error_set( |
1044 | 0 | error, |
1045 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1046 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
1047 | 0 | "%s: unable to retrieve UTF-8 name from MFT attribute.", |
1048 | 0 | function ); |
1049 | |
|
1050 | 0 | result = -1; |
1051 | 0 | } |
1052 | 0 | #if defined( HAVE_LIBFSNTFS_MULTI_THREAD_SUPPORT ) |
1053 | 0 | if( libcthreads_read_write_lock_release_for_read( |
1054 | 0 | internal_attribute->read_write_lock, |
1055 | 0 | error ) != 1 ) |
1056 | 0 | { |
1057 | 0 | libcerror_error_set( |
1058 | 0 | error, |
1059 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1060 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1061 | 0 | "%s: unable to release read/write lock for reading.", |
1062 | 0 | function ); |
1063 | |
|
1064 | 0 | return( -1 ); |
1065 | 0 | } |
1066 | 0 | #endif |
1067 | 0 | return( result ); |
1068 | 0 | } |
1069 | | |
1070 | | /* Retrieves the size of the UTF-16 encoded name |
1071 | | * The returned size includes the end of string character |
1072 | | * Returns 1 if successful or -1 on error |
1073 | | */ |
1074 | | int libfsntfs_attribute_get_utf16_name_size( |
1075 | | libfsntfs_attribute_t *attribute, |
1076 | | size_t *utf16_string_size, |
1077 | | libcerror_error_t **error ) |
1078 | 0 | { |
1079 | 0 | libfsntfs_internal_attribute_t *internal_attribute = NULL; |
1080 | 0 | static char *function = "libfsntfs_attribute_get_utf16_name_size"; |
1081 | 0 | int result = 1; |
1082 | |
|
1083 | 0 | if( attribute == NULL ) |
1084 | 0 | { |
1085 | 0 | libcerror_error_set( |
1086 | 0 | error, |
1087 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1088 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1089 | 0 | "%s: invalid attribute.", |
1090 | 0 | function ); |
1091 | |
|
1092 | 0 | return( -1 ); |
1093 | 0 | } |
1094 | 0 | internal_attribute = (libfsntfs_internal_attribute_t *) attribute; |
1095 | |
|
1096 | 0 | #if defined( HAVE_LIBFSNTFS_MULTI_THREAD_SUPPORT ) |
1097 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
1098 | 0 | internal_attribute->read_write_lock, |
1099 | 0 | error ) != 1 ) |
1100 | 0 | { |
1101 | 0 | libcerror_error_set( |
1102 | 0 | error, |
1103 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1104 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1105 | 0 | "%s: unable to grab read/write lock for reading.", |
1106 | 0 | function ); |
1107 | |
|
1108 | 0 | return( -1 ); |
1109 | 0 | } |
1110 | 0 | #endif |
1111 | 0 | if( libfsntfs_mft_attribute_get_utf16_name_size( |
1112 | 0 | internal_attribute->mft_attribute, |
1113 | 0 | utf16_string_size, |
1114 | 0 | error ) != 1 ) |
1115 | 0 | { |
1116 | 0 | libcerror_error_set( |
1117 | 0 | error, |
1118 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1119 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
1120 | 0 | "%s: unable to retrieve UTF-16 name size from MFT attribute.", |
1121 | 0 | function ); |
1122 | |
|
1123 | 0 | result = -1; |
1124 | 0 | } |
1125 | 0 | #if defined( HAVE_LIBFSNTFS_MULTI_THREAD_SUPPORT ) |
1126 | 0 | if( libcthreads_read_write_lock_release_for_read( |
1127 | 0 | internal_attribute->read_write_lock, |
1128 | 0 | error ) != 1 ) |
1129 | 0 | { |
1130 | 0 | libcerror_error_set( |
1131 | 0 | error, |
1132 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1133 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1134 | 0 | "%s: unable to release read/write lock for reading.", |
1135 | 0 | function ); |
1136 | |
|
1137 | 0 | return( -1 ); |
1138 | 0 | } |
1139 | 0 | #endif |
1140 | 0 | return( result ); |
1141 | 0 | } |
1142 | | |
1143 | | /* Retrieves the UTF-16 encoded name |
1144 | | * The size should include the end of string character |
1145 | | * Returns 1 if successful or -1 on error |
1146 | | */ |
1147 | | int libfsntfs_attribute_get_utf16_name( |
1148 | | libfsntfs_attribute_t *attribute, |
1149 | | uint16_t *utf16_string, |
1150 | | size_t utf16_string_size, |
1151 | | libcerror_error_t **error ) |
1152 | 0 | { |
1153 | 0 | libfsntfs_internal_attribute_t *internal_attribute = NULL; |
1154 | 0 | static char *function = "libfsntfs_attribute_get_utf16_name"; |
1155 | 0 | int result = 1; |
1156 | |
|
1157 | 0 | if( attribute == NULL ) |
1158 | 0 | { |
1159 | 0 | libcerror_error_set( |
1160 | 0 | error, |
1161 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1162 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1163 | 0 | "%s: invalid attribute.", |
1164 | 0 | function ); |
1165 | |
|
1166 | 0 | return( -1 ); |
1167 | 0 | } |
1168 | 0 | internal_attribute = (libfsntfs_internal_attribute_t *) attribute; |
1169 | |
|
1170 | 0 | #if defined( HAVE_LIBFSNTFS_MULTI_THREAD_SUPPORT ) |
1171 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
1172 | 0 | internal_attribute->read_write_lock, |
1173 | 0 | error ) != 1 ) |
1174 | 0 | { |
1175 | 0 | libcerror_error_set( |
1176 | 0 | error, |
1177 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1178 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1179 | 0 | "%s: unable to grab read/write lock for reading.", |
1180 | 0 | function ); |
1181 | |
|
1182 | 0 | return( -1 ); |
1183 | 0 | } |
1184 | 0 | #endif |
1185 | 0 | if( libfsntfs_mft_attribute_get_utf16_name( |
1186 | 0 | internal_attribute->mft_attribute, |
1187 | 0 | utf16_string, |
1188 | 0 | utf16_string_size, |
1189 | 0 | error ) != 1 ) |
1190 | 0 | { |
1191 | 0 | libcerror_error_set( |
1192 | 0 | error, |
1193 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1194 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
1195 | 0 | "%s: unable to retrieve UTF-16 name from MFT attribute.", |
1196 | 0 | function ); |
1197 | |
|
1198 | 0 | result = -1; |
1199 | 0 | } |
1200 | 0 | #if defined( HAVE_LIBFSNTFS_MULTI_THREAD_SUPPORT ) |
1201 | 0 | if( libcthreads_read_write_lock_release_for_read( |
1202 | 0 | internal_attribute->read_write_lock, |
1203 | 0 | error ) != 1 ) |
1204 | 0 | { |
1205 | 0 | libcerror_error_set( |
1206 | 0 | error, |
1207 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1208 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1209 | 0 | "%s: unable to release read/write lock for reading.", |
1210 | 0 | function ); |
1211 | |
|
1212 | 0 | return( -1 ); |
1213 | 0 | } |
1214 | 0 | #endif |
1215 | 0 | return( result ); |
1216 | 0 | } |
1217 | | |
1218 | | /* Retrieves the data VCN range |
1219 | | * Returns 1 if successful, 0 if not available or -1 on error |
1220 | | */ |
1221 | | int libfsntfs_attribute_get_data_vcn_range( |
1222 | | libfsntfs_attribute_t *attribute, |
1223 | | uint64_t *data_first_vcn, |
1224 | | uint64_t *data_last_vcn, |
1225 | | libcerror_error_t **error ) |
1226 | 0 | { |
1227 | 0 | libfsntfs_internal_attribute_t *internal_attribute = NULL; |
1228 | 0 | static char *function = "libfsntfs_attribute_get_data_vcn_range"; |
1229 | 0 | int result = 0; |
1230 | |
|
1231 | 0 | if( attribute == NULL ) |
1232 | 0 | { |
1233 | 0 | libcerror_error_set( |
1234 | 0 | error, |
1235 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1236 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1237 | 0 | "%s: invalid attribute.", |
1238 | 0 | function ); |
1239 | |
|
1240 | 0 | return( -1 ); |
1241 | 0 | } |
1242 | 0 | internal_attribute = (libfsntfs_internal_attribute_t *) attribute; |
1243 | |
|
1244 | 0 | if( data_first_vcn == NULL ) |
1245 | 0 | { |
1246 | 0 | libcerror_error_set( |
1247 | 0 | error, |
1248 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1249 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1250 | 0 | "%s: invalid data first VCN.", |
1251 | 0 | function ); |
1252 | |
|
1253 | 0 | return( -1 ); |
1254 | 0 | } |
1255 | 0 | if( data_last_vcn == NULL ) |
1256 | 0 | { |
1257 | 0 | libcerror_error_set( |
1258 | 0 | error, |
1259 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1260 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1261 | 0 | "%s: invalid data last VCN.", |
1262 | 0 | function ); |
1263 | |
|
1264 | 0 | return( -1 ); |
1265 | 0 | } |
1266 | 0 | #if defined( HAVE_LIBFSNTFS_MULTI_THREAD_SUPPORT ) |
1267 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
1268 | 0 | internal_attribute->read_write_lock, |
1269 | 0 | error ) != 1 ) |
1270 | 0 | { |
1271 | 0 | libcerror_error_set( |
1272 | 0 | error, |
1273 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1274 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1275 | 0 | "%s: unable to grab read/write lock for reading.", |
1276 | 0 | function ); |
1277 | |
|
1278 | 0 | return( -1 ); |
1279 | 0 | } |
1280 | 0 | #endif |
1281 | 0 | if( internal_attribute->mft_attribute != NULL ) |
1282 | 0 | { |
1283 | 0 | result = libfsntfs_mft_attribute_get_data_vcn_range( |
1284 | 0 | internal_attribute->mft_attribute, |
1285 | 0 | data_first_vcn, |
1286 | 0 | data_last_vcn, |
1287 | 0 | error ); |
1288 | |
|
1289 | 0 | if( result == -1 ) |
1290 | 0 | { |
1291 | 0 | libcerror_error_set( |
1292 | 0 | error, |
1293 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1294 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
1295 | 0 | "%s: unable to retrieve data VCN range from MFT attribute.", |
1296 | 0 | function ); |
1297 | |
|
1298 | 0 | result = -1; |
1299 | 0 | } |
1300 | 0 | } |
1301 | | /* TODO add support for attribute list entry ? */ |
1302 | |
|
1303 | 0 | #if defined( HAVE_LIBFSNTFS_MULTI_THREAD_SUPPORT ) |
1304 | 0 | if( libcthreads_read_write_lock_release_for_read( |
1305 | 0 | internal_attribute->read_write_lock, |
1306 | 0 | error ) != 1 ) |
1307 | 0 | { |
1308 | 0 | libcerror_error_set( |
1309 | 0 | error, |
1310 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1311 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1312 | 0 | "%s: unable to release read/write lock for reading.", |
1313 | 0 | function ); |
1314 | |
|
1315 | 0 | return( -1 ); |
1316 | 0 | } |
1317 | 0 | #endif |
1318 | 0 | return( result ); |
1319 | 0 | } |
1320 | | |
1321 | | /* Retrieves the data size |
1322 | | * Returns 1 if successful or -1 on error |
1323 | | */ |
1324 | | int libfsntfs_internal_attribute_get_data_size( |
1325 | | libfsntfs_internal_attribute_t *internal_attribute, |
1326 | | size64_t *data_size, |
1327 | | libcerror_error_t **error ) |
1328 | 0 | { |
1329 | 0 | static char *function = "libfsntfs_internal_attribute_get_data_size"; |
1330 | |
|
1331 | 0 | if( internal_attribute == NULL ) |
1332 | 0 | { |
1333 | 0 | libcerror_error_set( |
1334 | 0 | error, |
1335 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1336 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1337 | 0 | "%s: invalid attribute.", |
1338 | 0 | function ); |
1339 | |
|
1340 | 0 | return( -1 ); |
1341 | 0 | } |
1342 | 0 | if( internal_attribute->mft_attribute != NULL ) |
1343 | 0 | { |
1344 | 0 | if( libfsntfs_mft_attribute_get_data_size( |
1345 | 0 | internal_attribute->mft_attribute, |
1346 | 0 | (uint64_t *) data_size, |
1347 | 0 | error ) != 1 ) |
1348 | 0 | { |
1349 | 0 | libcerror_error_set( |
1350 | 0 | error, |
1351 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1352 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
1353 | 0 | "%s: unable to retrieve data size.", |
1354 | 0 | function ); |
1355 | |
|
1356 | 0 | return( -1 ); |
1357 | 0 | } |
1358 | 0 | } |
1359 | 0 | else |
1360 | 0 | { |
1361 | 0 | if( data_size == NULL ) |
1362 | 0 | { |
1363 | 0 | libcerror_error_set( |
1364 | 0 | error, |
1365 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1366 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1367 | 0 | "%s: invalid data size.", |
1368 | 0 | function ); |
1369 | |
|
1370 | 0 | return( -1 ); |
1371 | 0 | } |
1372 | 0 | *data_size = 0; |
1373 | 0 | } |
1374 | 0 | return( 1 ); |
1375 | 0 | } |
1376 | | |
1377 | | /* Retrieves the data size |
1378 | | * Returns 1 if successful or -1 on error |
1379 | | */ |
1380 | | int libfsntfs_attribute_get_data_size( |
1381 | | libfsntfs_attribute_t *attribute, |
1382 | | size64_t *data_size, |
1383 | | libcerror_error_t **error ) |
1384 | 0 | { |
1385 | 0 | libfsntfs_internal_attribute_t *internal_attribute = NULL; |
1386 | 0 | static char *function = "libfsntfs_attribute_get_data_size"; |
1387 | 0 | int result = 1; |
1388 | |
|
1389 | 0 | if( attribute == NULL ) |
1390 | 0 | { |
1391 | 0 | libcerror_error_set( |
1392 | 0 | error, |
1393 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1394 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1395 | 0 | "%s: invalid attribute.", |
1396 | 0 | function ); |
1397 | |
|
1398 | 0 | return( -1 ); |
1399 | 0 | } |
1400 | 0 | internal_attribute = (libfsntfs_internal_attribute_t *) attribute; |
1401 | |
|
1402 | 0 | #if defined( HAVE_LIBFSNTFS_MULTI_THREAD_SUPPORT ) |
1403 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
1404 | 0 | internal_attribute->read_write_lock, |
1405 | 0 | error ) != 1 ) |
1406 | 0 | { |
1407 | 0 | libcerror_error_set( |
1408 | 0 | error, |
1409 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1410 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1411 | 0 | "%s: unable to grab read/write lock for reading.", |
1412 | 0 | function ); |
1413 | |
|
1414 | 0 | return( -1 ); |
1415 | 0 | } |
1416 | 0 | #endif |
1417 | 0 | if( libfsntfs_internal_attribute_get_data_size( |
1418 | 0 | internal_attribute, |
1419 | 0 | data_size, |
1420 | 0 | error ) != 1 ) |
1421 | 0 | { |
1422 | 0 | libcerror_error_set( |
1423 | 0 | error, |
1424 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1425 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
1426 | 0 | "%s: unable to retrieve data size.", |
1427 | 0 | function ); |
1428 | |
|
1429 | 0 | result = -1; |
1430 | 0 | } |
1431 | 0 | #if defined( HAVE_LIBFSNTFS_MULTI_THREAD_SUPPORT ) |
1432 | 0 | if( libcthreads_read_write_lock_release_for_read( |
1433 | 0 | internal_attribute->read_write_lock, |
1434 | 0 | error ) != 1 ) |
1435 | 0 | { |
1436 | 0 | libcerror_error_set( |
1437 | 0 | error, |
1438 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1439 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1440 | 0 | "%s: unable to release read/write lock for reading.", |
1441 | 0 | function ); |
1442 | |
|
1443 | 0 | return( -1 ); |
1444 | 0 | } |
1445 | 0 | #endif |
1446 | 0 | return( result ); |
1447 | 0 | } |
1448 | | |
1449 | | /* Retrieves the valid data size |
1450 | | * Returns 1 if successful or -1 on error |
1451 | | */ |
1452 | | int libfsntfs_attribute_get_valid_data_size( |
1453 | | libfsntfs_attribute_t *attribute, |
1454 | | size64_t *valid_data_size, |
1455 | | libcerror_error_t **error ) |
1456 | 0 | { |
1457 | 0 | libfsntfs_internal_attribute_t *internal_attribute = NULL; |
1458 | 0 | static char *function = "libfsntfs_attribute_get_valid_data_size"; |
1459 | 0 | uint64_t safe_valid_data_size = 0; |
1460 | 0 | int result = 1; |
1461 | |
|
1462 | 0 | if( attribute == NULL ) |
1463 | 0 | { |
1464 | 0 | libcerror_error_set( |
1465 | 0 | error, |
1466 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1467 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1468 | 0 | "%s: invalid attribute.", |
1469 | 0 | function ); |
1470 | |
|
1471 | 0 | return( -1 ); |
1472 | 0 | } |
1473 | 0 | internal_attribute = (libfsntfs_internal_attribute_t *) attribute; |
1474 | |
|
1475 | 0 | if( valid_data_size == NULL ) |
1476 | 0 | { |
1477 | 0 | libcerror_error_set( |
1478 | 0 | error, |
1479 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1480 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1481 | 0 | "%s: invalid valid data size.", |
1482 | 0 | function ); |
1483 | |
|
1484 | 0 | return( -1 ); |
1485 | 0 | } |
1486 | 0 | #if defined( HAVE_LIBFSNTFS_MULTI_THREAD_SUPPORT ) |
1487 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
1488 | 0 | internal_attribute->read_write_lock, |
1489 | 0 | error ) != 1 ) |
1490 | 0 | { |
1491 | 0 | libcerror_error_set( |
1492 | 0 | error, |
1493 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1494 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1495 | 0 | "%s: unable to grab read/write lock for reading.", |
1496 | 0 | function ); |
1497 | |
|
1498 | 0 | return( -1 ); |
1499 | 0 | } |
1500 | 0 | #endif |
1501 | 0 | if( internal_attribute->mft_attribute != NULL ) |
1502 | 0 | { |
1503 | 0 | if( libfsntfs_mft_attribute_get_valid_data_size( |
1504 | 0 | internal_attribute->mft_attribute, |
1505 | 0 | &safe_valid_data_size, |
1506 | 0 | error ) != 1 ) |
1507 | 0 | { |
1508 | 0 | libcerror_error_set( |
1509 | 0 | error, |
1510 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1511 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
1512 | 0 | "%s: unable to retrieve valid data size.", |
1513 | 0 | function ); |
1514 | |
|
1515 | 0 | result = -1; |
1516 | 0 | } |
1517 | 0 | } |
1518 | 0 | #if defined( HAVE_LIBFSNTFS_MULTI_THREAD_SUPPORT ) |
1519 | 0 | if( libcthreads_read_write_lock_release_for_read( |
1520 | 0 | internal_attribute->read_write_lock, |
1521 | 0 | error ) != 1 ) |
1522 | 0 | { |
1523 | 0 | libcerror_error_set( |
1524 | 0 | error, |
1525 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1526 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1527 | 0 | "%s: unable to release read/write lock for reading.", |
1528 | 0 | function ); |
1529 | |
|
1530 | 0 | return( -1 ); |
1531 | 0 | } |
1532 | 0 | #endif |
1533 | 0 | if( result == 1 ) |
1534 | 0 | { |
1535 | 0 | *valid_data_size = safe_valid_data_size; |
1536 | 0 | } |
1537 | 0 | return( result ); |
1538 | 0 | } |
1539 | | |