@cryptotaxi247 / kubo / commits / fbd9cabd9

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>

Tommi Virtanen committed Aug 31, 2015 at 18:03 UTC fbd9cabd93b0eac097772436c64b5bcff6a5e4f4
3 files changed +10 -17
fuse/ipns/ipns_unix.go
+8 -12
@@ -109,7 +109,7 @@ func CreateRoot(ipfs *core.IpfsNode, keys []ci.PrivKey, ipfspath, ipnspath strin
109 // Attr returns file attributes.
110 func (*Root) Attr(ctx context.Context, a *fuse.Attr) error {
111 log.Debug("Root Attr")
112 - *a = fuse.Attr{Mode: os.ModeDir | 0111} // -rw+x
112 + a.Mode = os.ModeDir | 0111 // -rw+x
113 return nil
114 }
115
@@ -219,11 +219,9 @@ type File struct {
219 // Attr returns the attributes of a given node.
220 func (d *Directory) Attr(ctx context.Context, a *fuse.Attr) error {
221 log.Debug("Directory Attr")
222 - *a = fuse.Attr{
223 - Mode: os.ModeDir | 0555,
224 - Uid: uint32(os.Getuid()),
225 - Gid: uint32(os.Getgid()),
226 - }
222 + a.Mode = os.ModeDir | 0555
223 + a.Uid = uint32(os.Getuid())
224 + a.Gid = uint32(os.Getgid())
225 return nil
226 }
227
@@ -235,12 +233,10 @@ func (fi *File) Attr(ctx context.Context, a *fuse.Attr) error {
233 // In this case, the dag node in question may not be unixfs
234 return fmt.Errorf("fuse/ipns: failed to get file.Size(): %s", err)
235 }
238 - *a = fuse.Attr{
239 - Mode: os.FileMode(0666),
240 - Size: uint64(size),
241 - Uid: uint32(os.Getuid()),
242 - Gid: uint32(os.Getgid()),
243 - }
236 + a.Mode = os.FileMode(0666)
237 + a.Size = uint64(size)
238 + a.Uid = uint32(os.Getuid())
239 + a.Gid = uint32(os.Getgid())
240 return nil
241 }
242
fuse/ipns/link_unix.go
+1 -3
@@ -16,9 +16,7 @@ type Link struct {
16
17 func (l *Link) Attr(ctx context.Context, a *fuse.Attr) error {
18 log.Debug("Link attr.")
19 - *a = fuse.Attr{
20 - Mode: os.ModeSymlink | 0555,
21 - }
19 + a.Mode = os.ModeSymlink | 0555
20 return nil
21 }
22
fuse/readonly/readonly_unix.go
+1 -2
@@ -46,7 +46,7 @@ type Root struct {
46
47 // Attr returns file attributes.
48 func (*Root) Attr(ctx context.Context, a *fuse.Attr) error {
49 - *a = fuse.Attr{Mode: os.ModeDir | 0111} // -rw+x
49 + a.Mode = os.ModeDir | 0111 // -rw+x
50 return nil
51 }
52
@@ -118,7 +118,6 @@ func (s *Node) Attr(ctx context.Context, a *fuse.Attr) error {
118 a.Size = uint64(len(s.cached.GetData()))
119 a.Uid = uint32(os.Getuid())
120 a.Gid = uint32(os.Getgid())
121 -
121 default:
122 return fmt.Errorf("Invalid data type - %s", s.cached.GetType())
123 }