libfuse
printcap.c File Reference
#include <fuse_lowlevel.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>

Go to the source code of this file.

Detailed Description

minimal example filesystem that prints out all capabilities supported by the kernel and then exits.

Compile with:

gcc -Wall printcap.c `pkg-config fuse3 --cflags --libs` -o printcap

Source code

/*
FUSE: Filesystem in Userspace
Copyright (C) 2017 Nikolaus Rath <Nikolaus@rath.org>
This program can be distributed under the terms of the GNU GPLv2.
See the file COPYING.
*/
#define FUSE_USE_VERSION 31
#include <fuse_lowlevel.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
struct fuse_session *se;
static void pc_init(void *userdata,
struct fuse_conn_info *conn)
{
(void) userdata;
printf("Protocol version: %d.%d\n", conn->proto_major,
conn->proto_minor);
printf("Capabilities:\n");
printf("\tFUSE_CAP_ASYNC_READ\n");
printf("\tFUSE_CAP_POSIX_LOCKS\n");
printf("\tFUSE_CAP_ATOMIC_O_TRUNC\n");
printf("\tFUSE_CAP_EXPORT_SUPPORT\n");
printf("\tFUSE_CAP_DONT_MASK\n");
printf("\tFUSE_CAP_SPLICE_MOVE\n");
printf("\tFUSE_CAP_SPLICE_READ\n");
printf("\tFUSE_CAP_SPLICE_WRITE\n");
printf("\tFUSE_CAP_FLOCK_LOCKS\n");
printf("\tFUSE_CAP_IOCTL_DIR\n");
printf("\tFUSE_CAP_AUTO_INVAL_DATA\n");
printf("\tFUSE_CAP_READDIRPLUS\n");
printf("\tFUSE_CAP_READDIRPLUS_AUTO\n");
printf("\tFUSE_CAP_ASYNC_DIO\n");
printf("\tFUSE_CAP_WRITEBACK_CACHE\n");
printf("\tFUSE_CAP_NO_OPEN_SUPPORT\n");
printf("\tFUSE_CAP_PARALLEL_DIROPS\n");
printf("\tFUSE_CAP_POSIX_ACL\n");
printf("\tFUSE_CAP_CACHE_SYMLINKS\n");
printf("\tFUSE_CAP_NO_OPENDIR_SUPPORT\n");
printf("\tFUSE_CAP_EXPLICIT_INVAL_DATA\n");
printf("\tFUSE_CAP_EXPIRE_ONLY\n");
}
static const struct fuse_lowlevel_ops pc_oper = {
.init = pc_init,
};
int main(int argc, char **argv)
{
struct fuse_args args = FUSE_ARGS_INIT(argc, argv);
char *mountpoint;
int ret = -1;
mountpoint = strdup("/tmp/fuse_printcap_XXXXXX");
if(mkdtemp(mountpoint) == NULL) {
perror("mkdtemp");
return 1;
}
printf("FUSE library version %s\n", fuse_pkgversion());
se = fuse_session_new(&args, &pc_oper,
sizeof(pc_oper), NULL);
if (se == NULL)
goto err_out1;
goto err_out2;
if (fuse_session_mount(se, mountpoint) != 0)
goto err_out3;
ret = fuse_session_loop(se);
err_out3:
err_out2:
err_out1:
rmdir(mountpoint);
free(mountpoint);
return ret ? 1 : 0;
}
#define FUSE_CAP_IOCTL_DIR
Definition: fuse_common.h:241
#define FUSE_CAP_DONT_MASK
Definition: fuse_common.h:196
#define FUSE_CAP_AUTO_INVAL_DATA
Definition: fuse_common.h:263
int fuse_set_signal_handlers(struct fuse_session *se)
Definition: fuse_signals.c:62
#define FUSE_CAP_SPLICE_READ
Definition: fuse_common.h:221
#define FUSE_CAP_PARALLEL_DIROPS
Definition: fuse_common.h:342
#define FUSE_CAP_WRITEBACK_CACHE
Definition: fuse_common.h:319
#define FUSE_CAP_EXPIRE_ONLY
Definition: fuse_common.h:434
#define FUSE_CAP_ATOMIC_O_TRUNC
Definition: fuse_common.h:181
#define FUSE_CAP_ASYNC_READ
Definition: fuse_common.h:164
#define FUSE_CAP_SPLICE_WRITE
Definition: fuse_common.h:204
#define FUSE_CAP_CACHE_SYMLINKS
Definition: fuse_common.h:383
#define FUSE_CAP_POSIX_ACL
Definition: fuse_common.h:361
#define FUSE_CAP_EXPORT_SUPPORT
Definition: fuse_common.h:188
#define FUSE_CAP_POSIX_LOCKS
Definition: fuse_common.h:172
#define FUSE_CAP_EXPLICIT_INVAL_DATA
Definition: fuse_common.h:418
#define FUSE_CAP_READDIRPLUS_AUTO
Definition: fuse_common.h:299
#define FUSE_CAP_NO_OPENDIR_SUPPORT
Definition: fuse_common.h:395
#define FUSE_CAP_ASYNC_DIO
Definition: fuse_common.h:310
#define FUSE_CAP_NO_OPEN_SUPPORT
Definition: fuse_common.h:332
#define FUSE_CAP_READDIRPLUS
Definition: fuse_common.h:271
const char * fuse_pkgversion(void)
Definition: fuse.c:5124
void fuse_remove_signal_handlers(struct fuse_session *se)
Definition: fuse_signals.c:79
#define FUSE_CAP_SPLICE_MOVE
Definition: fuse_common.h:212
#define FUSE_CAP_FLOCK_LOCKS
Definition: fuse_common.h:234
void fuse_session_destroy(struct fuse_session *se)
void fuse_session_exit(struct fuse_session *se)
int fuse_session_loop(struct fuse_session *se)
Definition: fuse_loop.c:19
void fuse_session_unmount(struct fuse_session *se)
struct fuse_session * fuse_session_new(struct fuse_args *args, const struct fuse_lowlevel_ops *op, size_t op_size, void *userdata)
int fuse_session_mount(struct fuse_session *se, const char *mountpoint)
void fuse_lowlevel_version(void)
void fuse_opt_free_args(struct fuse_args *args)
Definition: fuse_opt.c:34
#define FUSE_ARGS_INIT(argc, argv)
Definition: fuse_opt.h:123
int argc
Definition: fuse_opt.h:111
char ** argv
Definition: fuse_opt.h:114
unsigned proto_major
Definition: fuse_common.h:471
unsigned proto_minor
Definition: fuse_common.h:476
unsigned capable
Definition: fuse_common.h:505
void(* init)(void *userdata, struct fuse_conn_info *conn)

Definition in file printcap.c.