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