mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
8b857eef9c
* Ship Stargz Snapshotter Signed-off-by: ktock <ktokunaga.mail@gmail.com> * Bump github.com/containerd/stargz-snapshotter to v0.8.0 Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
41 lines
1.0 KiB
Go
41 lines
1.0 KiB
Go
// Copyright 2019 the Go-FUSE Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package fs
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/hanwen/go-fuse/v2/fuse"
|
|
)
|
|
|
|
// Mount mounts the given NodeFS on the directory, and starts serving
|
|
// requests. This is a convenience wrapper around NewNodeFS and
|
|
// fuse.NewServer. If nil is given as options, default settings are
|
|
// applied, which are 1 second entry and attribute timeout.
|
|
func Mount(dir string, root InodeEmbedder, options *Options) (*fuse.Server, error) {
|
|
if options == nil {
|
|
oneSec := time.Second
|
|
options = &Options{
|
|
EntryTimeout: &oneSec,
|
|
AttrTimeout: &oneSec,
|
|
}
|
|
}
|
|
|
|
rawFS := NewNodeFS(root, options)
|
|
server, err := fuse.NewServer(rawFS, dir, &options.MountOptions)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
go server.Serve()
|
|
if err := server.WaitMount(); err != nil {
|
|
// we don't shutdown the serve loop. If the mount does
|
|
// not succeed, the loop won't work and exit.
|
|
return nil, err
|
|
}
|
|
|
|
return server, nil
|
|
}
|