1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: Apache-2.0
12 type siteFileSystem struct {
16 // SiteFileSystem returns a FileSystem that maps collections and other
17 // Arvados objects onto a filesystem layout.
19 // This is experimental: the filesystem layout is not stable, and
20 // there are significant known bugs and shortcomings. For example,
21 // writes are not persisted until Sync() is called.
22 func (c *Client) SiteFileSystem(kc keepClient) FileSystem {
23 fs := &siteFileSystem{
24 fileSystem: fileSystem{
25 fsBackend: keepBackend{apiClient: c, keepClient: kc},
32 mode: os.ModeDir | 0755,
35 inodes: make(map[string]inode),
38 root.Child("by_id", func(inode) inode {
44 inodes: make(map[string]inode),
48 mode: 0755 | os.ModeDir,
51 create: fs.mountCollection,
59 func (fs *siteFileSystem) newDirnode(parent inode, name string, perm os.FileMode, modTime time.Time) (node inode, err error) {
60 return nil, ErrInvalidOperation
63 func (fs *siteFileSystem) newFilenode(parent inode, name string, perm os.FileMode, modTime time.Time) (node inode, err error) {
64 return nil, ErrInvalidOperation
67 func (fs *siteFileSystem) mountCollection(parent inode, id string) inode {
69 err := fs.RequestAndDecode(&coll, "GET", "arvados/v1/collections/"+id, nil, nil)
73 cfs, err := coll.FileSystem(fs, fs)
77 root := cfs.rootnode()
78 root.SetParent(parent)
79 root.(*dirnode).fileinfo.name = id
83 // vdirnode wraps an inode by ignoring any requests to add/replace
84 // children, and calling a create() func when a non-existing child is
87 // create() can return either a new node, which will be added to the
88 // treenode, or nil for ENOENT.
89 type vdirnode struct {
91 create func(parent inode, name string) inode
94 func (vn *vdirnode) Child(name string, _ func(inode) inode) inode {
95 return vn.inode.Child(name, func(existing inode) inode {
99 n := vn.create(vn, name)