From ef3677046ab6225bd167c6ffaf3d830b325d72cd Mon Sep 17 00:00:00 2001 From: Ralph Ronnquist Date: Tue, 8 Oct 2024 10:48:53 +1100 Subject: [PATCH] Fully migrated to libfuse3 --- Makefile | 2 +- fusefile.c | 58 +++++++++++++++++++++++++++--------------------------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/Makefile b/Makefile index 9f02adc..1287fdc 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ ${BINS}: CFLAGS += -DDEBUG=1 -g endif ${BINS}: CFLAGS += -Wall -D_FILE_OFFSET_BITS=64 -fusefile: LDFLAGS = -lfuse -pthread +fusefile: LDFLAGS = -lfuse3 -pthread .INTERMEDIATE: fusefile.o fusefile.o: fusefile.c diff --git a/fusefile.c b/fusefile.c index a1bf2bd..2c7bc8d 100644 --- a/fusefile.c +++ b/fusefile.c @@ -25,8 +25,8 @@ #define FUSE_USE_VERSION 33 -#include -#include +#include +#include #include #include #include @@ -415,7 +415,9 @@ static int setup_sources(char **argv,int i,int n) { 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 @@ -437,17 +439,19 @@ static int fusefile_getattr(const char *path,struct stat *stbuf) { 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; @@ -507,7 +511,7 @@ static int overlay_merge(char *buf,off_t beg,off_t end) { // Read bytes from 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; @@ -576,8 +580,8 @@ static int fusefile_read(const char *path, char *buf, size_t size, /** * 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 ); @@ -798,7 +802,7 @@ static int write_block(off_t off,const char *buf,size_t size) { } 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 @@ -830,7 +834,7 @@ static int fusefile_write_buf(const char *path, struct fuse_bufvec *buf, * Write a fragment at . 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 ); @@ -903,7 +907,7 @@ static void fsync_all_dirty() { } } -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 @@ -914,7 +918,7 @@ static int fusefile_flush(const char *path, struct fuse_file_info *info) { 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 @@ -924,7 +928,8 @@ static int fusefile_release(const char *path, struct fuse_file_info *fi) { 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 @@ -938,7 +943,8 @@ static int fusefile_fsync(const char *path, int x, struct fuse_file_info *fi) { /** * */ -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 @@ -948,13 +954,12 @@ static int fusefile_truncate(const char *path, off_t len) { 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 @@ -1031,7 +1036,6 @@ static struct fuse_operations fusefile_oper = { .fsync = fusefile_fsync, // NYI .ftruncate = fusefile_ftruncate, .truncate = fusefile_truncate, - //.truncate = fusefile_truncate, //.release = fusefile_release, .init = fusefile_init, }; @@ -1082,8 +1086,6 @@ static int setup_argv(int argc,char ***argv) { int main(int argc, char *argv[]) { char *mnt; - int mt; - int fg; int i; int fuseargc; struct stat stbuf; @@ -1153,13 +1155,11 @@ int main(int argc, char *argv[]) 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 ); } -- 2.39.2