cgsecurity / testdisk

TestDisk & PhotoRec
https://www.cgsecurity.org/
GNU General Public License v2.0
1.61k stars 197 forks source link

build failure in apfs_common.h #152

Closed landryb closed 5 months ago

landryb commented 6 months ago

On OpenBSD, paddr_t is defined in sys/types.h, and thus 7.2 fails to build:

./apfs_common.h:37:19: error: typedef redefinition with different types ('int64_t' (aka 'long long') vs '__paddr_t' (aka 'unsigned long'))
  typedef int64_t paddr_t;
                  ^
/usr/include/sys/types.h:126:19: note: previous definition is here
typedef __paddr_t       paddr_t;

removing the line allows 7.2 to build.

cgsecurity commented 6 months ago

Can you try the following patch ?

diff -ruw testdisk-7.2/configure.ac testdisk-7.3-WIP/configure.ac
--- testdisk-7.2/configure.ac   2024-02-02 16:56:43.131177466 +0100
+++ testdisk-7.3-WIP/configure.ac       2024-03-31 17:28:56.349973770 +0200
@@ -486,6 +486,11 @@
 AC_TYPE_SIZE_T
 AC_STRUCT_ST_BLOCKS
 AC_STRUCT_TM
+AC_CHECK_TYPE(
+ [paddr_t],
+ [AC_DEFINE( [HAVE_PADDR_T], [1], [Define to 1 if paddr_t is available])],
+ [AC_DEFINE( [HAVE_PADDR_T], [0], [Define to 0 if paddr_t is not available])])
+
 AC_CHECK_MEMBERS([struct stat.st_blksize])
 AC_CHECK_MEMBERS([struct stat.st_rdev])
 AC_CHECK_MEMBERS([dal_t.block_size],,,[#include <dal/dal.h>])
diff -ruw testdisk-7.2/src/apfs_common.h testdisk-7.3-WIP/src/apfs_common.h
--- testdisk-7.2/src/apfs_common.h      2021-06-02 19:08:51.064846946 +0200
+++ testdisk-7.3-WIP/src/apfs_common.h  2024-03-31 17:32:13.484165767 +0200
@@ -34,7 +34,9 @@
   } __attribute__((gcc_struct, __packed__));

   typedef struct obj_phys obj_phys_t;
+#if HAVE_PADDR_T == 0
   typedef int64_t paddr_t;
+#endif

   struct prange {
     paddr_t pr_start_paddr;
landryb commented 6 months ago

that also works !

checking for paddr_t... yes
$grep PADDR /usr/obj/ports/testdisk-7.2/testdisk-7.2/config.h
#define HAVE_PADDR_T 1