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

fuse/ipns, fuse/readonly: Let the fuse library set defaults for Attr

Without this, all entries will have nlink==0, which confuses a bunch
of tools. Most dramatically, systemd-nspawn enters a busy loop in its
lock utility function.

License: MIT
Signed-off-by: Tommi Virtanen <tv@eagain.net>
This commit is contained in:
Tommi Virtanen
2015-08-31 18:03:59 -07:00
committed by Jeromy
parent 1d21fad697
commit fbd9cabd93
3 changed files with 10 additions and 17 deletions

View File

@ -109,7 +109,7 @@ func CreateRoot(ipfs *core.IpfsNode, keys []ci.PrivKey, ipfspath, ipnspath strin
// Attr returns file attributes.
func (*Root) Attr(ctx context.Context, a *fuse.Attr) error {
log.Debug("Root Attr")
*a = fuse.Attr{Mode: os.ModeDir | 0111} // -rw+x
a.Mode = os.ModeDir | 0111 // -rw+x
return nil
}
@ -219,11 +219,9 @@ type File struct {
// Attr returns the attributes of a given node.
func (d *Directory) Attr(ctx context.Context, a *fuse.Attr) error {
log.Debug("Directory Attr")
*a = fuse.Attr{
Mode: os.ModeDir | 0555,
Uid: uint32(os.Getuid()),
Gid: uint32(os.Getgid()),
}
a.Mode = os.ModeDir | 0555
a.Uid = uint32(os.Getuid())
a.Gid = uint32(os.Getgid())
return nil
}
@ -235,12 +233,10 @@ func (fi *File) Attr(ctx context.Context, a *fuse.Attr) error {
// In this case, the dag node in question may not be unixfs
return fmt.Errorf("fuse/ipns: failed to get file.Size(): %s", err)
}
*a = fuse.Attr{
Mode: os.FileMode(0666),
Size: uint64(size),
Uid: uint32(os.Getuid()),
Gid: uint32(os.Getgid()),
}
a.Mode = os.FileMode(0666)
a.Size = uint64(size)
a.Uid = uint32(os.Getuid())
a.Gid = uint32(os.Getgid())
return nil
}

View File

@ -16,9 +16,7 @@ type Link struct {
func (l *Link) Attr(ctx context.Context, a *fuse.Attr) error {
log.Debug("Link attr.")
*a = fuse.Attr{
Mode: os.ModeSymlink | 0555,
}
a.Mode = os.ModeSymlink | 0555
return nil
}

View File

@ -46,7 +46,7 @@ type Root struct {
// Attr returns file attributes.
func (*Root) Attr(ctx context.Context, a *fuse.Attr) error {
*a = fuse.Attr{Mode: os.ModeDir | 0111} // -rw+x
a.Mode = os.ModeDir | 0111 // -rw+x
return nil
}
@ -118,7 +118,6 @@ func (s *Node) Attr(ctx context.Context, a *fuse.Attr) error {
a.Size = uint64(len(s.cached.GetData()))
a.Uid = uint32(os.Getuid())
a.Gid = uint32(os.Getgid())
default:
return fmt.Errorf("Invalid data type - %s", s.cached.GetType())
}