Commit dc73e9f1 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

fuse: add SetAttrTimeout, SetEntryTimeout, SetTimeout to AttrOut/EntryOut

parent d0fca860
......@@ -64,8 +64,8 @@ func (m *fileSystemMount) setOwner(attr *fuse.Attr) {
}
func (m *fileSystemMount) fillEntry(out *fuse.EntryOut) {
splitDuration(m.options.EntryTimeout, &out.EntryValid, &out.EntryValidNsec)
splitDuration(m.options.AttrTimeout, &out.AttrValid, &out.AttrValidNsec)
out.SetEntryTimeout(m.options.EntryTimeout)
out.SetAttrTimeout(m.options.AttrTimeout)
m.setOwner(&out.Attr)
if out.Mode&fuse.S_IFDIR == 0 && out.Nlink == 0 {
out.Nlink = 1
......@@ -73,7 +73,7 @@ func (m *fileSystemMount) fillEntry(out *fuse.EntryOut) {
}
func (m *fileSystemMount) fillAttr(out *fuse.AttrOut, nodeId uint64) {
splitDuration(m.options.AttrTimeout, &out.AttrValid, &out.AttrValidNsec)
out.SetTimeout(m.options.AttrTimeout)
m.setOwner(&out.Attr)
if out.Ino == 0 {
out.Ino = nodeId
......@@ -179,7 +179,7 @@ func (m *fileSystemMount) registerFileHandle(node *Inode, dir *connectorDir, f F
func (m *fileSystemMount) negativeEntry(out *fuse.EntryOut) bool {
if m.options.NegativeTimeout > 0.0 {
out.NodeId = 0
splitDuration(m.options.NegativeTimeout, &out.EntryValid, &out.EntryValidNsec)
out.SetEntryTimeout(m.options.NegativeTimeout)
return true
}
return false
......
// Copyright 2016 the Go-FUSE Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package nodefs
import "time"
func splitDuration(dt time.Duration, secs *uint64, nsecs *uint32) {
ns := int64(dt)
*nsecs = uint32(ns % 1e9)
*secs = uint64(ns / 1e9)
}
......@@ -7,6 +7,7 @@ package fuse
import (
"io"
"syscall"
"time"
)
const (
......@@ -433,6 +434,18 @@ type EntryOut struct {
Attr
}
func (o *EntryOut) SetEntryTimeout(dt time.Duration) {
ns := int64(dt)
o.EntryValidNsec = uint32(ns % 1e9)
o.EntryValid = uint64(ns / 1e9)
}
func (o *EntryOut) SetAttrTimeout(dt time.Duration) {
ns := int64(dt)
o.AttrValidNsec = uint32(ns % 1e9)
o.AttrValid = uint64(ns / 1e9)
}
type AttrOut struct {
AttrValid uint64
AttrValidNsec uint32
......@@ -440,6 +453,12 @@ type AttrOut struct {
Attr
}
func (o *AttrOut) SetTimeout(dt time.Duration) {
ns := int64(dt)
o.AttrValidNsec = uint32(ns % 1e9)
o.AttrValid = uint64(ns / 1e9)
}
type CreateOut struct {
EntryOut
OpenOut
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment