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

nodefs: return []byte in Readlink

parent b423903e
...@@ -129,7 +129,7 @@ type SymlinkOperations interface { ...@@ -129,7 +129,7 @@ type SymlinkOperations interface {
Operations Operations
// Readlink reads the content of a symlink. // Readlink reads the content of a symlink.
Readlink(ctx context.Context) (string, fuse.Status) Readlink(ctx context.Context) ([]byte, fuse.Status)
} }
// FileOperations holds operations that apply to regular files. The // FileOperations holds operations that apply to regular files. The
......
...@@ -441,7 +441,7 @@ func (b *rawBridge) Readlink(cancel <-chan struct{}, header *fuse.InHeader) (out ...@@ -441,7 +441,7 @@ func (b *rawBridge) Readlink(cancel <-chan struct{}, header *fuse.InHeader) (out
return nil, status return nil, status
} }
return []byte(result), fuse.OK return result, fuse.OK
} }
func (b *rawBridge) Access(cancel <-chan struct{}, input *fuse.AccessIn) (status fuse.Status) { func (b *rawBridge) Access(cancel <-chan struct{}, input *fuse.AccessIn) (status fuse.Status) {
......
...@@ -175,8 +175,8 @@ func (n *DefaultOperations) Symlink(ctx context.Context, target, name string, ou ...@@ -175,8 +175,8 @@ func (n *DefaultOperations) Symlink(ctx context.Context, target, name string, ou
} }
// Readlink return ENOTSUP // Readlink return ENOTSUP
func (n *DefaultOperations) Readlink(ctx context.Context) (string, fuse.Status) { func (n *DefaultOperations) Readlink(ctx context.Context) ([]byte, fuse.Status) {
return "", fuse.ENOTSUP return nil, fuse.ENOTSUP
} }
// Fsync delegates to the FileHandle // Fsync delegates to the FileHandle
......
...@@ -223,18 +223,18 @@ func (n *loopbackNode) Link(ctx context.Context, target Operations, name string, ...@@ -223,18 +223,18 @@ func (n *loopbackNode) Link(ctx context.Context, target Operations, name string,
return ch, fuse.OK return ch, fuse.OK
} }
func (n *loopbackNode) Readlink(ctx context.Context) (string, fuse.Status) { func (n *loopbackNode) Readlink(ctx context.Context) ([]byte, fuse.Status) {
p := n.path() p := n.path()
for l := 256; ; l *= 2 { for l := 256; ; l *= 2 {
buf := make([]byte, l) buf := make([]byte, l)
sz, err := syscall.Readlink(p, buf) sz, err := syscall.Readlink(p, buf)
if err != nil { if err != nil {
return "", fuse.ToStatus(err) return nil, fuse.ToStatus(err)
} }
if sz < len(buf) { if sz < len(buf) {
return string(buf[:sz]), fuse.OK return buf[:sz], fuse.OK
} }
} }
} }
......
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