Skip to content

Commit

Permalink
Changes for cygfuse support
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimmetz committed Apr 13, 2024
1 parent bfd056d commit 59aa40b
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 36 deletions.
14 changes: 7 additions & 7 deletions bdetools/bdemount.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,10 @@ int main( int argc, char * const argv[] )
int unattended_mode = 0;
int verbose = 0;

#if defined( HAVE_LIBFUSE ) || defined( HAVE_LIBOSXFUSE )
#if defined( HAVE_LIBFUSE ) || defined( HAVE_LIBFUSE3 ) || defined( HAVE_LIBOSXFUSE )
struct fuse_operations bdemount_fuse_operations;

#if FUSE_USE_VERSION >= 30
#if defined( HAVE_LIBFUSE3 )
/* Need to set this to 1 even if there no arguments, otherwise this causes
* fuse: empty argv passed to fuse_session_new()
*/
Expand Down Expand Up @@ -435,7 +435,7 @@ int main( int argc, char * const argv[] )

goto on_error;
}
#if defined( HAVE_LIBFUSE ) || defined( HAVE_LIBOSXFUSE )
#if defined( HAVE_LIBFUSE ) || defined( HAVE_LIBFUSE3 ) || defined( HAVE_LIBOSXFUSE )
if( option_extended_options != NULL )
{
/* This argument is required but ignored
Expand Down Expand Up @@ -491,7 +491,7 @@ 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
#if defined( HAVE_LIBFUSE3 )
bdemount_fuse_handle = fuse_new(
&bdemount_fuse_arguments,
&bdemount_fuse_operations,
Expand Down Expand Up @@ -546,7 +546,7 @@ int main( int argc, char * const argv[] )

goto on_error;
}
#endif /* FUSE_USE_VERSION >= 30 */
#endif /* defined( HAVE_LIBFUSE3 ) */

if( verbose == 0 )
{
Expand Down Expand Up @@ -746,7 +746,7 @@ int main( int argc, char * const argv[] )

return( EXIT_FAILURE );

#endif /* defined( HAVE_LIBFUSE ) || defined( HAVE_LIBOSXFUSE ) */
#endif /* defined( HAVE_LIBFUSE ) || defined( HAVE_LIBFUSE3 ) || defined( HAVE_LIBOSXFUSE ) */

on_error:
if( error != NULL )
Expand All @@ -756,7 +756,7 @@ int main( int argc, char * const argv[] )
libcerror_error_free(
&error );
}
#if defined( HAVE_LIBFUSE ) || defined( HAVE_LIBOSXFUSE )
#if defined( HAVE_LIBFUSE ) || defined( HAVE_LIBFUSE3 ) || defined( HAVE_LIBOSXFUSE )
if( bdemount_fuse_handle != NULL )
{
fuse_destroy(
Expand Down
14 changes: 7 additions & 7 deletions bdetools/mount_fuse.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

extern mount_handle_t *bdemount_mount_handle;

#if defined( HAVE_LIBFUSE ) || defined( HAVE_LIBOSXFUSE )
#if defined( HAVE_LIBFUSE ) || defined( HAVE_LIBFUSE3 ) || defined( HAVE_LIBOSXFUSE )

#if ( SIZEOF_OFF_T != 8 ) && ( SIZEOF_OFF_T != 4 )
#error Size of off_t not supported
Expand Down Expand Up @@ -255,7 +255,7 @@ int mount_fuse_filldir(

return( -1 );
}
#if FUSE_USE_VERSION >= 30
#if defined( HAVE_LIBFUSE3 )
if( filler(
buffer,
name,
Expand Down Expand Up @@ -664,7 +664,7 @@ int mount_fuse_opendir(
/* Reads a directory
* Returns 0 if successful or a negative errno value otherwise
*/
#if FUSE_USE_VERSION >= 30
#if defined( HAVE_LIBFUSE3 )
int mount_fuse_readdir(
const char *path,
void *buffer,
Expand Down Expand Up @@ -694,7 +694,7 @@ int mount_fuse_readdir(

BDETOOLS_UNREFERENCED_PARAMETER( offset )

#if FUSE_USE_VERSION >= 30
#if defined( HAVE_LIBFUSE3 )
BDETOOLS_UNREFERENCED_PARAMETER( flags )
#endif

Expand Down Expand Up @@ -1067,7 +1067,7 @@ int mount_fuse_releasedir(
/* Retrieves the file stat info
* Returns 0 if successful or a negative errno value otherwise
*/
#if FUSE_USE_VERSION >= 30
#if defined( HAVE_LIBFUSE3 )
int mount_fuse_getattr(
const char *path,
struct stat *stat_info,
Expand All @@ -1088,7 +1088,7 @@ int mount_fuse_getattr(
uint16_t file_mode = 0;
int result = 0;

#if FUSE_USE_VERSION >= 30
#if defined( HAVE_LIBFUSE3 )
BDETOOLS_UNREFERENCED_PARAMETER( file_info )
#endif

Expand Down Expand Up @@ -1348,5 +1348,5 @@ void mount_fuse_destroy(
return;
}

#endif /* defined( HAVE_LIBFUSE ) || defined( HAVE_LIBOSXFUSE ) */
#endif /* defined( HAVE_LIBFUSE ) || defined( HAVE_LIBFUSE3 ) || defined( HAVE_LIBOSXFUSE ) */

23 changes: 14 additions & 9 deletions bdetools/mount_fuse.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,27 @@
#include <common.h>
#include <types.h>

#if defined( HAVE_LIBFUSE ) || defined( HAVE_LIBOSXFUSE )
#if defined( HAVE_LIBFUSE ) || defined( HAVE_LIBFUSE3 ) || defined( HAVE_LIBOSXFUSE )

#if !defined( FUSE_USE_VERSION ) && !defined( CYGFUSE )

/* Ensure FUSE_USE_VERSION is defined before including fuse.h
*/
#if !defined( FUSE_USE_VERSION )
#warning FUSE_USE_VERSION not set, defaulting to 26
#if defined( HAVE_LIBFUSE3 )
#define FUSE_USE_VERSION 30
#else
#define FUSE_USE_VERSION 26
#endif

#if defined( HAVE_LIBFUSE )
#endif /* !defined( FUSE_USE_VERSION ) && !defined( CYGFUSE ) */

#if defined( HAVE_LIBFUSE ) || defined( HAVE_LIBFUSE3 )
#include <fuse.h>
#elif defined( HAVE_LIBOSXFUSE )
#include <osxfuse/fuse.h>
#endif

#endif /* defined( HAVE_LIBFUSE ) || defined( HAVE_LIBOSXFUSE ) */
#endif /* defined( HAVE_LIBFUSE ) || defined( HAVE_LIBFUSE3 ) || defined( HAVE_LIBOSXFUSE ) */

#include "bdetools_libbde.h"
#include "bdetools_libcerror.h"
Expand All @@ -51,7 +56,7 @@
extern "C" {
#endif

#if defined( HAVE_LIBFUSE ) || defined( HAVE_LIBOSXFUSE )
#if defined( HAVE_LIBFUSE ) || defined( HAVE_LIBFUSE3 ) || defined( HAVE_LIBOSXFUSE )

int mount_fuse_set_stat_info(
struct stat *stat_info,
Expand Down Expand Up @@ -89,7 +94,7 @@ int mount_fuse_opendir(
const char *path,
struct fuse_file_info *file_info );

#if FUSE_USE_VERSION >= 30
#if defined( HAVE_LIBFUSE3 )
int mount_fuse_readdir(
const char *path,
void *buffer,
Expand All @@ -110,7 +115,7 @@ int mount_fuse_releasedir(
const char *path,
struct fuse_file_info *file_info );

#if FUSE_USE_VERSION >= 30
#if defined( HAVE_LIBFUSE3 )
int mount_fuse_getattr(
const char *path,
struct stat *stat_info,
Expand All @@ -124,7 +129,7 @@ int mount_fuse_getattr(
void mount_fuse_destroy(
void *private_data );

#endif /* defined( HAVE_LIBFUSE ) || defined( HAVE_LIBOSXFUSE ) */
#endif /* defined( HAVE_LIBFUSE ) || defined( HAVE_LIBFUSE3 ) || defined( HAVE_LIBOSXFUSE ) */

#if defined( __cplusplus )
}
Expand Down
31 changes: 18 additions & 13 deletions m4/libfuse.m4
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ AC_DEFUN([AX_LIBFUSE_CHECK_LIB],
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_CPPFLAGS="$pkg_cv_fuse3_CFLAGS -D_FILE_OFFSET_BITS=64"
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_CPPFLAGS="$pkg_cv_fuse_CFLAGS -D_FILE_OFFSET_BITS=64"
ac_cv_libfuse_LIBADD="$pkg_cv_fuse_LIBS"])
])
])
Expand All @@ -58,17 +58,13 @@ AC_DEFUN([AX_LIBFUSE_CHECK_LIB],
[test "x$ac_cv_libfuse" != xlibfuse && test "x$ac_cv_libfuse" != xlibfuse3],
[dnl Check for headers
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"
CPPFLAGS="$backup_CPPFLAGS -DFUSE_USE_VERSION=30"
AC_CHECK_HEADERS([fuse.h])
AS_IF(
[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"
[CPPFLAGS="$backup_CPPFLAGS -DFUSE_USE_VERSION=26"
AC_CHECK_HEADERS([fuse.h])
AS_IF(
Expand All @@ -80,7 +76,11 @@ AC_DEFUN([AX_LIBFUSE_CHECK_LIB],
[test "x$ac_cv_header_fuse_h" = xno],
[ac_cv_libfuse=no],
[dnl Check for the individual functions
ac_cv_libfuse=libfuse
AC_CHECK_LIB(
fuse,
fuse_invalidate,
[ac_cv_libfuse=libfuse],
[ac_cv_libfuse=libfuse3])
AC_CHECK_LIB(
fuse,
Expand All @@ -103,6 +103,9 @@ AC_DEFUN([AX_LIBFUSE_CHECK_LIB],
[ac_cv_libfuse_dummy=yes],
[ac_cv_libfuse=no])
dnl libfuse and libfuse3 require -D_FILE_OFFSET_BITS=64 to be set
ac_cv_libfuse_CPPFLAGS="-D_FILE_OFFSET_BITS=64"
AS_IF(
[test "x$ac_cv_libfuse" = xlibfuse3],
[ac_cv_libfuse_LIBADD="-lfuse3"],
Expand All @@ -113,9 +116,7 @@ AC_DEFUN([AX_LIBFUSE_CHECK_LIB],
dnl Check for libosxfuse
AS_IF(
[test "x$ac_cv_with_libfuse" != xno && test "x$ac_cv_header_fuse_h" = xno],
[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"
[CPPFLAGS="$backup_CPPFLAGS -DFUSE_USE_VERSION=26"
AC_CHECK_HEADERS([osxfuse/fuse.h])
AS_IF(
Expand Down Expand Up @@ -145,6 +146,9 @@ AC_DEFUN([AX_LIBFUSE_CHECK_LIB],
[ac_cv_libfuse_dummy=yes],
[ac_cv_libfuse=no])
dnl libosxfuse requires -D_FILE_OFFSET_BITS=64 to be set
ac_cv_libfuse_CPPFLAGS="-D_FILE_OFFSET_BITS=64"
ac_cv_libfuse_LIBADD="-losxfuse";
])
])
Expand All @@ -155,6 +159,7 @@ AC_DEFUN([AX_LIBFUSE_CHECK_LIB],
[unable to find supported libfuse in directory: $ac_cv_with_libfuse],
[1])
])
CPPFLAGS="$backup_CPPFLAGS"
])
Expand All @@ -168,7 +173,7 @@ AC_DEFUN([AX_LIBFUSE_CHECK_LIB],
AS_IF(
[test "x$ac_cv_libfuse" = xlibfuse3],
[AC_DEFINE(
[HAVE_LIBFUSE],
[HAVE_LIBFUSE3],
[1],
[Define to 1 if you have the 'fuse3' library (-lfuse3).])
])
Expand Down

0 comments on commit 59aa40b

Please sign in to comment.