From f73aee72f87ba6cd3e46184ae75824fd38250f04 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Mon, 5 Apr 2021 18:20:17 +0200 Subject: fusefrontend: print dirCache stats after unmount --- mount.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'mount.go') diff --git a/mount.go b/mount.go index 571b51b..1194104 100644 --- a/mount.go +++ b/mount.go @@ -37,6 +37,12 @@ import ( "github.com/rfjakob/gocryptfs/internal/tlog" ) +// AfterUnmount is called after the filesystem has been unmounted. +// This can be used for cleanup and printing statistics. +type AfterUnmounter interface { + AfterUnmount() +} + // doMount mounts an encrypted directory. // Called from main. func doMount(args *argContainer) { @@ -116,10 +122,13 @@ func doMount(args *argContainer) { tlog.Debug.Printf("cli args: %#v", args) // Initialize gocryptfs (read config file, ask for password, ...) fs, wipeKeys := initFuseFrontend(args) - // Initialize go-fuse FUSE server - srv := initGoFuse(fs, args) // Try to wipe secret keys from memory after unmount defer wipeKeys() + // Initialize go-fuse FUSE server + srv := initGoFuse(fs, args) + if x, ok := fs.(AfterUnmounter); ok { + defer x.AfterUnmount() + } tlog.Info.Println(tlog.ColorGreen + "Filesystem mounted and ready." + tlog.ColorReset) // We have been forked into the background, as evidenced by the set -- cgit v1.2.3