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) newNode(name string, perm os.FileMode, modTime time.Time) (node inode, err error) {
60 return nil, ErrInvalidOperation
63 func (fs *siteFileSystem) mountCollection(parent inode, id string) inode {
65 err := fs.RequestAndDecode(&coll, "GET", "arvados/v1/collections/"+id, nil, nil)
69 cfs, err := coll.FileSystem(fs, fs)
73 root := cfs.rootnode()
74 root.SetParent(parent, id)
78 // vdirnode wraps an inode by ignoring any requests to add/replace
79 // children, and calling a create() func when a non-existing child is
82 // create() can return either a new node, which will be added to the
83 // treenode, or nil for ENOENT.
84 type vdirnode struct {
86 create func(parent inode, name string) inode
89 func (vn *vdirnode) Child(name string, _ func(inode) inode) inode {
90 return vn.inode.Child(name, func(existing inode) inode {
94 n := vn.create(vn, name)
97 vn.inode.(*treenode).fileinfo.modTime = time.Now()