Rename DirIVCacheEnc to just DirIVCache
...and unexport dirIVCache
This commit is contained in:
parent
1573efec98
commit
adcfbd79a8
@ -28,7 +28,7 @@ type CryptFS struct {
|
||||
// Stores an all-zero block of size cipherBS
|
||||
allZeroBlock []byte
|
||||
// DirIV cache for filename encryption
|
||||
DirIVCacheEnc DirIVCache
|
||||
DirIVCache dirIVCache
|
||||
}
|
||||
|
||||
func NewCryptFS(key []byte, useOpenssl bool, plaintextNames bool, GCMIV128 bool) *CryptFS {
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
// A simple one-entry DirIV cache
|
||||
type DirIVCache struct {
|
||||
type dirIVCache struct {
|
||||
// Invalidated?
|
||||
cleared bool
|
||||
// The DirIV
|
||||
@ -24,7 +24,7 @@ type DirIVCache struct {
|
||||
}
|
||||
|
||||
// lookup - fetch entry for "dir" from the cache
|
||||
func (c *DirIVCache) lookup(dir string) (bool, []byte, string) {
|
||||
func (c *dirIVCache) lookup(dir string) (bool, []byte, string) {
|
||||
c.lock.RLock()
|
||||
defer c.lock.RUnlock()
|
||||
if !c.cleared && c.dir == dir {
|
||||
@ -34,7 +34,7 @@ func (c *DirIVCache) lookup(dir string) (bool, []byte, string) {
|
||||
}
|
||||
|
||||
// store - write entry for "dir" into the caches
|
||||
func (c *DirIVCache) store(dir string, iv []byte, translatedDir string) {
|
||||
func (c *dirIVCache) store(dir string, iv []byte, translatedDir string) {
|
||||
c.lock.Lock()
|
||||
defer c.lock.Unlock()
|
||||
c.cleared = false
|
||||
@ -43,7 +43,7 @@ func (c *DirIVCache) store(dir string, iv []byte, translatedDir string) {
|
||||
c.translatedDir = translatedDir
|
||||
}
|
||||
|
||||
func (c *DirIVCache) Clear() {
|
||||
func (c *dirIVCache) Clear() {
|
||||
c.lock.Lock()
|
||||
defer c.lock.Unlock()
|
||||
c.cleared = true
|
||||
@ -90,7 +90,7 @@ func (be *CryptFS) EncryptPathDirIV(plainPath string, rootDir string, eme bool)
|
||||
}
|
||||
// Check if the DirIV is cached
|
||||
parentDir := filepath.Dir(plainPath)
|
||||
found, iv, cParentDir := be.DirIVCacheEnc.lookup(parentDir)
|
||||
found, iv, cParentDir := be.DirIVCache.lookup(parentDir)
|
||||
if found {
|
||||
//fmt.Print("h")
|
||||
baseName := filepath.Base(plainPath)
|
||||
@ -114,7 +114,7 @@ func (be *CryptFS) EncryptPathDirIV(plainPath string, rootDir string, eme bool)
|
||||
// Cache the final DirIV
|
||||
cipherPath = strings.Join(encryptedNames, "/")
|
||||
cParentDir = filepath.Dir(cipherPath)
|
||||
be.DirIVCacheEnc.store(parentDir, iv, cParentDir)
|
||||
be.DirIVCache.store(parentDir, iv, cParentDir)
|
||||
return cipherPath, nil
|
||||
}
|
||||
|
||||
|
@ -305,7 +305,7 @@ func (fs *FS) Rename(oldPath string, newPath string, context *fuse.Context) (cod
|
||||
}
|
||||
// The Rename may cause a directory to take the place of another directory.
|
||||
// That directory may still be in the DirIV cache, clear it.
|
||||
fs.CryptFS.DirIVCacheEnc.Clear()
|
||||
fs.CryptFS.DirIVCache.Clear()
|
||||
|
||||
err = os.Rename(cOldPath, cNewPath)
|
||||
|
||||
|
@ -29,7 +29,7 @@ func (fs *FS) Mkdir(relPath string, mode uint32, context *fuse.Context) (code fu
|
||||
mode = mode | 0300
|
||||
|
||||
// The new directory may take the place of an older one that is still in the cache
|
||||
fs.CryptFS.DirIVCacheEnc.Clear()
|
||||
fs.CryptFS.DirIVCache.Clear()
|
||||
// Create directory
|
||||
fs.dirIVLock.Lock()
|
||||
defer fs.dirIVLock.Unlock()
|
||||
@ -148,6 +148,6 @@ func (fs *FS) Rmdir(name string, context *fuse.Context) (code fuse.Status) {
|
||||
cryptfs.Warn.Printf("Rmdir: Could not clean up %s: %v", tmpName, err)
|
||||
}
|
||||
// The now-deleted directory may have been in the DirIV cache. Clear it.
|
||||
fs.CryptFS.DirIVCacheEnc.Clear()
|
||||
fs.CryptFS.DirIVCache.Clear()
|
||||
return fuse.OK
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user