summaryrefslogtreecommitdiff
path: root/tests/can-use-fuse.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/can-use-fuse.c')
-rw-r--r--tests/can-use-fuse.c48
1 files changed, 43 insertions, 5 deletions
diff --git a/tests/can-use-fuse.c b/tests/can-use-fuse.c
index f39d2f15..fb6e2000 100644
--- a/tests/can-use-fuse.c
+++ b/tests/can-use-fuse.c
@@ -1,4 +1,4 @@
-/*
+/* vi:set et sw=2 sts=2 cin cino=t0,f0,(0,{s,>2s,n-s,^-s,e-s:
* Copyright 2019-2021 Collabora Ltd.
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
@@ -13,8 +13,15 @@
#include "libglnx.h"
-#define FUSE_USE_VERSION 26
+#ifndef FUSE_USE_VERSION
+#error config.h needs to define FUSE_USE_VERSION
+#endif
+
+#if FUSE_USE_VERSION >= 31
+#include <fuse.h>
+#else
#include <fuse_lowlevel.h>
+#endif
gchar *cannot_use_fuse = NULL;
@@ -26,10 +33,15 @@ check_fuse (void)
{
g_autofree gchar *fusermount = NULL;
g_autofree gchar *path = NULL;
- char *argv[] = { "flatpak-fuse-test" };
- struct fuse_args args = FUSE_ARGS_INIT (G_N_ELEMENTS (argv), argv);
- struct fuse_chan *chan = NULL;
+ char *argv[] = { "flatpak-fuse-test", NULL };
+ struct fuse_args args = FUSE_ARGS_INIT (G_N_ELEMENTS (argv) - 1, argv);
g_autoptr(GError) error = NULL;
+#if FUSE_USE_VERSION >= 31
+ struct fuse *fuse = NULL;
+ const struct fuse_operations ops = { NULL };
+#else
+ struct fuse_chan *chan = NULL;
+#endif
if (cannot_use_fuse != NULL)
return FALSE;
@@ -64,6 +76,26 @@ check_fuse (void)
path = g_dir_make_tmp ("flatpak-test.XXXXXX", &error);
g_assert_no_error (error);
+#if FUSE_USE_VERSION >= 31
+ fuse = fuse_new (&args, &ops, sizeof (ops), NULL);
+
+ if (fuse == NULL)
+ {
+ fuse_opt_free_args (&args);
+ cannot_use_fuse = g_strdup_printf ("fuse_new: %s",
+ g_strerror (errno));
+ return FALSE;
+ }
+
+ if (fuse_mount (fuse, path) != 0)
+ {
+ fuse_destroy (fuse);
+ fuse_opt_free_args (&args);
+ cannot_use_fuse = g_strdup_printf ("fuse_mount: %s",
+ g_strerror (errno));
+ return FALSE;
+ }
+#else
chan = fuse_mount (path, &args);
if (chan == NULL)
@@ -73,10 +105,16 @@ check_fuse (void)
g_strerror (errno));
return FALSE;
}
+#endif
g_test_message ("Successfully set up test FUSE fs on %s", path);
+#if FUSE_USE_VERSION >= 31
+ fuse_unmount (fuse);
+ fuse_destroy (fuse);
+#else
fuse_unmount (path, chan);
+#endif
if (g_rmdir (path) != 0)
g_error ("rmdir %s: %s", path, g_strerror (errno));