#define FUSE_USE_VERSION 33
-#include <fuse.h>
-#include <fuse/fuse_lowlevel.h>
+#include <fuse3/fuse.h>
+#include <fuse3/fuse_lowlevel.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
return 0;
}
-static int fusefile_getattr(const char *path,struct stat *stbuf) {
+static int fusefile_getattr(const char *path, struct stat *stbuf,
+ struct fuse_file_info *ffi)
+{
#if DEBUG
fprintf( stderr, "fusefile_getattr( %s )\n", path );
#endif
return 0;
}
-static int fusefile_chmod(const char *path,mode_t m) {
+static int fusefile_chmod(const char *path, mode_t m,
+ struct fuse_file_info *ffi)
+{
#if DEBUG
fprintf( stderr, "fusefile_chmod( %s, %d )\n", path, m );
#endif
return -1;
}
-static int fusefile_open(const char *path,struct fuse_file_info *fi) {
+static int fusefile_open(const char *path, struct fuse_file_info *ffi) {
#if DEBUG
- fprintf( stderr, "fusefile_open( %s, %d )\n", path, fi->flags );
- fprintf( stderr, "fixing( %d )\n", fi->flags | O_CLOEXEC );
+ fprintf( stderr, "fusefile_open( %s, %d )\n", path, ffi->flags );
+ fprintf( stderr, "fixing( %d )\n", ffi->flags | O_CLOEXEC );
#endif
if ( strcmp( path, "/" ) != 0 ) {
return -ENOENT;
// Read <size> bytes from <offset> in file
static int fusefile_read(const char *path, char *buf, size_t size,
- off_t off, struct fuse_file_info *fi)
+ off_t off, struct fuse_file_info *ffi)
{
if( strcmp( path, "/" ) != 0 ) {
return -ENOENT;
/**
* Poll for IO readiness.
*/
-int fusefile_poll(const char *path, struct fuse_file_info *fi,
- struct fuse_pollhandle *ph, unsigned *reventsp )
+int fusefile_poll(const char *path, struct fuse_file_info *ffi,
+ struct fuse_pollhandle *ph, unsigned *reventsp )
{
#if DEBUG
fprintf( stderr, "fusefile_poll( %s ) %p %d\n", path, ph, *reventsp );
}
static int fusefile_write_buf(const char *path, struct fuse_bufvec *buf,
- off_t off, struct fuse_file_info *fi) {
+ off_t off, struct fuse_file_info *ffi) {
#if DEBUG
fprintf( stderr, "fusefile_write_buf( %s )\n", path );
#endif
* Write a fragment at <off>. This overwrites files.
*/
static int fusefile_write(const char *path, const char *buf, size_t size,
- off_t off, struct fuse_file_info *fi)
+ off_t off, struct fuse_file_info *ffi)
{
#if DEBUG
fprintf( stderr, "fusefile_write( %s %ld )\n", path, size );
}
}
-static int fusefile_flush(const char *path, struct fuse_file_info *info) {
+static int fusefile_flush(const char *path, struct fuse_file_info *ffi) {
#if DEBUG
fprintf( stderr, "fusefile_flush( %s )\n", path );
#endif
return 0;
}
-static int fusefile_release(const char *path, struct fuse_file_info *fi) {
+static int fusefile_release(const char *path, struct fuse_file_info *ffi) {
#if DEBUG
fprintf( stderr, "fusefile_release( %s, %d )\n", path, fi->flags );
#endif
return 0;
}
-static int fusefile_fsync(const char *path, int x, struct fuse_file_info *fi) {
+static int fusefile_fsync(const char *path, int x,
+ struct fuse_file_info *ffi) {
#if DEBUG
fprintf( stderr, "fusefile_fsync( %s, %d )\n", path, x );
#endif
/**
*
*/
-static int fusefile_truncate(const char *path, off_t len) {
+static int fusefile_truncate(const char *path, off_t len,
+ struct fuse_file_info *ffi) {
#if DEBUG
fprintf( stderr, "fusefile_truncate( %s, %ld )\n", path, len );
#endif
return -EIO;
}
-void *fusefile_init(struct fuse_conn_info *fci) {
+void *fusefile_init(struct fuse_conn_info *fci, struct fuse_config *fc) {
#if DEBUG
fprintf( stderr, "fusefile_init( %d, %d )\n", fci->async_read, fci->want );
#endif
- // Disable asynchronous reading
- fci->async_read = 0;
- fci->want &= ~FUSE_CAP_ASYNC_READ;
+ // Disable asynchronous operations, both reading and direct I/O
+ fci->want &= ~ ( FUSE_CAP_ASYNC_READ | FUSE_CAP_ASYNC_DIO );
#if DEBUG
fprintf( stderr, "fusefile_init( %d, %d )\n", fci->async_read, fci->want );
#endif
.fsync = fusefile_fsync,
// NYI .ftruncate = fusefile_ftruncate,
.truncate = fusefile_truncate,
- //.truncate = fusefile_truncate,
//.release = fusefile_release,
.init = fusefile_init,
};
int main(int argc, char *argv[])
{
char *mnt;
- int mt;
- int fg;
int i;
int fuseargc;
struct stat stbuf;
return dump_fragments( 1 );
}
struct fuse_args args = FUSE_ARGS_INIT( fuseargc, argv );
- if ( fuse_parse_cmdline( &args, &mnt, &mt, &fg ) ) {
+ struct fuse_cmdline_opts opts = { 0 };
+ if ( fuse_parse_cmdline( &args, &opts ) ) {
return 1;
}
fuse_opt_free_args( &args );
- if ( ! mnt ) {
- fprintf( stderr, "missing mountpoint parameter\n" );
- return 1;
- }
- return fuse_main( fuseargc, argv, &fusefile_oper, temporary? mnt : NULL );
+ return fuse_main( fuseargc, argv, &fusefile_oper,
+ temporary? opts.mountpoint : NULL );
}