aboutsummaryrefslogtreecommitdiff
path: root/internal/fusefrontend_reverse
diff options
context:
space:
mode:
authorJakob Unterwurzacher2017-05-28 18:33:05 +0200
committerJakob Unterwurzacher2017-05-28 18:33:05 +0200
commit35f4f8af56ec4da9952df4feba4981f5d148b2cf (patch)
treee796176b7ad371fc335e9379d6c37c0dad06a2be /internal/fusefrontend_reverse
parentab10cf63ed21d09e239986ac125b990fe06b5572 (diff)
pathiv: move derivedIVContainer into the package
...under the new name "FileIVs". This will also be used by forward mode.
Diffstat (limited to 'internal/fusefrontend_reverse')
-rw-r--r--internal/fusefrontend_reverse/rfile.go18
1 files changed, 6 insertions, 12 deletions
diff --git a/internal/fusefrontend_reverse/rfile.go b/internal/fusefrontend_reverse/rfile.go
index b19ad5e..530547a 100644
--- a/internal/fusefrontend_reverse/rfile.go
+++ b/internal/fusefrontend_reverse/rfile.go
@@ -33,11 +33,6 @@ type reverseFile struct {
var inodeTable syncmap.Map
-type derivedIVContainer struct {
- id []byte
- block0IV []byte
-}
-
func (rfs *ReverseFS) newFile(relPath string, flags uint32) (nodefs.File, fuse.Status) {
absPath, err := rfs.abs(rfs.decryptPath(relPath))
if err != nil {
@@ -55,14 +50,13 @@ func (rfs *ReverseFS) newFile(relPath string, flags uint32) (nodefs.File, fuse.S
}
// See if we have that inode number already in the table
// (even if Nlink has dropped to 1)
- var derivedIVs derivedIVContainer
+ var derivedIVs pathiv.FileIVs
v, found := inodeTable.Load(st.Ino)
if found {
tlog.Debug.Printf("ino%d: newFile: found in the inode table", st.Ino)
- derivedIVs = v.(derivedIVContainer)
+ derivedIVs = v.(pathiv.FileIVs)
} else {
- derivedIVs.id = pathiv.Derive(relPath, pathiv.PurposeFileID)
- derivedIVs.block0IV = pathiv.Derive(relPath, pathiv.PurposeBlock0IV)
+ derivedIVs = pathiv.DeriveFile(relPath)
// Nlink > 1 means there is more than one path to this file.
// Store the derived values so we always return the same data,
// regardless of the path that is used to access the file.
@@ -71,7 +65,7 @@ func (rfs *ReverseFS) newFile(relPath string, flags uint32) (nodefs.File, fuse.S
v, found = inodeTable.LoadOrStore(st.Ino, derivedIVs)
if found {
// Another thread has stored a different value before we could.
- derivedIVs = v.(derivedIVContainer)
+ derivedIVs = v.(pathiv.FileIVs)
} else {
tlog.Debug.Printf("ino%d: newFile: Nlink=%d, stored in the inode table", st.Ino, st.Nlink)
}
@@ -79,13 +73,13 @@ func (rfs *ReverseFS) newFile(relPath string, flags uint32) (nodefs.File, fuse.S
}
header := contentenc.FileHeader{
Version: contentenc.CurrentVersion,
- ID: derivedIVs.id,
+ ID: derivedIVs.ID,
}
return &reverseFile{
File: nodefs.NewDefaultFile(),
fd: fd,
header: header,
- block0IV: derivedIVs.block0IV,
+ block0IV: derivedIVs.Block0IV,
contentEnc: rfs.contentEnc,
}, fuse.OK
}