diff options
Diffstat (limited to 'example')
-rw-r--r-- | example/Makefile.am | 6 | ||||
-rwxr-xr-x[-rw-r--r--] | example/cusexmp.c | 19 | ||||
-rwxr-xr-x[-rw-r--r--] | example/fioc.c | 19 | ||||
-rwxr-xr-x[-rw-r--r--] | example/fioc.h | 9 | ||||
-rwxr-xr-x[-rw-r--r--] | example/fioclient.c | 18 | ||||
-rwxr-xr-x[-rw-r--r--] | example/fsel.c | 19 | ||||
-rwxr-xr-x[-rw-r--r--] | example/fselclient.c | 16 | ||||
-rwxr-xr-x[-rw-r--r--] | example/fusexmp.c | 18 | ||||
-rwxr-xr-x[-rw-r--r--] | example/fusexmp_fh.c | 30 | ||||
-rwxr-xr-x[-rw-r--r--] | example/hello.c | 33 | ||||
-rwxr-xr-x[-rw-r--r--] | example/hello_ll.c | 42 | ||||
-rwxr-xr-x[-rw-r--r--] | example/null.c | 19 |
12 files changed, 216 insertions, 32 deletions
diff --git a/example/Makefile.am b/example/Makefile.am index 1c04057..0db537b 100644 --- a/example/Makefile.am +++ b/example/Makefile.am @@ -1,12 +1,12 @@ ## Process this file with automake to produce Makefile.in -AM_CPPFLAGS = -I$(top_srcdir)/include -D_FILE_OFFSET_BITS=64 -D_REENTRANT +AM_CPPFLAGS = -I$(top_srcdir)/include -D_REENTRANT noinst_HEADERS = fioc.h noinst_PROGRAMS = fusexmp fusexmp_fh null hello hello_ll fioc fioclient \ fsel fselclient cusexmp -LDADD = ../lib/libfuse.la -fusexmp_fh_LDADD = ../lib/libfuse.la ../lib/libulockmgr.la +LDADD = ../lib/libfuse3.la +fusexmp_fh_LDADD = ../lib/libfuse3.la @fusexmp_fh_libs@ fioclient_CPPFLAGS = fioclient_LDFLAGS = diff --git a/example/cusexmp.c b/example/cusexmp.c index 01fcdf7..8d22075 100644..100755 --- a/example/cusexmp.c +++ b/example/cusexmp.c @@ -6,10 +6,25 @@ This program can be distributed under the terms of the GNU GPL. See the file COPYING. - gcc -Wall cusexmp.c `pkg-config fuse --cflags --libs` -o cusexmp */ -#define FUSE_USE_VERSION 29 +/** @file + * @tableofcontents + * + * cusexmp.c - CUSE example: Character device in Userspace + * + * \section section_compile compiling this example + * + * gcc -Wall cusexmp.c `pkg-config fuse3 --cflags --libs` -o cusexmp + * + * \section section_source the complete source + * \include cusexmp.c + */ + + +#define FUSE_USE_VERSION 30 + +#include <config.h> #include <cuse_lowlevel.h> #include <fuse_opt.h> diff --git a/example/fioc.c b/example/fioc.c index bee40b9..2117ac8 100644..100755 --- a/example/fioc.c +++ b/example/fioc.c @@ -6,10 +6,25 @@ This program can be distributed under the terms of the GNU GPL. See the file COPYING. - gcc -Wall fioc.c `pkg-config fuse --cflags --libs` -o fioc */ -#define FUSE_USE_VERSION 26 +/** @file + * @tableofcontents + * + * fioc.c - FUSE fioc: FUSE ioctl example + * + * \section section_compile compiling this example + * + * gcc -Wall fioc.c `pkg-config fuse3 --cflags --libs` -o fioc + * + * \section section_source the complete source + * \include fioc.c + */ + + +#define FUSE_USE_VERSION 30 + +#include <config.h> #include <fuse.h> #include <stdlib.h> diff --git a/example/fioc.h b/example/fioc.h index ec1a39d..42799aa 100644..100755 --- a/example/fioc.h +++ b/example/fioc.h @@ -7,6 +7,15 @@ See the file COPYING. */ +/** @file + * @tableofcontents + * + * fioc.h - FUSE-ioctl: ioctl support for FUSE + * + * \include fioc.h + */ + + #include <sys/types.h> #include <sys/uio.h> #include <sys/ioctl.h> diff --git a/example/fioclient.c b/example/fioclient.c index 5f05525..a7c0dbe 100644..100755 --- a/example/fioclient.c +++ b/example/fioclient.c @@ -5,10 +5,24 @@ This program can be distributed under the terms of the GNU GPL. See the file COPYING. - - gcc -Wall fioclient.c -o fioclient */ +/** @file + * @tableofcontents + * + * fioclient.c - FUSE fioclient: FUSE ioctl example client + * + * \section section_compile compiling this example + * + * gcc -Wall fioclient.c -o fioclient + * + * \section section_source the complete source + * fioclient.c + * \include fioclient.c + */ + +#include <config.h> + #include <sys/types.h> #include <sys/fcntl.h> #include <sys/stat.h> diff --git a/example/fsel.c b/example/fsel.c index 9cf0221..69202ee 100644..100755 --- a/example/fsel.c +++ b/example/fsel.c @@ -6,10 +6,25 @@ This program can be distributed under the terms of the GNU GPL. See the file COPYING. - gcc -Wall fsel.c `pkg-config fuse --cflags --libs` -o fsel */ -#define FUSE_USE_VERSION 29 +/** @file + * @tableofcontents + * + * fsel.c - FUSE fsel: FUSE select example + * + * \section section_compile compiling this example + * + * gcc -Wall fsel.c `pkg-config fuse3 --cflags --libs` -o fsel + * + * \section section_source the complete source + * \include fsel.c + */ + + +#define FUSE_USE_VERSION 30 + +#include <config.h> #include <fuse.h> #include <unistd.h> diff --git a/example/fselclient.c b/example/fselclient.c index 7c4b837..ac8b7b0 100644..100755 --- a/example/fselclient.c +++ b/example/fselclient.c @@ -6,9 +6,23 @@ This program can be distributed under the terms of the GNU GPL. See the file COPYING. - gcc -Wall fselclient.c -o fselclient */ +/** @file + * @tableofcontents + * + * fselclient.c - FUSE fselclient: FUSE select example client + * + * \section section_compile compiling this example + * + * gcc -Wall fselclient.c -o fselclient + * + * \section section_source the complete source + * \include fselclient.c + */ + +#include <config.h> + #include <sys/select.h> #include <sys/time.h> #include <sys/types.h> diff --git a/example/fusexmp.c b/example/fusexmp.c index dca8a46..6f63ae9 100644..100755 --- a/example/fusexmp.c +++ b/example/fusexmp.c @@ -5,11 +5,23 @@ This program can be distributed under the terms of the GNU GPL. See the file COPYING. - - gcc -Wall fusexmp.c `pkg-config fuse --cflags --libs` -o fusexmp */ -#define FUSE_USE_VERSION 26 +/** @file + * @tableofcontents + * + * fusexmp.c - FUSE: Filesystem in Userspace + * + * \section section_compile compiling this example + * + * gcc -Wall fusexmp.c `pkg-config fuse3 --cflags --libs` -o fusexmp + * + * \section section_source the complete source + * \include fusexmp.c + */ + + +#define FUSE_USE_VERSION 30 #ifdef HAVE_CONFIG_H #include <config.h> diff --git a/example/fusexmp_fh.c b/example/fusexmp_fh.c index 1ba9dbc..ba6789b 100644..100755 --- a/example/fusexmp_fh.c +++ b/example/fusexmp_fh.c @@ -5,11 +5,22 @@ This program can be distributed under the terms of the GNU GPL. See the file COPYING. - - gcc -Wall fusexmp_fh.c `pkg-config fuse --cflags --libs` -lulockmgr -o fusexmp_fh */ -#define FUSE_USE_VERSION 26 +/** @file + * @tableofcontents + * + * fusexmp_fh.c - FUSE: Filesystem in Userspace + * + * \section section_compile compiling this example + * + * gcc -Wall fusexmp_fh.c `pkg-config fuse3 --cflags --libs` -lulockmgr -o fusexmp_fh + * + * \section section_source the complete source + * \include fusexmp_fh.c + */ + +#define FUSE_USE_VERSION 30 #ifdef HAVE_CONFIG_H #include <config.h> @@ -18,7 +29,11 @@ #define _GNU_SOURCE #include <fuse.h> + +#ifdef HAVE_LIBULOCKMGR #include <ulockmgr.h> +#endif + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -489,6 +504,7 @@ static int xmp_removexattr(const char *path, const char *name) } #endif /* HAVE_SETXATTR */ +#ifdef HAVE_LIBULOCKMGR static int xmp_lock(const char *path, struct fuse_file_info *fi, int cmd, struct flock *lock) { @@ -497,6 +513,7 @@ static int xmp_lock(const char *path, struct fuse_file_info *fi, int cmd, return ulockmgr_op(fi->fh, cmd, lock, &fi->lock_owner, sizeof(fi->lock_owner)); } +#endif static int xmp_flock(const char *path, struct fuse_file_info *fi, int op) { @@ -551,13 +568,10 @@ static struct fuse_operations xmp_oper = { .listxattr = xmp_listxattr, .removexattr = xmp_removexattr, #endif +#ifdef HAVE_LIBULOCKMGR .lock = xmp_lock, - .flock = xmp_flock, - - .flag_nullpath_ok = 1, -#if HAVE_UTIMENSAT - .flag_utime_omit_ok = 1, #endif + .flock = xmp_flock, }; int main(int argc, char *argv[]) diff --git a/example/hello.c b/example/hello.c index bcb6b4c..d26d826 100644..100755 --- a/example/hello.c +++ b/example/hello.c @@ -4,11 +4,38 @@ This program can be distributed under the terms of the GNU GPL. See the file COPYING. - - gcc -Wall hello.c `pkg-config fuse --cflags --libs` -o hello */ -#define FUSE_USE_VERSION 26 +/** @file + * + * hello.c - minimal FUSE example featuring fuse_main usage + * + * \section section_compile compiling this example + * + * gcc -Wall hello.c `pkg-config fuse3 --cflags --libs` -o hello + * + * \section section_usage usage + \verbatim + % mkdir mnt + % ./hello mnt # program will vanish into the background + % ls -la mnt + total 4 + drwxr-xr-x 2 root root 0 Jan 1 1970 ./ + drwxrwx--- 1 root vboxsf 4096 Jun 16 23:12 ../ + -r--r--r-- 1 root root 13 Jan 1 1970 hello + % cat mnt/hello + Hello World! + % fusermount -u mnt + \endverbatim + * + * \section section_source the complete source + * \include hello.c + */ + + +#define FUSE_USE_VERSION 30 + +#include <config.h> #include <fuse.h> #include <stdio.h> diff --git a/example/hello_ll.c b/example/hello_ll.c index 1405441..1bf7155 100644..100755 --- a/example/hello_ll.c +++ b/example/hello_ll.c @@ -4,11 +4,42 @@ This program can be distributed under the terms of the GNU GPL. See the file COPYING. - - gcc -Wall hello_ll.c `pkg-config fuse --cflags --libs` -o hello_ll */ -#define FUSE_USE_VERSION 26 +/** @file + * + * hello_ll.c - fuse low level functionality + * + * unlike hello.c this example will stay in the foreground. it also replaced + * the convenience function fuse_main(..) with a more low level approach. + * + * \section section_compile compiling this example + * + * gcc -Wall hello_ll.c `pkg-config fuse3 --cflags --libs` -o hello_ll + * + * \section section_usage usage + \verbatim + % mkdir mnt + % ./hello_ll mnt # program will wait in foreground until you press CTRL+C + in a different shell do: + % ls -la mnt + total 4 + drwxr-xr-x 2 root root 0 Jan 1 1970 ./ + drwxrwx--- 1 root vboxsf 4096 Jun 16 23:12 ../ + -r--r--r-- 1 root root 13 Jan 1 1970 hello + % cat mnt/hello + Hello World! + finally either press ctrl+c or do: + % fusermount -u mnt + \endverbatim + * + * \section section_source the complete source + * \include hello_ll.c + */ + +#define FUSE_USE_VERSION 30 + +#include <config.h> #include <fuse_lowlevel.h> #include <stdio.h> @@ -151,6 +182,7 @@ static struct fuse_lowlevel_ops hello_ll_oper = { .read = hello_ll_read, }; +/*! [doxygen_fuse_lowlevel_usage] */ int main(int argc, char *argv[]) { struct fuse_args args = FUSE_ARGS_INIT(argc, argv); @@ -167,7 +199,10 @@ int main(int argc, char *argv[]) if (se != NULL) { if (fuse_set_signal_handlers(se) != -1) { fuse_session_add_chan(se, ch); + + /* Block until ctrl+c or fusermount -u */ err = fuse_session_loop(se); + fuse_remove_signal_handlers(se); fuse_session_remove_chan(ch); } @@ -179,3 +214,4 @@ int main(int argc, char *argv[]) return err ? 1 : 0; } +/*! [doxygen_fuse_lowlevel_usage] */ diff --git a/example/null.c b/example/null.c index b72cf4d..1ff1954 100644..100755 --- a/example/null.c +++ b/example/null.c @@ -4,11 +4,24 @@ This program can be distributed under the terms of the GNU GPL. See the file COPYING. - - gcc -Wall null.c `pkg-config fuse --cflags --libs` -o null */ -#define FUSE_USE_VERSION 26 +/** @file + * + * null.c - FUSE: Filesystem in Userspace + * + * \section section_compile compiling this example + * + * gcc -Wall null.c `pkg-config fuse3 --cflags --libs` -o null + * + * \section section_source the complete source + * \include null.c + */ + + +#define FUSE_USE_VERSION 30 + +#include <config.h> #include <fuse.h> #include <string.h> |