From 26881538e1753e613b4143b28fa339812a9a6d16 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 7 May 2017 20:58:27 +0200 Subject: nametranform, fusefrontend: better errors on invalid names nametransform.DecryptName() now always returns syscall.EBADMSG if the name was invalid. fusefrontend.OpenDir error messages have been normalized. --- internal/fusefrontend/fs_dir.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'internal/fusefrontend') diff --git a/internal/fusefrontend/fs_dir.go b/internal/fusefrontend/fs_dir.go index 05cea75..7d1e3ef 100644 --- a/internal/fusefrontend/fs_dir.go +++ b/internal/fusefrontend/fs_dir.go @@ -291,8 +291,8 @@ func (fs *FS) OpenDir(dirName string, context *fuse.Context) ([]fuse.DirEntry, f if isLong == nametransform.LongNameContent { cNameLong, err := nametransform.ReadLongName(filepath.Join(cDirAbsPath, cName)) if err != nil { - tlog.Warn.Printf("Skipping entry %q in dir %q: Could not read .name: %v", - cName, cDirName, err) + tlog.Warn.Printf("OpenDir %q: invalid entry %q: Could not read .name: %v", + cDirName, cName, err) errorCount++ continue } @@ -304,12 +304,13 @@ func (fs *FS) OpenDir(dirName string, context *fuse.Context) ([]fuse.DirEntry, f name, err := fs.nameTransform.DecryptName(cName, cachedIV) if err != nil { - tlog.Warn.Printf("Skipping entry %q in dir %q: %s", - cName, cDirName, err) + tlog.Warn.Printf("OpenDir %q: invalid entry %q: %v", + cDirName, cName, err) errorCount++ continue } - + // Override the ciphertext name with the plaintext name but reuse the rest + // of the structure cipherEntries[i].Name = name plain = append(plain, cipherEntries[i]) } @@ -317,8 +318,8 @@ func (fs *FS) OpenDir(dirName string, context *fuse.Context) ([]fuse.DirEntry, f if errorCount > 0 && len(plain) == 0 { // Don't let the user stare on an empty directory. Report that things went // wrong. - tlog.Warn.Printf("All %d entries in directory %q were invalid, returning EIO", - errorCount, cDirName) + tlog.Warn.Printf("OpenDir %q: all %d entries were invalid, returning EIO", + cDirName, errorCount) status = fuse.EIO } -- cgit v1.2.3