From aa38abdd09bfe96019628d3de8321e846460c686 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Haziza?= Date: Tue, 10 Dec 2024 10:28:13 +0100 Subject: [PATCH] Upgrading to the new config struct --- .github/workflows/build.yml | 14 +++++++++++++- src/includes.h | 2 +- src/main.c | 25 +++++++------------------ 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 61ab5d3..66e15d2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,9 +21,21 @@ jobs: ./configure make sudo make install + - name: Print version + run: crypt4gh-sqlite.fs -V - name: Update the test and start the file system run: make -C example update up - - name: Test + - name: Test 1 run: diff example/mnt/crypt4gh/cleartext <(C4GH_PASSPHRASE=hello crypt4gh decrypt --sk example/example.seckey < example/mnt/crypt4gh/encrypted 2>/dev/null) + - name: Test 2 + run: diff example/subdir/file1.txt <(cat example/prepend.txt example/example.txt) + - name: Test 3 + run: diff example/subdir/file2.txt <(cat example/example.txt example/append.txt) + - name: Test 4 + run: diff example/extra/footer.txt example/append.txt + - name: Test 5 + run: diff example/extra/header.txt example/prepend.txt + - name: Test 6 + run: diff example/slim.txt example/example.txt - name: Tear down run: make -C example down diff --git a/src/includes.h b/src/includes.h index e4f6cfd..27e34ad 100644 --- a/src/includes.h +++ b/src/includes.h @@ -144,7 +144,7 @@ struct fs_config { /* multithreaded */ int singlethread; int clone_fd; - int max_idle_threads; + int idle_threads; int max_threads; }; diff --git a/src/main.c b/src/main.c index 3dfe369..862f3f6 100644 --- a/src/main.c +++ b/src/main.c @@ -48,6 +48,7 @@ static void usage(struct fuse_args *args) " read passphrase from environment variable \n" , args->argv[0]); } +// TODO: add the undescribed options, like max_threads, and clone_fd #define CRYPT4GH_SQLITE_OPT(t, p, v) { t, offsetof(struct fs_config, p), v } @@ -83,7 +84,7 @@ static struct fuse_opt fs_opts[] = { /* if multithreaded */ CRYPT4GH_SQLITE_OPT("-s" , singlethread , 1), CRYPT4GH_SQLITE_OPT("clone_fd" , clone_fd , 1), - CRYPT4GH_SQLITE_OPT("max_idle_threads=%u", max_idle_threads, 0), + CRYPT4GH_SQLITE_OPT("idle_threads=%u", idle_threads, 0), CRYPT4GH_SQLITE_OPT("max_threads=%u", max_threads, 0), CRYPT4GH_SQLITE_OPT("entry_timeout=%lf", entry_timeout, 0), @@ -272,8 +273,8 @@ int main(int argc, char *argv[]) struct fuse_lowlevel_ops *operations; - if(fuse_version() < FUSE_VERSION ){ - fprintf(stderr, "We need at least FUSE version %d\n", FUSE_VERSION); + if(fuse_version() < FUSE_MAKE_VERSION(3,12) ){ + fprintf(stderr, "We need at least FUSE version %d\n", FUSE_MAKE_VERSION(3,12)); fprintf(stderr, "You have FUSE version %d\n", fuse_version()); return 1; } @@ -292,7 +293,7 @@ int main(int argc, char *argv[]) config.attr_timeout = DEFAULT_ATTR_TIMEOUT; config.max_threads = DEFAULT_MAX_THREADS; - config.max_idle_threads = UINT_MAX; + config.max_threads = UINT_MAX; config.uid = getuid(); /* current user */ config.gid = getgid(); /* current group */ @@ -427,24 +428,12 @@ int main(int argc, char *argv[]) res = fuse_session_loop(se); } else { D2("Mode: multi-threaded (max threads: %d)", config.max_threads); -#if FUSE_USE_VERSION < FUSE_MAKE_VERSION(3, 12) - struct fuse_loop_config_v1 cf1 = { - .max_idle_threads = config.max_threads, - .clone_fd = config.clone_fd, - }; - struct fuse_loop_config cf; - fuse_loop_cfg_convert(&cf, &cf1); -#else struct fuse_loop_config *cf = fuse_loop_cfg_create(); - fuse_loop_cfg_set_idle_threads(cf, config.max_idle_threads); - fuse_loop_cfg_set_max_threads(cf, config.max_threads); fuse_loop_cfg_set_clone_fd(cf, config.clone_fd); -#endif - D2("Mode: multi-threaded (max idle threads: %d)", config.max_threads); + fuse_loop_cfg_set_idle_threads(cf, config.idle_threads); + fuse_loop_cfg_set_max_threads(cf, config.max_threads); res = fuse_session_loop_mt(se, cf); -#if FUSE_USE_VERSION > FUSE_MAKE_VERSION(3, 12) fuse_loop_cfg_destroy(cf); -#endif } bailout_unmount: