aboutsummaryrefslogtreecommitdiff
path: root/mount.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2017-11-12 20:06:13 +0100
committerJakob Unterwurzacher2017-11-12 20:06:13 +0100
commite36a0ebf189a826aaa63909c5518c16356f5f903 (patch)
tree448966f795f3aca9b64fa66af0616a7128bd39fa /mount.go
parent9ab6cdb9b9eb02b27b5b8574ebf36d3495a71a17 (diff)
main: add "-sharedstorage" flag
At the moment, it does two things: 1. Disable stat() caching so changes to the backing storage show up immediately. 2. Disable hard link tracking, as the inode numbers on the backing storage are not stable when files are deleted and re-created behind our back. This would otherwise produce strange "file does not exist" and other errors. Mitigates https://github.com/rfjakob/gocryptfs/issues/156
Diffstat (limited to 'mount.go')
-rw-r--r--mount.go25
1 files changed, 19 insertions, 6 deletions
diff --git a/mount.go b/mount.go
index 007cc46..c3fda80 100644
--- a/mount.go
+++ b/mount.go
@@ -230,6 +230,12 @@ func initFuseFrontend(masterkey []byte, args *argContainer, confFile *configfile
var ctlSockBackend ctlsock.Interface
// pathFsOpts are passed into go-fuse/pathfs
pathFsOpts := &pathfs.PathNodeFsOptions{ClientInodes: true}
+ if args.sharedstorage {
+ // shared storage mode disables hard link tracking as the backing inode
+ // numbers may change behind our back:
+ // https://github.com/rfjakob/gocryptfs/issues/156
+ pathFsOpts.ClientInodes = false
+ }
if args.reverse {
// The dance with the intermediate variables is because we need to
// cast the FS into pathfs.FileSystem *and* ctlsock.Interface. This
@@ -257,12 +263,19 @@ func initFuseFrontend(masterkey []byte, args *argContainer, confFile *configfile
go ctlsock.Serve(args._ctlsockFd, ctlSockBackend)
}
pathFs := pathfs.NewPathNodeFs(finalFs, pathFsOpts)
- fuseOpts := &nodefs.Options{
- // These options are to be compatible with libfuse defaults,
- // making benchmarking easier.
- NegativeTimeout: time.Second,
- AttrTimeout: time.Second,
- EntryTimeout: time.Second,
+ var fuseOpts *nodefs.Options
+ if args.sharedstorage {
+ // sharedstorage mode sets all cache timeouts to zero so changes to the
+ // backing shared storage show up immediately.
+ fuseOpts = &nodefs.Options{}
+ } else {
+ fuseOpts = &nodefs.Options{
+ // These options are to be compatible with libfuse defaults,
+ // making benchmarking easier.
+ NegativeTimeout: time.Second,
+ AttrTimeout: time.Second,
+ EntryTimeout: time.Second,
+ }
}
conn := nodefs.NewFileSystemConnector(pathFs.Root(), fuseOpts)
mOpts := fuse.MountOptions{