1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-09-10 09:52:20 +08:00

godeps: update bazil.org/fuse

fuse: Attr() now has a Context parameter and error return value

~GOPATH/src/bazil.org/fuse:master$ git shortlog 48c34fb7780b88aca1696bf865508f6703aa47f1..e4fcc9a2c7567d1c42861deebeb483315d222262
Tommi Virtanen (8):
      Remove dead code
      Make saveLookup take Context, return error
      Make serveNode.attr take Context, return error
      Make nodeAttr take Context, return error
      API change: Move attribute validity time inside Attr
      Set attribute validity default time in one place
      API change: Attr method takes Context, returns error
      Set LookupResponse validity times up front, instead of after the handler
This commit is contained in:
Henry
2015-05-28 22:09:26 +02:00
parent 97d75891b0
commit e9074beb6d
16 changed files with 407 additions and 139 deletions

View File

@ -4,6 +4,7 @@
package readonly
import (
"fmt"
"io"
"os"
@ -43,8 +44,9 @@ type Root struct {
}
// Attr returns file attributes.
func (*Root) Attr() fuse.Attr {
return fuse.Attr{Mode: os.ModeDir | 0111} // -rw+x
func (*Root) Attr(ctx context.Context, a *fuse.Attr) error {
*a = fuse.Attr{Mode: os.ModeDir | 0111} // -rw+x
return nil
}
// Lookup performs a lookup under this node.
@ -85,21 +87,23 @@ func (s *Node) loadData() error {
}
// Attr returns the attributes of a given node.
func (s *Node) Attr() fuse.Attr {
func (s *Node) Attr(ctx context.Context, a *fuse.Attr) error {
log.Debug("Node attr.")
if s.cached == nil {
s.loadData()
if err := s.loadData(); err != nil {
return fmt.Errorf("readonly: loadData() failed: %s", err)
}
}
switch s.cached.GetType() {
case ftpb.Data_Directory:
return fuse.Attr{
*a = fuse.Attr{
Mode: os.ModeDir | 0555,
Uid: uint32(os.Getuid()),
Gid: uint32(os.Getgid()),
}
case ftpb.Data_File:
size := s.cached.GetFilesize()
return fuse.Attr{
*a = fuse.Attr{
Mode: 0444,
Size: uint64(size),
Blocks: uint64(len(s.Nd.Links)),
@ -107,7 +111,7 @@ func (s *Node) Attr() fuse.Attr {
Gid: uint32(os.Getgid()),
}
case ftpb.Data_Raw:
return fuse.Attr{
*a = fuse.Attr{
Mode: 0444,
Size: uint64(len(s.cached.GetData())),
Blocks: uint64(len(s.Nd.Links)),
@ -116,9 +120,9 @@ func (s *Node) Attr() fuse.Attr {
}
default:
log.Debug("Invalid data type.")
return fuse.Attr{}
return fmt.Errorf("Invalid data type - %s", s.cached.GetType())
}
return nil
}
// Lookup performs a lookup under this node.