1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: Apache-2.0
13 // A getternode is a read-only character device that returns whatever
14 // data is returned by the supplied function.
15 type getternode struct {
16 Getter func() ([]byte, error)
22 func (*getternode) IsDir() bool {
26 func (*getternode) Child(string, func(inode) (inode, error)) (inode, error) {
27 return nil, ErrInvalidOperation
30 func (gn *getternode) get() error {
34 data, err := gn.Getter()
38 gn.data = bytes.NewReader(data)
42 func (gn *getternode) Size() int64 {
43 return gn.FileInfo().Size()
46 func (gn *getternode) FileInfo() os.FileInfo {
60 func (gn *getternode) Read(p []byte, ptr filenodePtr) (int, filenodePtr, error) {
61 if err := gn.get(); err != nil {
64 n, err := gn.data.ReadAt(p, ptr.off)
65 return n, filenodePtr{off: ptr.off + int64(n)}, err