diff --git a/bdetools/bdemount.c b/bdetools/bdemount.c index c974769..6eafaa1 100644 --- a/bdetools/bdemount.c +++ b/bdetools/bdemount.c @@ -160,8 +160,16 @@ int main( int argc, char * const argv[] ) #if defined( HAVE_LIBFUSE ) || defined( HAVE_LIBOSXFUSE ) struct fuse_operations bdemount_fuse_operations; +#if FUSE_USE_VERSION >= 30 + /* Need to set this to 1 even if there no arguments, otherwise this causes + * fuse: empty argv passed to fuse_session_new() + */ + char *fuse_argv[ 2 ] = { program, NULL }; + struct fuse_args bdemount_fuse_arguments = FUSE_ARGS_INIT(1, fuse_argv); +#else struct fuse_args bdemount_fuse_arguments = FUSE_ARGS_INIT(0, NULL); struct fuse_chan *bdemount_fuse_channel = NULL; +#endif struct fuse *bdemount_fuse_handle = NULL; #elif defined( HAVE_LIBDOKAN ) @@ -483,6 +491,34 @@ int main( int argc, char * const argv[] ) bdemount_fuse_operations.getattr = &mount_fuse_getattr; bdemount_fuse_operations.destroy = &mount_fuse_destroy; +#if FUSE_USE_VERSION >= 30 + bdemount_fuse_handle = fuse_new( + &bdemount_fuse_arguments, + &bdemount_fuse_operations, + sizeof( struct fuse_operations ), + bdemount_mount_handle ); + + if( bdemount_fuse_handle == NULL ) + { + fprintf( + stderr, + "Unable to create fuse handle.\n" ); + + goto on_error; + } + result = fuse_mount( + bdemount_fuse_handle, + mount_point ); + + if( result != 0 ) + { + fprintf( + stderr, + "Unable to fuse mount file system.\n" ); + + goto on_error; + } +#else bdemount_fuse_channel = fuse_mount( mount_point, &bdemount_fuse_arguments ); @@ -510,6 +546,8 @@ int main( int argc, char * const argv[] ) goto on_error; } +#endif /* FUSE_USE_VERSION >= 30 */ + if( verbose == 0 ) { if( fuse_daemonize( diff --git a/bdetools/mount_fuse.c b/bdetools/mount_fuse.c index 3be0178..d2872a6 100644 --- a/bdetools/mount_fuse.c +++ b/bdetools/mount_fuse.c @@ -255,11 +255,20 @@ int mount_fuse_filldir( return( -1 ); } +#if FUSE_USE_VERSION >= 30 + if( filler( + buffer, + name, + stat_info, + 0, + 0 ) == 1 ) +#else if( filler( buffer, name, stat_info, 0 ) == 1 ) +#endif { libcerror_error_set( error, @@ -655,12 +664,22 @@ int mount_fuse_opendir( /* Reads a directory * Returns 0 if successful or a negative errno value otherwise */ +#if FUSE_USE_VERSION >= 30 +int mount_fuse_readdir( + const char *path, + void *buffer, + fuse_fill_dir_t filler, + off_t offset BDETOOLS_ATTRIBUTE_UNUSED, + struct fuse_file_info *file_info BDETOOLS_ATTRIBUTE_UNUSED, + enum fuse_readdir_flags flags BDETOOLS_ATTRIBUTE_UNUSED ) +#else int mount_fuse_readdir( const char *path, void *buffer, fuse_fill_dir_t filler, off_t offset BDETOOLS_ATTRIBUTE_UNUSED, struct fuse_file_info *file_info BDETOOLS_ATTRIBUTE_UNUSED ) +#endif { struct stat *stat_info = NULL; libcerror_error_t *error = NULL; @@ -675,6 +694,10 @@ int mount_fuse_readdir( BDETOOLS_UNREFERENCED_PARAMETER( offset ) +#if FUSE_USE_VERSION >= 30 + BDETOOLS_UNREFERENCED_PARAMETER( flags ) +#endif + #if defined( HAVE_DEBUG_OUTPUT ) if( libcnotify_verbose != 0 ) { @@ -1044,9 +1067,16 @@ int mount_fuse_releasedir( /* Retrieves the file stat info * Returns 0 if successful or a negative errno value otherwise */ +#if FUSE_USE_VERSION >= 30 +int mount_fuse_getattr( + const char *path, + struct stat *stat_info, + struct fuse_file_info *file_info BDETOOLS_ATTRIBUTE_UNUSED ) +#else int mount_fuse_getattr( const char *path, struct stat *stat_info ) +#endif { libcerror_error_t *error = NULL; mount_file_entry_t *file_entry = NULL; @@ -1058,6 +1088,10 @@ int mount_fuse_getattr( uint16_t file_mode = 0; int result = 0; +#if FUSE_USE_VERSION >= 30 + BDETOOLS_UNREFERENCED_PARAMETER( file_info ) +#endif + #if defined( HAVE_DEBUG_OUTPUT ) if( libcnotify_verbose != 0 ) { diff --git a/bdetools/mount_fuse.h b/bdetools/mount_fuse.h index d9dd37e..7641f57 100644 --- a/bdetools/mount_fuse.h +++ b/bdetools/mount_fuse.h @@ -25,18 +25,19 @@ #include #include -#if defined( HAVE_LIBFUSE ) || defined( HAVE_LIBOSXFUSE ) +/* Ensure FUSE_USE_VERSION is defined before including fuse.h + */ +#if !defined( FUSE_USE_VERSION ) +#warning FUSE_USE_VERSION not set, defaulting to 26 #define FUSE_USE_VERSION 26 +#endif #if defined( HAVE_LIBFUSE ) #include - #elif defined( HAVE_LIBOSXFUSE ) #include #endif -#endif /* defined( HAVE_LIBFUSE ) || defined( HAVE_LIBOSXFUSE ) */ - #include "bdetools_libbde.h" #include "bdetools_libcerror.h" #include "mount_file_entry.h" @@ -84,20 +85,37 @@ int mount_fuse_opendir( const char *path, struct fuse_file_info *file_info ); +#if FUSE_USE_VERSION >= 30 +int mount_fuse_readdir( + const char *path, + void *buffer, + fuse_fill_dir_t filler, + off_t offset, + struct fuse_file_info *file_info, + enum fuse_readdir_flags flags ); +#else int mount_fuse_readdir( const char *path, void *buffer, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *file_info ); +#endif int mount_fuse_releasedir( const char *path, struct fuse_file_info *file_info ); +#if FUSE_USE_VERSION >= 30 +int mount_fuse_getattr( + const char *path, + struct stat *stat_info, + struct fuse_file_info *file_info ); +#else int mount_fuse_getattr( const char *path, struct stat *stat_info ); +#endif void mount_fuse_destroy( void *private_data ); diff --git a/bdetools/mount_handle.c b/bdetools/mount_handle.c index b975501..efc137b 100644 --- a/bdetools/mount_handle.c +++ b/bdetools/mount_handle.c @@ -1173,7 +1173,7 @@ int mount_handle_open( if( bdetools_prompt_for_password( stdout, - "Password", + _SYSTEM_STRING( "Password" ), password, 64, error ) != 1 ) diff --git a/libbde/libbde_metadata_entry.c b/libbde/libbde_metadata_entry.c index 1123496..cff9fa4 100644 --- a/libbde/libbde_metadata_entry.c +++ b/libbde/libbde_metadata_entry.c @@ -469,14 +469,14 @@ int libbde_metadata_entry_read_string( return( 1 ); -on_error: #if defined( HAVE_DEBUG_OUTPUT ) +on_error: if( value_string != NULL ) { memory_free( value_string ); } -#endif return( -1 ); +#endif } diff --git a/m4/libfuse.m4 b/m4/libfuse.m4 index a6fc990..7bd4e89 100644 --- a/m4/libfuse.m4 +++ b/m4/libfuse.m4 @@ -1,52 +1,80 @@ dnl Checks for libfuse required headers and functions dnl -dnl Version: 20220118 +dnl Version: 20240413 dnl Function to detect if libfuse is available dnl ac_libfuse_dummy is used to prevent AC_CHECK_LIB adding unnecessary -l arguments AC_DEFUN([AX_LIBFUSE_CHECK_LIB], - [dnl Check if parameters were provided - AS_IF( - [test "x$ac_cv_with_libfuse" != x && test "x$ac_cv_with_libfuse" != xno && test "x$ac_cv_with_libfuse" != xauto-detect], - [AS_IF( - [test -d "$ac_cv_with_libfuse"], - [CFLAGS="$CFLAGS -I${ac_cv_with_libfuse}/include" - LDFLAGS="$LDFLAGS -L${ac_cv_with_libfuse}/lib"], - [AC_MSG_WARN([no such directory: $ac_cv_with_libfuse]) - ]) - ]) - - AS_IF( - [test "x$ac_cv_with_libfuse" = xno], + [AS_IF( + [test "x$ac_cv_enable_shared_libs" = xno || test "x$ac_cv_with_libfuse" = xno], [ac_cv_libfuse=no], - [dnl Check for a pkg-config file + [dnl Check if the directory provided as parameter exists + dnl For both --with-libfuse which returns "yes" and --with-libfuse= which returns "" + dnl treat them as auto-detection. AS_IF( - [test "x$cross_compiling" != "xyes" && test "x$PKGCONFIG" != "x"], - [PKG_CHECK_MODULES( - [fuse], - [fuse >= 2.6], - [ac_cv_libfuse=libfuse], - [ac_cv_libfuse=no]) + [test "x$ac_cv_with_libfuse" != x && test "x$ac_cv_with_libfuse" != xauto-detect && test "x$ac_cv_with_libfuse" != xyes], + [AS_IF( + [test -d "$ac_cv_with_libfuse"], + [CFLAGS="$CFLAGS -I${ac_cv_with_libfuse}/include" + LDFLAGS="$LDFLAGS -L${ac_cv_with_libfuse}/lib"], + [AC_MSG_FAILURE( + [no such directory: $ac_cv_with_libfuse], + [1]) + ])], + [dnl Check for a pkg-config file + AS_IF( + [test "x$cross_compiling" != "xyes" && test "x$PKGCONFIG" != "x"], + [PKG_CHECK_MODULES( + [fuse3], + [fuse3 >= 3.0], + [ac_cv_libfuse=libfuse3], + [ac_cv_libfuse=no]) + + AS_IF( + [test "x$ac_cv_libfuse" = xno], + [PKG_CHECK_MODULES( + [fuse], + [fuse >= 2.6], + [ac_cv_libfuse=libfuse], + [ac_cv_libfuse=no]) + ]) + + AS_IF( + [test "x$ac_cv_libfuse" = xlibfuse3], + [ac_cv_libfuse_CPPFLAGS="$pkg_cv_fuse3_CFLAGS -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=30" + ac_cv_libfuse_LIBADD="$pkg_cv_fuse3_LIBS"]) + + AS_IF( + [test "x$ac_cv_libfuse" = xlibfuse], + [ac_cv_libfuse_CPPFLAGS="$pkg_cv_fuse_CFLAGS -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=26" + ac_cv_libfuse_LIBADD="$pkg_cv_fuse_LIBS"]) + ]) ]) + backup_CPPFLAGS="$CPPFLAGS" + + dnl Check for libfuse and libfuse3 AS_IF( - [test "x$ac_cv_libfuse" = xlibfuse], - [ac_cv_libfuse_CPPFLAGS="$pkg_cv_fuse_CFLAGS" - ac_cv_libfuse_LIBADD="$pkg_cv_fuse_LIBS"], + [test "x$ac_cv_libfuse" != xlibfuse && test "x$ac_cv_libfuse" != xlibfuse3], [dnl Check for headers - AC_CHECK_HEADERS( - [fuse.h], - [ac_cv_header_fuse_h=yes], - [ac_cv_header_fuse_h=no]) - dnl libfuse sometimes requires -D_FILE_OFFSET_BITS=64 to be set - dnl macFuse requires -DFUSE_USE_VERSION=26 to be set + dnl libfuse3 requires -D_FILE_OFFSET_BITS=64 to be set + ac_cv_libfuse_CPPFLAGS="-D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=30" + CPPFLAGS="$backup_CPPFLAGS $ac_cv_libfuse_CPPFLAGS" + AC_CHECK_HEADERS([fuse.h]) + AS_IF( - [test "x$ac_cv_header_fuse_h" = xno], - [AS_UNSET([ac_cv_header_fuse_h]) - CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=26" + [test "x$ac_cv_header_fuse_h" = xyes], + [ac_cv_libfuse=libfuse3], + [dnl libfuse requires -D_FILE_OFFSET_BITS=64 to be set + ac_cv_libfuse_CPPFLAGS="-D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=26" + CPPFLAGS="$backup_CPPFLAGS $ac_cv_libfuse_CPPFLAGS" AC_CHECK_HEADERS([fuse.h]) - ]) + + AS_IF( + [test "x$ac_cv_header_fuse_h" = xyes], + [ac_cv_libfuse=libfuse]) + ]) AS_IF( [test "x$ac_cv_header_fuse_h" = xno], @@ -75,24 +103,21 @@ AC_DEFUN([AX_LIBFUSE_CHECK_LIB], [ac_cv_libfuse_dummy=yes], [ac_cv_libfuse=no]) - ac_cv_libfuse_LIBADD="-lfuse"; + AS_IF( + [test "x$ac_cv_libfuse" = xlibfuse3], + [ac_cv_libfuse_LIBADD="-lfuse3"], + [ac_cv_libfuse_LIBADD="-lfuse"]) ]) ]) dnl Check for libosxfuse AS_IF( [test "x$ac_cv_with_libfuse" != xno && test "x$ac_cv_header_fuse_h" = xno], - [CPPFLAGS="$CPPFLAGS -DFUSE_USE_VERSION=26" + [dnl libosxfuse requires -D_FILE_OFFSET_BITS=64 to be set + ac_cv_libfuse_CPPFLAGS="-D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=26" + CPPFLAGS="$backup_CPPFLAGS $ac_cv_libfuse_CPPFLAGS" AC_CHECK_HEADERS([osxfuse/fuse.h]) - dnl libosxfuse sometimes requires -D_FILE_OFFSET_BITS=64 to be set - AS_IF( - [test "x$ac_cv_header_osxfuse_fuse_h" = xno], - [AS_UNSET([ac_cv_header_osxfuse_fuse_h]) - CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64" - AC_CHECK_HEADERS([osxfuse/fuse.h]) - ]) - AS_IF( [test "x$ac_cv_header_osxfuse_fuse_h" = xno], [ac_cv_libfuse=no], @@ -123,6 +148,14 @@ AC_DEFUN([AX_LIBFUSE_CHECK_LIB], ac_cv_libfuse_LIBADD="-losxfuse"; ]) ]) + + AS_IF( + [test "x$ac_cv_libfuse" != xyes && test "x$ac_cv_with_libfuse" != x && test "x$ac_cv_with_libfuse" != xauto-detect && test "x$ac_cv_with_libfuse" != xyes], + [AC_MSG_FAILURE( + [unable to find supported libfuse in directory: $ac_cv_with_libfuse], + [1]) + ]) + CPPFLAGS="$backup_CPPFLAGS" ]) AS_IF( @@ -132,6 +165,13 @@ AC_DEFUN([AX_LIBFUSE_CHECK_LIB], [1], [Define to 1 if you have the 'fuse' library (-lfuse).]) ]) + AS_IF( + [test "x$ac_cv_libfuse" = xlibfuse3], + [AC_DEFINE( + [HAVE_LIBFUSE], + [1], + [Define to 1 if you have the 'fuse3' library (-lfuse3).]) + ]) AS_IF( [test "x$ac_cv_libfuse" = xlibosxfuse], [AC_DEFINE( @@ -182,6 +222,12 @@ AC_DEFUN([AX_LIBFUSE_CHECK_ENABLE], [ax_libfuse_pc_libs_private], [-lfuse]) ]) + AS_IF( + [test "x$ac_cv_libfuse" = xlibfuse3], + [AC_SUBST( + [ax_libfuse_pc_libs_private], + [-lfuse3]) + ]) AS_IF( [test "x$ac_cv_libfuse" = xlibosxfuse], [AC_SUBST( @@ -198,5 +244,14 @@ AC_DEFUN([AX_LIBFUSE_CHECK_ENABLE], [ax_libfuse_spec_build_requires], [fuse-devel]) ]) + AS_IF( + [test "x$ac_cv_libfuse" = xlibfuse3], + [AC_SUBST( + [ax_libfuse_spec_requires], + [fuse3-libs]) + AC_SUBST( + [ax_libfuse_spec_build_requires], + [fuse3-devel]) + ]) ])