Miroslav Rezanina Fix issues using GCC 11 with gtk >= 3.20 and glib >=2.66.3
- https://github.com/vmware/open-vm-tools/pull/505
+
+Marco Trevisan Update open-vm-tools to build with either Fuse 3 or Fuse 2
+ - https://github.com/vmware/open-vm-tools/pull/544
#
# Check for fuse.
#
-AC_VMW_CHECK_LIB([fuse],
- [FUSE],
- [fuse],
- [],
- [],
- [fuse.h],
- [fuse_main],
- [have_fuse=yes],
- [have_fuse=no;
- AC_MSG_WARN([Fuse is missing, vmblock-fuse/vmhgfs-fuse will be disabled.])])
+
+AC_ARG_WITH([fuse],
+ [AS_HELP_STRING([--without-fuse],
+ [compiles without FUSE support (disables vmblock-fuse/vmhgfs-fuse).])],
+ [with_fuse="$withval"],
+ [with_fuse=auto])
+
+case "$with_fuse" in
+ fuse|2)
+ with_fuse="fuse"
+ ;;
+ fuse3|3)
+ with_fuse="fuse3"
+ ;;
+ auto)
+ ;;
+ yes)
+ ;;
+ no)
+ have_fuse3=no;
+ have_fuse=no;
+ ;;
+ *)
+ AC_MSG_FAILURE([--with-fuse was given with an unsupported paramter $with_fuse])
+ ;;
+esac
+
+
+if test "$with_fuse" = "auto" ||
+ test "$with_fuse" = "fuse3" ||
+ test "$with_fuse" = "yes"; then
+ #
+ # Check for fuse3.
+ #
+ # FUSE_USE_VERSION sets the version of the FUSE API that will be exported.
+ AC_VMW_CHECK_LIB([fuse3],
+ [FUSE3],
+ [fuse3],
+ [],
+ [3.10.0],
+ [fuse3/fuse.h],
+ [fuse_main],
+ [have_fuse3=yes;
+ AC_DEFINE([HAVE_FUSE3], 1, [Define to 1 if using FUSE3.])
+ AC_DEFINE([FUSE_USE_VERSION], 35, [FUSE API version to use.])],
+ [have_fuse3=no])
+
+ if test "$have_fuse3" = "no"; then
+ if test "$with_fuse" = "auto" || test "$with_fuse" = "yes"; then
+ AC_MSG_NOTICE([Fuse3 is missing, trying to use older Fuse library.])
+ else
+ AC_MSG_FAILURE([Fuse3 was requested but unavailable on the system.])
+ fi
+ fi
+fi
+
+if test "$with_fuse" = "fuse" ||
+ ( ( test "$with_fuse" = "auto" || test "$with_fuse" = "yes" ) &&
+ test "$have_fuse3" = "no" ); then
+ #
+ # Check for fuse.
+ #
+ # FUSE_USE_VERSION sets the version of the FUSE API that will be exported.
+ AC_VMW_CHECK_LIB([fuse],
+ [FUSE],
+ [fuse],
+ [],
+ [],
+ [fuse.h],
+ [fuse_main],
+ [have_fuse=yes;
+ AC_DEFINE([HAVE_FUSE], 1, [Define to 1 if using FUSE.])
+ AC_DEFINE([FUSE_USE_VERSION], 29, [FUSE API version to use.])],
+ [have_fuse=no])
+
+ if test "$have_fuse" = "no"; then
+ if test "$with_fuse" = "auto" || test "$with_fuse" = "yes"; then
+ AC_MSG_NOTICE([Fuse is missing, vmblock-fuse/vmhgfs-fuse will be disabled.])
+ else
+ AC_MSG_FAILURE([Fuse2 was requested but unavailable on the system.])
+ fi
+ fi
+fi
+
+if test "$with_fuse" = "no"; then
+ AC_MSG_WARN([Fuse or Fuse3 is suppressed, vmblock-fuse/vmhgfs-fuse will be disabled.])
+fi
#
# Check for PAM.
AM_CONDITIONAL(ENABLE_TESTS, test "$have_cunit" = "yes")
AM_CONDITIONAL(WITH_ROOT_PRIVILEGES, test "$with_root_privileges" = "yes")
AM_CONDITIONAL(HAVE_DOXYGEN, test "$have_doxygen" = "yes")
-AM_CONDITIONAL(HAVE_FUSE, test "$have_fuse" = "yes")
+AM_CONDITIONAL(HAVE_FUSE, test "$have_fuse" = "yes" || test "$have_fuse3" = "yes")
+AM_CONDITIONAL(HAVE_FUSE3, test "$have_fuse3" = "yes")
AM_CONDITIONAL(HAVE_GNU_LD, test "$with_gnu_ld" = "yes")
AM_CONDITIONAL(HAVE_GTKMM, test "$have_x" = "yes" -a \( "$with_gtkmm" = "yes" -o "$with_gtkmm3" = "yes" \) )
AM_CONDITIONAL(HAVE_PAM, test "$with_pam" = "yes")
### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
################################################################################
+ noinst_PROGRAMS =
if HAVE_FUSE
- noinst_PROGRAMS = vmware-testvmblock-fuse
+ noinst_PROGRAMS += vmware-testvmblock-fuse
+ noinst_PROGRAMS += vmware-testvmblock-manual-fuse
+endif
+if HAVE_FUSE3
+ noinst_PROGRAMS += vmware-testvmblock-fuse
noinst_PROGRAMS += vmware-testvmblock-manual-fuse
-else
- noinst_PROGRAMS = vmware-testvmblock-legacy
- noinst_PROGRAMS += vmware-testvmblock-manual-legacy
endif
AM_CFLAGS =
AM_LDFLAGS =
AM_LDFLAGS += -lpthread
-vmware_testvmblock_legacy_SOURCES = vmblocktest.c
-
-vmware_testvmblock_manual_legacy_SOURCES = manual-blocker.c
-
vmware_testvmblock_fuse_CFLAGS = $(AM_CFLAGS) -Dvmblock_fuse
vmware_testvmblock_fuse_SOURCES = vmblocktest.c
################################################################################
-### Copyright (C) 2008-2016 VMware, Inc. All rights reserved.
+### Copyright (c) 2008-2016,2021 VMware, Inc. All rights reserved.
###
### This program is free software; you can redistribute it and/or modify
### it under the terms of version 2 of the GNU General Public License as
AM_CFLAGS += -DUSERLEVEL
AM_CFLAGS += -D_FILE_OFFSET_BITS=64
AM_CFLAGS += @FUSE_CPPFLAGS@
+AM_CFLAGS += @FUSE3_CPPFLAGS@
AM_CFLAGS += @GLIB2_CPPFLAGS@
AM_CFLAGS += -I$(top_srcdir)/modules/shared/vmblock
AM_CFLAGS += -I$(srcdir)
vmware_vmblock_fuse_LDADD =
vmware_vmblock_fuse_LDADD += @FUSE_LIBS@
+vmware_vmblock_fuse_LDADD += @FUSE3_LIBS@
vmware_vmblock_fuse_LDADD += @GLIB2_LIBS@
vmware_vmblock_fuse_SOURCES =
static vmblockSpecialDirEntry notifyDirEntry =
{ NOTIFY_DIR "/*", S_IFREG | 0444, 1, 0 };
+#if FUSE_MAJOR_VERSION == 3
+#define CALL_FUSE_FILLER(buf, name, stbuf, off, flags) \
+ filler(buf, name, stbuf, off, flags)
+#else
+#define CALL_FUSE_FILLER(buf, name, stbuf, off, flags) \
+ filler(buf, name, stbuf, off)
+#endif
+
/*
*-----------------------------------------------------------------------------
*
*-----------------------------------------------------------------------------
*/
+#if FUSE_MAJOR_VERSION == 3
+int
+VMBlockGetAttr(const char *path, // IN: File to get attributes of.
+ struct stat *statBuf, // OUT: Where to put the attributes.
+ struct fuse_file_info *fi) // IN: Ignored
+#else
int
VMBlockGetAttr(const char *path, // IN: File to get attributes of.
struct stat *statBuf) // OUT: Where to put the attributes.
+#endif
{
vmblockSpecialDirEntry *dirEntry;
ASSERT(path != NULL);
errno = 0;
while ((dentry = readdir(dir)) != NULL) {
- status = filler(buf, dentry->d_name, &statBuf, 0);
+ status = CALL_FUSE_FILLER(buf, dentry->d_name, &statBuf, 0, 0);
if (status == 1) {
break;
}
*-----------------------------------------------------------------------------
*/
+#if FUSE_MAJOR_VERSION == 3
+int
+VMBlockReadDir(const char *path, // IN: Directory to read.
+ void *buf, // OUT: Where to put directory
+ // listing.
+ fuse_fill_dir_t filler, // IN: Function to add an entry
+ // to buf.
+ off_t offset, // IN: Ignored.
+ struct fuse_file_info *fileInfo, // IN: Ignored.
+ enum fuse_readdir_flags flags) // IN: Ignored.
+#else
int
VMBlockReadDir(const char *path, // IN: Directory to read.
void *buf, // OUT: Where to put directory
// to buf.
off_t offset, // IN: Ignored.
struct fuse_file_info *fileInfo) // IN: Ignored.
+#endif
{
struct stat fileStat;
struct stat dirStat;
dirStat.st_mode = S_IFDIR;
if (strcmp(path, "/") == 0) {
- (void)(filler(buf, ".", &dirStat, 0) ||
- filler(buf, "..", &dirStat, 0) ||
- filler(buf, VMBLOCK_DEVICE_NAME, &fileStat, 0) ||
- filler(buf, REDIRECT_DIR_NAME, &dirStat, 0) ||
- filler(buf, NOTIFY_DIR_NAME, &dirStat, 0));
+ (void)(CALL_FUSE_FILLER(buf, ".", &dirStat, 0, 0) ||
+ CALL_FUSE_FILLER(buf, "..", &dirStat, 0, 0) ||
+ CALL_FUSE_FILLER(buf, VMBLOCK_DEVICE_NAME, &fileStat, 0, 0) ||
+ CALL_FUSE_FILLER(buf, REDIRECT_DIR_NAME, &dirStat, 0, 0) ||
+ CALL_FUSE_FILLER(buf, NOTIFY_DIR_NAME, &dirStat, 0, 0));
return 0;
} else if ( (strcmp(path, REDIRECT_DIR) == 0)
|| (strcmp(path, NOTIFY_DIR) == 0)) {
*-----------------------------------------------------------------------------
*/
+#if FUSE_MAJOR_VERSION == 3
+void *
+VMBlockInit(struct fuse_conn_info *conn,
+ struct fuse_config *config)
+#else
+#if FUSE_USE_VERSION < 26
void *
VMBlockInit(void)
+#else
+void *
+VMBlockInit(struct fuse_conn_info *conn)
+#endif
+#endif
{
BlockInit();
return NULL;
/*********************************************************
- * Copyright (C) 2008-2018 VMware, Inc. All rights reserved.
+ * Copyright (C) 2008-2018,2021 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
#ifndef _VMBLOCK_FUSE_H_
#define _VMBLOCK_FUSE_H_
+/*
+ * FUSE_USE_VERSION must be set before the fuse or fuse3 headers are
+ * included. If undefined, fall back to previous default used.
+ */
+#ifndef FUSE_USE_VERSION
/*
* FUSE_USE_VERSION sets the version of the FUSE API that will be exported.
* Version 25 is the newest version supported by the libfuse in our toolchain
* as of 2008-07.
*/
-
#define FUSE_USE_VERSION 25
+#endif
+
#include <fuse.h>
#include "vmblock.h"
*/
int VMBlockReadLink(const char *path, char *buf, size_t bufSize);
+
+#if FUSE_MAJOR_VERSION == 3
+int VMBlockGetAttr(const char *path, struct stat *statBuf,
+ struct fuse_file_info *fi);
+int VMBlockReadDir(const char *path, void *buf, fuse_fill_dir_t filler,
+ off_t offset, struct fuse_file_info *fileInfo,
+ enum fuse_readdir_flags);
+#else
int VMBlockGetAttr(const char *path, struct stat *statBuf);
int VMBlockReadDir(const char *path, void *buf, fuse_fill_dir_t filler,
off_t offset, struct fuse_file_info *fileInfo);
+#endif
int VMBlockOpen(const char *path, struct fuse_file_info *fileInfo);
int VMBlockWrite(const char *path, const char *buf, size_t size, off_t offset,
struct fuse_file_info *fileInfo);
/*********************************************************
- * Copyright (C) 2008-2016 VMware, Inc. All rights reserved.
+ * Copyright (C) 2008-2016,2021 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
LOGLEVEL_THRESHOLD = 4;
}
}
+#if FUSE_USE_VERSION < 26
return fuse_main(argc, argv, &vmblockOperations);
+#else
+ return fuse_main(argc, argv, &vmblockOperations, NULL);
+#endif
}
################################################################################
-### Copyright (C) 2015-2016 VMware, Inc. All rights reserved.
+### Copyright (c) 2015-2016,2021 VMware, Inc. All rights reserved.
###
### This program is free software; you can redistribute it and/or modify
### it under the terms of version 2 of the GNU General Public License as
AM_CFLAGS =
AM_CFLAGS += @FUSE_CPPFLAGS@
+AM_CFLAGS += @FUSE3_CPPFLAGS@
AM_CFLAGS += @GLIB2_CPPFLAGS@
vmhgfs_fuse_LDADD =
vmhgfs_fuse_LDADD += @FUSE_LIBS@
+vmhgfs_fuse_LDADD += @FUSE3_LIBS@
vmhgfs_fuse_LDADD += @GLIB2_LIBS@
vmhgfs_fuse_LDADD += @VMTOOLS_LIBS@
/*********************************************************
- * Copyright (C) 2015-2018 VMware, Inc. All rights reserved.
+ * Copyright (C) 2015-2018,2021 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
*/
#include "module.h"
+#include <fuse_lowlevel.h>
#include <sys/utsname.h>
#ifdef VMX86_DEVEL
VMHGFS_OPT("-l %i", logLevel, 4),
#endif
/* We will change the default value, unless it is specified explicitly. */
+#if FUSE_MAJOR_VERSION != 3
FUSE_OPT_KEY("big_writes", KEY_BIG_WRITES),
FUSE_OPT_KEY("nobig_writes", KEY_NO_BIG_WRITES),
+#endif
FUSE_OPT_KEY("-V", KEY_VERSION),
FUSE_OPT_KEY("--version", KEY_VERSION),
#define LIB_MODULEPATH "/lib/modules"
#define MODULES_DEP "modules.dep"
+#if FUSE_MAJOR_VERSION == 3
+#define FUSER_MOUNT_BIN "/bin/fusermount3"
+#define FUSER_MOUNT_USR_BIN "/usr/bin/fusermount3"
+#else
#define FUSER_MOUNT_BIN "/bin/fusermount"
#define FUSER_MOUNT_USR_BIN "/usr/bin/fusermount"
+#endif
#define PROC_FILESYSTEMS "/proc/filesystems"
#define FUSER_KERNEL_FS "fuse"
int key, // IN
struct fuse_args *outargs) // OUT
{
+#if FUSE_MAJOR_VERSION != 3
struct vmhgfsConfig *config = data;
+#endif
switch (key) {
case FUSE_OPT_KEY_NONOPT:
}
return 1;
+#if FUSE_MAJOR_VERSION != 3
case KEY_BIG_WRITES:
config->addBigWrites = TRUE;
return 0;
case KEY_NO_BIG_WRITES:
config->addBigWrites = FALSE;
return 0;
+#endif
case KEY_HELP:
Usage(outargs->argv[0]);
+#if FUSE_MAJOR_VERSION != 3
fuse_opt_add_arg(outargs, "-ho");
fuse_main(outargs->argc, outargs->argv, NULL, NULL);
+#else
+ fprintf(stdout, "FUSE options:\n");
+ fuse_cmdline_help();
+ fuse_lib_help(outargs);
+#endif
exit(1);
case KEY_ENABLED_FUSE: {
#ifdef VMX86_DEVEL
config.logLevel = LOGLEVEL_THRESHOLD;
#endif
-#ifdef __APPLE__
- /* osxfuse does not have option 'big_writes'. */
+#if defined(__APPLE__) || FUSE_MAJOR_VERSION == 3
+ /* osxfuse and fuse3 does not have option 'big_writes'. */
config.addBigWrites = FALSE;
#else
config.addBigWrites = TRUE;
/*********************************************************
- * Copyright (C) 2013,2019 VMware, Inc. All rights reserved.
+ * Copyright (C) 2013,2019,2021 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
st.st_size = attr.size;
st.st_ino = ino;
st.st_mode = d_type << 12;
+#if FUSE_MAJOR_VERSION == 3
+ result = filldir(vfsDirent, escName, &st, 0, 0);
+#else
result = filldir(vfsDirent, escName, &st, 0);
+#endif
if (result) {
/*
/*********************************************************
- * Copyright (C) 2013 VMware, Inc. All rights reserved.
+ * Copyright (C) 2013,2021 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* Main entry points for fuse file operations for HGFS
*/
-#if FUSE_USE_VERSION >= 26
-#define HAVE_UTIMENSAT 1
-#endif
-
#include "module.h"
#include "cache.h"
#include "filesystem.h"
*----------------------------------------------------------------------
*/
+#if FUSE_MAJOR_VERSION == 3
+static int
+hgfs_getattr(const char *path, //IN: path of a file/directory
+ struct stat *stbuf, //IN/OUT: file/directoy attribute
+ struct fuse_file_info *fi) //IN/OUT: Unused
+#else
static int
hgfs_getattr(const char *path, //IN: path of a file/directory
struct stat *stbuf) //IN/OUT: file/directoy attribute
+#endif
{
HgfsHandle fileHandle = HGFS_INVALID_HANDLE;
HgfsAttrInfo newAttr = {0};
*----------------------------------------------------------------------
*/
+#if FUSE_MAJOR_VERSION == 3
+static int
+hgfs_readdir(const char *path, //IN: path to a directory
+ void *buf, //OUT: buffer to fill the dir entry
+ fuse_fill_dir_t filler, //IN: function pointer to fill buf
+ off_t offset, //IN: offset to read the dir
+ struct fuse_file_info *fi, //IN: file info set by open call
+ enum fuse_readdir_flags flags) //IN: unused
+#else
static int
hgfs_readdir(const char *path, //IN: path to a directory
void *buf, //OUT: buffer to fill the dir entry
fuse_fill_dir_t filler, //IN: function pointer to fill buf
off_t offset, //IN: offset to read the dir
struct fuse_file_info *fi) //IN: file info set by open call
+#endif
{
char *abspath = NULL;
int res = 0;
*----------------------------------------------------------------------
*/
+#if FUSE_MAJOR_VERSION == 3
+static int
+hgfs_rename(const char *from, //IN: from path name
+ const char *to, //IN: to path name
+ unsigned int flags) //IN: unused
+#else
static int
hgfs_rename(const char *from, //IN: from path name
const char *to) //IN: to path name
+#endif
{
char *absfrom = NULL;
char *absto = NULL;
*----------------------------------------------------------------------
*/
+#if FUSE_MAJOR_VERSION == 3
+static int
+hgfs_chmod(const char *path, //IN: path to a file
+ mode_t mode, //IN: mode to set
+ struct fuse_file_info *fi) //IN/OUT: unused
+#else
static int
hgfs_chmod(const char *path, //IN: path to a file
mode_t mode) //IN: mode to set
+#endif
{
char *abspath = NULL;
int res;
*----------------------------------------------------------------------
*/
+#if FUSE_MAJOR_VERSION == 3
+static int
+hgfs_chown(const char *path, //IN: Path to a file
+ uid_t uid, //IN: User id
+ gid_t gid, //IN: Group id
+ struct fuse_file_info *fi) //IN/OUT: unused
+#else
static int
hgfs_chown(const char *path, //IN: Path to a file
uid_t uid, //IN: User id
gid_t gid) //IN: Group id
+#endif
{
HgfsHandle fileHandle = HGFS_INVALID_HANDLE;
HgfsAttrInfo newAttr = {0};
*----------------------------------------------------------------------
*/
+#if FUSE_MAJOR_VERSION == 3
+static int
+hgfs_truncate(const char *path, //IN: path to a file
+ off_t size, //IN: new size
+ struct fuse_file_info *fi) //IN/OUT: unused
+#else
static int
hgfs_truncate(const char *path, //IN: path to a file
off_t size) //IN: new size
+#endif
{
HgfsHandle fileHandle = HGFS_INVALID_HANDLE;
HgfsAttrInfo newAttr = {0};
*----------------------------------------------------------------------
*/
-#ifdef HAVE_UTIMENSAT
+#if FUSE_MAJOR_VERSION == 3
static int
hgfs_utimens(const char *path, //IN: path to a file
- const struct timespec ts[2]) //IN: new time
+ const struct timespec ts[2], //IN: new time
+ struct fuse_file_info *fi) //IN/OUT: unused
#else
static int
-hgfs_utime(const char *path, //IN: path to a file
- struct utimbuf *times) //IN: new time
+hgfs_utimens(const char *path, //IN: path to a file
+ const struct timespec ts[2]) //IN: new time
#endif
{
HgfsHandle fileHandle = HGFS_INVALID_HANDLE;
attr->mask = (HGFS_ATTR_VALID_WRITE_TIME |
HGFS_ATTR_VALID_ACCESS_TIME);
-#ifdef HAVE_UTIMENSAT
accessTimeSec = ts[0].tv_sec;
accessTimeNsec = ts[0].tv_nsec;
writeTimeSec = ts[1].tv_sec;
writeTimeNsec = ts[1].tv_nsec;
-#else
- accessTimeSec = times->actime;
- accessTimeNsec = 0;
- writeTimeSec = times->modtime;
- writeTimeNsec = 0;
-#endif
attr->accessTime = HgfsConvertToNtTime(accessTimeSec, accessTimeNsec);
attr->writeTime = HgfsConvertToNtTime(writeTimeSec, writeTimeNsec);
*----------------------------------------------------------------------
*/
+#if FUSE_MAJOR_VERSION == 3
+static void*
+hgfs_init(struct fuse_conn_info *conn, // IN: unused
+ struct fuse_config *cfg) // IN/OUT: unused
+#else
static void*
hgfs_init(struct fuse_conn_info *conn) // IN: unused
+#endif
{
pthread_t purgeCacheThread;
int dummy;
.chmod = hgfs_chmod,
.chown = hgfs_chown,
.truncate = hgfs_truncate,
-#ifdef HAVE_UTIMENSAT
.utimens = hgfs_utimens,
-#else // HAVE_UTIMENSAT
- .utime = hgfs_utime,
-#endif // defined HAVE_UTIMENSAT
.open = hgfs_open,
.read = hgfs_read,
.write = hgfs_write,
/*********************************************************
- * Copyright (C) 2013 VMware, Inc. All rights reserved.
+ * Copyright (C) 2013,2021 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
#ifndef _VMHGFS_FUSE_MODULE_H_
#define _VMHGFS_FUSE_MODULE_H_
-#define FUSE_USE_VERSION 29
+/*
+ * FUSE_USE_VERSION must be set before the fuse or fuse3 headers are
+ * included. If undefined, fall back to previous default used.
+ */
+#ifndef FUSE_USE_VERSION
+# define FUSE_USE_VERSION 29
+#endif
#include <sys/types.h>
#include "hgfsUtil.h"