diff --git a/configure.ac b/configure.ac index 27c39456..401ea399 100644 --- a/configure.ac +++ b/configure.ac @@ -460,6 +460,20 @@ if test -z "${use_ewf}"; then else LIBS="${ewf_lib_a} $LIBS" fi + AC_TRY_COMPILE([#include ], + [void foo() { libewf_get_bytes_per_sector(NULL,NULL); }], + ac_cv_c_libewf_get_bytes_per_sector_have_two_arguments=yes, + ac_cv_c_libewf_get_bytes_per_sector_have_two_arguments=no) + if test "${ac_cv_c_libewf_get_bytes_per_sector_have_two_arguments}" != "no"; then + AC_DEFINE([LIBEWF_GET_BYTES_PER_SECTOR_HAVE_TWO_ARGUMENTS], 1, [Define if libewf_get_bytes_per_sector takes two parameters.]) + fi + AC_TRY_COMPILE([#include ], + [void foo() { libewf_get_media_size(NULL,NULL); }], + ac_cv_c_libewf_get_media_size_have_two_arguments=yes, + ac_cv_c_libewf_get_media_size_have_two_arguments=no) + if test "${ac_cv_c_libewf_get_media_size_have_two_arguments}" != "no"; then + AC_DEFINE([LIBEWF_GET_MEDIA_SIZE_HAVE_TWO_ARGUMENTS], 1, [Define if libewf_get_media_size takes two parameters.]) + fi ],[ AC_MSG_WARN(No ewf library detected) LIBS="$OLDLIBS" diff --git a/src/ewf.c b/src/ewf.c index 4152f736..ed45d5d6 100644 --- a/src/ewf.c +++ b/src/ewf.c @@ -124,13 +124,33 @@ disk_t *fewf_init(const char *device, const int verbose, const arch_fnct_t *arch } disk_car=(disk_t *)MALLOC(sizeof(*disk_car)); disk_car->arch=arch; +#ifdef LIBEWF_GET_BYTES_PER_SECTOR_HAVE_TWO_ARGUMENTS + { + uint32_t bytes_per_sector; + if(libewf_get_bytes_per_sector(data->handle, &bytes_per_sector)<0) + disk_car->sector_size=DEFAULT_SECTOR_SIZE; + else + disk_car->sector_size=bytes_per_sector; + } +#else disk_car->sector_size=libewf_get_bytes_per_sector(data->handle); +#endif // printf("libewf_get_bytes_per_sector %u\n",disk_car->sector_size); if(disk_car->sector_size==0) disk_car->sector_size=DEFAULT_SECTOR_SIZE; +#ifdef LIBEWF_GET_MEDIA_SIZE_HAVE_TWO_ARGUMENTS + { + size64_t media_size; + if(libewf_get_media_size(data->handle, &media_size)<0) + disk_car->disk_size=0; + else + disk_car->disk_size=media_size; + } +#else disk_car->disk_size=libewf_get_media_size(data->handle); - disk_car->disk_real_size=disk_car->disk_size; +#endif // printf("libewf_get_media_size %llu\n",(long long unsigned) (disk_car->sector_size/disk_car->sector_size)); + disk_car->disk_real_size=disk_car->disk_size; disk_car->CHS.head=255-1; disk_car->CHS.sector=63; disk_car->CHS.cylinder=(disk_car->disk_size/(disk_car->CHS.head+1))/disk_car->CHS.sector/disk_car->sector_size-1;