summaryrefslogtreecommitdiff
path: root/internal/fusefrontend/node.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2020-06-21 12:42:18 +0200
committerJakob Unterwurzacher2020-06-21 12:42:18 +0200
commitebdf58b9ebf366ac6dbf500c0f4f4d211451bb44 (patch)
treed30c80ae667d844ce0081820b9b07e48940d4cf0 /internal/fusefrontend/node.go
parent77632b7554000f2e832a0e9fded1a3894b2502c3 (diff)
v2api: implement GetAttr and Readdir
Diffstat (limited to 'internal/fusefrontend/node.go')
-rw-r--r--internal/fusefrontend/node.go27
1 files changed, 23 insertions, 4 deletions
diff --git a/internal/fusefrontend/node.go b/internal/fusefrontend/node.go
index f246408..f4359a2 100644
--- a/internal/fusefrontend/node.go
+++ b/internal/fusefrontend/node.go
@@ -31,6 +31,15 @@ type RootNode struct {
nameTransform nametransform.NameTransformer
// Content encryption helper
contentEnc *contentenc.ContentEnc
+ // MitigatedCorruptions is used to report data corruption that is internally
+ // mitigated by ignoring the corrupt item. For example, when OpenDir() finds
+ // a corrupt filename, we still return the other valid filenames.
+ // The corruption is logged to syslog to inform the user, and in addition,
+ // the corrupt filename is logged to this channel via
+ // reportMitigatedCorruption().
+ // "gocryptfs -fsck" reads from the channel to also catch these transparently-
+ // mitigated corruptions.
+ MitigatedCorruptions chan string
// IsIdle flag is set to zero each time fs.isFiltered() is called
// (uint32 so that it can be reset with CompareAndSwapUint32).
// When -idle was used when mounting, idleMonitor() sets it to 1
@@ -68,6 +77,7 @@ func (n *Node) Lookup(ctx context.Context, name string, out *fuse.EntryOut) (*fs
if err != nil {
return nil, fs.ToErrno(err)
}
+ defer syscall.Close(dirfd)
// Get device number and inode number into `st`
st, err := syscallcompat.Fstatat2(dirfd, cName, unix.AT_SYMLINK_NOFOLLOW)
if err != nil {
@@ -88,9 +98,18 @@ func (n *Node) Lookup(ctx context.Context, name string, out *fuse.EntryOut) (*fs
}
func (n *Node) Getattr(ctx context.Context, f fs.FileHandle, out *fuse.AttrOut) syscall.Errno {
- return 1
-}
+ rn := n.rootNode()
+ dirfd, cName, err := rn.openBackingDir(n.path())
+ if err != nil {
+ return fs.ToErrno(err)
+ }
+ defer syscall.Close(dirfd)
-func (n *Node) Readdir(ctx context.Context) (fs.DirStream, syscall.Errno) {
- return nil, 1
+ st, err := syscallcompat.Fstatat2(dirfd, cName, unix.AT_SYMLINK_NOFOLLOW)
+ if err != nil {
+ return fs.ToErrno(err)
+ }
+ rn.inoMap.TranslateStat(st)
+ out.Attr.FromStat(st)
+ return 0
}