summaryrefslogtreecommitdiff
path: root/internal/fusefrontend_reverse/rfs.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2016-09-22 19:54:37 +0200
committerJakob Unterwurzacher2016-09-25 16:43:17 +0200
commit35bcc2dca2dc928e3b7c31e34d785b7a42c06722 (patch)
tree9530244dbb74a028d0f3377eb5767d662ee1ee15 /internal/fusefrontend_reverse/rfs.go
parentb34a665da4a15762fc2e21e125ba705f691ec5d7 (diff)
reverse: transform long names in OpenDir
Diffstat (limited to 'internal/fusefrontend_reverse/rfs.go')
-rw-r--r--internal/fusefrontend_reverse/rfs.go18
1 files changed, 13 insertions, 5 deletions
diff --git a/internal/fusefrontend_reverse/rfs.go b/internal/fusefrontend_reverse/rfs.go
index 4f516fd..9fac591 100644
--- a/internal/fusefrontend_reverse/rfs.go
+++ b/internal/fusefrontend_reverse/rfs.go
@@ -218,19 +218,27 @@ func (rfs *reverseFS) OpenDir(cipherPath string, context *fuse.Context) ([]fuse.
if entries == nil {
return nil, status
}
+ // Virtual gocryptfs.diriv file
+ dirIVEntry := fuse.DirEntry{syscall.S_IFREG | 0400, nametransform.DirIVFilename}
+ virtualFiles := []fuse.DirEntry{dirIVEntry}
// Encrypt names
dirIV := deriveDirIV(cipherPath)
for i := range entries {
+ var cName string
// ".gocryptfs.reverse.conf" in the root directory is mapped to "gocryptfs.conf"
if cipherPath == "" && entries[i].Name == configfile.ConfReverseName {
- entries[i].Name = configfile.ConfDefaultName
+ cName = configfile.ConfDefaultName
} else {
- entries[i].Name = rfs.nameTransform.EncryptName(entries[i].Name, dirIV)
+ cName = rfs.nameTransform.EncryptName(entries[i].Name, dirIV)
+ if len(cName) > syscall.NAME_MAX {
+ cName = nametransform.HashLongName(cName)
+ dotNameFile := fuse.DirEntry{syscall.S_IFREG | 0600, cName + nametransform.LongNameSuffix}
+ virtualFiles = append(virtualFiles, dotNameFile)
+ }
}
+ entries[i].Name = cName
}
- // Add virtual gocryptfs.diriv
- entries = append(entries, fuse.DirEntry{syscall.S_IFREG | 0400, nametransform.DirIVFilename})
-
+ entries = append(entries, virtualFiles...)
return entries, fuse.OK
}