summaryrefslogtreecommitdiff
path: root/internal/fusefrontend/fs.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2016-02-07 11:29:54 +0100
committerJakob Unterwurzacher2016-02-07 11:29:54 +0100
commit6b5d977cce3a65f04f17c84aa9b2776b52487946 (patch)
tree074b5d747d607d466b75a7eb49e1c2f3cb662eae /internal/fusefrontend/fs.go
parent3a4922b5d747d54c9cb62833c9d69acb96b072f6 (diff)
Move OpenDir to fs_dir.go
Diffstat (limited to 'internal/fusefrontend/fs.go')
-rw-r--r--internal/fusefrontend/fs.go67
1 files changed, 1 insertions, 66 deletions
diff --git a/internal/fusefrontend/fs.go b/internal/fusefrontend/fs.go
index a15e004..f11c05e 100644
--- a/internal/fusefrontend/fs.go
+++ b/internal/fusefrontend/fs.go
@@ -72,72 +72,6 @@ func (fs *FS) GetAttr(name string, context *fuse.Context) (*fuse.Attr, fuse.Stat
return a, status
}
-func (fs *FS) OpenDir(dirName string, context *fuse.Context) ([]fuse.DirEntry, fuse.Status) {
- toggledlog.Debug.Printf("OpenDir(%s)", dirName)
- cDirName, err := fs.encryptPath(dirName)
- if err != nil {
- return nil, fuse.ToStatus(err)
- }
- // Read ciphertext directory
- cipherEntries, status := fs.FileSystem.OpenDir(cDirName, context)
- if cipherEntries == nil {
- return nil, status
- }
- // Get DirIV (stays nil if DirIV if off)
- var cachedIV []byte
- var cDirAbsPath string
- if fs.args.DirIV {
- // Read the DirIV once and use it for all later name decryptions
- cDirAbsPath = filepath.Join(fs.args.Cipherdir, cDirName)
- cachedIV, err = nametransform.ReadDirIV(cDirAbsPath)
- if err != nil {
- return nil, fuse.ToStatus(err)
- }
- }
- // Filter and decrypt filenames
- var plain []fuse.DirEntry
- for i := range cipherEntries {
- cName := cipherEntries[i].Name
- if dirName == "" && cName == configfile.ConfDefaultName {
- // silently ignore "gocryptfs.conf" in the top level dir
- continue
- }
- if fs.args.DirIV && cName == nametransform.DirIVFilename {
- // silently ignore "gocryptfs.diriv" everywhere if dirIV is enabled
- continue
- }
-
- if fs.args.PlaintextNames {
- plain = append(plain, cipherEntries[i])
- continue
- }
-
- if fs.args.LongNames {
- isLong := nametransform.IsLongName(cName)
- if isLong == 1 {
- cNameLong, err := nametransform.ReadLongName(filepath.Join(cDirAbsPath, cName))
- if err != nil {
- toggledlog.Warn.Printf("Could not read long name for file %s, skipping file", cName)
- continue
- }
- cName = cNameLong
- } else if isLong == 2 {
- // ignore "gocryptfs.longname.*.name"
- continue
- }
- }
- name, err := fs.nameTransform.DecryptName(cName, cachedIV)
- if err != nil {
- toggledlog.Warn.Printf("Skipping invalid name '%s' in dir '%s': %s", cName, cDirName, err)
- continue
- }
-
- cipherEntries[i].Name = name
- plain = append(plain, cipherEntries[i])
- }
- return plain, status
-}
-
// We always need read access to do read-modify-write cycles
func (fs *FS) mangleOpenFlags(flags uint32) (newFlags int, writeOnly bool) {
newFlags = int(flags)
@@ -181,6 +115,7 @@ func (fs *FS) Create(path string, flags uint32, mode uint32, context *fuse.Conte
}
cBaseName := filepath.Base(cPath)
if fs.args.LongNames && nametransform.IsLongName(cBaseName) == 1 {
+ // Create the ".name" file before creating the content
err = fs.nameTransform.WriteLongName(filepath.Dir(cPath), cBaseName, filepath.Base(path))
if err != nil {
return nil, fuse.ToStatus(err)