/src/libewf/libewf/libewf_file_entry.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * File entry functions |
3 | | * |
4 | | * Copyright (C) 2006-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 "libewf_access_control_entry.h" |
27 | | #include "libewf_attribute.h" |
28 | | #include "libewf_definitions.h" |
29 | | #include "libewf_file_entry.h" |
30 | | #include "libewf_handle.h" |
31 | | #include "libewf_lef_file_entry.h" |
32 | | #include "libewf_lef_source.h" |
33 | | #include "libewf_libcdata.h" |
34 | | #include "libewf_libcerror.h" |
35 | | #include "libewf_libcnotify.h" |
36 | | #include "libewf_libcthreads.h" |
37 | | #include "libewf_permission_group.h" |
38 | | #include "libewf_single_file_tree.h" |
39 | | #include "libewf_source.h" |
40 | | #include "libewf_types.h" |
41 | | |
42 | | /* Creates a file entry |
43 | | * Make sure the value file_entry is referencing, is set to NULL |
44 | | * Returns 1 if successful or -1 on error |
45 | | */ |
46 | | int libewf_file_entry_initialize( |
47 | | libewf_file_entry_t **file_entry, |
48 | | libewf_handle_t *handle, |
49 | | libewf_single_files_t *single_files, |
50 | | libcdata_tree_node_t *file_entry_tree_node, |
51 | | libcerror_error_t **error ) |
52 | 0 | { |
53 | 0 | libewf_internal_file_entry_t *internal_file_entry = NULL; |
54 | 0 | static char *function = "libewf_file_entry_initialize"; |
55 | 0 | int permission_group_index = 0; |
56 | 0 | int source_identifier = 0; |
57 | |
|
58 | 0 | if( file_entry == NULL ) |
59 | 0 | { |
60 | 0 | libcerror_error_set( |
61 | 0 | error, |
62 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
63 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
64 | 0 | "%s: invalid file entry.", |
65 | 0 | function ); |
66 | |
|
67 | 0 | return( -1 ); |
68 | 0 | } |
69 | 0 | if( *file_entry != NULL ) |
70 | 0 | { |
71 | 0 | libcerror_error_set( |
72 | 0 | error, |
73 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
74 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET, |
75 | 0 | "%s: invalid file entry value already set.", |
76 | 0 | function ); |
77 | |
|
78 | 0 | return( -1 ); |
79 | 0 | } |
80 | 0 | if( file_entry_tree_node == NULL ) |
81 | 0 | { |
82 | 0 | libcerror_error_set( |
83 | 0 | error, |
84 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
85 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
86 | 0 | "%s: invalid file entry tree node.", |
87 | 0 | function ); |
88 | |
|
89 | 0 | return( -1 ); |
90 | 0 | } |
91 | 0 | internal_file_entry = memory_allocate_structure( |
92 | 0 | libewf_internal_file_entry_t ); |
93 | |
|
94 | 0 | if( internal_file_entry == NULL ) |
95 | 0 | { |
96 | 0 | libcerror_error_set( |
97 | 0 | error, |
98 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
99 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
100 | 0 | "%s: unable to create file entry.", |
101 | 0 | function ); |
102 | |
|
103 | 0 | goto on_error; |
104 | 0 | } |
105 | 0 | if( memory_set( |
106 | 0 | internal_file_entry, |
107 | 0 | 0, |
108 | 0 | sizeof( libewf_internal_file_entry_t ) ) == NULL ) |
109 | 0 | { |
110 | 0 | libcerror_error_set( |
111 | 0 | error, |
112 | 0 | LIBCERROR_ERROR_DOMAIN_MEMORY, |
113 | 0 | LIBCERROR_MEMORY_ERROR_SET_FAILED, |
114 | 0 | "%s: unable to clear file entry.", |
115 | 0 | function ); |
116 | |
|
117 | 0 | memory_free( |
118 | 0 | internal_file_entry ); |
119 | |
|
120 | 0 | return( -1 ); |
121 | 0 | } |
122 | 0 | if( libcdata_tree_node_get_value( |
123 | 0 | file_entry_tree_node, |
124 | 0 | (intptr_t **) &( internal_file_entry->lef_file_entry ), |
125 | 0 | error ) != 1 ) |
126 | 0 | { |
127 | 0 | libcerror_error_set( |
128 | 0 | error, |
129 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
130 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
131 | 0 | "%s: unable to retrieve value from file entry tree node.", |
132 | 0 | function ); |
133 | |
|
134 | 0 | goto on_error; |
135 | 0 | } |
136 | 0 | if( libewf_lef_file_entry_get_permission_group_index( |
137 | 0 | internal_file_entry->lef_file_entry, |
138 | 0 | &permission_group_index, |
139 | 0 | error ) != 1 ) |
140 | 0 | { |
141 | 0 | libcerror_error_set( |
142 | 0 | error, |
143 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
144 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
145 | 0 | "%s: unable to retrieve permission group index.", |
146 | 0 | function ); |
147 | |
|
148 | 0 | goto on_error; |
149 | 0 | } |
150 | 0 | if( permission_group_index >= 0 ) |
151 | 0 | { |
152 | 0 | if( libewf_single_files_get_permission_group_by_index( |
153 | 0 | single_files, |
154 | 0 | permission_group_index, |
155 | 0 | &( internal_file_entry->permission_group ), |
156 | 0 | error ) != 1 ) |
157 | 0 | { |
158 | 0 | libcerror_error_set( |
159 | 0 | error, |
160 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
161 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
162 | 0 | "%s: unable to retrieve permission group: %d.", |
163 | 0 | function, |
164 | 0 | permission_group_index ); |
165 | |
|
166 | 0 | goto on_error; |
167 | 0 | } |
168 | 0 | } |
169 | 0 | if( libewf_lef_file_entry_get_source_identifier( |
170 | 0 | internal_file_entry->lef_file_entry, |
171 | 0 | &source_identifier, |
172 | 0 | error ) != 1 ) |
173 | 0 | { |
174 | 0 | libcerror_error_set( |
175 | 0 | error, |
176 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
177 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
178 | 0 | "%s: unable to retrieve source identifier.", |
179 | 0 | function ); |
180 | |
|
181 | 0 | goto on_error; |
182 | 0 | } |
183 | 0 | if( source_identifier >= 1 ) |
184 | 0 | { |
185 | 0 | if( libewf_single_files_get_source_by_index( |
186 | 0 | single_files, |
187 | 0 | source_identifier, |
188 | 0 | &( internal_file_entry->lef_source ), |
189 | 0 | error ) != 1 ) |
190 | 0 | { |
191 | 0 | libcerror_error_set( |
192 | 0 | error, |
193 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
194 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
195 | 0 | "%s: unable to retrieve source: %d.", |
196 | 0 | function, |
197 | 0 | source_identifier ); |
198 | |
|
199 | 0 | goto on_error; |
200 | 0 | } |
201 | 0 | } |
202 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
203 | 0 | if( libcthreads_read_write_lock_initialize( |
204 | 0 | &( internal_file_entry->read_write_lock ), |
205 | 0 | error ) != 1 ) |
206 | 0 | { |
207 | 0 | libcerror_error_set( |
208 | 0 | error, |
209 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
210 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
211 | 0 | "%s: unable to initialize read/write lock.", |
212 | 0 | function ); |
213 | |
|
214 | 0 | goto on_error; |
215 | 0 | } |
216 | 0 | #endif |
217 | 0 | internal_file_entry->handle = handle; |
218 | 0 | internal_file_entry->single_files = single_files; |
219 | 0 | internal_file_entry->file_entry_tree_node = file_entry_tree_node; |
220 | |
|
221 | 0 | *file_entry = (libewf_file_entry_t *) internal_file_entry; |
222 | |
|
223 | 0 | return( 1 ); |
224 | | |
225 | 0 | on_error: |
226 | 0 | if( internal_file_entry != NULL ) |
227 | 0 | { |
228 | 0 | memory_free( |
229 | 0 | internal_file_entry ); |
230 | 0 | } |
231 | 0 | return( -1 ); |
232 | 0 | } |
233 | | |
234 | | /* Frees a file entry |
235 | | * Returns 1 if successful or -1 on error |
236 | | */ |
237 | | int libewf_file_entry_free( |
238 | | libewf_file_entry_t **file_entry, |
239 | | libcerror_error_t **error ) |
240 | 0 | { |
241 | 0 | libewf_internal_file_entry_t *internal_file_entry = NULL; |
242 | 0 | static char *function = "libewf_file_entry_free"; |
243 | 0 | int result = 1; |
244 | |
|
245 | 0 | if( file_entry == NULL ) |
246 | 0 | { |
247 | 0 | libcerror_error_set( |
248 | 0 | error, |
249 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
250 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
251 | 0 | "%s: invalid file entry.", |
252 | 0 | function ); |
253 | |
|
254 | 0 | return( -1 ); |
255 | 0 | } |
256 | 0 | if( *file_entry != NULL ) |
257 | 0 | { |
258 | 0 | internal_file_entry = (libewf_internal_file_entry_t *) *file_entry; |
259 | 0 | *file_entry = NULL; |
260 | |
|
261 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
262 | 0 | if( libcthreads_read_write_lock_free( |
263 | 0 | &( internal_file_entry->read_write_lock ), |
264 | 0 | error ) != 1 ) |
265 | 0 | { |
266 | 0 | libcerror_error_set( |
267 | 0 | error, |
268 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
269 | 0 | LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED, |
270 | 0 | "%s: unable to free read/write lock.", |
271 | 0 | function ); |
272 | |
|
273 | 0 | result = -1; |
274 | 0 | } |
275 | 0 | #endif |
276 | | /* The handle, file_entry_tree_node, lef_file_entry, permission_group and lef_source references are freed elsewhere |
277 | | */ |
278 | 0 | memory_free( |
279 | 0 | internal_file_entry ); |
280 | 0 | } |
281 | 0 | return( result ); |
282 | 0 | } |
283 | | |
284 | | /* Retrieves the identifier |
285 | | * Returns 1 if successful or -1 on error |
286 | | */ |
287 | | int libewf_file_entry_get_identifier( |
288 | | libewf_file_entry_t *file_entry, |
289 | | uint64_t *identifier, |
290 | | libcerror_error_t **error ) |
291 | 0 | { |
292 | 0 | libewf_internal_file_entry_t *internal_file_entry = NULL; |
293 | 0 | static char *function = "libewf_file_entry_get_identifier"; |
294 | 0 | int result = 1; |
295 | |
|
296 | 0 | if( file_entry == NULL ) |
297 | 0 | { |
298 | 0 | libcerror_error_set( |
299 | 0 | error, |
300 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
301 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
302 | 0 | "%s: invalid file entry.", |
303 | 0 | function ); |
304 | |
|
305 | 0 | return( -1 ); |
306 | 0 | } |
307 | 0 | internal_file_entry = (libewf_internal_file_entry_t *) file_entry; |
308 | |
|
309 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
310 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
311 | 0 | internal_file_entry->read_write_lock, |
312 | 0 | error ) != 1 ) |
313 | 0 | { |
314 | 0 | libcerror_error_set( |
315 | 0 | error, |
316 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
317 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
318 | 0 | "%s: unable to grab read/write lock for reading.", |
319 | 0 | function ); |
320 | |
|
321 | 0 | return( -1 ); |
322 | 0 | } |
323 | 0 | #endif |
324 | 0 | if( libewf_lef_file_entry_get_identifier( |
325 | 0 | internal_file_entry->lef_file_entry, |
326 | 0 | identifier, |
327 | 0 | error ) != 1 ) |
328 | 0 | { |
329 | 0 | libcerror_error_set( |
330 | 0 | error, |
331 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
332 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
333 | 0 | "%s: unable to retrieve identifier.", |
334 | 0 | function ); |
335 | |
|
336 | 0 | result = -1; |
337 | 0 | } |
338 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
339 | 0 | if( libcthreads_read_write_lock_release_for_read( |
340 | 0 | internal_file_entry->read_write_lock, |
341 | 0 | error ) != 1 ) |
342 | 0 | { |
343 | 0 | libcerror_error_set( |
344 | 0 | error, |
345 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
346 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
347 | 0 | "%s: unable to release read/write lock for reading.", |
348 | 0 | function ); |
349 | |
|
350 | 0 | return( -1 ); |
351 | 0 | } |
352 | 0 | #endif |
353 | 0 | return( result ); |
354 | 0 | } |
355 | | |
356 | | /* Retrieves the type |
357 | | * Returns 1 if successful or -1 on error |
358 | | */ |
359 | | int libewf_file_entry_get_type( |
360 | | libewf_file_entry_t *file_entry, |
361 | | uint8_t *type, |
362 | | libcerror_error_t **error ) |
363 | 0 | { |
364 | 0 | libewf_internal_file_entry_t *internal_file_entry = NULL; |
365 | 0 | static char *function = "libewf_file_entry_get_type"; |
366 | 0 | int result = 1; |
367 | |
|
368 | 0 | if( file_entry == NULL ) |
369 | 0 | { |
370 | 0 | libcerror_error_set( |
371 | 0 | error, |
372 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
373 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
374 | 0 | "%s: invalid file entry.", |
375 | 0 | function ); |
376 | |
|
377 | 0 | return( -1 ); |
378 | 0 | } |
379 | 0 | internal_file_entry = (libewf_internal_file_entry_t *) file_entry; |
380 | |
|
381 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
382 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
383 | 0 | internal_file_entry->read_write_lock, |
384 | 0 | error ) != 1 ) |
385 | 0 | { |
386 | 0 | libcerror_error_set( |
387 | 0 | error, |
388 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
389 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
390 | 0 | "%s: unable to grab read/write lock for reading.", |
391 | 0 | function ); |
392 | |
|
393 | 0 | return( -1 ); |
394 | 0 | } |
395 | 0 | #endif |
396 | 0 | if( libewf_lef_file_entry_get_type( |
397 | 0 | internal_file_entry->lef_file_entry, |
398 | 0 | type, |
399 | 0 | error ) != 1 ) |
400 | 0 | { |
401 | 0 | libcerror_error_set( |
402 | 0 | error, |
403 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
404 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
405 | 0 | "%s: unable to retrieve type.", |
406 | 0 | function ); |
407 | |
|
408 | 0 | result = -1; |
409 | 0 | } |
410 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
411 | 0 | if( libcthreads_read_write_lock_release_for_read( |
412 | 0 | internal_file_entry->read_write_lock, |
413 | 0 | error ) != 1 ) |
414 | 0 | { |
415 | 0 | libcerror_error_set( |
416 | 0 | error, |
417 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
418 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
419 | 0 | "%s: unable to release read/write lock for reading.", |
420 | 0 | function ); |
421 | |
|
422 | 0 | return( -1 ); |
423 | 0 | } |
424 | 0 | #endif |
425 | 0 | return( result ); |
426 | 0 | } |
427 | | |
428 | | /* Retrieves the flags |
429 | | * Returns 1 if successful or -1 on error |
430 | | */ |
431 | | int libewf_file_entry_get_flags( |
432 | | libewf_file_entry_t *file_entry, |
433 | | uint32_t *flags, |
434 | | libcerror_error_t **error ) |
435 | 0 | { |
436 | 0 | libewf_internal_file_entry_t *internal_file_entry = NULL; |
437 | 0 | static char *function = "libewf_file_entry_get_flags"; |
438 | 0 | int result = 1; |
439 | |
|
440 | 0 | if( file_entry == NULL ) |
441 | 0 | { |
442 | 0 | libcerror_error_set( |
443 | 0 | error, |
444 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
445 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
446 | 0 | "%s: invalid file entry.", |
447 | 0 | function ); |
448 | |
|
449 | 0 | return( -1 ); |
450 | 0 | } |
451 | 0 | internal_file_entry = (libewf_internal_file_entry_t *) file_entry; |
452 | |
|
453 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
454 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
455 | 0 | internal_file_entry->read_write_lock, |
456 | 0 | error ) != 1 ) |
457 | 0 | { |
458 | 0 | libcerror_error_set( |
459 | 0 | error, |
460 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
461 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
462 | 0 | "%s: unable to grab read/write lock for reading.", |
463 | 0 | function ); |
464 | |
|
465 | 0 | return( -1 ); |
466 | 0 | } |
467 | 0 | #endif |
468 | 0 | if( libewf_lef_file_entry_get_flags( |
469 | 0 | internal_file_entry->lef_file_entry, |
470 | 0 | flags, |
471 | 0 | error ) != 1 ) |
472 | 0 | { |
473 | 0 | libcerror_error_set( |
474 | 0 | error, |
475 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
476 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
477 | 0 | "%s: unable to retrieve flags.", |
478 | 0 | function ); |
479 | |
|
480 | 0 | result = -1; |
481 | 0 | } |
482 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
483 | 0 | if( libcthreads_read_write_lock_release_for_read( |
484 | 0 | internal_file_entry->read_write_lock, |
485 | 0 | error ) != 1 ) |
486 | 0 | { |
487 | 0 | libcerror_error_set( |
488 | 0 | error, |
489 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
490 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
491 | 0 | "%s: unable to release read/write lock for reading.", |
492 | 0 | function ); |
493 | |
|
494 | 0 | return( -1 ); |
495 | 0 | } |
496 | 0 | #endif |
497 | 0 | return( result ); |
498 | 0 | } |
499 | | |
500 | | /* Retrieves the media data offset |
501 | | * Returns 1 if successful or -1 on error |
502 | | */ |
503 | | int libewf_file_entry_get_media_data_offset( |
504 | | libewf_file_entry_t *file_entry, |
505 | | off64_t *media_data_offset, |
506 | | libcerror_error_t **error ) |
507 | 0 | { |
508 | 0 | libewf_internal_file_entry_t *internal_file_entry = NULL; |
509 | 0 | static char *function = "libewf_file_entry_get_media_data_offset"; |
510 | 0 | int result = 1; |
511 | |
|
512 | 0 | if( file_entry == NULL ) |
513 | 0 | { |
514 | 0 | libcerror_error_set( |
515 | 0 | error, |
516 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
517 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
518 | 0 | "%s: invalid file entry.", |
519 | 0 | function ); |
520 | |
|
521 | 0 | return( -1 ); |
522 | 0 | } |
523 | 0 | internal_file_entry = (libewf_internal_file_entry_t *) file_entry; |
524 | |
|
525 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
526 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
527 | 0 | internal_file_entry->read_write_lock, |
528 | 0 | error ) != 1 ) |
529 | 0 | { |
530 | 0 | libcerror_error_set( |
531 | 0 | error, |
532 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
533 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
534 | 0 | "%s: unable to grab read/write lock for reading.", |
535 | 0 | function ); |
536 | |
|
537 | 0 | return( -1 ); |
538 | 0 | } |
539 | 0 | #endif |
540 | 0 | if( libewf_lef_file_entry_get_data_offset( |
541 | 0 | internal_file_entry->lef_file_entry, |
542 | 0 | media_data_offset, |
543 | 0 | error ) != 1 ) |
544 | 0 | { |
545 | 0 | libcerror_error_set( |
546 | 0 | error, |
547 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
548 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
549 | 0 | "%s: unable to retrieve data offset.", |
550 | 0 | function ); |
551 | |
|
552 | 0 | result = -1; |
553 | 0 | } |
554 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
555 | 0 | if( libcthreads_read_write_lock_release_for_read( |
556 | 0 | internal_file_entry->read_write_lock, |
557 | 0 | error ) != 1 ) |
558 | 0 | { |
559 | 0 | libcerror_error_set( |
560 | 0 | error, |
561 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
562 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
563 | 0 | "%s: unable to release read/write lock for reading.", |
564 | 0 | function ); |
565 | |
|
566 | 0 | return( -1 ); |
567 | 0 | } |
568 | 0 | #endif |
569 | 0 | return( result ); |
570 | 0 | } |
571 | | |
572 | | /* Retrieves the media data size |
573 | | * Returns 1 if successful or -1 on error |
574 | | */ |
575 | | int libewf_file_entry_get_media_data_size( |
576 | | libewf_file_entry_t *file_entry, |
577 | | size64_t *media_data_size, |
578 | | libcerror_error_t **error ) |
579 | 0 | { |
580 | 0 | libewf_internal_file_entry_t *internal_file_entry = NULL; |
581 | 0 | static char *function = "libewf_file_entry_get_media_data_size"; |
582 | 0 | int result = 1; |
583 | |
|
584 | 0 | if( file_entry == NULL ) |
585 | 0 | { |
586 | 0 | libcerror_error_set( |
587 | 0 | error, |
588 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
589 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
590 | 0 | "%s: invalid file entry.", |
591 | 0 | function ); |
592 | |
|
593 | 0 | return( -1 ); |
594 | 0 | } |
595 | 0 | internal_file_entry = (libewf_internal_file_entry_t *) file_entry; |
596 | |
|
597 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
598 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
599 | 0 | internal_file_entry->read_write_lock, |
600 | 0 | error ) != 1 ) |
601 | 0 | { |
602 | 0 | libcerror_error_set( |
603 | 0 | error, |
604 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
605 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
606 | 0 | "%s: unable to grab read/write lock for reading.", |
607 | 0 | function ); |
608 | |
|
609 | 0 | return( -1 ); |
610 | 0 | } |
611 | 0 | #endif |
612 | 0 | if( libewf_lef_file_entry_get_data_size( |
613 | 0 | internal_file_entry->lef_file_entry, |
614 | 0 | media_data_size, |
615 | 0 | error ) != 1 ) |
616 | 0 | { |
617 | 0 | libcerror_error_set( |
618 | 0 | error, |
619 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
620 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
621 | 0 | "%s: unable to retrieve data size.", |
622 | 0 | function ); |
623 | |
|
624 | 0 | result = -1; |
625 | 0 | } |
626 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
627 | 0 | if( libcthreads_read_write_lock_release_for_read( |
628 | 0 | internal_file_entry->read_write_lock, |
629 | 0 | error ) != 1 ) |
630 | 0 | { |
631 | 0 | libcerror_error_set( |
632 | 0 | error, |
633 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
634 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
635 | 0 | "%s: unable to release read/write lock for reading.", |
636 | 0 | function ); |
637 | |
|
638 | 0 | return( -1 ); |
639 | 0 | } |
640 | 0 | #endif |
641 | 0 | return( result ); |
642 | 0 | } |
643 | | |
644 | | /* Retrieves the duplicate media data offset |
645 | | * Returns 1 if successful or -1 on error |
646 | | */ |
647 | | int libewf_file_entry_get_duplicate_media_data_offset( |
648 | | libewf_file_entry_t *file_entry, |
649 | | off64_t *duplicate_media_data_offset, |
650 | | libcerror_error_t **error ) |
651 | 0 | { |
652 | 0 | libewf_internal_file_entry_t *internal_file_entry = NULL; |
653 | 0 | static char *function = "libewf_file_entry_get_media_data_offset"; |
654 | 0 | int result = 1; |
655 | |
|
656 | 0 | if( file_entry == NULL ) |
657 | 0 | { |
658 | 0 | libcerror_error_set( |
659 | 0 | error, |
660 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
661 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
662 | 0 | "%s: invalid file entry.", |
663 | 0 | function ); |
664 | |
|
665 | 0 | return( -1 ); |
666 | 0 | } |
667 | 0 | internal_file_entry = (libewf_internal_file_entry_t *) file_entry; |
668 | |
|
669 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
670 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
671 | 0 | internal_file_entry->read_write_lock, |
672 | 0 | error ) != 1 ) |
673 | 0 | { |
674 | 0 | libcerror_error_set( |
675 | 0 | error, |
676 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
677 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
678 | 0 | "%s: unable to grab read/write lock for reading.", |
679 | 0 | function ); |
680 | |
|
681 | 0 | return( -1 ); |
682 | 0 | } |
683 | 0 | #endif |
684 | 0 | if( libewf_lef_file_entry_get_duplicate_data_offset( |
685 | 0 | internal_file_entry->lef_file_entry, |
686 | 0 | duplicate_media_data_offset, |
687 | 0 | error ) != 1 ) |
688 | 0 | { |
689 | 0 | libcerror_error_set( |
690 | 0 | error, |
691 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
692 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
693 | 0 | "%s: unable to retrieve duplicate data offset.", |
694 | 0 | function ); |
695 | |
|
696 | 0 | result = -1; |
697 | 0 | } |
698 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
699 | 0 | if( libcthreads_read_write_lock_release_for_read( |
700 | 0 | internal_file_entry->read_write_lock, |
701 | 0 | error ) != 1 ) |
702 | 0 | { |
703 | 0 | libcerror_error_set( |
704 | 0 | error, |
705 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
706 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
707 | 0 | "%s: unable to release read/write lock for reading.", |
708 | 0 | function ); |
709 | |
|
710 | 0 | return( -1 ); |
711 | 0 | } |
712 | 0 | #endif |
713 | 0 | return( result ); |
714 | 0 | } |
715 | | |
716 | | /* Retrieves the size of the UTF-8 encoded name |
717 | | * This function uses UTF-8 RFC 2279 (or 6-byte UTF-8) to support characters outside Unicode |
718 | | * The returned size includes the end of string character |
719 | | * Returns 1 if successful or -1 on error |
720 | | */ |
721 | | int libewf_file_entry_get_utf8_name_size( |
722 | | libewf_file_entry_t *file_entry, |
723 | | size_t *utf8_string_size, |
724 | | libcerror_error_t **error ) |
725 | 0 | { |
726 | 0 | libewf_internal_file_entry_t *internal_file_entry = NULL; |
727 | 0 | static char *function = "libewf_file_entry_get_utf8_name_size"; |
728 | 0 | int result = 1; |
729 | |
|
730 | 0 | if( file_entry == NULL ) |
731 | 0 | { |
732 | 0 | libcerror_error_set( |
733 | 0 | error, |
734 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
735 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
736 | 0 | "%s: invalid file entry.", |
737 | 0 | function ); |
738 | |
|
739 | 0 | return( -1 ); |
740 | 0 | } |
741 | 0 | internal_file_entry = (libewf_internal_file_entry_t *) file_entry; |
742 | |
|
743 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
744 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
745 | 0 | internal_file_entry->read_write_lock, |
746 | 0 | error ) != 1 ) |
747 | 0 | { |
748 | 0 | libcerror_error_set( |
749 | 0 | error, |
750 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
751 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
752 | 0 | "%s: unable to grab read/write lock for reading.", |
753 | 0 | function ); |
754 | |
|
755 | 0 | return( -1 ); |
756 | 0 | } |
757 | 0 | #endif |
758 | 0 | if( libewf_lef_file_entry_get_utf8_name_size( |
759 | 0 | internal_file_entry->lef_file_entry, |
760 | 0 | utf8_string_size, |
761 | 0 | error ) != 1 ) |
762 | 0 | { |
763 | 0 | libcerror_error_set( |
764 | 0 | error, |
765 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
766 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
767 | 0 | "%s: unable to retrieve UTF-8 name size.", |
768 | 0 | function ); |
769 | |
|
770 | 0 | result = -1; |
771 | 0 | } |
772 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
773 | 0 | if( libcthreads_read_write_lock_release_for_read( |
774 | 0 | internal_file_entry->read_write_lock, |
775 | 0 | error ) != 1 ) |
776 | 0 | { |
777 | 0 | libcerror_error_set( |
778 | 0 | error, |
779 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
780 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
781 | 0 | "%s: unable to release read/write lock for reading.", |
782 | 0 | function ); |
783 | |
|
784 | 0 | return( -1 ); |
785 | 0 | } |
786 | 0 | #endif |
787 | 0 | return( result ); |
788 | 0 | } |
789 | | |
790 | | /* Retrieves the UTF-8 encoded name |
791 | | * This function uses UTF-8 RFC 2279 (or 6-byte UTF-8) to support characters outside Unicode |
792 | | * The size should include the end of string character |
793 | | * Returns 1 if successful or -1 on error |
794 | | */ |
795 | | int libewf_file_entry_get_utf8_name( |
796 | | libewf_file_entry_t *file_entry, |
797 | | uint8_t *utf8_string, |
798 | | size_t utf8_string_size, |
799 | | libcerror_error_t **error ) |
800 | 0 | { |
801 | 0 | libewf_internal_file_entry_t *internal_file_entry = NULL; |
802 | 0 | static char *function = "libewf_file_entry_get_utf8_name"; |
803 | 0 | int result = 1; |
804 | |
|
805 | 0 | if( file_entry == NULL ) |
806 | 0 | { |
807 | 0 | libcerror_error_set( |
808 | 0 | error, |
809 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
810 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
811 | 0 | "%s: invalid file entry.", |
812 | 0 | function ); |
813 | |
|
814 | 0 | return( -1 ); |
815 | 0 | } |
816 | 0 | internal_file_entry = (libewf_internal_file_entry_t *) file_entry; |
817 | |
|
818 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
819 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
820 | 0 | internal_file_entry->read_write_lock, |
821 | 0 | error ) != 1 ) |
822 | 0 | { |
823 | 0 | libcerror_error_set( |
824 | 0 | error, |
825 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
826 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
827 | 0 | "%s: unable to grab read/write lock for reading.", |
828 | 0 | function ); |
829 | |
|
830 | 0 | return( -1 ); |
831 | 0 | } |
832 | 0 | #endif |
833 | 0 | if( libewf_lef_file_entry_get_utf8_name( |
834 | 0 | internal_file_entry->lef_file_entry, |
835 | 0 | utf8_string, |
836 | 0 | utf8_string_size, |
837 | 0 | error ) != 1 ) |
838 | 0 | { |
839 | 0 | libcerror_error_set( |
840 | 0 | error, |
841 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
842 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
843 | 0 | "%s: unable to retrieve UTF-8 name.", |
844 | 0 | function ); |
845 | |
|
846 | 0 | result = -1; |
847 | 0 | } |
848 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
849 | 0 | if( libcthreads_read_write_lock_release_for_read( |
850 | 0 | internal_file_entry->read_write_lock, |
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_SET_FAILED, |
857 | 0 | "%s: unable to release read/write lock for reading.", |
858 | 0 | function ); |
859 | |
|
860 | 0 | return( -1 ); |
861 | 0 | } |
862 | 0 | #endif |
863 | 0 | return( result ); |
864 | 0 | } |
865 | | |
866 | | /* Retrieves the size of the UTF-16 encoded name |
867 | | * This function uses UCS-2 (with surrogates) to support characters outside Unicode |
868 | | * The returned size includes the end of string character |
869 | | * Returns 1 if successful or -1 on error |
870 | | */ |
871 | | int libewf_file_entry_get_utf16_name_size( |
872 | | libewf_file_entry_t *file_entry, |
873 | | size_t *utf16_string_size, |
874 | | libcerror_error_t **error ) |
875 | 0 | { |
876 | 0 | libewf_internal_file_entry_t *internal_file_entry = NULL; |
877 | 0 | static char *function = "libewf_file_entry_get_utf16_name_size"; |
878 | 0 | int result = 1; |
879 | |
|
880 | 0 | if( file_entry == NULL ) |
881 | 0 | { |
882 | 0 | libcerror_error_set( |
883 | 0 | error, |
884 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
885 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
886 | 0 | "%s: invalid file entry.", |
887 | 0 | function ); |
888 | |
|
889 | 0 | return( -1 ); |
890 | 0 | } |
891 | 0 | internal_file_entry = (libewf_internal_file_entry_t *) file_entry; |
892 | |
|
893 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
894 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
895 | 0 | internal_file_entry->read_write_lock, |
896 | 0 | error ) != 1 ) |
897 | 0 | { |
898 | 0 | libcerror_error_set( |
899 | 0 | error, |
900 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
901 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
902 | 0 | "%s: unable to grab read/write lock for reading.", |
903 | 0 | function ); |
904 | |
|
905 | 0 | return( -1 ); |
906 | 0 | } |
907 | 0 | #endif |
908 | 0 | if( libewf_lef_file_entry_get_utf16_name_size( |
909 | 0 | internal_file_entry->lef_file_entry, |
910 | 0 | utf16_string_size, |
911 | 0 | error ) != 1 ) |
912 | 0 | { |
913 | 0 | libcerror_error_set( |
914 | 0 | error, |
915 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
916 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
917 | 0 | "%s: unable to retrieve UTF-16 name size.", |
918 | 0 | function ); |
919 | |
|
920 | 0 | result = -1; |
921 | 0 | } |
922 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
923 | 0 | if( libcthreads_read_write_lock_release_for_read( |
924 | 0 | internal_file_entry->read_write_lock, |
925 | 0 | error ) != 1 ) |
926 | 0 | { |
927 | 0 | libcerror_error_set( |
928 | 0 | error, |
929 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
930 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
931 | 0 | "%s: unable to release read/write lock for reading.", |
932 | 0 | function ); |
933 | |
|
934 | 0 | return( -1 ); |
935 | 0 | } |
936 | 0 | #endif |
937 | 0 | return( result ); |
938 | 0 | } |
939 | | |
940 | | /* Retrieves the UTF-16 encoded name |
941 | | * This function uses UCS-2 (with surrogates) to support characters outside Unicode |
942 | | * The size should include the end of string character |
943 | | * Returns 1 if successful or -1 on error |
944 | | */ |
945 | | int libewf_file_entry_get_utf16_name( |
946 | | libewf_file_entry_t *file_entry, |
947 | | uint16_t *utf16_string, |
948 | | size_t utf16_string_size, |
949 | | libcerror_error_t **error ) |
950 | 0 | { |
951 | 0 | libewf_internal_file_entry_t *internal_file_entry = NULL; |
952 | 0 | static char *function = "libewf_file_entry_get_utf16_name"; |
953 | 0 | int result = 1; |
954 | |
|
955 | 0 | if( file_entry == NULL ) |
956 | 0 | { |
957 | 0 | libcerror_error_set( |
958 | 0 | error, |
959 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
960 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
961 | 0 | "%s: invalid file entry.", |
962 | 0 | function ); |
963 | |
|
964 | 0 | return( -1 ); |
965 | 0 | } |
966 | 0 | internal_file_entry = (libewf_internal_file_entry_t *) file_entry; |
967 | |
|
968 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
969 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
970 | 0 | internal_file_entry->read_write_lock, |
971 | 0 | error ) != 1 ) |
972 | 0 | { |
973 | 0 | libcerror_error_set( |
974 | 0 | error, |
975 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
976 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
977 | 0 | "%s: unable to grab read/write lock for reading.", |
978 | 0 | function ); |
979 | |
|
980 | 0 | return( -1 ); |
981 | 0 | } |
982 | 0 | #endif |
983 | 0 | if( libewf_lef_file_entry_get_utf16_name( |
984 | 0 | internal_file_entry->lef_file_entry, |
985 | 0 | utf16_string, |
986 | 0 | utf16_string_size, |
987 | 0 | error ) != 1 ) |
988 | 0 | { |
989 | 0 | libcerror_error_set( |
990 | 0 | error, |
991 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
992 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
993 | 0 | "%s: unable to retrieve UTF-8 name.", |
994 | 0 | function ); |
995 | |
|
996 | 0 | result = -1; |
997 | 0 | } |
998 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
999 | 0 | if( libcthreads_read_write_lock_release_for_read( |
1000 | 0 | internal_file_entry->read_write_lock, |
1001 | 0 | error ) != 1 ) |
1002 | 0 | { |
1003 | 0 | libcerror_error_set( |
1004 | 0 | error, |
1005 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1006 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1007 | 0 | "%s: unable to release read/write lock for reading.", |
1008 | 0 | function ); |
1009 | |
|
1010 | 0 | return( -1 ); |
1011 | 0 | } |
1012 | 0 | #endif |
1013 | 0 | return( result ); |
1014 | 0 | } |
1015 | | |
1016 | | /* Retrieves the size of the UTF-8 encoded short name |
1017 | | * The returned size includes the end of string character |
1018 | | * Returns 1 if successful or -1 on error |
1019 | | */ |
1020 | | int libewf_file_entry_get_utf8_short_name_size( |
1021 | | libewf_file_entry_t *file_entry, |
1022 | | size_t *utf8_string_size, |
1023 | | libcerror_error_t **error ) |
1024 | 0 | { |
1025 | 0 | libewf_internal_file_entry_t *internal_file_entry = NULL; |
1026 | 0 | static char *function = "libewf_file_entry_get_utf8_short_name_size"; |
1027 | 0 | int result = 1; |
1028 | |
|
1029 | 0 | if( file_entry == NULL ) |
1030 | 0 | { |
1031 | 0 | libcerror_error_set( |
1032 | 0 | error, |
1033 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1034 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1035 | 0 | "%s: invalid file entry.", |
1036 | 0 | function ); |
1037 | |
|
1038 | 0 | return( -1 ); |
1039 | 0 | } |
1040 | 0 | internal_file_entry = (libewf_internal_file_entry_t *) file_entry; |
1041 | |
|
1042 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
1043 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
1044 | 0 | internal_file_entry->read_write_lock, |
1045 | 0 | error ) != 1 ) |
1046 | 0 | { |
1047 | 0 | libcerror_error_set( |
1048 | 0 | error, |
1049 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1050 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1051 | 0 | "%s: unable to grab read/write lock for reading.", |
1052 | 0 | function ); |
1053 | |
|
1054 | 0 | return( -1 ); |
1055 | 0 | } |
1056 | 0 | #endif |
1057 | 0 | if( libewf_lef_file_entry_get_utf8_short_name_size( |
1058 | 0 | internal_file_entry->lef_file_entry, |
1059 | 0 | utf8_string_size, |
1060 | 0 | error ) != 1 ) |
1061 | 0 | { |
1062 | 0 | libcerror_error_set( |
1063 | 0 | error, |
1064 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1065 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
1066 | 0 | "%s: unable to retrieve UTF-8 short name size.", |
1067 | 0 | function ); |
1068 | |
|
1069 | 0 | result = -1; |
1070 | 0 | } |
1071 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
1072 | 0 | if( libcthreads_read_write_lock_release_for_read( |
1073 | 0 | internal_file_entry->read_write_lock, |
1074 | 0 | error ) != 1 ) |
1075 | 0 | { |
1076 | 0 | libcerror_error_set( |
1077 | 0 | error, |
1078 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1079 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1080 | 0 | "%s: unable to release read/write lock for reading.", |
1081 | 0 | function ); |
1082 | |
|
1083 | 0 | return( -1 ); |
1084 | 0 | } |
1085 | 0 | #endif |
1086 | 0 | return( result ); |
1087 | 0 | } |
1088 | | |
1089 | | /* Retrieves the UTF-8 encoded short name |
1090 | | * The size should include the end of string character |
1091 | | * Returns 1 if successful or -1 on error |
1092 | | */ |
1093 | | int libewf_file_entry_get_utf8_short_name( |
1094 | | libewf_file_entry_t *file_entry, |
1095 | | uint8_t *utf8_string, |
1096 | | size_t utf8_string_size, |
1097 | | libcerror_error_t **error ) |
1098 | 0 | { |
1099 | 0 | libewf_internal_file_entry_t *internal_file_entry = NULL; |
1100 | 0 | static char *function = "libewf_file_entry_get_utf8_short_name"; |
1101 | 0 | int result = 1; |
1102 | |
|
1103 | 0 | if( file_entry == NULL ) |
1104 | 0 | { |
1105 | 0 | libcerror_error_set( |
1106 | 0 | error, |
1107 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1108 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1109 | 0 | "%s: invalid file entry.", |
1110 | 0 | function ); |
1111 | |
|
1112 | 0 | return( -1 ); |
1113 | 0 | } |
1114 | 0 | internal_file_entry = (libewf_internal_file_entry_t *) file_entry; |
1115 | |
|
1116 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
1117 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
1118 | 0 | internal_file_entry->read_write_lock, |
1119 | 0 | error ) != 1 ) |
1120 | 0 | { |
1121 | 0 | libcerror_error_set( |
1122 | 0 | error, |
1123 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1124 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1125 | 0 | "%s: unable to grab read/write lock for reading.", |
1126 | 0 | function ); |
1127 | |
|
1128 | 0 | return( -1 ); |
1129 | 0 | } |
1130 | 0 | #endif |
1131 | 0 | if( libewf_lef_file_entry_get_utf8_short_name( |
1132 | 0 | internal_file_entry->lef_file_entry, |
1133 | 0 | utf8_string, |
1134 | 0 | utf8_string_size, |
1135 | 0 | error ) != 1 ) |
1136 | 0 | { |
1137 | 0 | libcerror_error_set( |
1138 | 0 | error, |
1139 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1140 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
1141 | 0 | "%s: unable to retrieve UTF-8 short name.", |
1142 | 0 | function ); |
1143 | |
|
1144 | 0 | result = -1; |
1145 | 0 | } |
1146 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
1147 | 0 | if( libcthreads_read_write_lock_release_for_read( |
1148 | 0 | internal_file_entry->read_write_lock, |
1149 | 0 | error ) != 1 ) |
1150 | 0 | { |
1151 | 0 | libcerror_error_set( |
1152 | 0 | error, |
1153 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1154 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1155 | 0 | "%s: unable to release read/write lock for reading.", |
1156 | 0 | function ); |
1157 | |
|
1158 | 0 | return( -1 ); |
1159 | 0 | } |
1160 | 0 | #endif |
1161 | 0 | return( result ); |
1162 | 0 | } |
1163 | | |
1164 | | /* Retrieves the size of the UTF-16 encoded short name |
1165 | | * The returned size includes the end of string character |
1166 | | * Returns 1 if successful or -1 on error |
1167 | | */ |
1168 | | int libewf_file_entry_get_utf16_short_name_size( |
1169 | | libewf_file_entry_t *file_entry, |
1170 | | size_t *utf16_string_size, |
1171 | | libcerror_error_t **error ) |
1172 | 0 | { |
1173 | 0 | libewf_internal_file_entry_t *internal_file_entry = NULL; |
1174 | 0 | static char *function = "libewf_file_entry_get_utf16_short_name_size"; |
1175 | 0 | int result = 1; |
1176 | |
|
1177 | 0 | if( file_entry == NULL ) |
1178 | 0 | { |
1179 | 0 | libcerror_error_set( |
1180 | 0 | error, |
1181 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1182 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1183 | 0 | "%s: invalid file entry.", |
1184 | 0 | function ); |
1185 | |
|
1186 | 0 | return( -1 ); |
1187 | 0 | } |
1188 | 0 | internal_file_entry = (libewf_internal_file_entry_t *) file_entry; |
1189 | |
|
1190 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
1191 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
1192 | 0 | internal_file_entry->read_write_lock, |
1193 | 0 | error ) != 1 ) |
1194 | 0 | { |
1195 | 0 | libcerror_error_set( |
1196 | 0 | error, |
1197 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1198 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1199 | 0 | "%s: unable to grab read/write lock for reading.", |
1200 | 0 | function ); |
1201 | |
|
1202 | 0 | return( -1 ); |
1203 | 0 | } |
1204 | 0 | #endif |
1205 | 0 | if( libewf_lef_file_entry_get_utf16_short_name_size( |
1206 | 0 | internal_file_entry->lef_file_entry, |
1207 | 0 | utf16_string_size, |
1208 | 0 | error ) != 1 ) |
1209 | 0 | { |
1210 | 0 | libcerror_error_set( |
1211 | 0 | error, |
1212 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1213 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
1214 | 0 | "%s: unable to retrieve UTF-16 short name size.", |
1215 | 0 | function ); |
1216 | |
|
1217 | 0 | result = -1; |
1218 | 0 | } |
1219 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
1220 | 0 | if( libcthreads_read_write_lock_release_for_read( |
1221 | 0 | internal_file_entry->read_write_lock, |
1222 | 0 | error ) != 1 ) |
1223 | 0 | { |
1224 | 0 | libcerror_error_set( |
1225 | 0 | error, |
1226 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1227 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1228 | 0 | "%s: unable to release read/write lock for reading.", |
1229 | 0 | function ); |
1230 | |
|
1231 | 0 | return( -1 ); |
1232 | 0 | } |
1233 | 0 | #endif |
1234 | 0 | return( result ); |
1235 | 0 | } |
1236 | | |
1237 | | /* Retrieves the UTF-16 encoded short name |
1238 | | * The size should include the end of string character |
1239 | | * Returns 1 if successful or -1 on error |
1240 | | */ |
1241 | | int libewf_file_entry_get_utf16_short_name( |
1242 | | libewf_file_entry_t *file_entry, |
1243 | | uint16_t *utf16_string, |
1244 | | size_t utf16_string_size, |
1245 | | libcerror_error_t **error ) |
1246 | 0 | { |
1247 | 0 | libewf_internal_file_entry_t *internal_file_entry = NULL; |
1248 | 0 | static char *function = "libewf_file_entry_get_utf16_short_name"; |
1249 | 0 | int result = 1; |
1250 | |
|
1251 | 0 | if( file_entry == NULL ) |
1252 | 0 | { |
1253 | 0 | libcerror_error_set( |
1254 | 0 | error, |
1255 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1256 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1257 | 0 | "%s: invalid file entry.", |
1258 | 0 | function ); |
1259 | |
|
1260 | 0 | return( -1 ); |
1261 | 0 | } |
1262 | 0 | internal_file_entry = (libewf_internal_file_entry_t *) file_entry; |
1263 | |
|
1264 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
1265 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
1266 | 0 | internal_file_entry->read_write_lock, |
1267 | 0 | error ) != 1 ) |
1268 | 0 | { |
1269 | 0 | libcerror_error_set( |
1270 | 0 | error, |
1271 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1272 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1273 | 0 | "%s: unable to grab read/write lock for reading.", |
1274 | 0 | function ); |
1275 | |
|
1276 | 0 | return( -1 ); |
1277 | 0 | } |
1278 | 0 | #endif |
1279 | 0 | if( libewf_lef_file_entry_get_utf16_short_name( |
1280 | 0 | internal_file_entry->lef_file_entry, |
1281 | 0 | utf16_string, |
1282 | 0 | utf16_string_size, |
1283 | 0 | error ) != 1 ) |
1284 | 0 | { |
1285 | 0 | libcerror_error_set( |
1286 | 0 | error, |
1287 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1288 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
1289 | 0 | "%s: unable to retrieve UTF-8 short name.", |
1290 | 0 | function ); |
1291 | |
|
1292 | 0 | result = -1; |
1293 | 0 | } |
1294 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
1295 | 0 | if( libcthreads_read_write_lock_release_for_read( |
1296 | 0 | internal_file_entry->read_write_lock, |
1297 | 0 | error ) != 1 ) |
1298 | 0 | { |
1299 | 0 | libcerror_error_set( |
1300 | 0 | error, |
1301 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1302 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1303 | 0 | "%s: unable to release read/write lock for reading.", |
1304 | 0 | function ); |
1305 | |
|
1306 | 0 | return( -1 ); |
1307 | 0 | } |
1308 | 0 | #endif |
1309 | 0 | return( result ); |
1310 | 0 | } |
1311 | | |
1312 | | /* Retrieves the size |
1313 | | * Returns 1 if successful or -1 on error |
1314 | | */ |
1315 | | int libewf_file_entry_get_size( |
1316 | | libewf_file_entry_t *file_entry, |
1317 | | size64_t *size, |
1318 | | libcerror_error_t **error ) |
1319 | 0 | { |
1320 | 0 | libewf_internal_file_entry_t *internal_file_entry = NULL; |
1321 | 0 | static char *function = "libewf_file_entry_get_size"; |
1322 | 0 | int result = 1; |
1323 | |
|
1324 | 0 | if( file_entry == NULL ) |
1325 | 0 | { |
1326 | 0 | libcerror_error_set( |
1327 | 0 | error, |
1328 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1329 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1330 | 0 | "%s: invalid file entry.", |
1331 | 0 | function ); |
1332 | |
|
1333 | 0 | return( -1 ); |
1334 | 0 | } |
1335 | 0 | internal_file_entry = (libewf_internal_file_entry_t *) file_entry; |
1336 | |
|
1337 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
1338 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
1339 | 0 | internal_file_entry->read_write_lock, |
1340 | 0 | error ) != 1 ) |
1341 | 0 | { |
1342 | 0 | libcerror_error_set( |
1343 | 0 | error, |
1344 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1345 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1346 | 0 | "%s: unable to grab read/write lock for reading.", |
1347 | 0 | function ); |
1348 | |
|
1349 | 0 | return( -1 ); |
1350 | 0 | } |
1351 | 0 | #endif |
1352 | 0 | if( libewf_lef_file_entry_get_size( |
1353 | 0 | internal_file_entry->lef_file_entry, |
1354 | 0 | size, |
1355 | 0 | error ) != 1 ) |
1356 | 0 | { |
1357 | 0 | libcerror_error_set( |
1358 | 0 | error, |
1359 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1360 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
1361 | 0 | "%s: unable to retrieve size.", |
1362 | 0 | function ); |
1363 | |
|
1364 | 0 | result = -1; |
1365 | 0 | } |
1366 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
1367 | 0 | if( libcthreads_read_write_lock_release_for_read( |
1368 | 0 | internal_file_entry->read_write_lock, |
1369 | 0 | error ) != 1 ) |
1370 | 0 | { |
1371 | 0 | libcerror_error_set( |
1372 | 0 | error, |
1373 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1374 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1375 | 0 | "%s: unable to release read/write lock for reading.", |
1376 | 0 | function ); |
1377 | |
|
1378 | 0 | return( -1 ); |
1379 | 0 | } |
1380 | 0 | #endif |
1381 | 0 | return( result ); |
1382 | 0 | } |
1383 | | |
1384 | | /* Retrieves the creation date and time |
1385 | | * The date and time is formatted as a POSIX timestamp |
1386 | | * Returns 1 if successful, 0 if not set or -1 on error |
1387 | | */ |
1388 | | int libewf_file_entry_get_creation_time( |
1389 | | libewf_file_entry_t *file_entry, |
1390 | | int64_t *posix_time, |
1391 | | libcerror_error_t **error ) |
1392 | 0 | { |
1393 | 0 | libewf_internal_file_entry_t *internal_file_entry = NULL; |
1394 | 0 | static char *function = "libewf_file_entry_get_creation_time"; |
1395 | 0 | int result = 1; |
1396 | |
|
1397 | 0 | if( file_entry == NULL ) |
1398 | 0 | { |
1399 | 0 | libcerror_error_set( |
1400 | 0 | error, |
1401 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1402 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1403 | 0 | "%s: invalid file entry.", |
1404 | 0 | function ); |
1405 | |
|
1406 | 0 | return( -1 ); |
1407 | 0 | } |
1408 | 0 | internal_file_entry = (libewf_internal_file_entry_t *) file_entry; |
1409 | |
|
1410 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
1411 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
1412 | 0 | internal_file_entry->read_write_lock, |
1413 | 0 | error ) != 1 ) |
1414 | 0 | { |
1415 | 0 | libcerror_error_set( |
1416 | 0 | error, |
1417 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1418 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1419 | 0 | "%s: unable to grab read/write lock for reading.", |
1420 | 0 | function ); |
1421 | |
|
1422 | 0 | return( -1 ); |
1423 | 0 | } |
1424 | 0 | #endif |
1425 | 0 | result = libewf_lef_file_entry_get_creation_time( |
1426 | 0 | internal_file_entry->lef_file_entry, |
1427 | 0 | posix_time, |
1428 | 0 | error ); |
1429 | |
|
1430 | 0 | if( result == -1 ) |
1431 | 0 | { |
1432 | 0 | libcerror_error_set( |
1433 | 0 | error, |
1434 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1435 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
1436 | 0 | "%s: unable to retrieve creation time.", |
1437 | 0 | function ); |
1438 | |
|
1439 | 0 | result = -1; |
1440 | 0 | } |
1441 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
1442 | 0 | if( libcthreads_read_write_lock_release_for_read( |
1443 | 0 | internal_file_entry->read_write_lock, |
1444 | 0 | error ) != 1 ) |
1445 | 0 | { |
1446 | 0 | libcerror_error_set( |
1447 | 0 | error, |
1448 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1449 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1450 | 0 | "%s: unable to release read/write lock for reading.", |
1451 | 0 | function ); |
1452 | |
|
1453 | 0 | return( -1 ); |
1454 | 0 | } |
1455 | 0 | #endif |
1456 | 0 | return( result ); |
1457 | 0 | } |
1458 | | |
1459 | | /* Retrieves the (file) modification (last written) date and time |
1460 | | * The date and time is formatted as a POSIX timestamp |
1461 | | * Returns 1 if successful, 0 if not set or -1 on error |
1462 | | */ |
1463 | | int libewf_file_entry_get_modification_time( |
1464 | | libewf_file_entry_t *file_entry, |
1465 | | int64_t *posix_time, |
1466 | | libcerror_error_t **error ) |
1467 | 0 | { |
1468 | 0 | libewf_internal_file_entry_t *internal_file_entry = NULL; |
1469 | 0 | static char *function = "libewf_file_entry_get_modification_time"; |
1470 | 0 | int result = 1; |
1471 | |
|
1472 | 0 | if( file_entry == NULL ) |
1473 | 0 | { |
1474 | 0 | libcerror_error_set( |
1475 | 0 | error, |
1476 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1477 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1478 | 0 | "%s: invalid file entry.", |
1479 | 0 | function ); |
1480 | |
|
1481 | 0 | return( -1 ); |
1482 | 0 | } |
1483 | 0 | internal_file_entry = (libewf_internal_file_entry_t *) file_entry; |
1484 | |
|
1485 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
1486 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
1487 | 0 | internal_file_entry->read_write_lock, |
1488 | 0 | error ) != 1 ) |
1489 | 0 | { |
1490 | 0 | libcerror_error_set( |
1491 | 0 | error, |
1492 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1493 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1494 | 0 | "%s: unable to grab read/write lock for reading.", |
1495 | 0 | function ); |
1496 | |
|
1497 | 0 | return( -1 ); |
1498 | 0 | } |
1499 | 0 | #endif |
1500 | 0 | result = libewf_lef_file_entry_get_modification_time( |
1501 | 0 | internal_file_entry->lef_file_entry, |
1502 | 0 | posix_time, |
1503 | 0 | error ); |
1504 | |
|
1505 | 0 | if( result == -1 ) |
1506 | 0 | { |
1507 | 0 | libcerror_error_set( |
1508 | 0 | error, |
1509 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1510 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
1511 | 0 | "%s: unable to retrieve modification time.", |
1512 | 0 | function ); |
1513 | |
|
1514 | 0 | result = -1; |
1515 | 0 | } |
1516 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
1517 | 0 | if( libcthreads_read_write_lock_release_for_read( |
1518 | 0 | internal_file_entry->read_write_lock, |
1519 | 0 | error ) != 1 ) |
1520 | 0 | { |
1521 | 0 | libcerror_error_set( |
1522 | 0 | error, |
1523 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1524 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1525 | 0 | "%s: unable to release read/write lock for reading.", |
1526 | 0 | function ); |
1527 | |
|
1528 | 0 | return( -1 ); |
1529 | 0 | } |
1530 | 0 | #endif |
1531 | 0 | return( result ); |
1532 | 0 | } |
1533 | | |
1534 | | /* Retrieves the access date and time |
1535 | | * The date and time is formatted as a POSIX timestamp |
1536 | | * Returns 1 if successful, 0 if not set or -1 on error |
1537 | | */ |
1538 | | int libewf_file_entry_get_access_time( |
1539 | | libewf_file_entry_t *file_entry, |
1540 | | int64_t *posix_time, |
1541 | | libcerror_error_t **error ) |
1542 | 0 | { |
1543 | 0 | libewf_internal_file_entry_t *internal_file_entry = NULL; |
1544 | 0 | static char *function = "libewf_file_entry_get_access_time"; |
1545 | 0 | int result = 1; |
1546 | |
|
1547 | 0 | if( file_entry == NULL ) |
1548 | 0 | { |
1549 | 0 | libcerror_error_set( |
1550 | 0 | error, |
1551 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1552 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1553 | 0 | "%s: invalid file entry.", |
1554 | 0 | function ); |
1555 | |
|
1556 | 0 | return( -1 ); |
1557 | 0 | } |
1558 | 0 | internal_file_entry = (libewf_internal_file_entry_t *) file_entry; |
1559 | |
|
1560 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
1561 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
1562 | 0 | internal_file_entry->read_write_lock, |
1563 | 0 | error ) != 1 ) |
1564 | 0 | { |
1565 | 0 | libcerror_error_set( |
1566 | 0 | error, |
1567 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1568 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1569 | 0 | "%s: unable to grab read/write lock for reading.", |
1570 | 0 | function ); |
1571 | |
|
1572 | 0 | return( -1 ); |
1573 | 0 | } |
1574 | 0 | #endif |
1575 | 0 | result = libewf_lef_file_entry_get_access_time( |
1576 | 0 | internal_file_entry->lef_file_entry, |
1577 | 0 | posix_time, |
1578 | 0 | error ); |
1579 | |
|
1580 | 0 | if( result == -1 ) |
1581 | 0 | { |
1582 | 0 | libcerror_error_set( |
1583 | 0 | error, |
1584 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1585 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
1586 | 0 | "%s: unable to retrieve access time.", |
1587 | 0 | function ); |
1588 | |
|
1589 | 0 | result = -1; |
1590 | 0 | } |
1591 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
1592 | 0 | if( libcthreads_read_write_lock_release_for_read( |
1593 | 0 | internal_file_entry->read_write_lock, |
1594 | 0 | error ) != 1 ) |
1595 | 0 | { |
1596 | 0 | libcerror_error_set( |
1597 | 0 | error, |
1598 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1599 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1600 | 0 | "%s: unable to release read/write lock for reading.", |
1601 | 0 | function ); |
1602 | |
|
1603 | 0 | return( -1 ); |
1604 | 0 | } |
1605 | 0 | #endif |
1606 | 0 | return( result ); |
1607 | 0 | } |
1608 | | |
1609 | | /* Retrieves the (file system) entry modification date and time |
1610 | | * The date and time is formatted as a POSIX timestamp |
1611 | | * Returns 1 if successful, 0 if not set or -1 on error |
1612 | | */ |
1613 | | int libewf_file_entry_get_entry_modification_time( |
1614 | | libewf_file_entry_t *file_entry, |
1615 | | int64_t *posix_time, |
1616 | | libcerror_error_t **error ) |
1617 | 0 | { |
1618 | 0 | libewf_internal_file_entry_t *internal_file_entry = NULL; |
1619 | 0 | static char *function = "libewf_file_entry_get_entry_modification_time"; |
1620 | 0 | int result = 1; |
1621 | |
|
1622 | 0 | if( file_entry == NULL ) |
1623 | 0 | { |
1624 | 0 | libcerror_error_set( |
1625 | 0 | error, |
1626 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1627 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1628 | 0 | "%s: invalid file entry.", |
1629 | 0 | function ); |
1630 | |
|
1631 | 0 | return( -1 ); |
1632 | 0 | } |
1633 | 0 | internal_file_entry = (libewf_internal_file_entry_t *) file_entry; |
1634 | |
|
1635 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
1636 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
1637 | 0 | internal_file_entry->read_write_lock, |
1638 | 0 | error ) != 1 ) |
1639 | 0 | { |
1640 | 0 | libcerror_error_set( |
1641 | 0 | error, |
1642 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1643 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1644 | 0 | "%s: unable to grab read/write lock for reading.", |
1645 | 0 | function ); |
1646 | |
|
1647 | 0 | return( -1 ); |
1648 | 0 | } |
1649 | 0 | #endif |
1650 | 0 | result = libewf_lef_file_entry_get_entry_modification_time( |
1651 | 0 | internal_file_entry->lef_file_entry, |
1652 | 0 | posix_time, |
1653 | 0 | error ); |
1654 | |
|
1655 | 0 | if( result == -1 ) |
1656 | 0 | { |
1657 | 0 | libcerror_error_set( |
1658 | 0 | error, |
1659 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1660 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
1661 | 0 | "%s: unable to retrieve entry modification time.", |
1662 | 0 | function ); |
1663 | |
|
1664 | 0 | result = -1; |
1665 | 0 | } |
1666 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
1667 | 0 | if( libcthreads_read_write_lock_release_for_read( |
1668 | 0 | internal_file_entry->read_write_lock, |
1669 | 0 | error ) != 1 ) |
1670 | 0 | { |
1671 | 0 | libcerror_error_set( |
1672 | 0 | error, |
1673 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1674 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1675 | 0 | "%s: unable to release read/write lock for reading.", |
1676 | 0 | function ); |
1677 | |
|
1678 | 0 | return( -1 ); |
1679 | 0 | } |
1680 | 0 | #endif |
1681 | 0 | return( result ); |
1682 | 0 | } |
1683 | | |
1684 | | /* Retrieves the deletion date and time |
1685 | | * The date and time is formatted as a POSIX timestamp |
1686 | | * Returns 1 if successful, 0 if not set or -1 on error |
1687 | | */ |
1688 | | int libewf_file_entry_get_deletion_time( |
1689 | | libewf_file_entry_t *file_entry, |
1690 | | int64_t *posix_time, |
1691 | | libcerror_error_t **error ) |
1692 | 0 | { |
1693 | 0 | libewf_internal_file_entry_t *internal_file_entry = NULL; |
1694 | 0 | static char *function = "libewf_file_entry_get_deletion_time"; |
1695 | 0 | int result = 1; |
1696 | |
|
1697 | 0 | if( file_entry == NULL ) |
1698 | 0 | { |
1699 | 0 | libcerror_error_set( |
1700 | 0 | error, |
1701 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1702 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1703 | 0 | "%s: invalid file entry.", |
1704 | 0 | function ); |
1705 | |
|
1706 | 0 | return( -1 ); |
1707 | 0 | } |
1708 | 0 | internal_file_entry = (libewf_internal_file_entry_t *) file_entry; |
1709 | |
|
1710 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
1711 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
1712 | 0 | internal_file_entry->read_write_lock, |
1713 | 0 | error ) != 1 ) |
1714 | 0 | { |
1715 | 0 | libcerror_error_set( |
1716 | 0 | error, |
1717 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1718 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1719 | 0 | "%s: unable to grab read/write lock for reading.", |
1720 | 0 | function ); |
1721 | |
|
1722 | 0 | return( -1 ); |
1723 | 0 | } |
1724 | 0 | #endif |
1725 | 0 | result = libewf_lef_file_entry_get_deletion_time( |
1726 | 0 | internal_file_entry->lef_file_entry, |
1727 | 0 | posix_time, |
1728 | 0 | error ); |
1729 | |
|
1730 | 0 | if( result == -1 ) |
1731 | 0 | { |
1732 | 0 | libcerror_error_set( |
1733 | 0 | error, |
1734 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1735 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
1736 | 0 | "%s: unable to retrieve deletion time.", |
1737 | 0 | function ); |
1738 | |
|
1739 | 0 | result = -1; |
1740 | 0 | } |
1741 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
1742 | 0 | if( libcthreads_read_write_lock_release_for_read( |
1743 | 0 | internal_file_entry->read_write_lock, |
1744 | 0 | error ) != 1 ) |
1745 | 0 | { |
1746 | 0 | libcerror_error_set( |
1747 | 0 | error, |
1748 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1749 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1750 | 0 | "%s: unable to release read/write lock for reading.", |
1751 | 0 | function ); |
1752 | |
|
1753 | 0 | return( -1 ); |
1754 | 0 | } |
1755 | 0 | #endif |
1756 | 0 | return( result ); |
1757 | 0 | } |
1758 | | |
1759 | | /* Retrieves the UTF-8 encoded MD5 hash value |
1760 | | * The size should include the end of string character |
1761 | | * Returns 1 if successful, 0 if not set or -1 on error |
1762 | | */ |
1763 | | int libewf_file_entry_get_utf8_hash_value_md5( |
1764 | | libewf_file_entry_t *file_entry, |
1765 | | uint8_t *utf8_string, |
1766 | | size_t utf8_string_size, |
1767 | | libcerror_error_t **error ) |
1768 | 0 | { |
1769 | 0 | libewf_internal_file_entry_t *internal_file_entry = NULL; |
1770 | 0 | static char *function = "libewf_file_entry_get_utf8_hash_value_md5"; |
1771 | 0 | int result = 0; |
1772 | |
|
1773 | 0 | if( file_entry == NULL ) |
1774 | 0 | { |
1775 | 0 | libcerror_error_set( |
1776 | 0 | error, |
1777 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1778 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1779 | 0 | "%s: invalid file entry.", |
1780 | 0 | function ); |
1781 | |
|
1782 | 0 | return( -1 ); |
1783 | 0 | } |
1784 | 0 | internal_file_entry = (libewf_internal_file_entry_t *) file_entry; |
1785 | |
|
1786 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
1787 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
1788 | 0 | internal_file_entry->read_write_lock, |
1789 | 0 | error ) != 1 ) |
1790 | 0 | { |
1791 | 0 | libcerror_error_set( |
1792 | 0 | error, |
1793 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1794 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1795 | 0 | "%s: unable to grab read/write lock for reading.", |
1796 | 0 | function ); |
1797 | |
|
1798 | 0 | return( -1 ); |
1799 | 0 | } |
1800 | 0 | #endif |
1801 | 0 | result = libewf_lef_file_entry_get_utf8_hash_value_md5( |
1802 | 0 | internal_file_entry->lef_file_entry, |
1803 | 0 | utf8_string, |
1804 | 0 | utf8_string_size, |
1805 | 0 | error ); |
1806 | |
|
1807 | 0 | if( result == -1 ) |
1808 | 0 | { |
1809 | 0 | libcerror_error_set( |
1810 | 0 | error, |
1811 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1812 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
1813 | 0 | "%s: unable to retrieve hash value: MD5.", |
1814 | 0 | function ); |
1815 | |
|
1816 | 0 | result = -1; |
1817 | 0 | } |
1818 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
1819 | 0 | if( libcthreads_read_write_lock_release_for_read( |
1820 | 0 | internal_file_entry->read_write_lock, |
1821 | 0 | error ) != 1 ) |
1822 | 0 | { |
1823 | 0 | libcerror_error_set( |
1824 | 0 | error, |
1825 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1826 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1827 | 0 | "%s: unable to release read/write lock for reading.", |
1828 | 0 | function ); |
1829 | |
|
1830 | 0 | return( -1 ); |
1831 | 0 | } |
1832 | 0 | #endif |
1833 | 0 | return( result ); |
1834 | 0 | } |
1835 | | |
1836 | | /* Retrieves the UTF-16 encoded MD5 hash value |
1837 | | * The size should include the end of string character |
1838 | | * Returns 1 if successful, 0 if not set or -1 on error |
1839 | | */ |
1840 | | int libewf_file_entry_get_utf16_hash_value_md5( |
1841 | | libewf_file_entry_t *file_entry, |
1842 | | uint16_t *utf16_string, |
1843 | | size_t utf16_string_size, |
1844 | | libcerror_error_t **error ) |
1845 | 0 | { |
1846 | 0 | libewf_internal_file_entry_t *internal_file_entry = NULL; |
1847 | 0 | static char *function = "libewf_file_entry_get_utf16_hash_value_md5"; |
1848 | 0 | int result = 0; |
1849 | |
|
1850 | 0 | if( file_entry == NULL ) |
1851 | 0 | { |
1852 | 0 | libcerror_error_set( |
1853 | 0 | error, |
1854 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1855 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1856 | 0 | "%s: invalid file entry.", |
1857 | 0 | function ); |
1858 | |
|
1859 | 0 | return( -1 ); |
1860 | 0 | } |
1861 | 0 | internal_file_entry = (libewf_internal_file_entry_t *) file_entry; |
1862 | |
|
1863 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
1864 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
1865 | 0 | internal_file_entry->read_write_lock, |
1866 | 0 | error ) != 1 ) |
1867 | 0 | { |
1868 | 0 | libcerror_error_set( |
1869 | 0 | error, |
1870 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1871 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1872 | 0 | "%s: unable to grab read/write lock for reading.", |
1873 | 0 | function ); |
1874 | |
|
1875 | 0 | return( -1 ); |
1876 | 0 | } |
1877 | 0 | #endif |
1878 | 0 | result = libewf_lef_file_entry_get_utf16_hash_value_md5( |
1879 | 0 | internal_file_entry->lef_file_entry, |
1880 | 0 | utf16_string, |
1881 | 0 | utf16_string_size, |
1882 | 0 | error ); |
1883 | |
|
1884 | 0 | if( result == -1 ) |
1885 | 0 | { |
1886 | 0 | libcerror_error_set( |
1887 | 0 | error, |
1888 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1889 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
1890 | 0 | "%s: unable to retrieve hash value: MD5.", |
1891 | 0 | function ); |
1892 | |
|
1893 | 0 | result = -1; |
1894 | 0 | } |
1895 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
1896 | 0 | if( libcthreads_read_write_lock_release_for_read( |
1897 | 0 | internal_file_entry->read_write_lock, |
1898 | 0 | error ) != 1 ) |
1899 | 0 | { |
1900 | 0 | libcerror_error_set( |
1901 | 0 | error, |
1902 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1903 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1904 | 0 | "%s: unable to release read/write lock for reading.", |
1905 | 0 | function ); |
1906 | |
|
1907 | 0 | return( -1 ); |
1908 | 0 | } |
1909 | 0 | #endif |
1910 | 0 | return( result ); |
1911 | 0 | } |
1912 | | |
1913 | | /* Retrieves the UTF-8 encoded SHA1 hash value |
1914 | | * The size should include the end of string character |
1915 | | * Returns 1 if successful, 0 if not set or -1 on error |
1916 | | */ |
1917 | | int libewf_file_entry_get_utf8_hash_value_sha1( |
1918 | | libewf_file_entry_t *file_entry, |
1919 | | uint8_t *utf8_string, |
1920 | | size_t utf8_string_size, |
1921 | | libcerror_error_t **error ) |
1922 | 0 | { |
1923 | 0 | libewf_internal_file_entry_t *internal_file_entry = NULL; |
1924 | 0 | static char *function = "libewf_file_entry_get_utf8_hash_value_sha1"; |
1925 | 0 | int result = 0; |
1926 | |
|
1927 | 0 | if( file_entry == NULL ) |
1928 | 0 | { |
1929 | 0 | libcerror_error_set( |
1930 | 0 | error, |
1931 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1932 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1933 | 0 | "%s: invalid file entry.", |
1934 | 0 | function ); |
1935 | |
|
1936 | 0 | return( -1 ); |
1937 | 0 | } |
1938 | 0 | internal_file_entry = (libewf_internal_file_entry_t *) file_entry; |
1939 | |
|
1940 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
1941 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
1942 | 0 | internal_file_entry->read_write_lock, |
1943 | 0 | error ) != 1 ) |
1944 | 0 | { |
1945 | 0 | libcerror_error_set( |
1946 | 0 | error, |
1947 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1948 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1949 | 0 | "%s: unable to grab read/write lock for reading.", |
1950 | 0 | function ); |
1951 | |
|
1952 | 0 | return( -1 ); |
1953 | 0 | } |
1954 | 0 | #endif |
1955 | 0 | result = libewf_lef_file_entry_get_utf8_hash_value_sha1( |
1956 | 0 | internal_file_entry->lef_file_entry, |
1957 | 0 | utf8_string, |
1958 | 0 | utf8_string_size, |
1959 | 0 | error ); |
1960 | |
|
1961 | 0 | if( result == -1 ) |
1962 | 0 | { |
1963 | 0 | libcerror_error_set( |
1964 | 0 | error, |
1965 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1966 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
1967 | 0 | "%s: unable to retrieve hash value: SHA1.", |
1968 | 0 | function ); |
1969 | |
|
1970 | 0 | result = -1; |
1971 | 0 | } |
1972 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
1973 | 0 | if( libcthreads_read_write_lock_release_for_read( |
1974 | 0 | internal_file_entry->read_write_lock, |
1975 | 0 | error ) != 1 ) |
1976 | 0 | { |
1977 | 0 | libcerror_error_set( |
1978 | 0 | error, |
1979 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1980 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1981 | 0 | "%s: unable to release read/write lock for reading.", |
1982 | 0 | function ); |
1983 | |
|
1984 | 0 | return( -1 ); |
1985 | 0 | } |
1986 | 0 | #endif |
1987 | 0 | return( result ); |
1988 | 0 | } |
1989 | | |
1990 | | /* Retrieves the UTF-16 encoded SHA1 hash value |
1991 | | * The size should include the end of string character |
1992 | | * Returns 1 if successful, 0 if not set or -1 on error |
1993 | | */ |
1994 | | int libewf_file_entry_get_utf16_hash_value_sha1( |
1995 | | libewf_file_entry_t *file_entry, |
1996 | | uint16_t *utf16_string, |
1997 | | size_t utf16_string_size, |
1998 | | libcerror_error_t **error ) |
1999 | 0 | { |
2000 | 0 | libewf_internal_file_entry_t *internal_file_entry = NULL; |
2001 | 0 | static char *function = "libewf_file_entry_get_utf16_hash_value_sha1"; |
2002 | 0 | int result = 0; |
2003 | |
|
2004 | 0 | if( file_entry == NULL ) |
2005 | 0 | { |
2006 | 0 | libcerror_error_set( |
2007 | 0 | error, |
2008 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2009 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2010 | 0 | "%s: invalid file entry.", |
2011 | 0 | function ); |
2012 | |
|
2013 | 0 | return( -1 ); |
2014 | 0 | } |
2015 | 0 | internal_file_entry = (libewf_internal_file_entry_t *) file_entry; |
2016 | |
|
2017 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
2018 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
2019 | 0 | internal_file_entry->read_write_lock, |
2020 | 0 | error ) != 1 ) |
2021 | 0 | { |
2022 | 0 | libcerror_error_set( |
2023 | 0 | error, |
2024 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2025 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
2026 | 0 | "%s: unable to grab read/write lock for reading.", |
2027 | 0 | function ); |
2028 | |
|
2029 | 0 | return( -1 ); |
2030 | 0 | } |
2031 | 0 | #endif |
2032 | 0 | result = libewf_lef_file_entry_get_utf16_hash_value_sha1( |
2033 | 0 | internal_file_entry->lef_file_entry, |
2034 | 0 | utf16_string, |
2035 | 0 | utf16_string_size, |
2036 | 0 | error ); |
2037 | |
|
2038 | 0 | if( result == -1 ) |
2039 | 0 | { |
2040 | 0 | libcerror_error_set( |
2041 | 0 | error, |
2042 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2043 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
2044 | 0 | "%s: unable to retrieve hash value: SHA1.", |
2045 | 0 | function ); |
2046 | |
|
2047 | 0 | result = -1; |
2048 | 0 | } |
2049 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
2050 | 0 | if( libcthreads_read_write_lock_release_for_read( |
2051 | 0 | internal_file_entry->read_write_lock, |
2052 | 0 | error ) != 1 ) |
2053 | 0 | { |
2054 | 0 | libcerror_error_set( |
2055 | 0 | error, |
2056 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2057 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
2058 | 0 | "%s: unable to release read/write lock for reading.", |
2059 | 0 | function ); |
2060 | |
|
2061 | 0 | return( -1 ); |
2062 | 0 | } |
2063 | 0 | #endif |
2064 | 0 | return( result ); |
2065 | 0 | } |
2066 | | |
2067 | | /* Reads data at the current offset |
2068 | | * This function is not multi-thread safe acquire write lock before call |
2069 | | * Returns the number of bytes read or -1 on error |
2070 | | */ |
2071 | | ssize_t libewf_internal_file_entry_read_buffer( |
2072 | | libewf_internal_file_entry_t *internal_file_entry, |
2073 | | libewf_lef_file_entry_t *lef_file_entry, |
2074 | | void *buffer, |
2075 | | size_t buffer_size, |
2076 | | libcerror_error_t **error ) |
2077 | 0 | { |
2078 | 0 | static char *function = "libewf_internal_file_entry_read_buffer"; |
2079 | 0 | size64_t data_size = 0; |
2080 | 0 | size64_t size = 0; |
2081 | 0 | size_t read_size = 0; |
2082 | 0 | ssize_t read_count = 0; |
2083 | 0 | off64_t data_offset = 0; |
2084 | 0 | off64_t duplicate_data_offset = 0; |
2085 | 0 | uint32_t flags = 0; |
2086 | |
|
2087 | 0 | if( internal_file_entry == NULL ) |
2088 | 0 | { |
2089 | 0 | libcerror_error_set( |
2090 | 0 | error, |
2091 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2092 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2093 | 0 | "%s: invalid file entry.", |
2094 | 0 | function ); |
2095 | |
|
2096 | 0 | return( -1 ); |
2097 | 0 | } |
2098 | 0 | if( internal_file_entry->offset < 0 ) |
2099 | 0 | { |
2100 | 0 | libcerror_error_set( |
2101 | 0 | error, |
2102 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2103 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS, |
2104 | 0 | "%s: invalid file entry - offset value out of bounds.", |
2105 | 0 | function ); |
2106 | |
|
2107 | 0 | return( -1 ); |
2108 | 0 | } |
2109 | 0 | if( buffer == NULL ) |
2110 | 0 | { |
2111 | 0 | libcerror_error_set( |
2112 | 0 | error, |
2113 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2114 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2115 | 0 | "%s: invalid buffer.", |
2116 | 0 | function ); |
2117 | |
|
2118 | 0 | return( -1 ); |
2119 | 0 | } |
2120 | 0 | if( buffer_size > (size_t) SSIZE_MAX ) |
2121 | 0 | { |
2122 | 0 | libcerror_error_set( |
2123 | 0 | error, |
2124 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2125 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM, |
2126 | 0 | "%s: invalid buffer size value exceeds maximum.", |
2127 | 0 | function ); |
2128 | |
|
2129 | 0 | return( -1 ); |
2130 | 0 | } |
2131 | 0 | if( libewf_lef_file_entry_get_size( |
2132 | 0 | lef_file_entry, |
2133 | 0 | &size, |
2134 | 0 | error ) != 1 ) |
2135 | 0 | { |
2136 | 0 | libcerror_error_set( |
2137 | 0 | error, |
2138 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2139 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
2140 | 0 | "%s: unable to retrieve size.", |
2141 | 0 | function ); |
2142 | |
|
2143 | 0 | return( -1 ); |
2144 | 0 | } |
2145 | 0 | if( libewf_lef_file_entry_get_data_offset( |
2146 | 0 | lef_file_entry, |
2147 | 0 | &data_offset, |
2148 | 0 | error ) != 1 ) |
2149 | 0 | { |
2150 | 0 | libcerror_error_set( |
2151 | 0 | error, |
2152 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2153 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
2154 | 0 | "%s: unable to retrieve data offset.", |
2155 | 0 | function ); |
2156 | |
|
2157 | 0 | return( -1 ); |
2158 | 0 | } |
2159 | 0 | if( libewf_lef_file_entry_get_data_size( |
2160 | 0 | lef_file_entry, |
2161 | 0 | &data_size, |
2162 | 0 | error ) != 1 ) |
2163 | 0 | { |
2164 | 0 | libcerror_error_set( |
2165 | 0 | error, |
2166 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2167 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
2168 | 0 | "%s: unable to retrieve data size.", |
2169 | 0 | function ); |
2170 | |
|
2171 | 0 | return( -1 ); |
2172 | 0 | } |
2173 | 0 | if( libewf_lef_file_entry_get_flags( |
2174 | 0 | lef_file_entry, |
2175 | 0 | &flags, |
2176 | 0 | error ) != 1 ) |
2177 | 0 | { |
2178 | 0 | libcerror_error_set( |
2179 | 0 | error, |
2180 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2181 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
2182 | 0 | "%s: unable to retrieve flags.", |
2183 | 0 | function ); |
2184 | |
|
2185 | 0 | return( -1 ); |
2186 | 0 | } |
2187 | 0 | if( ( flags & LIBEWF_FILE_ENTRY_FLAG_SPARSE_DATA ) == 0 ) |
2188 | 0 | { |
2189 | 0 | if( ( ( size == 0 ) |
2190 | 0 | && ( data_size != 1 ) ) |
2191 | 0 | || ( ( size != 0 ) |
2192 | 0 | && ( data_size != size ) ) ) |
2193 | 0 | { |
2194 | 0 | libcerror_error_set( |
2195 | 0 | error, |
2196 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2197 | 0 | LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE, |
2198 | 0 | "%s: unsupported data size.", |
2199 | 0 | function ); |
2200 | |
|
2201 | 0 | return( -1 ); |
2202 | 0 | } |
2203 | 0 | } |
2204 | 0 | else |
2205 | 0 | { |
2206 | 0 | if( ( data_size != 1 ) |
2207 | 0 | && ( data_size != size ) ) |
2208 | 0 | { |
2209 | 0 | libcerror_error_set( |
2210 | 0 | error, |
2211 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2212 | 0 | LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE, |
2213 | 0 | "%s: unsupported data size.", |
2214 | 0 | function ); |
2215 | |
|
2216 | 0 | return( -1 ); |
2217 | 0 | } |
2218 | 0 | if( libewf_lef_file_entry_get_duplicate_data_offset( |
2219 | 0 | lef_file_entry, |
2220 | 0 | &duplicate_data_offset, |
2221 | 0 | error ) != 1 ) |
2222 | 0 | { |
2223 | 0 | libcerror_error_set( |
2224 | 0 | error, |
2225 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2226 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
2227 | 0 | "%s: unable to retrieve duplicate data offset.", |
2228 | 0 | function ); |
2229 | |
|
2230 | 0 | return( -1 ); |
2231 | 0 | } |
2232 | 0 | } |
2233 | 0 | if( internal_file_entry->offset >= (off64_t) size ) |
2234 | 0 | { |
2235 | 0 | return( 0 ); |
2236 | 0 | } |
2237 | 0 | if( (off64_t) ( internal_file_entry->offset + buffer_size ) > (off64_t) size ) |
2238 | 0 | { |
2239 | 0 | buffer_size = (size_t) ( size - internal_file_entry->offset ); |
2240 | 0 | } |
2241 | 0 | if( ( flags & LIBEWF_FILE_ENTRY_FLAG_SPARSE_DATA ) == 0 ) |
2242 | 0 | { |
2243 | 0 | data_offset += internal_file_entry->offset; |
2244 | 0 | read_size = buffer_size; |
2245 | 0 | } |
2246 | 0 | else if( duplicate_data_offset >= 0 ) |
2247 | 0 | { |
2248 | 0 | data_offset = duplicate_data_offset + internal_file_entry->offset; |
2249 | 0 | read_size = buffer_size; |
2250 | 0 | } |
2251 | 0 | else |
2252 | 0 | { |
2253 | 0 | read_size = 1; |
2254 | 0 | } |
2255 | 0 | read_count = libewf_handle_read_buffer_at_offset( |
2256 | 0 | internal_file_entry->handle, |
2257 | 0 | buffer, |
2258 | 0 | read_size, |
2259 | 0 | data_offset, |
2260 | 0 | error ); |
2261 | |
|
2262 | 0 | if( read_count <= -1 ) |
2263 | 0 | { |
2264 | 0 | libcerror_error_set( |
2265 | 0 | error, |
2266 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
2267 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
2268 | 0 | "%s: unable to read buffer.", |
2269 | 0 | function ); |
2270 | |
|
2271 | 0 | return( -1 ); |
2272 | 0 | } |
2273 | 0 | internal_file_entry->offset += read_count; |
2274 | |
|
2275 | 0 | if( ( flags & LIBEWF_FILE_ENTRY_FLAG_SPARSE_DATA ) != 0 ) |
2276 | 0 | { |
2277 | 0 | if( read_count == 1 ) |
2278 | 0 | { |
2279 | 0 | if( memory_set( |
2280 | 0 | &( ( (uint8_t *) buffer )[ 1 ] ), |
2281 | 0 | ( (uint8_t *) buffer )[ 0 ], |
2282 | 0 | buffer_size - 1 ) == NULL ) |
2283 | 0 | { |
2284 | 0 | libcerror_error_set( |
2285 | 0 | error, |
2286 | 0 | LIBCERROR_ERROR_DOMAIN_MEMORY, |
2287 | 0 | LIBCERROR_MEMORY_ERROR_SET_FAILED, |
2288 | 0 | "%s: unable to set sparse data in buffer.", |
2289 | 0 | function ); |
2290 | |
|
2291 | 0 | return( -1 ); |
2292 | 0 | } |
2293 | 0 | read_count = (ssize_t) buffer_size; |
2294 | 0 | } |
2295 | 0 | } |
2296 | 0 | return( read_count ); |
2297 | 0 | } |
2298 | | |
2299 | | /* Reads data at the current offset |
2300 | | * Returns the number of bytes read or -1 on error |
2301 | | */ |
2302 | | ssize_t libewf_file_entry_read_buffer( |
2303 | | libewf_file_entry_t *file_entry, |
2304 | | void *buffer, |
2305 | | size_t buffer_size, |
2306 | | libcerror_error_t **error ) |
2307 | 0 | { |
2308 | 0 | libewf_internal_file_entry_t *internal_file_entry = NULL; |
2309 | 0 | static char *function = "libewf_file_entry_read_buffer"; |
2310 | 0 | ssize_t read_count = 0; |
2311 | |
|
2312 | 0 | if( file_entry == NULL ) |
2313 | 0 | { |
2314 | 0 | libcerror_error_set( |
2315 | 0 | error, |
2316 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2317 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2318 | 0 | "%s: invalid handle.", |
2319 | 0 | function ); |
2320 | |
|
2321 | 0 | return( -1 ); |
2322 | 0 | } |
2323 | 0 | internal_file_entry = (libewf_internal_file_entry_t *) file_entry; |
2324 | |
|
2325 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
2326 | 0 | if( libcthreads_read_write_lock_grab_for_write( |
2327 | 0 | internal_file_entry->read_write_lock, |
2328 | 0 | error ) != 1 ) |
2329 | 0 | { |
2330 | 0 | libcerror_error_set( |
2331 | 0 | error, |
2332 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2333 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
2334 | 0 | "%s: unable to grab read/write lock for writing.", |
2335 | 0 | function ); |
2336 | |
|
2337 | 0 | return( -1 ); |
2338 | 0 | } |
2339 | 0 | #endif |
2340 | 0 | read_count = libewf_internal_file_entry_read_buffer( |
2341 | 0 | internal_file_entry, |
2342 | 0 | internal_file_entry->lef_file_entry, |
2343 | 0 | buffer, |
2344 | 0 | buffer_size, |
2345 | 0 | error ); |
2346 | |
|
2347 | 0 | if( read_count == -1 ) |
2348 | 0 | { |
2349 | 0 | libcerror_error_set( |
2350 | 0 | error, |
2351 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
2352 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
2353 | 0 | "%s: unable to read buffer.", |
2354 | 0 | function ); |
2355 | |
|
2356 | 0 | read_count = -1; |
2357 | 0 | } |
2358 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
2359 | 0 | if( libcthreads_read_write_lock_release_for_write( |
2360 | 0 | internal_file_entry->read_write_lock, |
2361 | 0 | error ) != 1 ) |
2362 | 0 | { |
2363 | 0 | libcerror_error_set( |
2364 | 0 | error, |
2365 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2366 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
2367 | 0 | "%s: unable to release read/write lock for writing.", |
2368 | 0 | function ); |
2369 | |
|
2370 | 0 | return( -1 ); |
2371 | 0 | } |
2372 | 0 | #endif |
2373 | 0 | return( read_count ); |
2374 | 0 | } |
2375 | | |
2376 | | /* Reads data at a specific offset |
2377 | | * Returns the number of bytes read or -1 on error |
2378 | | */ |
2379 | | ssize_t libewf_file_entry_read_buffer_at_offset( |
2380 | | libewf_file_entry_t *file_entry, |
2381 | | void *buffer, |
2382 | | size_t buffer_size, |
2383 | | off64_t offset, |
2384 | | libcerror_error_t **error ) |
2385 | 0 | { |
2386 | 0 | libewf_internal_file_entry_t *internal_file_entry = NULL; |
2387 | 0 | static char *function = "libewf_file_entry_read_buffer_at_offset"; |
2388 | 0 | ssize_t read_count = 0; |
2389 | |
|
2390 | 0 | if( file_entry == NULL ) |
2391 | 0 | { |
2392 | 0 | libcerror_error_set( |
2393 | 0 | error, |
2394 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2395 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2396 | 0 | "%s: invalid handle.", |
2397 | 0 | function ); |
2398 | |
|
2399 | 0 | return( -1 ); |
2400 | 0 | } |
2401 | 0 | internal_file_entry = (libewf_internal_file_entry_t *) file_entry; |
2402 | |
|
2403 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
2404 | 0 | if( libcthreads_read_write_lock_grab_for_write( |
2405 | 0 | internal_file_entry->read_write_lock, |
2406 | 0 | error ) != 1 ) |
2407 | 0 | { |
2408 | 0 | libcerror_error_set( |
2409 | 0 | error, |
2410 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2411 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
2412 | 0 | "%s: unable to grab read/write lock for writing.", |
2413 | 0 | function ); |
2414 | |
|
2415 | 0 | return( -1 ); |
2416 | 0 | } |
2417 | 0 | #endif |
2418 | 0 | offset = libewf_internal_file_entry_seek_offset( |
2419 | 0 | internal_file_entry, |
2420 | 0 | internal_file_entry->lef_file_entry, |
2421 | 0 | offset, |
2422 | 0 | SEEK_SET, |
2423 | 0 | error ); |
2424 | |
|
2425 | 0 | if( offset == -1 ) |
2426 | 0 | { |
2427 | 0 | libcerror_error_set( |
2428 | 0 | error, |
2429 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
2430 | 0 | LIBCERROR_IO_ERROR_SEEK_FAILED, |
2431 | 0 | "%s: unable to seek offset.", |
2432 | 0 | function ); |
2433 | |
|
2434 | 0 | read_count = -1; |
2435 | 0 | } |
2436 | 0 | else |
2437 | 0 | { |
2438 | 0 | read_count = libewf_internal_file_entry_read_buffer( |
2439 | 0 | internal_file_entry, |
2440 | 0 | internal_file_entry->lef_file_entry, |
2441 | 0 | buffer, |
2442 | 0 | buffer_size, |
2443 | 0 | error ); |
2444 | |
|
2445 | 0 | if( read_count == -1 ) |
2446 | 0 | { |
2447 | 0 | libcerror_error_set( |
2448 | 0 | error, |
2449 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
2450 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
2451 | 0 | "%s: unable to read buffer.", |
2452 | 0 | function ); |
2453 | |
|
2454 | 0 | read_count = -1; |
2455 | 0 | } |
2456 | 0 | } |
2457 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
2458 | 0 | if( libcthreads_read_write_lock_release_for_write( |
2459 | 0 | internal_file_entry->read_write_lock, |
2460 | 0 | error ) != 1 ) |
2461 | 0 | { |
2462 | 0 | libcerror_error_set( |
2463 | 0 | error, |
2464 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2465 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
2466 | 0 | "%s: unable to release read/write lock for writing.", |
2467 | 0 | function ); |
2468 | |
|
2469 | 0 | return( -1 ); |
2470 | 0 | } |
2471 | 0 | #endif |
2472 | 0 | return( read_count ); |
2473 | 0 | } |
2474 | | |
2475 | | /* Seeks a certain offset of the data |
2476 | | * This function is not multi-thread safe acquire write lock before call |
2477 | | * Returns the offset if seek is successful or -1 on error |
2478 | | */ |
2479 | | off64_t libewf_internal_file_entry_seek_offset( |
2480 | | libewf_internal_file_entry_t *internal_file_entry, |
2481 | | libewf_lef_file_entry_t *lef_file_entry, |
2482 | | off64_t offset, |
2483 | | int whence, |
2484 | | libcerror_error_t **error ) |
2485 | 0 | { |
2486 | 0 | static char *function = "libewf_internal_file_entry_seek_offset"; |
2487 | 0 | size64_t size = 0; |
2488 | |
|
2489 | 0 | if( internal_file_entry == NULL ) |
2490 | 0 | { |
2491 | 0 | libcerror_error_set( |
2492 | 0 | error, |
2493 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2494 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2495 | 0 | "%s: invalid file entry.", |
2496 | 0 | function ); |
2497 | |
|
2498 | 0 | return( -1 ); |
2499 | 0 | } |
2500 | 0 | if( libewf_lef_file_entry_get_size( |
2501 | 0 | lef_file_entry, |
2502 | 0 | &size, |
2503 | 0 | error ) != 1 ) |
2504 | 0 | { |
2505 | 0 | libcerror_error_set( |
2506 | 0 | error, |
2507 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2508 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
2509 | 0 | "%s: unable to retrieve size.", |
2510 | 0 | function ); |
2511 | |
|
2512 | 0 | return( -1 ); |
2513 | 0 | } |
2514 | 0 | if( ( whence != SEEK_CUR ) |
2515 | 0 | && ( whence != SEEK_END ) |
2516 | 0 | && ( whence != SEEK_SET ) ) |
2517 | 0 | { |
2518 | 0 | libcerror_error_set( |
2519 | 0 | error, |
2520 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2521 | 0 | LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE, |
2522 | 0 | "%s: unsupported whence.", |
2523 | 0 | function ); |
2524 | |
|
2525 | 0 | return( -1 ); |
2526 | 0 | } |
2527 | 0 | if( whence == SEEK_CUR ) |
2528 | 0 | { |
2529 | 0 | offset += internal_file_entry->offset; |
2530 | 0 | } |
2531 | 0 | else if( whence == SEEK_END ) |
2532 | 0 | { |
2533 | 0 | offset += (off64_t) size; |
2534 | 0 | } |
2535 | | #if defined( HAVE_DEBUG_OUTPUT ) |
2536 | | if( libcnotify_verbose != 0 ) |
2537 | | { |
2538 | | libcnotify_printf( |
2539 | | "%s: seeking offset: %" PRIi64 ".\n", |
2540 | | function, |
2541 | | offset ); |
2542 | | } |
2543 | | #endif |
2544 | 0 | if( offset < 0 ) |
2545 | 0 | { |
2546 | 0 | libcerror_error_set( |
2547 | 0 | error, |
2548 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2549 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS, |
2550 | 0 | "%s: invalid offset value out of bounds.", |
2551 | 0 | function ); |
2552 | |
|
2553 | 0 | return( -1 ); |
2554 | 0 | } |
2555 | 0 | internal_file_entry->offset = offset; |
2556 | |
|
2557 | 0 | return( offset ); |
2558 | 0 | } |
2559 | | |
2560 | | /* Seeks a certain offset of the data |
2561 | | * Returns the offset if seek is successful or -1 on error |
2562 | | */ |
2563 | | off64_t libewf_file_entry_seek_offset( |
2564 | | libewf_file_entry_t *file_entry, |
2565 | | off64_t offset, |
2566 | | int whence, |
2567 | | libcerror_error_t **error ) |
2568 | 0 | { |
2569 | 0 | libewf_internal_file_entry_t *internal_file_entry = NULL; |
2570 | 0 | static char *function = "libewf_file_entry_seek_offset"; |
2571 | |
|
2572 | 0 | if( file_entry == NULL ) |
2573 | 0 | { |
2574 | 0 | libcerror_error_set( |
2575 | 0 | error, |
2576 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2577 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2578 | 0 | "%s: invalid handle.", |
2579 | 0 | function ); |
2580 | |
|
2581 | 0 | return( -1 ); |
2582 | 0 | } |
2583 | 0 | internal_file_entry = (libewf_internal_file_entry_t *) file_entry; |
2584 | |
|
2585 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
2586 | 0 | if( libcthreads_read_write_lock_grab_for_write( |
2587 | 0 | internal_file_entry->read_write_lock, |
2588 | 0 | error ) != 1 ) |
2589 | 0 | { |
2590 | 0 | libcerror_error_set( |
2591 | 0 | error, |
2592 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2593 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
2594 | 0 | "%s: unable to grab read/write lock for writing.", |
2595 | 0 | function ); |
2596 | |
|
2597 | 0 | return( -1 ); |
2598 | 0 | } |
2599 | 0 | #endif |
2600 | 0 | offset = libewf_internal_file_entry_seek_offset( |
2601 | 0 | internal_file_entry, |
2602 | 0 | internal_file_entry->lef_file_entry, |
2603 | 0 | offset, |
2604 | 0 | whence, |
2605 | 0 | error ); |
2606 | |
|
2607 | 0 | if( offset == -1 ) |
2608 | 0 | { |
2609 | 0 | libcerror_error_set( |
2610 | 0 | error, |
2611 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
2612 | 0 | LIBCERROR_IO_ERROR_SEEK_FAILED, |
2613 | 0 | "%s: unable to seek offset.", |
2614 | 0 | function ); |
2615 | |
|
2616 | 0 | offset = -1; |
2617 | 0 | } |
2618 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
2619 | 0 | if( libcthreads_read_write_lock_release_for_write( |
2620 | 0 | internal_file_entry->read_write_lock, |
2621 | 0 | error ) != 1 ) |
2622 | 0 | { |
2623 | 0 | libcerror_error_set( |
2624 | 0 | error, |
2625 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2626 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
2627 | 0 | "%s: unable to release read/write lock for writing.", |
2628 | 0 | function ); |
2629 | |
|
2630 | 0 | return( -1 ); |
2631 | 0 | } |
2632 | 0 | #endif |
2633 | 0 | return( offset ); |
2634 | 0 | } |
2635 | | |
2636 | | /* Retrieves the current offset of the data |
2637 | | * Returns the offset if successful or -1 on error |
2638 | | */ |
2639 | | int libewf_file_entry_get_offset( |
2640 | | libewf_file_entry_t *file_entry, |
2641 | | off64_t *offset, |
2642 | | libcerror_error_t **error ) |
2643 | 0 | { |
2644 | 0 | libewf_internal_file_entry_t *internal_file_entry = NULL; |
2645 | 0 | static char *function = "libewf_file_entry_get_offset"; |
2646 | |
|
2647 | 0 | if( file_entry == NULL ) |
2648 | 0 | { |
2649 | 0 | libcerror_error_set( |
2650 | 0 | error, |
2651 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2652 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2653 | 0 | "%s: invalid file entry.", |
2654 | 0 | function ); |
2655 | |
|
2656 | 0 | return( -1 ); |
2657 | 0 | } |
2658 | 0 | internal_file_entry = (libewf_internal_file_entry_t *) file_entry; |
2659 | |
|
2660 | 0 | if( offset == NULL ) |
2661 | 0 | { |
2662 | 0 | libcerror_error_set( |
2663 | 0 | error, |
2664 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2665 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2666 | 0 | "%s: invalid offset.", |
2667 | 0 | function ); |
2668 | |
|
2669 | 0 | return( -1 ); |
2670 | 0 | } |
2671 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
2672 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
2673 | 0 | internal_file_entry->read_write_lock, |
2674 | 0 | error ) != 1 ) |
2675 | 0 | { |
2676 | 0 | libcerror_error_set( |
2677 | 0 | error, |
2678 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2679 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
2680 | 0 | "%s: unable to grab read/write lock for reading.", |
2681 | 0 | function ); |
2682 | |
|
2683 | 0 | return( -1 ); |
2684 | 0 | } |
2685 | 0 | #endif |
2686 | 0 | *offset = internal_file_entry->offset; |
2687 | |
|
2688 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
2689 | 0 | if( libcthreads_read_write_lock_release_for_read( |
2690 | 0 | internal_file_entry->read_write_lock, |
2691 | 0 | error ) != 1 ) |
2692 | 0 | { |
2693 | 0 | libcerror_error_set( |
2694 | 0 | error, |
2695 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2696 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
2697 | 0 | "%s: unable to release read/write lock for reading.", |
2698 | 0 | function ); |
2699 | |
|
2700 | 0 | return( -1 ); |
2701 | 0 | } |
2702 | 0 | #endif |
2703 | 0 | return( 1 ); |
2704 | 0 | } |
2705 | | |
2706 | | /* Retrieves the number of sub file entries |
2707 | | * Returns 1 if successful or -1 on error |
2708 | | */ |
2709 | | int libewf_file_entry_get_number_of_sub_file_entries( |
2710 | | libewf_file_entry_t *file_entry, |
2711 | | int *number_of_sub_file_entries, |
2712 | | libcerror_error_t **error ) |
2713 | 0 | { |
2714 | 0 | libewf_internal_file_entry_t *internal_file_entry = NULL; |
2715 | 0 | static char *function = "libewf_file_entry_get_number_of_sub_file_entries"; |
2716 | 0 | int result = 1; |
2717 | |
|
2718 | 0 | if( file_entry == NULL ) |
2719 | 0 | { |
2720 | 0 | libcerror_error_set( |
2721 | 0 | error, |
2722 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2723 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2724 | 0 | "%s: invalid file entry.", |
2725 | 0 | function ); |
2726 | |
|
2727 | 0 | return( -1 ); |
2728 | 0 | } |
2729 | 0 | internal_file_entry = (libewf_internal_file_entry_t *) file_entry; |
2730 | |
|
2731 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
2732 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
2733 | 0 | internal_file_entry->read_write_lock, |
2734 | 0 | error ) != 1 ) |
2735 | 0 | { |
2736 | 0 | libcerror_error_set( |
2737 | 0 | error, |
2738 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2739 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
2740 | 0 | "%s: unable to grab read/write lock for reading.", |
2741 | 0 | function ); |
2742 | |
|
2743 | 0 | return( -1 ); |
2744 | 0 | } |
2745 | 0 | #endif |
2746 | 0 | if( libcdata_tree_node_get_number_of_sub_nodes( |
2747 | 0 | internal_file_entry->file_entry_tree_node, |
2748 | 0 | number_of_sub_file_entries, |
2749 | 0 | error ) != 1 ) |
2750 | 0 | { |
2751 | 0 | libcerror_error_set( |
2752 | 0 | error, |
2753 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2754 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
2755 | 0 | "%s: unable to retrieve number of sub file entries.", |
2756 | 0 | function ); |
2757 | |
|
2758 | 0 | result = -1; |
2759 | 0 | } |
2760 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
2761 | 0 | if( libcthreads_read_write_lock_release_for_read( |
2762 | 0 | internal_file_entry->read_write_lock, |
2763 | 0 | error ) != 1 ) |
2764 | 0 | { |
2765 | 0 | libcerror_error_set( |
2766 | 0 | error, |
2767 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2768 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
2769 | 0 | "%s: unable to release read/write lock for reading.", |
2770 | 0 | function ); |
2771 | |
|
2772 | 0 | return( -1 ); |
2773 | 0 | } |
2774 | 0 | #endif |
2775 | 0 | return( result ); |
2776 | 0 | } |
2777 | | |
2778 | | /* Retrieves the sub file entry for the specific index |
2779 | | * Returns 1 if successful or -1 on error |
2780 | | */ |
2781 | | int libewf_file_entry_get_sub_file_entry( |
2782 | | libewf_file_entry_t *file_entry, |
2783 | | int sub_file_entry_index, |
2784 | | libewf_file_entry_t **sub_file_entry, |
2785 | | libcerror_error_t **error ) |
2786 | 0 | { |
2787 | 0 | libewf_internal_file_entry_t *internal_file_entry = NULL; |
2788 | 0 | libcdata_tree_node_t *sub_node = NULL; |
2789 | 0 | static char *function = "libewf_file_entry_get_sub_file_entry"; |
2790 | 0 | int result = 1; |
2791 | |
|
2792 | 0 | if( file_entry == NULL ) |
2793 | 0 | { |
2794 | 0 | libcerror_error_set( |
2795 | 0 | error, |
2796 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2797 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2798 | 0 | "%s: invalid file entry.", |
2799 | 0 | function ); |
2800 | |
|
2801 | 0 | return( -1 ); |
2802 | 0 | } |
2803 | 0 | internal_file_entry = (libewf_internal_file_entry_t *) file_entry; |
2804 | |
|
2805 | 0 | if( sub_file_entry == NULL ) |
2806 | 0 | { |
2807 | 0 | libcerror_error_set( |
2808 | 0 | error, |
2809 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2810 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2811 | 0 | "%s: invalid sub file entry.", |
2812 | 0 | function ); |
2813 | |
|
2814 | 0 | return( -1 ); |
2815 | 0 | } |
2816 | 0 | if( *sub_file_entry != NULL ) |
2817 | 0 | { |
2818 | 0 | libcerror_error_set( |
2819 | 0 | error, |
2820 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2821 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET, |
2822 | 0 | "%s: sub file entry already set.", |
2823 | 0 | function ); |
2824 | |
|
2825 | 0 | return( -1 ); |
2826 | 0 | } |
2827 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
2828 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
2829 | 0 | internal_file_entry->read_write_lock, |
2830 | 0 | error ) != 1 ) |
2831 | 0 | { |
2832 | 0 | libcerror_error_set( |
2833 | 0 | error, |
2834 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2835 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
2836 | 0 | "%s: unable to grab read/write lock for reading.", |
2837 | 0 | function ); |
2838 | |
|
2839 | 0 | return( -1 ); |
2840 | 0 | } |
2841 | 0 | #endif |
2842 | 0 | if( libcdata_tree_node_get_sub_node_by_index( |
2843 | 0 | internal_file_entry->file_entry_tree_node, |
2844 | 0 | sub_file_entry_index, |
2845 | 0 | &sub_node, |
2846 | 0 | error ) != 1 ) |
2847 | 0 | { |
2848 | 0 | libcerror_error_set( |
2849 | 0 | error, |
2850 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2851 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
2852 | 0 | "%s: unable to retrieve sub file entry tree node.", |
2853 | 0 | function ); |
2854 | |
|
2855 | 0 | result = -1; |
2856 | 0 | } |
2857 | 0 | else if( libewf_file_entry_initialize( |
2858 | 0 | sub_file_entry, |
2859 | 0 | internal_file_entry->handle, |
2860 | 0 | internal_file_entry->single_files, |
2861 | 0 | sub_node, |
2862 | 0 | error ) != 1 ) |
2863 | 0 | { |
2864 | 0 | libcerror_error_set( |
2865 | 0 | error, |
2866 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2867 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
2868 | 0 | "%s: unable to initialize sub file entry.", |
2869 | 0 | function ); |
2870 | |
|
2871 | 0 | result = -1; |
2872 | 0 | } |
2873 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
2874 | 0 | if( libcthreads_read_write_lock_release_for_read( |
2875 | 0 | internal_file_entry->read_write_lock, |
2876 | 0 | error ) != 1 ) |
2877 | 0 | { |
2878 | 0 | libcerror_error_set( |
2879 | 0 | error, |
2880 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2881 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
2882 | 0 | "%s: unable to release read/write lock for reading.", |
2883 | 0 | function ); |
2884 | |
|
2885 | 0 | return( -1 ); |
2886 | 0 | } |
2887 | 0 | #endif |
2888 | 0 | return( result ); |
2889 | 0 | } |
2890 | | |
2891 | | /* Retrieves the sub file entry for the specific UTF-8 encoded name |
2892 | | * Returns 1 if successful, 0 if not such value or -1 on error |
2893 | | */ |
2894 | | int libewf_file_entry_get_sub_file_entry_by_utf8_name( |
2895 | | libewf_file_entry_t *file_entry, |
2896 | | const uint8_t *utf8_string, |
2897 | | size_t utf8_string_length, |
2898 | | libewf_file_entry_t **sub_file_entry, |
2899 | | libcerror_error_t **error ) |
2900 | 0 | { |
2901 | 0 | libcdata_tree_node_t *sub_node = NULL; |
2902 | 0 | libewf_internal_file_entry_t *internal_file_entry = NULL; |
2903 | 0 | libewf_lef_file_entry_t *sub_lef_file_entry = NULL; |
2904 | 0 | static char *function = "libewf_file_entry_get_sub_file_entry_by_utf8_name"; |
2905 | 0 | int result = 0; |
2906 | |
|
2907 | 0 | if( file_entry == NULL ) |
2908 | 0 | { |
2909 | 0 | libcerror_error_set( |
2910 | 0 | error, |
2911 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2912 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2913 | 0 | "%s: invalid file entry.", |
2914 | 0 | function ); |
2915 | |
|
2916 | 0 | return( -1 ); |
2917 | 0 | } |
2918 | 0 | internal_file_entry = (libewf_internal_file_entry_t *) file_entry; |
2919 | |
|
2920 | 0 | if( sub_file_entry == NULL ) |
2921 | 0 | { |
2922 | 0 | libcerror_error_set( |
2923 | 0 | error, |
2924 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2925 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2926 | 0 | "%s: invalid sub file entry.", |
2927 | 0 | function ); |
2928 | |
|
2929 | 0 | return( -1 ); |
2930 | 0 | } |
2931 | 0 | if( *sub_file_entry != NULL ) |
2932 | 0 | { |
2933 | 0 | libcerror_error_set( |
2934 | 0 | error, |
2935 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2936 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET, |
2937 | 0 | "%s: sub file entry already set.", |
2938 | 0 | function ); |
2939 | |
|
2940 | 0 | return( -1 ); |
2941 | 0 | } |
2942 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
2943 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
2944 | 0 | internal_file_entry->read_write_lock, |
2945 | 0 | error ) != 1 ) |
2946 | 0 | { |
2947 | 0 | libcerror_error_set( |
2948 | 0 | error, |
2949 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2950 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
2951 | 0 | "%s: unable to grab read/write lock for reading.", |
2952 | 0 | function ); |
2953 | |
|
2954 | 0 | return( -1 ); |
2955 | 0 | } |
2956 | 0 | #endif |
2957 | 0 | result = libewf_single_file_tree_get_sub_node_by_utf8_name( |
2958 | 0 | internal_file_entry->file_entry_tree_node, |
2959 | 0 | utf8_string, |
2960 | 0 | utf8_string_length, |
2961 | 0 | &sub_node, |
2962 | 0 | &sub_lef_file_entry, |
2963 | 0 | error ); |
2964 | |
|
2965 | 0 | if( result == -1 ) |
2966 | 0 | { |
2967 | 0 | libcerror_error_set( |
2968 | 0 | error, |
2969 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2970 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
2971 | 0 | "%s: unable to retrieve sub file entry by UTF-8 name.", |
2972 | 0 | function ); |
2973 | |
|
2974 | 0 | result = -1; |
2975 | 0 | } |
2976 | 0 | else if( result != 0 ) |
2977 | 0 | { |
2978 | 0 | if( libewf_file_entry_initialize( |
2979 | 0 | sub_file_entry, |
2980 | 0 | internal_file_entry->handle, |
2981 | 0 | internal_file_entry->single_files, |
2982 | 0 | sub_node, |
2983 | 0 | error ) != 1 ) |
2984 | 0 | { |
2985 | 0 | libcerror_error_set( |
2986 | 0 | error, |
2987 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2988 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
2989 | 0 | "%s: unable to initialize sub file entry.", |
2990 | 0 | function ); |
2991 | |
|
2992 | 0 | result = -1; |
2993 | 0 | } |
2994 | 0 | } |
2995 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
2996 | 0 | if( libcthreads_read_write_lock_release_for_read( |
2997 | 0 | internal_file_entry->read_write_lock, |
2998 | 0 | error ) != 1 ) |
2999 | 0 | { |
3000 | 0 | libcerror_error_set( |
3001 | 0 | error, |
3002 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3003 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
3004 | 0 | "%s: unable to release read/write lock for reading.", |
3005 | 0 | function ); |
3006 | |
|
3007 | 0 | return( -1 ); |
3008 | 0 | } |
3009 | 0 | #endif |
3010 | 0 | return( result ); |
3011 | 0 | } |
3012 | | |
3013 | | /* Retrieves the sub file entry for the specific UTF-8 encoded path |
3014 | | * This function uses UTF-8 RFC 2279 (or 6-byte UTF-8) to support characters outside Unicode |
3015 | | * The path separator is defined by LIBEWF_SEPARATOR |
3016 | | * Returns 1 if successful, 0 if no such file entry or -1 on error |
3017 | | */ |
3018 | | int libewf_file_entry_get_sub_file_entry_by_utf8_path( |
3019 | | libewf_file_entry_t *file_entry, |
3020 | | const uint8_t *utf8_string, |
3021 | | size_t utf8_string_length, |
3022 | | libewf_file_entry_t **sub_file_entry, |
3023 | | libcerror_error_t **error ) |
3024 | 0 | { |
3025 | 0 | libcdata_tree_node_t *node = NULL; |
3026 | 0 | libcdata_tree_node_t *sub_node = NULL; |
3027 | 0 | libewf_internal_file_entry_t *internal_file_entry = NULL; |
3028 | 0 | libewf_lef_file_entry_t *sub_lef_file_entry = NULL; |
3029 | 0 | uint8_t *utf8_string_segment = NULL; |
3030 | 0 | static char *function = "libewf_file_entry_get_sub_file_entry_by_utf8_path"; |
3031 | 0 | size_t utf8_string_index = 0; |
3032 | 0 | size_t utf8_string_segment_length = 0; |
3033 | 0 | int result = 0; |
3034 | |
|
3035 | 0 | if( file_entry == NULL ) |
3036 | 0 | { |
3037 | 0 | libcerror_error_set( |
3038 | 0 | error, |
3039 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3040 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3041 | 0 | "%s: invalid file entry.", |
3042 | 0 | function ); |
3043 | |
|
3044 | 0 | return( -1 ); |
3045 | 0 | } |
3046 | 0 | internal_file_entry = (libewf_internal_file_entry_t *) file_entry; |
3047 | |
|
3048 | 0 | if( utf8_string == NULL ) |
3049 | 0 | { |
3050 | 0 | libcerror_error_set( |
3051 | 0 | error, |
3052 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3053 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3054 | 0 | "%s: invalid UTF-8 string.", |
3055 | 0 | function ); |
3056 | |
|
3057 | 0 | return( -1 ); |
3058 | 0 | } |
3059 | 0 | if( utf8_string_length > (size_t) SSIZE_MAX ) |
3060 | 0 | { |
3061 | 0 | libcerror_error_set( |
3062 | 0 | error, |
3063 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3064 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_EXCEEDS_MAXIMUM, |
3065 | 0 | "%s: invalid UTF-8 string length value exceeds maximum.", |
3066 | 0 | function ); |
3067 | |
|
3068 | 0 | return( -1 ); |
3069 | 0 | } |
3070 | 0 | if( sub_file_entry == NULL ) |
3071 | 0 | { |
3072 | 0 | libcerror_error_set( |
3073 | 0 | error, |
3074 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3075 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3076 | 0 | "%s: invalid sub file entry.", |
3077 | 0 | function ); |
3078 | |
|
3079 | 0 | return( -1 ); |
3080 | 0 | } |
3081 | 0 | if( *sub_file_entry != NULL ) |
3082 | 0 | { |
3083 | 0 | libcerror_error_set( |
3084 | 0 | error, |
3085 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3086 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET, |
3087 | 0 | "%s: sub file entry already set.", |
3088 | 0 | function ); |
3089 | |
|
3090 | 0 | return( -1 ); |
3091 | 0 | } |
3092 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
3093 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
3094 | 0 | internal_file_entry->read_write_lock, |
3095 | 0 | error ) != 1 ) |
3096 | 0 | { |
3097 | 0 | libcerror_error_set( |
3098 | 0 | error, |
3099 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3100 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
3101 | 0 | "%s: unable to grab read/write lock for reading.", |
3102 | 0 | function ); |
3103 | |
|
3104 | 0 | return( -1 ); |
3105 | 0 | } |
3106 | 0 | #endif |
3107 | 0 | node = internal_file_entry->file_entry_tree_node; |
3108 | |
|
3109 | 0 | if( utf8_string_length > 0 ) |
3110 | 0 | { |
3111 | | /* Ignore a leading separator |
3112 | | */ |
3113 | 0 | if( utf8_string[ utf8_string_index ] == (uint8_t) LIBEWF_SEPARATOR ) |
3114 | 0 | { |
3115 | 0 | utf8_string_index++; |
3116 | 0 | } |
3117 | 0 | } |
3118 | 0 | if( ( utf8_string_length == 0 ) |
3119 | 0 | || ( utf8_string_length == 1 ) ) |
3120 | 0 | { |
3121 | 0 | result = 1; |
3122 | 0 | } |
3123 | 0 | while( utf8_string_index < utf8_string_length ) |
3124 | 0 | { |
3125 | 0 | utf8_string_segment = (uint8_t *) &( utf8_string[ utf8_string_index ] ); |
3126 | 0 | utf8_string_segment_length = 0; |
3127 | |
|
3128 | 0 | while( utf8_string_index < utf8_string_length ) |
3129 | 0 | { |
3130 | 0 | if( ( utf8_string[ utf8_string_index ] == (uint8_t) LIBEWF_SEPARATOR ) |
3131 | 0 | || ( utf8_string[ utf8_string_index ] == (uint8_t) 0 ) ) |
3132 | 0 | { |
3133 | 0 | utf8_string_index++; |
3134 | |
|
3135 | 0 | break; |
3136 | 0 | } |
3137 | 0 | utf8_string_index++; |
3138 | |
|
3139 | 0 | utf8_string_segment_length++; |
3140 | 0 | } |
3141 | 0 | if( utf8_string_segment_length == 0 ) |
3142 | 0 | { |
3143 | 0 | libcerror_error_set( |
3144 | 0 | error, |
3145 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3146 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_MISSING, |
3147 | 0 | "%s: missing sub file entry name.", |
3148 | 0 | function ); |
3149 | |
|
3150 | 0 | goto on_error; |
3151 | 0 | } |
3152 | 0 | result = libewf_single_file_tree_get_sub_node_by_utf8_name( |
3153 | 0 | node, |
3154 | 0 | utf8_string_segment, |
3155 | 0 | utf8_string_segment_length, |
3156 | 0 | &sub_node, |
3157 | 0 | &sub_lef_file_entry, |
3158 | 0 | error ); |
3159 | |
|
3160 | 0 | if( result == -1 ) |
3161 | 0 | { |
3162 | 0 | libcerror_error_set( |
3163 | 0 | error, |
3164 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3165 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
3166 | 0 | "%s: unable to retrieve sub node by name.", |
3167 | 0 | function ); |
3168 | |
|
3169 | 0 | goto on_error; |
3170 | 0 | } |
3171 | 0 | else if( result == 0 ) |
3172 | 0 | { |
3173 | 0 | break; |
3174 | 0 | } |
3175 | 0 | node = sub_node; |
3176 | 0 | } |
3177 | 0 | if( result != 0 ) |
3178 | 0 | { |
3179 | 0 | if( libewf_file_entry_initialize( |
3180 | 0 | sub_file_entry, |
3181 | 0 | internal_file_entry->handle, |
3182 | 0 | internal_file_entry->single_files, |
3183 | 0 | sub_node, |
3184 | 0 | error ) != 1 ) |
3185 | 0 | { |
3186 | 0 | libcerror_error_set( |
3187 | 0 | error, |
3188 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3189 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
3190 | 0 | "%s: unable to initialize sub file entry.", |
3191 | 0 | function ); |
3192 | |
|
3193 | 0 | goto on_error; |
3194 | 0 | } |
3195 | 0 | } |
3196 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
3197 | 0 | if( libcthreads_read_write_lock_release_for_read( |
3198 | 0 | internal_file_entry->read_write_lock, |
3199 | 0 | error ) != 1 ) |
3200 | 0 | { |
3201 | 0 | libcerror_error_set( |
3202 | 0 | error, |
3203 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3204 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
3205 | 0 | "%s: unable to release read/write lock for reading.", |
3206 | 0 | function ); |
3207 | |
|
3208 | 0 | return( -1 ); |
3209 | 0 | } |
3210 | 0 | #endif |
3211 | 0 | return( result ); |
3212 | | |
3213 | 0 | on_error: |
3214 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
3215 | 0 | libcthreads_read_write_lock_release_for_read( |
3216 | 0 | internal_file_entry->read_write_lock, |
3217 | 0 | NULL ); |
3218 | 0 | #endif |
3219 | 0 | return( -1 ); |
3220 | 0 | } |
3221 | | |
3222 | | /* Retrieves the sub file entry for the specific UTF-16 encoded name |
3223 | | * Returns 1 if successful, 0 if not such value or -1 on error |
3224 | | */ |
3225 | | int libewf_file_entry_get_sub_file_entry_by_utf16_name( |
3226 | | libewf_file_entry_t *file_entry, |
3227 | | const uint16_t *utf16_string, |
3228 | | size_t utf16_string_length, |
3229 | | libewf_file_entry_t **sub_file_entry, |
3230 | | libcerror_error_t **error ) |
3231 | 0 | { |
3232 | 0 | libcdata_tree_node_t *sub_node = NULL; |
3233 | 0 | libewf_internal_file_entry_t *internal_file_entry = NULL; |
3234 | 0 | libewf_lef_file_entry_t *sub_lef_file_entry = NULL; |
3235 | 0 | static char *function = "libewf_file_entry_get_sub_file_entry_by_utf16_name"; |
3236 | 0 | int result = 0; |
3237 | |
|
3238 | 0 | if( file_entry == NULL ) |
3239 | 0 | { |
3240 | 0 | libcerror_error_set( |
3241 | 0 | error, |
3242 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3243 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3244 | 0 | "%s: invalid file entry.", |
3245 | 0 | function ); |
3246 | |
|
3247 | 0 | return( -1 ); |
3248 | 0 | } |
3249 | 0 | internal_file_entry = (libewf_internal_file_entry_t *) file_entry; |
3250 | |
|
3251 | 0 | if( sub_file_entry == NULL ) |
3252 | 0 | { |
3253 | 0 | libcerror_error_set( |
3254 | 0 | error, |
3255 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3256 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3257 | 0 | "%s: invalid sub file entry.", |
3258 | 0 | function ); |
3259 | |
|
3260 | 0 | return( -1 ); |
3261 | 0 | } |
3262 | 0 | if( *sub_file_entry != NULL ) |
3263 | 0 | { |
3264 | 0 | libcerror_error_set( |
3265 | 0 | error, |
3266 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3267 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET, |
3268 | 0 | "%s: sub file entry already set.", |
3269 | 0 | function ); |
3270 | |
|
3271 | 0 | return( -1 ); |
3272 | 0 | } |
3273 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
3274 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
3275 | 0 | internal_file_entry->read_write_lock, |
3276 | 0 | error ) != 1 ) |
3277 | 0 | { |
3278 | 0 | libcerror_error_set( |
3279 | 0 | error, |
3280 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3281 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
3282 | 0 | "%s: unable to grab read/write lock for reading.", |
3283 | 0 | function ); |
3284 | |
|
3285 | 0 | return( -1 ); |
3286 | 0 | } |
3287 | 0 | #endif |
3288 | 0 | result = libewf_single_file_tree_get_sub_node_by_utf16_name( |
3289 | 0 | internal_file_entry->file_entry_tree_node, |
3290 | 0 | utf16_string, |
3291 | 0 | utf16_string_length, |
3292 | 0 | &sub_node, |
3293 | 0 | &sub_lef_file_entry, |
3294 | 0 | error ); |
3295 | |
|
3296 | 0 | if( result == -1 ) |
3297 | 0 | { |
3298 | 0 | libcerror_error_set( |
3299 | 0 | error, |
3300 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3301 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
3302 | 0 | "%s: unable to retrieve sub file entry by UTF-16 name.", |
3303 | 0 | function ); |
3304 | |
|
3305 | 0 | result = -1; |
3306 | 0 | } |
3307 | 0 | else if( result != 0 ) |
3308 | 0 | { |
3309 | 0 | if( libewf_file_entry_initialize( |
3310 | 0 | sub_file_entry, |
3311 | 0 | internal_file_entry->handle, |
3312 | 0 | internal_file_entry->single_files, |
3313 | 0 | sub_node, |
3314 | 0 | error ) != 1 ) |
3315 | 0 | { |
3316 | 0 | libcerror_error_set( |
3317 | 0 | error, |
3318 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3319 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
3320 | 0 | "%s: unable to initialize sub file entry.", |
3321 | 0 | function ); |
3322 | |
|
3323 | 0 | result = -1; |
3324 | 0 | } |
3325 | 0 | } |
3326 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
3327 | 0 | if( libcthreads_read_write_lock_release_for_read( |
3328 | 0 | internal_file_entry->read_write_lock, |
3329 | 0 | error ) != 1 ) |
3330 | 0 | { |
3331 | 0 | libcerror_error_set( |
3332 | 0 | error, |
3333 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3334 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
3335 | 0 | "%s: unable to release read/write lock for reading.", |
3336 | 0 | function ); |
3337 | |
|
3338 | 0 | return( -1 ); |
3339 | 0 | } |
3340 | 0 | #endif |
3341 | 0 | return( result ); |
3342 | 0 | } |
3343 | | |
3344 | | /* Retrieves the sub file entry for the specific UTF-16 encoded path |
3345 | | * This function uses UCS-2 (with surrogates) to support characters outside Unicode |
3346 | | * The path separator is defined by LIBEWF_SEPARATOR |
3347 | | * Returns 1 if successful, 0 if no such file entry or -1 on error |
3348 | | */ |
3349 | | int libewf_file_entry_get_sub_file_entry_by_utf16_path( |
3350 | | libewf_file_entry_t *file_entry, |
3351 | | const uint16_t *utf16_string, |
3352 | | size_t utf16_string_length, |
3353 | | libewf_file_entry_t **sub_file_entry, |
3354 | | libcerror_error_t **error ) |
3355 | 0 | { |
3356 | 0 | libcdata_tree_node_t *node = NULL; |
3357 | 0 | libcdata_tree_node_t *sub_node = NULL; |
3358 | 0 | libewf_internal_file_entry_t *internal_file_entry = NULL; |
3359 | 0 | libewf_lef_file_entry_t *sub_lef_file_entry = NULL; |
3360 | 0 | uint16_t *utf16_string_segment = NULL; |
3361 | 0 | static char *function = "libewf_file_entry_get_sub_file_entry_by_utf16_path"; |
3362 | 0 | size_t utf16_string_index = 0; |
3363 | 0 | size_t utf16_string_segment_length = 0; |
3364 | 0 | int result = 0; |
3365 | |
|
3366 | 0 | if( file_entry == NULL ) |
3367 | 0 | { |
3368 | 0 | libcerror_error_set( |
3369 | 0 | error, |
3370 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3371 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3372 | 0 | "%s: invalid file entry.", |
3373 | 0 | function ); |
3374 | |
|
3375 | 0 | return( -1 ); |
3376 | 0 | } |
3377 | 0 | internal_file_entry = (libewf_internal_file_entry_t *) file_entry; |
3378 | |
|
3379 | 0 | if( utf16_string == NULL ) |
3380 | 0 | { |
3381 | 0 | libcerror_error_set( |
3382 | 0 | error, |
3383 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3384 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3385 | 0 | "%s: invalid UTF-16 string.", |
3386 | 0 | function ); |
3387 | |
|
3388 | 0 | return( -1 ); |
3389 | 0 | } |
3390 | 0 | if( utf16_string_length > (size_t) SSIZE_MAX ) |
3391 | 0 | { |
3392 | 0 | libcerror_error_set( |
3393 | 0 | error, |
3394 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3395 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_EXCEEDS_MAXIMUM, |
3396 | 0 | "%s: invalid UTF-16 string length value exceeds maximum.", |
3397 | 0 | function ); |
3398 | |
|
3399 | 0 | return( -1 ); |
3400 | 0 | } |
3401 | 0 | if( sub_file_entry == NULL ) |
3402 | 0 | { |
3403 | 0 | libcerror_error_set( |
3404 | 0 | error, |
3405 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3406 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3407 | 0 | "%s: invalid sub file entry.", |
3408 | 0 | function ); |
3409 | |
|
3410 | 0 | return( -1 ); |
3411 | 0 | } |
3412 | 0 | if( *sub_file_entry != NULL ) |
3413 | 0 | { |
3414 | 0 | libcerror_error_set( |
3415 | 0 | error, |
3416 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3417 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET, |
3418 | 0 | "%s: sub file entry already set.", |
3419 | 0 | function ); |
3420 | |
|
3421 | 0 | return( -1 ); |
3422 | 0 | } |
3423 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
3424 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
3425 | 0 | internal_file_entry->read_write_lock, |
3426 | 0 | error ) != 1 ) |
3427 | 0 | { |
3428 | 0 | libcerror_error_set( |
3429 | 0 | error, |
3430 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3431 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
3432 | 0 | "%s: unable to grab read/write lock for reading.", |
3433 | 0 | function ); |
3434 | |
|
3435 | 0 | return( -1 ); |
3436 | 0 | } |
3437 | 0 | #endif |
3438 | 0 | node = internal_file_entry->file_entry_tree_node; |
3439 | |
|
3440 | 0 | if( utf16_string_length > 0 ) |
3441 | 0 | { |
3442 | | /* Ignore a leading separator |
3443 | | */ |
3444 | 0 | if( utf16_string[ utf16_string_index ] == (uint16_t) LIBEWF_SEPARATOR ) |
3445 | 0 | { |
3446 | 0 | utf16_string_index++; |
3447 | 0 | } |
3448 | 0 | } |
3449 | 0 | if( ( utf16_string_length == 0 ) |
3450 | 0 | || ( utf16_string_length == 1 ) ) |
3451 | 0 | { |
3452 | 0 | result = 1; |
3453 | 0 | } |
3454 | 0 | while( utf16_string_index < utf16_string_length ) |
3455 | 0 | { |
3456 | 0 | utf16_string_segment = (uint16_t *) &( utf16_string[ utf16_string_index ] ); |
3457 | 0 | utf16_string_segment_length = 0; |
3458 | |
|
3459 | 0 | while( utf16_string_index < utf16_string_length ) |
3460 | 0 | { |
3461 | 0 | if( ( utf16_string[ utf16_string_index ] == (uint16_t) LIBEWF_SEPARATOR ) |
3462 | 0 | || ( utf16_string[ utf16_string_index ] == (uint16_t) 0 ) ) |
3463 | 0 | { |
3464 | 0 | utf16_string_index++; |
3465 | |
|
3466 | 0 | break; |
3467 | 0 | } |
3468 | 0 | utf16_string_index++; |
3469 | |
|
3470 | 0 | utf16_string_segment_length++; |
3471 | 0 | } |
3472 | 0 | if( utf16_string_segment_length == 0 ) |
3473 | 0 | { |
3474 | 0 | libcerror_error_set( |
3475 | 0 | error, |
3476 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3477 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_MISSING, |
3478 | 0 | "%s: missing sub file entry name.", |
3479 | 0 | function ); |
3480 | |
|
3481 | 0 | goto on_error; |
3482 | 0 | } |
3483 | 0 | result = libewf_single_file_tree_get_sub_node_by_utf16_name( |
3484 | 0 | node, |
3485 | 0 | utf16_string_segment, |
3486 | 0 | utf16_string_segment_length, |
3487 | 0 | &sub_node, |
3488 | 0 | &sub_lef_file_entry, |
3489 | 0 | error ); |
3490 | |
|
3491 | 0 | if( result == -1 ) |
3492 | 0 | { |
3493 | 0 | libcerror_error_set( |
3494 | 0 | error, |
3495 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3496 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
3497 | 0 | "%s: unable to retrieve sub node by name.", |
3498 | 0 | function ); |
3499 | |
|
3500 | 0 | goto on_error; |
3501 | 0 | } |
3502 | 0 | else if( result == 0 ) |
3503 | 0 | { |
3504 | 0 | break; |
3505 | 0 | } |
3506 | 0 | node = sub_node; |
3507 | 0 | } |
3508 | 0 | if( result != 0 ) |
3509 | 0 | { |
3510 | 0 | if( libewf_file_entry_initialize( |
3511 | 0 | sub_file_entry, |
3512 | 0 | internal_file_entry->handle, |
3513 | 0 | internal_file_entry->single_files, |
3514 | 0 | sub_node, |
3515 | 0 | error ) != 1 ) |
3516 | 0 | { |
3517 | 0 | libcerror_error_set( |
3518 | 0 | error, |
3519 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3520 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
3521 | 0 | "%s: unable to initialize sub file entry.", |
3522 | 0 | function ); |
3523 | |
|
3524 | 0 | goto on_error; |
3525 | 0 | } |
3526 | 0 | } |
3527 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
3528 | 0 | if( libcthreads_read_write_lock_release_for_read( |
3529 | 0 | internal_file_entry->read_write_lock, |
3530 | 0 | error ) != 1 ) |
3531 | 0 | { |
3532 | 0 | libcerror_error_set( |
3533 | 0 | error, |
3534 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3535 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
3536 | 0 | "%s: unable to release read/write lock for reading.", |
3537 | 0 | function ); |
3538 | |
|
3539 | 0 | return( -1 ); |
3540 | 0 | } |
3541 | 0 | #endif |
3542 | 0 | return( result ); |
3543 | | |
3544 | 0 | on_error: |
3545 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
3546 | 0 | libcthreads_read_write_lock_release_for_read( |
3547 | 0 | internal_file_entry->read_write_lock, |
3548 | 0 | NULL ); |
3549 | 0 | #endif |
3550 | 0 | return( -1 ); |
3551 | 0 | } |
3552 | | |
3553 | | /* Retrieves the number of attributes |
3554 | | * Returns 1 if successful or -1 on error |
3555 | | */ |
3556 | | int libewf_file_entry_get_number_of_attributes( |
3557 | | libewf_file_entry_t *file_entry, |
3558 | | int *number_of_attributes, |
3559 | | libcerror_error_t **error ) |
3560 | 0 | { |
3561 | 0 | libewf_internal_file_entry_t *internal_file_entry = NULL; |
3562 | 0 | static char *function = "libewf_file_entry_get_number_of_attributes"; |
3563 | 0 | int result = 1; |
3564 | |
|
3565 | 0 | if( file_entry == NULL ) |
3566 | 0 | { |
3567 | 0 | libcerror_error_set( |
3568 | 0 | error, |
3569 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3570 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3571 | 0 | "%s: invalid file entry.", |
3572 | 0 | function ); |
3573 | |
|
3574 | 0 | return( -1 ); |
3575 | 0 | } |
3576 | 0 | internal_file_entry = (libewf_internal_file_entry_t *) file_entry; |
3577 | |
|
3578 | 0 | if( number_of_attributes == NULL ) |
3579 | 0 | { |
3580 | 0 | libcerror_error_set( |
3581 | 0 | error, |
3582 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3583 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3584 | 0 | "%s: invalid number of attributes.", |
3585 | 0 | function ); |
3586 | |
|
3587 | 0 | return( -1 ); |
3588 | 0 | } |
3589 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
3590 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
3591 | 0 | internal_file_entry->read_write_lock, |
3592 | 0 | error ) != 1 ) |
3593 | 0 | { |
3594 | 0 | libcerror_error_set( |
3595 | 0 | error, |
3596 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3597 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
3598 | 0 | "%s: unable to grab read/write lock for reading.", |
3599 | 0 | function ); |
3600 | |
|
3601 | 0 | return( -1 ); |
3602 | 0 | } |
3603 | 0 | #endif |
3604 | 0 | if( libewf_lef_file_entry_get_number_of_extended_attributes( |
3605 | 0 | internal_file_entry->lef_file_entry, |
3606 | 0 | number_of_attributes, |
3607 | 0 | error ) != 1 ) |
3608 | 0 | { |
3609 | 0 | libcerror_error_set( |
3610 | 0 | error, |
3611 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3612 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
3613 | 0 | "%s: unable to retrieve number of extended attributes.", |
3614 | 0 | function ); |
3615 | |
|
3616 | 0 | result = -1; |
3617 | 0 | } |
3618 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
3619 | 0 | if( libcthreads_read_write_lock_release_for_read( |
3620 | 0 | internal_file_entry->read_write_lock, |
3621 | 0 | error ) != 1 ) |
3622 | 0 | { |
3623 | 0 | libcerror_error_set( |
3624 | 0 | error, |
3625 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3626 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
3627 | 0 | "%s: unable to release read/write lock for reading.", |
3628 | 0 | function ); |
3629 | |
|
3630 | 0 | return( -1 ); |
3631 | 0 | } |
3632 | 0 | #endif |
3633 | 0 | return( result ); |
3634 | 0 | } |
3635 | | |
3636 | | /* Retrieves the attribute for the specific index |
3637 | | * Returns 1 if successful or -1 on error |
3638 | | */ |
3639 | | int libewf_file_entry_get_attribute( |
3640 | | libewf_file_entry_t *file_entry, |
3641 | | int attribute_index, |
3642 | | libewf_attribute_t **attribute, |
3643 | | libcerror_error_t **error ) |
3644 | 0 | { |
3645 | 0 | libewf_internal_file_entry_t *internal_file_entry = NULL; |
3646 | 0 | libewf_lef_extended_attribute_t *lef_extended_attribute = NULL; |
3647 | 0 | static char *function = "libewf_file_entry_get_attribute"; |
3648 | 0 | int result = 1; |
3649 | |
|
3650 | 0 | if( file_entry == NULL ) |
3651 | 0 | { |
3652 | 0 | libcerror_error_set( |
3653 | 0 | error, |
3654 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3655 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3656 | 0 | "%s: invalid file entry.", |
3657 | 0 | function ); |
3658 | |
|
3659 | 0 | return( -1 ); |
3660 | 0 | } |
3661 | 0 | internal_file_entry = (libewf_internal_file_entry_t *) file_entry; |
3662 | |
|
3663 | 0 | if( attribute == NULL ) |
3664 | 0 | { |
3665 | 0 | libcerror_error_set( |
3666 | 0 | error, |
3667 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3668 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3669 | 0 | "%s: invalid attribute.", |
3670 | 0 | function ); |
3671 | |
|
3672 | 0 | return( -1 ); |
3673 | 0 | } |
3674 | 0 | if( *attribute != NULL ) |
3675 | 0 | { |
3676 | 0 | libcerror_error_set( |
3677 | 0 | error, |
3678 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3679 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET, |
3680 | 0 | "%s: attribute already set.", |
3681 | 0 | function ); |
3682 | |
|
3683 | 0 | return( -1 ); |
3684 | 0 | } |
3685 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
3686 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
3687 | 0 | internal_file_entry->read_write_lock, |
3688 | 0 | error ) != 1 ) |
3689 | 0 | { |
3690 | 0 | libcerror_error_set( |
3691 | 0 | error, |
3692 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3693 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
3694 | 0 | "%s: unable to grab read/write lock for reading.", |
3695 | 0 | function ); |
3696 | |
|
3697 | 0 | return( -1 ); |
3698 | 0 | } |
3699 | 0 | #endif |
3700 | 0 | if( libewf_lef_file_entry_get_extended_attribute_by_index( |
3701 | 0 | internal_file_entry->lef_file_entry, |
3702 | 0 | attribute_index, |
3703 | 0 | &lef_extended_attribute, |
3704 | 0 | error ) != 1 ) |
3705 | 0 | { |
3706 | 0 | libcerror_error_set( |
3707 | 0 | error, |
3708 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3709 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
3710 | 0 | "%s: unable to retrieve extended attribute: %d.", |
3711 | 0 | function, |
3712 | 0 | attribute_index ); |
3713 | |
|
3714 | 0 | result = -1; |
3715 | 0 | } |
3716 | 0 | else if( libewf_attribute_initialize( |
3717 | 0 | attribute, |
3718 | 0 | lef_extended_attribute, |
3719 | 0 | error ) != 1 ) |
3720 | 0 | { |
3721 | 0 | libcerror_error_set( |
3722 | 0 | error, |
3723 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3724 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
3725 | 0 | "%s: unable to initialize attribute: %d.", |
3726 | 0 | function, |
3727 | 0 | attribute_index ); |
3728 | |
|
3729 | 0 | result = -1; |
3730 | 0 | } |
3731 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
3732 | 0 | if( libcthreads_read_write_lock_release_for_read( |
3733 | 0 | internal_file_entry->read_write_lock, |
3734 | 0 | error ) != 1 ) |
3735 | 0 | { |
3736 | 0 | libcerror_error_set( |
3737 | 0 | error, |
3738 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3739 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
3740 | 0 | "%s: unable to release read/write lock for reading.", |
3741 | 0 | function ); |
3742 | |
|
3743 | 0 | return( -1 ); |
3744 | 0 | } |
3745 | 0 | #endif |
3746 | 0 | return( result ); |
3747 | 0 | } |
3748 | | |
3749 | | /* Retrieves the number of access control entries |
3750 | | * Returns 1 if successful or -1 on error |
3751 | | */ |
3752 | | int libewf_file_entry_get_number_of_access_control_entries( |
3753 | | libewf_file_entry_t *file_entry, |
3754 | | int *number_of_access_control_entries, |
3755 | | libcerror_error_t **error ) |
3756 | 0 | { |
3757 | 0 | libewf_internal_file_entry_t *internal_file_entry = NULL; |
3758 | 0 | static char *function = "libewf_file_entry_get_number_of_access_control_entries"; |
3759 | 0 | int result = 1; |
3760 | 0 | int safe_number_of_access_control_entries = 0; |
3761 | |
|
3762 | 0 | if( file_entry == NULL ) |
3763 | 0 | { |
3764 | 0 | libcerror_error_set( |
3765 | 0 | error, |
3766 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3767 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3768 | 0 | "%s: invalid file entry.", |
3769 | 0 | function ); |
3770 | |
|
3771 | 0 | return( -1 ); |
3772 | 0 | } |
3773 | 0 | internal_file_entry = (libewf_internal_file_entry_t *) file_entry; |
3774 | |
|
3775 | 0 | if( number_of_access_control_entries == NULL ) |
3776 | 0 | { |
3777 | 0 | libcerror_error_set( |
3778 | 0 | error, |
3779 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3780 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3781 | 0 | "%s: invalid number of access control entries.", |
3782 | 0 | function ); |
3783 | |
|
3784 | 0 | return( -1 ); |
3785 | 0 | } |
3786 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
3787 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
3788 | 0 | internal_file_entry->read_write_lock, |
3789 | 0 | error ) != 1 ) |
3790 | 0 | { |
3791 | 0 | libcerror_error_set( |
3792 | 0 | error, |
3793 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3794 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
3795 | 0 | "%s: unable to grab read/write lock for reading.", |
3796 | 0 | function ); |
3797 | |
|
3798 | 0 | return( -1 ); |
3799 | 0 | } |
3800 | 0 | #endif |
3801 | 0 | if( internal_file_entry->permission_group != NULL ) |
3802 | 0 | { |
3803 | 0 | if( libewf_permission_group_get_number_of_entries( |
3804 | 0 | internal_file_entry->permission_group, |
3805 | 0 | &safe_number_of_access_control_entries, |
3806 | 0 | error ) != 1 ) |
3807 | 0 | { |
3808 | 0 | libcerror_error_set( |
3809 | 0 | error, |
3810 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3811 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
3812 | 0 | "%s: unable to retrieve number of permission group entries.", |
3813 | 0 | function ); |
3814 | |
|
3815 | 0 | result = -1; |
3816 | 0 | } |
3817 | 0 | } |
3818 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
3819 | 0 | if( libcthreads_read_write_lock_release_for_read( |
3820 | 0 | internal_file_entry->read_write_lock, |
3821 | 0 | error ) != 1 ) |
3822 | 0 | { |
3823 | 0 | libcerror_error_set( |
3824 | 0 | error, |
3825 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3826 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
3827 | 0 | "%s: unable to release read/write lock for reading.", |
3828 | 0 | function ); |
3829 | |
|
3830 | 0 | return( -1 ); |
3831 | 0 | } |
3832 | 0 | #endif |
3833 | 0 | *number_of_access_control_entries = safe_number_of_access_control_entries; |
3834 | |
|
3835 | 0 | return( result ); |
3836 | 0 | } |
3837 | | |
3838 | | /* Retrieves the access control entry for the specific index |
3839 | | * Returns 1 if successful or -1 on error |
3840 | | */ |
3841 | | int libewf_file_entry_get_access_control_entry( |
3842 | | libewf_file_entry_t *file_entry, |
3843 | | int access_control_entry_index, |
3844 | | libewf_access_control_entry_t **access_control_entry, |
3845 | | libcerror_error_t **error ) |
3846 | 0 | { |
3847 | 0 | libewf_internal_file_entry_t *internal_file_entry = NULL; |
3848 | 0 | libewf_lef_permission_t *lef_permission = NULL; |
3849 | 0 | static char *function = "libewf_file_entry_get_access_control_entry"; |
3850 | 0 | int result = 1; |
3851 | |
|
3852 | 0 | if( file_entry == NULL ) |
3853 | 0 | { |
3854 | 0 | libcerror_error_set( |
3855 | 0 | error, |
3856 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3857 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3858 | 0 | "%s: invalid file entry.", |
3859 | 0 | function ); |
3860 | |
|
3861 | 0 | return( -1 ); |
3862 | 0 | } |
3863 | 0 | internal_file_entry = (libewf_internal_file_entry_t *) file_entry; |
3864 | |
|
3865 | 0 | if( access_control_entry == NULL ) |
3866 | 0 | { |
3867 | 0 | libcerror_error_set( |
3868 | 0 | error, |
3869 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3870 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3871 | 0 | "%s: invalid access control entry.", |
3872 | 0 | function ); |
3873 | |
|
3874 | 0 | return( -1 ); |
3875 | 0 | } |
3876 | 0 | if( *access_control_entry != NULL ) |
3877 | 0 | { |
3878 | 0 | libcerror_error_set( |
3879 | 0 | error, |
3880 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3881 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET, |
3882 | 0 | "%s: access control entry already set.", |
3883 | 0 | function ); |
3884 | |
|
3885 | 0 | return( -1 ); |
3886 | 0 | } |
3887 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
3888 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
3889 | 0 | internal_file_entry->read_write_lock, |
3890 | 0 | error ) != 1 ) |
3891 | 0 | { |
3892 | 0 | libcerror_error_set( |
3893 | 0 | error, |
3894 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3895 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
3896 | 0 | "%s: unable to grab read/write lock for reading.", |
3897 | 0 | function ); |
3898 | |
|
3899 | 0 | return( -1 ); |
3900 | 0 | } |
3901 | 0 | #endif |
3902 | 0 | if( libewf_permission_group_get_entry_by_index( |
3903 | 0 | internal_file_entry->permission_group, |
3904 | 0 | access_control_entry_index, |
3905 | 0 | &lef_permission, |
3906 | 0 | error ) != 1 ) |
3907 | 0 | { |
3908 | 0 | libcerror_error_set( |
3909 | 0 | error, |
3910 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3911 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
3912 | 0 | "%s: unable to retrieve entry: %d from permission group.", |
3913 | 0 | function, |
3914 | 0 | access_control_entry_index ); |
3915 | |
|
3916 | 0 | result = -1; |
3917 | 0 | } |
3918 | 0 | else if( libewf_access_control_entry_initialize( |
3919 | 0 | access_control_entry, |
3920 | 0 | lef_permission, |
3921 | 0 | error ) != 1 ) |
3922 | 0 | { |
3923 | 0 | libcerror_error_set( |
3924 | 0 | error, |
3925 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3926 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
3927 | 0 | "%s: unable to initialize access control entry: %d.", |
3928 | 0 | function, |
3929 | 0 | access_control_entry_index ); |
3930 | |
|
3931 | 0 | result = -1; |
3932 | 0 | } |
3933 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
3934 | 0 | if( libcthreads_read_write_lock_release_for_read( |
3935 | 0 | internal_file_entry->read_write_lock, |
3936 | 0 | error ) != 1 ) |
3937 | 0 | { |
3938 | 0 | libcerror_error_set( |
3939 | 0 | error, |
3940 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3941 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
3942 | 0 | "%s: unable to release read/write lock for reading.", |
3943 | 0 | function ); |
3944 | |
|
3945 | 0 | return( -1 ); |
3946 | 0 | } |
3947 | 0 | #endif |
3948 | 0 | return( result ); |
3949 | 0 | } |
3950 | | |
3951 | | /* Retrieves the (acquisition) source |
3952 | | * Returns 1 if successful, 0 if not set or -1 on error |
3953 | | */ |
3954 | | int libewf_file_entry_get_source( |
3955 | | libewf_file_entry_t *file_entry, |
3956 | | libewf_source_t **source, |
3957 | | libcerror_error_t **error ) |
3958 | 0 | { |
3959 | 0 | libewf_internal_file_entry_t *internal_file_entry = NULL; |
3960 | 0 | static char *function = "libewf_file_entry_get_source"; |
3961 | 0 | int result = 0; |
3962 | |
|
3963 | 0 | if( file_entry == NULL ) |
3964 | 0 | { |
3965 | 0 | libcerror_error_set( |
3966 | 0 | error, |
3967 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3968 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3969 | 0 | "%s: invalid file entry.", |
3970 | 0 | function ); |
3971 | |
|
3972 | 0 | return( -1 ); |
3973 | 0 | } |
3974 | 0 | internal_file_entry = (libewf_internal_file_entry_t *) file_entry; |
3975 | |
|
3976 | 0 | if( source == NULL ) |
3977 | 0 | { |
3978 | 0 | libcerror_error_set( |
3979 | 0 | error, |
3980 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3981 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3982 | 0 | "%s: invalid source.", |
3983 | 0 | function ); |
3984 | |
|
3985 | 0 | return( -1 ); |
3986 | 0 | } |
3987 | 0 | if( *source != NULL ) |
3988 | 0 | { |
3989 | 0 | libcerror_error_set( |
3990 | 0 | error, |
3991 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3992 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET, |
3993 | 0 | "%s: source already set.", |
3994 | 0 | function ); |
3995 | |
|
3996 | 0 | return( -1 ); |
3997 | 0 | } |
3998 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
3999 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
4000 | 0 | internal_file_entry->read_write_lock, |
4001 | 0 | error ) != 1 ) |
4002 | 0 | { |
4003 | 0 | libcerror_error_set( |
4004 | 0 | error, |
4005 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
4006 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
4007 | 0 | "%s: unable to grab read/write lock for reading.", |
4008 | 0 | function ); |
4009 | |
|
4010 | 0 | return( -1 ); |
4011 | 0 | } |
4012 | 0 | #endif |
4013 | 0 | if( internal_file_entry->lef_source != NULL ) |
4014 | 0 | { |
4015 | 0 | result = libewf_source_initialize( |
4016 | 0 | source, |
4017 | 0 | internal_file_entry->lef_source, |
4018 | 0 | error ); |
4019 | |
|
4020 | 0 | if( result != 1 ) |
4021 | 0 | { |
4022 | 0 | libcerror_error_set( |
4023 | 0 | error, |
4024 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
4025 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
4026 | 0 | "%s: unable to initialize source.", |
4027 | 0 | function ); |
4028 | |
|
4029 | 0 | result = -1; |
4030 | 0 | } |
4031 | 0 | } |
4032 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
4033 | 0 | if( libcthreads_read_write_lock_release_for_read( |
4034 | 0 | internal_file_entry->read_write_lock, |
4035 | 0 | error ) != 1 ) |
4036 | 0 | { |
4037 | 0 | libcerror_error_set( |
4038 | 0 | error, |
4039 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
4040 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
4041 | 0 | "%s: unable to release read/write lock for reading.", |
4042 | 0 | function ); |
4043 | |
|
4044 | 0 | return( -1 ); |
4045 | 0 | } |
4046 | 0 | #endif |
4047 | 0 | return( result ); |
4048 | 0 | } |
4049 | | |