rfjakob/gocryptfs

-idle option not working properly

bertogg opened this issue · 2 comments

The -idle option should unmount the filesystem if it has been idle for the specified amount of time.

However it seems to do it always, regardless of whether the filesystem is idle or not.

This script should create a new filesystem, mount it (with -idle 20s), create a directory inside it, and create 100 files, one every 5 seconds.

This should guarantee that the filesystem is always busy so all 100 files should be created. However the filesystem is unmounted after 20 seconds and the script exits with an error.

I tested this with gocryptfs 1.7

#!/bin/sh

set -eu

DIR=`mktemp -d /tmp/tmpdir.XXXXXX`
mkdir $DIR/crypt $DIR/plain

echo foo | gocryptfs -init $DIR/crypt
echo foo | gocryptfs -idle 20s $DIR/crypt $DIR/plain

mkdir $DIR/plain/data

for f in `seq -w 0 99`; do
    date
    echo sometext > $DIR/plain/data/$f
    ls $DIR/plain/data
    sleep 5
done

fusermount -u $DIR/plain

Thanks for the report. I looked at the code and I think I see the problem, and how to fix this.

Note to self: we have a test that checks that -idle unmounts as expected, but we do not have a test that -idle does NOT unmount when the filesystem is active.