/* Retrieves the number of entries in the array * Returns 1 if successful or -1 on error */ int libcdata_array_get_number_of_entries( libcdata_array_t *array, int *number_of_entries, libcerror_error_t **error ) { libcdata_internal_array_t *internal_array = NULL; static char *function = "libcdata_array_get_number_of_entries"; if( array == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid array.", function ); return( -1 ); } internal_array = (libcdata_internal_array_t *) array; if( number_of_entries == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid number of entries.", function ); return( -1 ); } #if defined( HAVE_MULTI_THREAD_SUPPORT ) && !defined( HAVE_LOCAL_LIBCDATA ) if( libcthreads_read_write_lock_grab_for_read( internal_array->read_write_lock, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_SET_FAILED, "%s: unable to grab read/write lock for reading.", function ); return( -1 ); } #endif *number_of_entries = internal_array->number_of_entries; #if defined( HAVE_MULTI_THREAD_SUPPORT ) && !defined( HAVE_LOCAL_LIBCDATA ) if( libcthreads_read_write_lock_release_for_read( internal_array->read_write_lock, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_SET_FAILED, "%s: unable to release read/write lock for reading.", function ); return( -1 ); } #endif return( 1 ); }
/* Retrieves a specific entry from the array * * Uses the entry_compare_function to determine the similarity of the entries * The entry_compare_function should return LIBCDATA_BTREE_COMPARE_LESS, * LIBCDATA_BTREE_COMPARE_EQUAL, LIBCDATA_BTREE_COMPARE_GREATER if successful or -1 on error * * Returns 1 if successful, 0 if no such value or -1 on error */ int libcdata_array_get_entry_by_value( libcdata_array_t *array, intptr_t *entry, int (*entry_compare_function)( intptr_t *first_entry, intptr_t *second_entry, libcerror_error_t **error ), intptr_t **existing_entry, libcerror_error_t **error ) { libcdata_internal_array_t *internal_array = NULL; static char *function = "libcdata_array_get_entry_by_value"; int compare_result = 0; int entry_index = 0; int result = 0; if( array == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid array.", function ); return( -1 ); } internal_array = (libcdata_internal_array_t *) array; if( entry_compare_function == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid entry compare function.", function ); return( -1 ); } if( existing_entry == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid existing entry.", function ); return( -1 ); } #if defined( HAVE_MULTI_THREAD_SUPPORT ) && !defined( HAVE_LOCAL_LIBCDATA ) if( libcthreads_read_write_lock_grab_for_read( internal_array->read_write_lock, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_SET_FAILED, "%s: unable to grab read/write lock for reading.", function ); return( -1 ); } #endif if( internal_array->entries != NULL ) { for( entry_index = 0; entry_index < internal_array->number_of_entries; entry_index++ ) { compare_result = entry_compare_function( entry, internal_array->entries[ entry_index ], error ); if( compare_result == -1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to compare entry: %d.", function, entry_index ); result = -1; break; } else if( compare_result == LIBCDATA_COMPARE_EQUAL ) { *existing_entry = internal_array->entries[ entry_index ]; result = 1; break; } } } #if defined( HAVE_MULTI_THREAD_SUPPORT ) && !defined( HAVE_LOCAL_LIBCDATA ) if( libcthreads_read_write_lock_release_for_read( internal_array->read_write_lock, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_SET_FAILED, "%s: unable to release read/write lock for reading.", function ); return( -1 ); } #endif return( result ); }
/* Clones the array and its entries * * The entries are cloned using the entry_clone_function * On error the entries are freed using the entry_free_function * * Returns 1 if successful or -1 on error */ int libcdata_array_clone( libcdata_array_t **destination_array, libcdata_array_t *source_array, int (*entry_free_function)( intptr_t **entry, libcerror_error_t **error ), int (*entry_clone_function)( intptr_t **destination_entry, intptr_t *source_entry, libcerror_error_t **error ), libcerror_error_t **error ) { libcdata_internal_array_t *internal_destination_array = NULL; libcdata_internal_array_t *internal_source_array = NULL; static char *function = "libcdata_array_clone"; int entry_iterator = 0; int result = 1; if( destination_array == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid destination array.", function ); return( -1 ); } if( *destination_array != NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET, "%s: invalid destination array already set.", function ); return( -1 ); } if( entry_free_function == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid entry free function.", function ); return( -1 ); } if( entry_clone_function == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid entry clone function.", function ); return( -1 ); } if( source_array == NULL ) { *destination_array = NULL; return( 1 ); } internal_source_array = (libcdata_internal_array_t *) source_array; if( libcdata_array_initialize( destination_array, internal_source_array->number_of_entries, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, "%s: unable to create destination array.", function ); goto on_error; } if( *destination_array == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_VALUE_MISSING, "%s: missing destination array.", function ); goto on_error; } internal_destination_array = (libcdata_internal_array_t *) *destination_array; #if defined( HAVE_MULTI_THREAD_SUPPORT ) && !defined( HAVE_LOCAL_LIBCDATA ) if( libcthreads_read_write_lock_grab_for_read( internal_source_array->read_write_lock, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_SET_FAILED, "%s: unable to grab read/write lock for reading.", function ); goto on_error; } #endif if( internal_source_array->entries != NULL ) { for( entry_iterator = 0; entry_iterator < internal_source_array->number_of_entries; entry_iterator++ ) { if( internal_source_array->entries[ entry_iterator ] != NULL ) { result = entry_clone_function( &( internal_destination_array->entries[ entry_iterator ] ), internal_source_array->entries[ entry_iterator ], error ); if( result != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, "%s: unable to create destination array entry: %d.", function, entry_iterator ); break; } } } } #if defined( HAVE_MULTI_THREAD_SUPPORT ) && !defined( HAVE_LOCAL_LIBCDATA ) if( libcthreads_read_write_lock_release_for_read( internal_source_array->read_write_lock, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_SET_FAILED, "%s: unable to release read/write lock for reading.", function ); goto on_error; } #endif if( result != 1 ) { goto on_error; } return( 1 ); on_error: if( *destination_array != NULL ) { libcdata_array_free( destination_array, entry_free_function, NULL ); } return( -1 ); }
/* Retrieves a specific extent descriptor * Returns 1 if successful or -1 on error */ int libvmdk_handle_get_extent_descriptor( libvmdk_handle_t *handle, int extent_index, libvmdk_extent_descriptor_t **extent_descriptor, libcerror_error_t **error ) { libvmdk_internal_handle_t *internal_handle = NULL; static char *function = "libvmdk_handle_get_extent_descriptor"; if( handle == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid handle.", function ); return( -1 ); } internal_handle = (libvmdk_internal_handle_t *) handle; if( internal_handle->descriptor_file == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_VALUE_MISSING, "%s: invalid handle - missing descriptor file.", function ); return( -1 ); } if( extent_descriptor == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid extent descriptor.", function ); return( -1 ); } if( *extent_descriptor != NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET, "%s: invalid extent descriptor value already set.", function ); return( -1 ); } #if defined( HAVE_LIBVMDK_MULTI_THREAD_SUPPORT ) if( libcthreads_read_write_lock_grab_for_read( internal_handle->read_write_lock, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_SET_FAILED, "%s: unable to grab read/write lock for reading.", function ); return( -1 ); } #endif if( libvmdk_descriptor_file_get_extent_by_index( internal_handle->descriptor_file, extent_index, (libvmdk_internal_extent_descriptor_t **) extent_descriptor, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve extent: %d from descriptor file.", function, extent_index ); goto on_error; } if( *extent_descriptor == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_VALUE_MISSING, "%s: missing extent descriptor: %d.", function, extent_index ); goto on_error; } #if defined( HAVE_LIBVMDK_MULTI_THREAD_SUPPORT ) if( libcthreads_read_write_lock_release_for_read( internal_handle->read_write_lock, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_SET_FAILED, "%s: unable to release read/write lock for reading.", function ); return( -1 ); } #endif return( 1 ); on_error: #if defined( HAVE_LIBVMDK_MULTI_THREAD_SUPPORT ) libcthreads_read_write_lock_release_for_read( internal_handle->read_write_lock, NULL ); #endif return( -1 ); }
/* Retrieves a specific entry from the array * Returns 1 if successful or -1 on error */ int libcdata_array_get_entry_by_index( libcdata_array_t *array, int entry_index, intptr_t **entry, libcerror_error_t **error ) { libcdata_internal_array_t *internal_array = NULL; static char *function = "libcdata_array_get_entry_by_index"; if( array == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid array.", function ); return( -1 ); } internal_array = (libcdata_internal_array_t *) array; if( internal_array->entries == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_VALUE_MISSING, "%s: invalid array - missing entries.", function ); return( -1 ); } if( ( entry_index < 0 ) || ( entry_index >= internal_array->number_of_entries ) ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_VALUE_OUT_OF_BOUNDS, "%s: invalid entry index value out of bounds.", function ); return( -1 ); } if( entry == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid entry.", function ); return( -1 ); } #if defined( HAVE_MULTI_THREAD_SUPPORT ) && !defined( HAVE_LOCAL_LIBCDATA ) if( libcthreads_read_write_lock_grab_for_read( internal_array->read_write_lock, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_SET_FAILED, "%s: unable to grab read/write lock for reading.", function ); return( -1 ); } #endif *entry = internal_array->entries[ entry_index ]; #if defined( HAVE_MULTI_THREAD_SUPPORT ) && !defined( HAVE_LOCAL_LIBCDATA ) if( libcthreads_read_write_lock_release_for_read( internal_array->read_write_lock, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_SET_FAILED, "%s: unable to release read/write lock for reading.", function ); return( -1 ); } #endif return( 1 ); }
/* Retrieves the UTF-16 encoded parent filename * The size should include the end of string character * Returns 1 if successful, 0 if not available or -1 on error */ int libvmdk_handle_get_utf16_parent_filename( libvmdk_handle_t *handle, uint16_t *utf16_string, size_t utf16_string_size, libcerror_error_t **error ) { libvmdk_internal_handle_t *internal_handle = NULL; static char *function = "libvmdk_handle_get_utf16_parent_filename"; int result = 0; if( handle == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid handle.", function ); return( -1 ); } internal_handle = (libvmdk_internal_handle_t *) handle; #if defined( HAVE_LIBVMDK_MULTI_THREAD_SUPPORT ) if( libcthreads_read_write_lock_grab_for_read( internal_handle->read_write_lock, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_SET_FAILED, "%s: unable to grab read/write lock for reading.", function ); return( -1 ); } #endif result = libvmdk_descriptor_file_get_utf16_parent_filename( internal_handle->descriptor_file, utf16_string, utf16_string_size, error ); if( result == -1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve UTF-16 parent filename.", function ); goto on_error; } #if defined( HAVE_LIBVMDK_MULTI_THREAD_SUPPORT ) if( libcthreads_read_write_lock_release_for_read( internal_handle->read_write_lock, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_SET_FAILED, "%s: unable to release read/write lock for reading.", function ); return( -1 ); } #endif return( result ); on_error: #if defined( HAVE_LIBVMDK_MULTI_THREAD_SUPPORT ) libcthreads_read_write_lock_release_for_read( internal_handle->read_write_lock, NULL ); #endif return( -1 ); }
/* Retrieves the number of extents * Returns 1 if successful or -1 on error */ int libvmdk_handle_get_number_of_extents( libvmdk_handle_t *handle, int *number_of_extents, libcerror_error_t **error ) { libvmdk_internal_handle_t *internal_handle = NULL; static char *function = "libvmdk_handle_get_number_of_extents"; if( handle == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid handle.", function ); return( -1 ); } internal_handle = (libvmdk_internal_handle_t *) handle; if( internal_handle->descriptor_file == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_VALUE_MISSING, "%s: invalid handle - missing descriptor file.", function ); return( -1 ); } #if defined( HAVE_LIBVMDK_MULTI_THREAD_SUPPORT ) if( libcthreads_read_write_lock_grab_for_read( internal_handle->read_write_lock, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_SET_FAILED, "%s: unable to grab read/write lock for reading.", function ); return( -1 ); } #endif if( libvmdk_descriptor_file_get_number_of_extents( internal_handle->descriptor_file, number_of_extents, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve number of extents.", function ); goto on_error; } #if defined( HAVE_LIBVMDK_MULTI_THREAD_SUPPORT ) if( libcthreads_read_write_lock_release_for_read( internal_handle->read_write_lock, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_SET_FAILED, "%s: unable to release read/write lock for reading.", function ); return( -1 ); } #endif return( 1 ); on_error: #if defined( HAVE_LIBVMDK_MULTI_THREAD_SUPPORT ) libcthreads_read_write_lock_release_for_read( internal_handle->read_write_lock, NULL ); #endif return( -1 ); }
/* Retrieves the disk type * Returns 1 if successful or -1 on error */ int libvmdk_handle_get_disk_type( libvmdk_handle_t *handle, int *disk_type, libcerror_error_t **error ) { libvmdk_internal_handle_t *internal_handle = NULL; static char *function = "libvmdk_handle_get_disk_type"; if( handle == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid handle.", function ); return( -1 ); } internal_handle = (libvmdk_internal_handle_t *) handle; if( internal_handle->descriptor_file == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_VALUE_MISSING, "%s: invalid handle - missing descriptor file.", function ); return( -1 ); } if( disk_type == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid disk type.", function ); return( -1 ); } #if defined( HAVE_LIBVMDK_MULTI_THREAD_SUPPORT ) if( libcthreads_read_write_lock_grab_for_read( internal_handle->read_write_lock, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_SET_FAILED, "%s: unable to grab read/write lock for reading.", function ); return( -1 ); } #endif *disk_type = internal_handle->descriptor_file->disk_type; #if defined( HAVE_LIBVMDK_MULTI_THREAD_SUPPORT ) if( libcthreads_read_write_lock_release_for_read( internal_handle->read_write_lock, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_SET_FAILED, "%s: unable to release read/write lock for reading.", function ); return( -1 ); } #endif return( 1 ); }
/* Retrieves a specific store identifier * Returns 1 if successful or -1 on error */ int libvshadow_volume_get_store_identifier( libvshadow_volume_t *volume, int store_index, uint8_t *guid, size_t size, libcerror_error_t **error ) { libvshadow_internal_volume_t *internal_volume = NULL; libvshadow_store_descriptor_t *store_descriptor = NULL; static char *function = "libvshadow_volume_get_store_identifier"; if( volume == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid volume.", function ); return( -1 ); } internal_volume = (libvshadow_internal_volume_t *) volume; #if defined( HAVE_LIBVSHADOW_MULTI_THREAD_SUPPORT ) if( libcthreads_read_write_lock_grab_for_read( internal_volume->read_write_lock, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_SET_FAILED, "%s: unable to grab read/write lock for reading.", function ); return( -1 ); } #endif if( libcdata_array_get_entry_by_index( internal_volume->store_descriptors_array, store_index, (intptr_t **) &store_descriptor, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve store descriptor: %d.", function, store_index ); goto on_error; } if( libvshadow_store_descriptor_get_identifier( store_descriptor, guid, size, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve identifier from store descriptor: %d.", function, store_index ); goto on_error; } #if defined( HAVE_LIBVSHADOW_MULTI_THREAD_SUPPORT ) if( libcthreads_read_write_lock_release_for_read( internal_volume->read_write_lock, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_SET_FAILED, "%s: unable to release read/write lock for reading.", function ); return( -1 ); } #endif return( 1 ); on_error: #if defined( HAVE_LIBVSHADOW_MULTI_THREAD_SUPPORT ) libcthreads_read_write_lock_release_for_read( internal_volume->read_write_lock, NULL ); #endif return( -1 ); }
/* Retrieves a specific store * Returns 1 if successful or -1 on error */ int libvshadow_volume_get_store( libvshadow_volume_t *volume, int store_index, libvshadow_store_t **store, libcerror_error_t **error ) { libvshadow_internal_volume_t *internal_volume = NULL; static char *function = "libvshadow_volume_get_store"; int result = 1; if( volume == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid volume.", function ); return( -1 ); } internal_volume = (libvshadow_internal_volume_t *) volume; if( store == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid store.", function ); return( -1 ); } if( *store != NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET, "%s: invalid store value already set.", function ); return( -1 ); } #if defined( HAVE_LIBVSHADOW_MULTI_THREAD_SUPPORT ) if( libcthreads_read_write_lock_grab_for_read( internal_volume->read_write_lock, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_SET_FAILED, "%s: unable to grab read/write lock for reading.", function ); return( -1 ); } #endif if( libvshadow_store_initialize( store, internal_volume->file_io_handle, internal_volume->io_handle, internal_volume, store_index, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, "%s: unable to create store: %d.", function, store_index ); result = -1; } #if defined( HAVE_LIBVSHADOW_MULTI_THREAD_SUPPORT ) if( libcthreads_read_write_lock_release_for_read( internal_volume->read_write_lock, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_SET_FAILED, "%s: unable to release read/write lock for reading.", function ); return( -1 ); } #endif return( result ); }
/* Retrieves the number of stores * Returns 1 if successful or -1 on error */ int libvshadow_volume_get_number_of_stores( libvshadow_volume_t *volume, int *number_of_stores, libcerror_error_t **error ) { libvshadow_internal_volume_t *internal_volume = NULL; static char *function = "libvshadow_volume_get_number_of_stores"; int result = 1; if( volume == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid volume.", function ); return( -1 ); } internal_volume = (libvshadow_internal_volume_t *) volume; #if defined( HAVE_LIBVSHADOW_MULTI_THREAD_SUPPORT ) if( libcthreads_read_write_lock_grab_for_read( internal_volume->read_write_lock, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_SET_FAILED, "%s: unable to grab read/write lock for reading.", function ); return( -1 ); } #endif if( libcdata_array_get_number_of_entries( internal_volume->store_descriptors_array, number_of_stores, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve number of store descriptors.", function ); result = -1; } #if defined( HAVE_LIBVSHADOW_MULTI_THREAD_SUPPORT ) if( libcthreads_read_write_lock_release_for_read( internal_volume->read_write_lock, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_SET_FAILED, "%s: unable to release read/write lock for reading.", function ); return( -1 ); } #endif return( result ); }
/* Retrieves the size * Returns 1 if successful or -1 on error */ int libvshadow_volume_get_size( libvshadow_volume_t *volume, size64_t *size, libcerror_error_t **error ) { libvshadow_internal_volume_t *internal_volume = NULL; static char *function = "libvshadow_volume_get_size"; if( volume == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid volume.", function ); return( -1 ); } internal_volume = (libvshadow_internal_volume_t *) volume; if( size == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid size.", function ); return( -1 ); } #if defined( HAVE_LIBVSHADOW_MULTI_THREAD_SUPPORT ) if( libcthreads_read_write_lock_grab_for_read( internal_volume->read_write_lock, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_SET_FAILED, "%s: unable to grab read/write lock for reading.", function ); return( -1 ); } #endif *size = internal_volume->size; #if defined( HAVE_LIBVSHADOW_MULTI_THREAD_SUPPORT ) if( libcthreads_read_write_lock_release_for_read( internal_volume->read_write_lock, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_SET_FAILED, "%s: unable to release read/write lock for reading.", function ); return( -1 ); } #endif return( 1 ); }