Coverage Report

Created: 2024-02-25 07:20

/src/libvmdk/libvmdk/libvmdk_extent_descriptor.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Extent descriptor functions
3
 *
4
 * Copyright (C) 2009-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 "libvmdk_extent_descriptor.h"
27
#include "libvmdk_extent_values.h"
28
#include "libvmdk_libcerror.h"
29
#include "libvmdk_libcthreads.h"
30
#include "libvmdk_types.h"
31
32
/* Creates an extent descriptor
33
 * Make sure the value extent_descriptor is referencing, is set to NULL
34
 * Returns 1 if successful or -1 on error
35
 */
36
int libvmdk_extent_descriptor_initialize(
37
     libvmdk_extent_descriptor_t **extent_descriptor,
38
     libvmdk_extent_values_t *extent_values,
39
     libcerror_error_t **error )
40
0
{
41
0
  libvmdk_internal_extent_descriptor_t *internal_extent_descriptor = NULL;
42
0
  static char *function                                            = "libvmdk_extent_descriptor_initialize";
43
44
0
  if( extent_descriptor == NULL )
45
0
  {
46
0
    libcerror_error_set(
47
0
     error,
48
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
49
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
50
0
     "%s: invalid extent descriptor.",
51
0
     function );
52
53
0
    return( -1 );
54
0
  }
55
0
  if( *extent_descriptor != NULL )
56
0
  {
57
0
    libcerror_error_set(
58
0
     error,
59
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
60
0
     LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET,
61
0
     "%s: invalid extent descriptor value already set.",
62
0
     function );
63
64
0
    return( -1 );
65
0
  }
66
0
  if( extent_values == NULL )
67
0
  {
68
0
    libcerror_error_set(
69
0
     error,
70
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
71
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
72
0
     "%s: invalid extent values.",
73
0
     function );
74
75
0
    return( -1 );
76
0
  }
77
0
  internal_extent_descriptor = memory_allocate_structure(
78
0
                                libvmdk_internal_extent_descriptor_t );
79
80
0
  if( internal_extent_descriptor == NULL )
81
0
  {
82
0
    libcerror_error_set(
83
0
     error,
84
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
85
0
     LIBCERROR_MEMORY_ERROR_INSUFFICIENT,
86
0
     "%s: unable to create extent descriptor.",
87
0
     function );
88
89
0
    goto on_error;
90
0
  }
91
0
  if( memory_set(
92
0
       internal_extent_descriptor,
93
0
       0,
94
0
       sizeof( libvmdk_internal_extent_descriptor_t ) ) == NULL )
95
0
  {
96
0
    libcerror_error_set(
97
0
     error,
98
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
99
0
     LIBCERROR_MEMORY_ERROR_SET_FAILED,
100
0
     "%s: unable to clear extent descriptor.",
101
0
     function );
102
103
0
    memory_free(
104
0
     internal_extent_descriptor );
105
106
0
    return( -1 );
107
0
  }
108
0
#if defined( HAVE_LIBVMDK_MULTI_THREAD_SUPPORT )
109
0
  if( libcthreads_read_write_lock_initialize(
110
0
       &( internal_extent_descriptor->read_write_lock ),
111
0
       error ) != 1 )
112
0
  {
113
0
    libcerror_error_set(
114
0
     error,
115
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
116
0
     LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED,
117
0
     "%s: unable to initialize read/write lock.",
118
0
     function );
119
120
0
    goto on_error;
121
0
  }
122
0
#endif
123
0
  internal_extent_descriptor->extent_values = extent_values;
124
125
0
  *extent_descriptor = (libvmdk_extent_descriptor_t *) internal_extent_descriptor;
126
127
0
  return( 1 );
128
129
0
on_error:
130
0
  if( internal_extent_descriptor != NULL )
131
0
  {
132
0
    memory_free(
133
0
     internal_extent_descriptor );
134
0
  }
135
0
  return( -1 );
136
0
}
137
138
/* Frees an extent descriptor
139
 * Returns 1 if successful or -1 on error
140
 */
141
int libvmdk_extent_descriptor_free(
142
     libvmdk_extent_descriptor_t **extent_descriptor,
143
     libcerror_error_t **error )
144
0
{
145
0
  libvmdk_internal_extent_descriptor_t *internal_extent_descriptor = NULL;
146
0
  static char *function                                            = "libvmdk_extent_descriptor_free";
147
0
  int result                                                       = 1;
148
149
0
  if( extent_descriptor == NULL )
150
0
  {
151
0
    libcerror_error_set(
152
0
     error,
153
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
154
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
155
0
     "%s: invalid extent descriptor.",
156
0
     function );
157
158
0
    return( -1 );
159
0
  }
160
0
  if( *extent_descriptor != NULL )
161
0
  {
162
0
    internal_extent_descriptor = (libvmdk_internal_extent_descriptor_t *) *extent_descriptor;
163
0
    *extent_descriptor         = NULL;
164
165
0
#if defined( HAVE_LIBVMDK_MULTI_THREAD_SUPPORT )
166
0
    if( libcthreads_read_write_lock_free(
167
0
         &( internal_extent_descriptor->read_write_lock ),
168
0
         error ) != 1 )
169
0
    {
170
0
      libcerror_error_set(
171
0
       error,
172
0
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
173
0
       LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED,
174
0
       "%s: unable to free read/write lock.",
175
0
       function );
176
177
0
      result = -1;
178
0
    }
179
0
#endif
180
    /* The extent values reference is freed elsewhere
181
     */
182
0
    memory_free(
183
0
     internal_extent_descriptor );
184
0
  }
185
0
  return( result );
186
0
}
187
188
/* Retrieves the extent type
189
 * Returns 1 if successful or -1 on error
190
 */
191
int libvmdk_extent_descriptor_get_type(
192
     libvmdk_extent_descriptor_t *extent_descriptor,
193
     int *type,
194
     libcerror_error_t **error )
195
0
{
196
0
  libvmdk_internal_extent_descriptor_t *internal_extent_descriptor = NULL;
197
0
  static char *function                                            = "libvmdk_extent_descriptor_get_type";
198
0
  int result                                                       = 1;
199
200
0
  if( extent_descriptor == NULL )
201
0
  {
202
0
    libcerror_error_set(
203
0
     error,
204
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
205
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
206
0
     "%s: invalid extent descriptor.",
207
0
     function );
208
209
0
    return( -1 );
210
0
  }
211
0
  internal_extent_descriptor = (libvmdk_internal_extent_descriptor_t *) extent_descriptor;
212
213
0
#if defined( HAVE_LIBVMDK_MULTI_THREAD_SUPPORT )
214
0
  if( libcthreads_read_write_lock_grab_for_read(
215
0
       internal_extent_descriptor->read_write_lock,
216
0
       error ) != 1 )
217
0
  {
218
0
    libcerror_error_set(
219
0
     error,
220
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
221
0
     LIBCERROR_RUNTIME_ERROR_SET_FAILED,
222
0
     "%s: unable to grab read/write lock for reading.",
223
0
     function );
224
225
0
    return( -1 );
226
0
  }
227
0
#endif
228
0
  if( libvmdk_extent_values_get_type(
229
0
       internal_extent_descriptor->extent_values,
230
0
       type,
231
0
       error ) != 1 )
232
0
  {
233
0
    libcerror_error_set(
234
0
     error,
235
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
236
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
237
0
     "%s: unable to retrieve type.",
238
0
     function );
239
240
0
    result = -1;
241
0
  }
242
0
#if defined( HAVE_LIBVMDK_MULTI_THREAD_SUPPORT )
243
0
  if( libcthreads_read_write_lock_release_for_read(
244
0
       internal_extent_descriptor->read_write_lock,
245
0
       error ) != 1 )
246
0
  {
247
0
    libcerror_error_set(
248
0
     error,
249
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
250
0
     LIBCERROR_RUNTIME_ERROR_SET_FAILED,
251
0
     "%s: unable to release read/write lock for reading.",
252
0
     function );
253
254
0
    return( -1 );
255
0
  }
256
0
#endif
257
0
  return( result );
258
0
}
259
260
/* Retrieves the extent range (offset and size)
261
 * Returns 1 if successful or -1 on error
262
 */
263
int libvmdk_extent_descriptor_get_range(
264
     libvmdk_extent_descriptor_t *extent_descriptor,
265
     off64_t *offset,
266
     size64_t *size,
267
     libcerror_error_t **error )
268
0
{
269
0
  libvmdk_internal_extent_descriptor_t *internal_extent_descriptor = NULL;
270
0
  static char *function                                            = "libvmdk_extent_descriptor_get_range";
271
0
  int result                                                       = 1;
272
273
0
  if( extent_descriptor == NULL )
274
0
  {
275
0
    libcerror_error_set(
276
0
     error,
277
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
278
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
279
0
     "%s: invalid extent descriptor.",
280
0
     function );
281
282
0
    return( -1 );
283
0
  }
284
0
  internal_extent_descriptor = (libvmdk_internal_extent_descriptor_t *) extent_descriptor;
285
286
0
#if defined( HAVE_LIBVMDK_MULTI_THREAD_SUPPORT )
287
0
  if( libcthreads_read_write_lock_grab_for_read(
288
0
       internal_extent_descriptor->read_write_lock,
289
0
       error ) != 1 )
290
0
  {
291
0
    libcerror_error_set(
292
0
     error,
293
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
294
0
     LIBCERROR_RUNTIME_ERROR_SET_FAILED,
295
0
     "%s: unable to grab read/write lock for reading.",
296
0
     function );
297
298
0
    return( -1 );
299
0
  }
300
0
#endif
301
0
  if( libvmdk_extent_values_get_range(
302
0
       internal_extent_descriptor->extent_values,
303
0
       offset,
304
0
       size,
305
0
       error ) != 1 )
306
0
  {
307
0
    libcerror_error_set(
308
0
     error,
309
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
310
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
311
0
     "%s: unable to retrieve range.",
312
0
     function );
313
314
0
    result = -1;
315
0
  }
316
0
#if defined( HAVE_LIBVMDK_MULTI_THREAD_SUPPORT )
317
0
  if( libcthreads_read_write_lock_release_for_read(
318
0
       internal_extent_descriptor->read_write_lock,
319
0
       error ) != 1 )
320
0
  {
321
0
    libcerror_error_set(
322
0
     error,
323
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
324
0
     LIBCERROR_RUNTIME_ERROR_SET_FAILED,
325
0
     "%s: unable to release read/write lock for reading.",
326
0
     function );
327
328
0
    return( -1 );
329
0
  }
330
0
#endif
331
0
  return( result );
332
0
}
333
334
/* Retrieves the size of the UTF-8 encoded filename
335
 * The returned size includes the end of string character
336
 * Returns 1 if successful, 0 if not available or -1 on error
337
 */
338
int libvmdk_extent_descriptor_get_utf8_filename_size(
339
     libvmdk_extent_descriptor_t *extent_descriptor,
340
     size_t *utf8_string_size,
341
     libcerror_error_t **error )
342
0
{
343
0
  libvmdk_internal_extent_descriptor_t *internal_extent_descriptor = NULL;
344
0
  static char *function                                            = "libvmdk_extent_descriptor_get_utf8_filename_size";
345
0
  int result                                                       = 1;
346
347
0
  if( extent_descriptor == NULL )
348
0
  {
349
0
    libcerror_error_set(
350
0
     error,
351
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
352
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
353
0
     "%s: invalid extent descriptor.",
354
0
     function );
355
356
0
    return( -1 );
357
0
  }
358
0
  internal_extent_descriptor = (libvmdk_internal_extent_descriptor_t *) extent_descriptor;
359
360
0
#if defined( HAVE_LIBVMDK_MULTI_THREAD_SUPPORT )
361
0
  if( libcthreads_read_write_lock_grab_for_read(
362
0
       internal_extent_descriptor->read_write_lock,
363
0
       error ) != 1 )
364
0
  {
365
0
    libcerror_error_set(
366
0
     error,
367
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
368
0
     LIBCERROR_RUNTIME_ERROR_SET_FAILED,
369
0
     "%s: unable to grab read/write lock for reading.",
370
0
     function );
371
372
0
    return( -1 );
373
0
  }
374
0
#endif
375
0
  if( libvmdk_extent_values_get_utf8_filename_size(
376
0
       internal_extent_descriptor->extent_values,
377
0
       utf8_string_size,
378
0
       error ) != 1 )
379
0
  {
380
0
    libcerror_error_set(
381
0
     error,
382
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
383
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
384
0
     "%s: unable to retrieve UTF-8 string size.",
385
0
     function );
386
387
0
    result = -1;
388
0
  }
389
0
#if defined( HAVE_LIBVMDK_MULTI_THREAD_SUPPORT )
390
0
  if( libcthreads_read_write_lock_release_for_read(
391
0
       internal_extent_descriptor->read_write_lock,
392
0
       error ) != 1 )
393
0
  {
394
0
    libcerror_error_set(
395
0
     error,
396
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
397
0
     LIBCERROR_RUNTIME_ERROR_SET_FAILED,
398
0
     "%s: unable to release read/write lock for reading.",
399
0
     function );
400
401
0
    return( -1 );
402
0
  }
403
0
#endif
404
0
  return( result );
405
0
}
406
407
/* Retrieves the UTF-8 encoded filename
408
 * The size should include the end of string character
409
 * Returns 1 if successful, 0 if not available or -1 on error
410
 */
411
int libvmdk_extent_descriptor_get_utf8_filename(
412
     libvmdk_extent_descriptor_t *extent_descriptor,
413
     uint8_t *utf8_string,
414
     size_t utf8_string_size,
415
     libcerror_error_t **error )
416
0
{
417
0
  libvmdk_internal_extent_descriptor_t *internal_extent_descriptor = NULL;
418
0
  static char *function                                            = "libvmdk_extent_descriptor_get_utf8_filename";
419
0
  int result                                                       = 1;
420
421
0
  if( extent_descriptor == NULL )
422
0
  {
423
0
    libcerror_error_set(
424
0
     error,
425
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
426
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
427
0
     "%s: invalid extent descriptor.",
428
0
     function );
429
430
0
    return( -1 );
431
0
  }
432
0
  internal_extent_descriptor = (libvmdk_internal_extent_descriptor_t *) extent_descriptor;
433
434
0
#if defined( HAVE_LIBVMDK_MULTI_THREAD_SUPPORT )
435
0
  if( libcthreads_read_write_lock_grab_for_read(
436
0
       internal_extent_descriptor->read_write_lock,
437
0
       error ) != 1 )
438
0
  {
439
0
    libcerror_error_set(
440
0
     error,
441
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
442
0
     LIBCERROR_RUNTIME_ERROR_SET_FAILED,
443
0
     "%s: unable to grab read/write lock for reading.",
444
0
     function );
445
446
0
    return( -1 );
447
0
  }
448
0
#endif
449
0
  if( libvmdk_extent_values_get_utf8_filename(
450
0
       internal_extent_descriptor->extent_values,
451
0
       utf8_string,
452
0
       utf8_string_size,
453
0
       error ) != 1 )
454
0
  {
455
0
    libcerror_error_set(
456
0
     error,
457
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
458
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
459
0
     "%s: unable to retrieve UTF-8 string.",
460
0
     function );
461
462
0
    result = -1;
463
0
  }
464
0
#if defined( HAVE_LIBVMDK_MULTI_THREAD_SUPPORT )
465
0
  if( libcthreads_read_write_lock_release_for_read(
466
0
       internal_extent_descriptor->read_write_lock,
467
0
       error ) != 1 )
468
0
  {
469
0
    libcerror_error_set(
470
0
     error,
471
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
472
0
     LIBCERROR_RUNTIME_ERROR_SET_FAILED,
473
0
     "%s: unable to release read/write lock for reading.",
474
0
     function );
475
476
0
    return( -1 );
477
0
  }
478
0
#endif
479
0
  return( result );
480
0
}
481
482
/* Retrieves the size of the UTF-16 encoded filename
483
 * The returned size includes the end of string character
484
 * Returns 1 if successful, 0 if not available or -1 on error
485
 */
486
int libvmdk_extent_descriptor_get_utf16_filename_size(
487
     libvmdk_extent_descriptor_t *extent_descriptor,
488
     size_t *utf16_string_size,
489
     libcerror_error_t **error )
490
0
{
491
0
  libvmdk_internal_extent_descriptor_t *internal_extent_descriptor = NULL;
492
0
  static char *function                                            = "libvmdk_extent_descriptor_get_utf16_filename_size";
493
0
  int result                                                       = 1;
494
495
0
  if( extent_descriptor == NULL )
496
0
  {
497
0
    libcerror_error_set(
498
0
     error,
499
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
500
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
501
0
     "%s: invalid extent descriptor.",
502
0
     function );
503
504
0
    return( -1 );
505
0
  }
506
0
  internal_extent_descriptor = (libvmdk_internal_extent_descriptor_t *) extent_descriptor;
507
508
0
#if defined( HAVE_LIBVMDK_MULTI_THREAD_SUPPORT )
509
0
  if( libcthreads_read_write_lock_grab_for_read(
510
0
       internal_extent_descriptor->read_write_lock,
511
0
       error ) != 1 )
512
0
  {
513
0
    libcerror_error_set(
514
0
     error,
515
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
516
0
     LIBCERROR_RUNTIME_ERROR_SET_FAILED,
517
0
     "%s: unable to grab read/write lock for reading.",
518
0
     function );
519
520
0
    return( -1 );
521
0
  }
522
0
#endif
523
0
  if( libvmdk_extent_values_get_utf16_filename_size(
524
0
       internal_extent_descriptor->extent_values,
525
0
       utf16_string_size,
526
0
       error ) != 1 )
527
0
  {
528
0
    libcerror_error_set(
529
0
     error,
530
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
531
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
532
0
     "%s: unable to retrieve UTF-16 string size.",
533
0
     function );
534
535
0
    result = -1;
536
0
  }
537
0
#if defined( HAVE_LIBVMDK_MULTI_THREAD_SUPPORT )
538
0
  if( libcthreads_read_write_lock_release_for_read(
539
0
       internal_extent_descriptor->read_write_lock,
540
0
       error ) != 1 )
541
0
  {
542
0
    libcerror_error_set(
543
0
     error,
544
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
545
0
     LIBCERROR_RUNTIME_ERROR_SET_FAILED,
546
0
     "%s: unable to release read/write lock for reading.",
547
0
     function );
548
549
0
    return( -1 );
550
0
  }
551
0
#endif
552
0
  return( result );
553
0
}
554
555
/* Retrieves the UTF-16 encoded filename
556
 * The size should include the end of string character
557
 * Returns 1 if successful, 0 if not available or -1 on error
558
 */
559
int libvmdk_extent_descriptor_get_utf16_filename(
560
     libvmdk_extent_descriptor_t *extent_descriptor,
561
     uint16_t *utf16_string,
562
     size_t utf16_string_size,
563
     libcerror_error_t **error )
564
0
{
565
0
  libvmdk_internal_extent_descriptor_t *internal_extent_descriptor = NULL;
566
0
  static char *function                                            = "libvmdk_extent_descriptor_get_utf16_filename";
567
0
  int result                                                       = 1;
568
569
0
  if( extent_descriptor == NULL )
570
0
  {
571
0
    libcerror_error_set(
572
0
     error,
573
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
574
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
575
0
     "%s: invalid extent descriptor.",
576
0
     function );
577
578
0
    return( -1 );
579
0
  }
580
0
  internal_extent_descriptor = (libvmdk_internal_extent_descriptor_t *) extent_descriptor;
581
582
0
#if defined( HAVE_LIBVMDK_MULTI_THREAD_SUPPORT )
583
0
  if( libcthreads_read_write_lock_grab_for_read(
584
0
       internal_extent_descriptor->read_write_lock,
585
0
       error ) != 1 )
586
0
  {
587
0
    libcerror_error_set(
588
0
     error,
589
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
590
0
     LIBCERROR_RUNTIME_ERROR_SET_FAILED,
591
0
     "%s: unable to grab read/write lock for reading.",
592
0
     function );
593
594
0
    return( -1 );
595
0
  }
596
0
#endif
597
0
  if( libvmdk_extent_values_get_utf16_filename(
598
0
       internal_extent_descriptor->extent_values,
599
0
       utf16_string,
600
0
       utf16_string_size,
601
0
       error ) != 1 )
602
0
  {
603
0
    libcerror_error_set(
604
0
     error,
605
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
606
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
607
0
     "%s: unable to retrieve UTF-16 string.",
608
0
     function );
609
610
0
    result = -1;
611
0
  }
612
0
#if defined( HAVE_LIBVMDK_MULTI_THREAD_SUPPORT )
613
0
  if( libcthreads_read_write_lock_release_for_read(
614
0
       internal_extent_descriptor->read_write_lock,
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_SET_FAILED,
621
0
     "%s: unable to release read/write lock for reading.",
622
0
     function );
623
624
0
    return( -1 );
625
0
  }
626
0
#endif
627
0
  return( result );
628
0
}
629