From 87d3ed9187cb9caccaa8df0769d4cb722cc5bd00 Mon Sep 17 00:00:00 2001 From: Jesse Dunietz Date: Sat, 6 Oct 2018 15:49:33 -0400 Subject: Add option for autounmount Even though filesystem notifications aren't implemented for FUSE, I decided to try my hand at implementing the autounmount feature (#128). I based it on the EncFS autounmount code, which records filesystem accesses and checks every X seconds whether it's idled long enough to unmount. I've tested the feature locally, but I haven't added any tests for this flag. I also haven't worked with Go before. So please let me know if there's anything that should be done differently. One particular concern: I worked from the assumption that the open files table is unique per-filesystem. If that's not true, I'll need to add an open file count and associated lock to the Filesystem type instead. https://github.com/rfjakob/gocryptfs/pull/265 --- internal/openfiletable/open_file_table.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'internal/openfiletable') diff --git a/internal/openfiletable/open_file_table.go b/internal/openfiletable/open_file_table.go index e21c96d..4a8ce28 100644 --- a/internal/openfiletable/open_file_table.go +++ b/internal/openfiletable/open_file_table.go @@ -112,3 +112,11 @@ func (c *countingMutex) Lock() { func WriteOpCount() uint64 { return atomic.LoadUint64(&t.writeOpCount) } + +// CountOpenFiles returns how many entries are currently in the table +// in a threadsafe manner. +func CountOpenFiles() int { + t.Lock() + defer t.Unlock() + return len(t.entries) +} -- cgit v1.2.3