aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Nikolaus Rath <Nikolaus@rath.org>2016-10-09 19:22:57 -0700
committerGravatar Nikolaus Rath <Nikolaus@rath.org>2016-10-09 22:03:07 -0700
commit463189cd121ce9a9f79d24c207e7c6c31898ea06 (patch)
tree62d41459282f2d79bf16d4fa14a95f8f07f208bf
parent225c12aebf2d2f27e1d032d6b2149c7bb1d63506 (diff)
Renamed some examples to make their function more obvious
Also, added more comments for the same purpose.
-rw-r--r--configure.ac4
-rw-r--r--example/.gitignore6
-rw-r--r--example/Makefile.am6
-rw-r--r--example/passthrough.c (renamed from example/fusexmp.c)9
-rw-r--r--example/passthrough_fh.c (renamed from example/fusexmp_fh.c)10
-rw-r--r--example/passthrough_ll.c (renamed from example/fuse_lo-plus.c)18
-rwxr-xr-xtest/test_examples.py45
-rwxr-xr-xtest/test_fuse.py33
8 files changed, 46 insertions, 85 deletions
diff --git a/configure.ac b/configure.ac
index 39bddc7..7482f8a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -69,8 +69,8 @@ AC_SEARCH_LIBS(clock_gettime, [rt])
libfuse_libs=$LIBS
LIBS=
AC_CHECK_LIB(ulockmgr, ulockmgr_op)
-fusexmp_fh_libs=$LIBS
-AC_SUBST(fusexmp_fh_libs)
+passthrough_fh_libs=$LIBS
+AC_SUBST(passthrough_fh_libs)
LIBS=
AC_ARG_WITH([libiconv-prefix],
diff --git a/example/.gitignore b/example/.gitignore
index a738dbc..ea56c8d 100644
--- a/example/.gitignore
+++ b/example/.gitignore
@@ -1,5 +1,5 @@
-/fusexmp
-/fusexmp_fh
+/passthrough
+/passthrough_fh
/hello
/hello_ll
/fioc
@@ -7,6 +7,6 @@
/fsel
/fselclient
/cusexmp
-/fuse_lo-plus
+/passthrough_ll
/timefs1
/timefs2
diff --git a/example/Makefile.am b/example/Makefile.am
index 7ddd7d9..5d82f64 100644
--- a/example/Makefile.am
+++ b/example/Makefile.am
@@ -2,12 +2,12 @@
AM_CPPFLAGS = -I$(top_srcdir)/include -D_REENTRANT
noinst_HEADERS = fioc.h
-noinst_PROGRAMS = fusexmp fusexmp_fh hello hello_ll fioc fioclient \
- fsel fselclient cusexmp fuse_lo-plus timefs1 timefs2 \
+noinst_PROGRAMS = passthrough passthrough_fh hello hello_ll fioc fioclient \
+ fsel fselclient cusexmp passthrough_ll timefs1 timefs2 \
timefs3
LDADD = ../lib/libfuse3.la
-fusexmp_fh_LDADD = ../lib/libfuse3.la @fusexmp_fh_libs@
+passthrough_fh_LDADD = ../lib/libfuse3.la @passthrough_fh_libs@
fioclient_CPPFLAGS =
fioclient_LDFLAGS =
diff --git a/example/fusexmp.c b/example/passthrough.c
index eae3562..cf72cb2 100644
--- a/example/fusexmp.c
+++ b/example/passthrough.c
@@ -10,14 +10,17 @@
/** @file
* @tableofcontents
*
- * fusexmp.c - FUSE: Filesystem in Userspace
+ * This file system mirrors the existing file system hierarchy of the
+ * system, starting at the root file system. This is implemented by
+ * just "passing through" all requests to the corresponding user-space
+ * libc functions. It's performance is terrible.
*
* \section section_compile compiling this example
*
- * gcc -Wall fusexmp.c `pkg-config fuse3 --cflags --libs` -o fusexmp
+ * gcc -Wall passthrough.c `pkg-config fuse3 --cflags --libs` -o passthrough
*
* \section section_source the complete source
- * \include fusexmp.c
+ * \include passthrough.c
*/
diff --git a/example/fusexmp_fh.c b/example/passthrough_fh.c
index 84fce3f..a179f65 100644
--- a/example/fusexmp_fh.c
+++ b/example/passthrough_fh.c
@@ -10,14 +10,18 @@
/** @file
* @tableofcontents
*
- * fusexmp_fh.c - FUSE: Filesystem in Userspace
+ * This file system mirrors the existing file system hierarchy of the
+ * system, starting at the root file system. This is implemented by
+ * just "passing through" all requests to the corresponding user-space
+ * libc functions. This implementation is a little more sophisticated
+ * than the one in passthrough.c, so performance is not quite as bad.
*
* \section section_compile compiling this example
*
- * gcc -Wall fusexmp_fh.c `pkg-config fuse3 --cflags --libs` -lulockmgr -o fusexmp_fh
+ * gcc -Wall passthrough_fh.c `pkg-config fuse3 --cflags --libs` -lulockmgr -o passthrough_fh
*
* \section section_source the complete source
- * \include fusexmp_fh.c
+ * \include passthrough_fh.c
*/
#define FUSE_USE_VERSION 30
diff --git a/example/fuse_lo-plus.c b/example/passthrough_ll.c
index c27f377..66f92cf 100644
--- a/example/fuse_lo-plus.c
+++ b/example/passthrough_ll.c
@@ -6,8 +6,22 @@
See the file COPYING.
*/
-/*
- * gcc -Wall fuse_lo-plus.c `pkg-config fuse3 --cflags --libs` -o fuse_lo-plus
+/** @file
+ * @tableofcontents
+ *
+ * This file system mirrors the existing file system hierarchy of the
+ * system, starting at the root file system. This is implemented by
+ * just "passing through" all requests to the corresponding user-space
+ * libc functions. In contrast to passthrough.c and passthrough_fh.c,
+ * this implementation ises the low-level API. Its performance should
+ * be the least bad among the three.
+ *
+ * \section section_compile compiling this example
+ *
+ * gcc -Wall passthrough_ll.c `pkg-config fuse3 --cflags --libs` -o passthrough_ll
+ *
+ * \section section_source the complete source
+ * \include passthrough_ll.c
*/
#define _GNU_SOURCE
diff --git a/test/test_examples.py b/test/test_examples.py
index ef4932c..6deaff1 100755
--- a/test/test_examples.py
+++ b/test/test_examples.py
@@ -60,53 +60,26 @@ def test_hello(tmpdir, name, options):
else:
umount(mount_process, mnt_dir)
+@pytest.mark.parametrize("name", ('passthrough', 'passthrough_fh',
+ 'passthrough_ll'))
@pytest.mark.parametrize("options", LL_OPTIONS)
-def test_fuse_lo_plus(tmpdir, options):
+def test_passthrough(tmpdir, name, options):
mnt_dir = str(tmpdir.mkdir('mnt'))
src_dir = str(tmpdir.mkdir('src'))
cmdline = base_cmdline + \
- [ pjoin(basename, 'example', 'fuse_lo-plus'),
- '-f', '-s', mnt_dir ] + options
+ [ pjoin(basename, 'example', name),
+ '-f', mnt_dir ] + options
+ if not name.endswith('_ll'):
+ cmdline += [ '-o', 'use_ino,readdir_ino,kernel_cache' ]
mount_process = subprocess.Popen(cmdline)
try:
wait_for_mount(mount_process, mnt_dir)
work_dir = pjoin(mnt_dir, src_dir)
- tst_write(work_dir)
- tst_mkdir(work_dir)
- tst_symlink(work_dir)
- tst_mknod(work_dir)
- if os.getuid() == 0:
- tst_chown(work_dir)
- # Underlying fs may not have full nanosecond resolution
- tst_utimens(work_dir, ns_tol=1000)
- tst_link(work_dir)
- tst_readdir(work_dir)
- tst_statvfs(work_dir)
- tst_truncate_path(work_dir)
- tst_truncate_fd(work_dir)
- tst_unlink(work_dir)
- tst_passthrough(src_dir, work_dir)
- except:
- cleanup(mnt_dir)
- raise
- else:
- umount(mount_process, mnt_dir)
-@pytest.mark.parametrize("name", ('fusexmp', 'fusexmp_fh'))
-@pytest.mark.parametrize("options", LL_OPTIONS)
-def test_fusexmp_fh(tmpdir, name, options):
- mnt_dir = str(tmpdir.mkdir('mnt'))
- src_dir = str(tmpdir.mkdir('src'))
+ subprocess.check_call([ os.path.join(basename, 'test', 'test'),
+ work_dir, ':' + src_dir ])
- cmdline = base_cmdline + \
- [ pjoin(basename, 'example', name),
- '-f', '-o', 'use_ino,readdir_ino,kernel_cache',
- mnt_dir ] + options
- mount_process = subprocess.Popen(cmdline)
- try:
- wait_for_mount(mount_process, mnt_dir)
- work_dir = pjoin(mnt_dir, src_dir)
tst_write(work_dir)
tst_mkdir(work_dir)
tst_symlink(work_dir)
diff --git a/test/test_fuse.py b/test/test_fuse.py
deleted file mode 100755
index 3c60d80..0000000
--- a/test/test_fuse.py
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/usr/bin/env python3
-import pytest
-import sys
-
-if __name__ == '__main__':
- sys.exit(pytest.main([__file__] + sys.argv[1:]))
-
-import subprocess
-import os
-from util import wait_for_mount, umount, cleanup, base_cmdline
-
-basename = os.path.join(os.path.dirname(__file__), '..')
-
-def test_fuse(tmpdir):
- mnt_dir = str(tmpdir.mkdir('mnt'))
- src_dir = str(tmpdir.mkdir('src'))
-
- cmdline = base_cmdline + \
- [ os.path.join(basename, 'example', 'fusexmp_fh'),
- '-f', '-o' , 'use_ino,readdir_ino,kernel_cache',
- mnt_dir ]
- mount_process = subprocess.Popen(cmdline)
- try:
- wait_for_mount(mount_process, mnt_dir)
- cmdline = [ os.path.join(basename, 'test', 'test'),
- os.path.join(mnt_dir, src_dir),
- ':' + src_dir ]
- subprocess.check_call(cmdline)
- except:
- cleanup(mnt_dir)
- raise
- else:
- umount(mount_process, mnt_dir)