Skip to content

Commit

Permalink
Upgrading to the new config struct
Browse files Browse the repository at this point in the history
  • Loading branch information
silverdaz committed Dec 10, 2024
1 parent cffaec8 commit aa38abd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
14 changes: 13 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/includes.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ struct fs_config {
/* multithreaded */
int singlethread;
int clone_fd;
int max_idle_threads;
int idle_threads;
int max_threads;
};

Expand Down
25 changes: 7 additions & 18 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ static void usage(struct fuse_args *args)
" read passphrase from environment variable <ENVVAR>\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 }
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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;
}
Expand All @@ -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 */
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit aa38abd

Please sign in to comment.