本文整理汇总了Golang中github.com/hanwen/go-fuse/fuse/nodefs.MountRoot函数的典型用法代码示例。如果您正苦于以下问题:Golang MountRoot函数的具体用法?Golang MountRoot怎么用?Golang MountRoot使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MountRoot函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestNonseekable
func TestNonseekable(t *testing.T) {
fs := &nonseekFs{FileSystem: pathfs.NewDefaultFileSystem()}
fs.Length = 200 * 1024
dir, err := ioutil.TempDir("", "go-fuse-cache_test")
if err != nil {
t.Fatalf("failed: %v", err)
}
defer os.RemoveAll(dir)
nfs := pathfs.NewPathNodeFs(fs, nil)
state, _, err := nodefs.MountRoot(dir, nfs.Root(), nil)
if err != nil {
t.Fatalf("failed: %v", err)
}
state.SetDebug(VerboseTest())
defer state.Unmount()
go state.Serve()
f, err := os.Open(dir + "/file")
if err != nil {
t.Fatalf("failed: %v", err)
}
defer f.Close()
b := make([]byte, 200)
n, err := f.ReadAt(b, 20)
if err == nil || n > 0 {
t.Errorf("file was opened nonseekable, but seek successful")
}
}
开发者ID:freakmac,项目名称:adbfs,代码行数:31,代码来源:cache_test.go
示例2: setupCacheTest
func setupCacheTest(t *testing.T) (string, *pathfs.PathNodeFs, func()) {
dir, err := ioutil.TempDir("", "go-fuse-cachetest")
if err != nil {
t.Fatalf("TempDir failed: %v", err)
}
os.Mkdir(dir+"/mnt", 0755)
os.Mkdir(dir+"/orig", 0755)
fs := &cacheFs{
pathfs.NewLoopbackFileSystem(dir + "/orig"),
}
pfs := pathfs.NewPathNodeFs(fs, nil)
state, conn, err := nodefs.MountRoot(dir+"/mnt", pfs.Root(), nil)
if err != nil {
t.Fatalf("MountNodeFileSystem failed: %v", err)
}
state.SetDebug(VerboseTest())
conn.SetDebug(VerboseTest())
pfs.SetDebug(VerboseTest())
go state.Serve()
return dir, pfs, func() {
err := state.Unmount()
if err == nil {
os.RemoveAll(dir)
}
}
}
开发者ID:freakmac,项目名称:adbfs,代码行数:28,代码来源:cache_test.go
示例3: main
func main() {
if len(os.Args) != 2 {
fmt.Println("Usage: %s <mountpath>")
os.Exit(1)
}
root := os.Args[1]
dialOpts := []grpc.DialOption{grpc.WithInsecure()}
conn, err := grpc.Dial("127.0.0.1:50000", dialOpts...)
if err != nil {
log.Fatal(err)
}
cli := pb.NewPathFSClient(conn)
fs := grpcfs.New(cli)
nfs := pathfs.NewPathNodeFs(fs, nil)
server, _, err := nodefs.MountRoot(root, nfs.Root(), nil)
if err != nil {
log.Fatal(err)
}
go server.Serve()
log.Printf("Fs mounted to root %s", root)
sigCh := make(chan os.Signal)
signal.Notify(sigCh, os.Interrupt)
for range sigCh {
server.Unmount()
os.Exit(0)
}
}
开发者ID:LK4D4,项目名称:grfuse,代码行数:28,代码来源:client.go
示例4: main
func main() {
if len(os.Args) != 2 {
fmt.Println("Usage: %s <mountpath>")
os.Exit(1)
}
root := os.Args[1]
hfs := &HelloFs{FileSystem: pathfs.NewDefaultFileSystem()}
nfs := pathfs.NewPathNodeFs(hfs, nil)
fuseSrv, _, err := nodefs.MountRoot(root, nfs.Root(), nil)
if err != nil {
log.Fatal(err)
}
go fuseSrv.Serve()
l, err := net.Listen("tcp", "127.0.0.1:50000")
if err != nil {
log.Fatal(err)
}
s := grpc.NewServer()
pb.RegisterPathFSServer(s, server.New(hfs))
go s.Serve(l)
log.Printf("Listen on %s for dir %s", l.Addr(), root)
sigCh := make(chan os.Signal)
signal.Notify(sigCh, os.Interrupt)
for range sigCh {
fuseSrv.Unmount()
s.Stop()
os.Exit(0)
}
}
开发者ID:LK4D4,项目名称:grfuse,代码行数:31,代码来源:server.go
示例5: New
func New(config *conf.Fuse, logger log_driver.Logger) (*GitFs, error) {
gitfsDir, err := gitfsDir(logger)
if err != nil {
return nil, err
}
defaultfs := pathfs.NewDefaultFileSystem()
gitfs := &GitFs{FileSystem: pathfs.NewReadonlyFileSystem(defaultfs), GitRepoDir: config.GitRepoDir, GitFsDir: gitfsDir, logger: logger}
fs := pathfs.NewPathNodeFs(gitfs, nil)
server, _, err := nodefs.MountRoot(gitfsDir, fs.Root(), nil)
if err != nil {
logger.Errorf("Failed to mount GitFS on %s due to %s", gitfsDir, err)
return nil, err
}
logger.Debugf("Mount GitFs on %s", gitfsDir)
gitfs.server = server
server.SetDebug(config.Debug)
gitfs.cache, err = cache.New(1024)
if err != nil {
logger.Errorf("Failed to initialize object cache due to %s\n", err)
return nil, err
}
return gitfs, nil
}
开发者ID:bachue,项目名称:pages,代码行数:26,代码来源:gitfuse.go
示例6: TestLiveness
func TestLiveness(t *testing.T) {
dir := testutil.TempDir()
defer os.RemoveAll(dir)
root := nodefs.NewDefaultNode()
s, _, err := nodefs.MountRoot(dir, root, nil)
if err != nil {
t.Fatalf("MountRoot: %v", err)
}
go s.Serve()
if err := s.WaitMount(); err != nil {
t.Fatal("WaitMount", err)
}
defer s.Unmount()
if _, err := ioutil.ReadDir(dir); err != nil {
t.Fatalf("ReadDir: %v", err)
}
// We previously encountered a sitation where a finalizer would close our fd out from under us. Try to force both finalizers to run and object destruction to complete.
runtime.GC()
runtime.GC()
if _, err := ioutil.ReadDir(dir); err != nil {
t.Fatalf("ReadDir: %v", err)
}
}
开发者ID:jszwedko,项目名称:ec2-metadatafs,代码行数:26,代码来源:mount_test.go
示例7: setupFs
func setupFs(fs pathfs.FileSystem) (string, func()) {
opts := &nodefs.Options{
EntryTimeout: 0.0,
AttrTimeout: 0.0,
NegativeTimeout: 0.0,
}
mountPoint, _ := ioutil.TempDir("", "stat_test")
nfs := pathfs.NewPathNodeFs(fs, nil)
state, _, err := nodefs.MountRoot(mountPoint, nfs.Root(), opts)
if err != nil {
panic(fmt.Sprintf("cannot mount %v", err)) // ugh - benchmark has no error methods.
}
lmap := NewLatencyMap()
state.RecordLatencies(lmap)
// state.SetDebug(true)
go state.Serve()
return mountPoint, func() {
lc, lns := lmap.Get("LOOKUP")
gc, gns := lmap.Get("GETATTR")
fmt.Printf("GETATTR %v/call n=%d, LOOKUP %v/call n=%d\n",
gns/time.Duration(gc), gc,
lns/time.Duration(lc), lc)
err := state.Unmount()
if err != nil {
log.Println("error during unmount", err)
} else {
os.RemoveAll(mountPoint)
}
}
}
开发者ID:carriercomm,项目名称:go-fuse,代码行数:33,代码来源:stat_test.go
示例8: Create
func (d *etcDriver) Create(rq dkvolume.Request) dkvolume.Response {
var res dkvolume.Response
if !strings.HasPrefix(rq.Name, "@") {
return responseErrorString("a etcd path has to start with a @")
}
d.mux.Lock()
defer d.mux.Unlock()
_, ok := d.mountpoints[rq.Name]
if ok {
return res
}
pt := d.createPath(rq.Name)
if err := os.MkdirAll(pt, 0755); err != nil {
return responseError(fmt.Errorf("cannot mkdir: %s", err))
}
rootfs := "/" + d.asEtcdRoot(rq.Name)
root := pathfs.NewPrefixFileSystem(&d.etcdbackend, rootfs)
nfs := pathfs.NewPathNodeFs(root, nil)
server, _, err := nodefs.MountRoot(pt, nfs.Root(), nil)
if err != nil {
return responseError(fmt.Errorf("cannot mount root : %s", err))
}
es := etcdFuseServer{pt, server, 0}
d.mountpoints[rq.Name] = &es
go server.Serve()
return res
}
开发者ID:ulrichSchreiner,项目名称:etcdriver,代码行数:31,代码来源:driver.go
示例9: TestDefaultNodeMount
func TestDefaultNodeMount(t *testing.T) {
dir, err := ioutil.TempDir("", "go-fuse")
if err != nil {
t.Fatalf("TempDir: %v", err)
}
defer os.RemoveAll(dir)
root := nodefs.NewDefaultNode()
s, conn, err := nodefs.MountRoot(dir, root, nil)
if err != nil {
t.Fatalf("MountRoot: %v", err)
}
go s.Serve()
defer s.Unmount()
if err := conn.Mount(root.Inode(), "sub", nodefs.NewDefaultNode(), nil); !err.Ok() {
t.Fatalf("Mount: %v", err)
}
if entries, err := ioutil.ReadDir(dir); err != nil {
t.Fatalf("ReadDir: %v", err)
} else if len(entries) != 1 {
t.Fatalf("got %d entries", len(entries))
} else if entries[0].Name() != "sub" {
t.Fatalf("got %q, want %q", entries[0].Name(), "sub")
}
}
开发者ID:yeonsh,项目名称:go-fuse,代码行数:26,代码来源:mount_test.go
示例10: NewNotifyTest
func NewNotifyTest(t *testing.T) *NotifyTest {
me := &NotifyTest{}
me.fs = newNotifyFs()
var err error
me.dir, err = ioutil.TempDir("", "go-fuse-notify_test")
if err != nil {
t.Fatalf("TempDir failed: %v", err)
}
entryTtl := 100 * time.Millisecond
opts := &nodefs.Options{
EntryTimeout: entryTtl,
AttrTimeout: entryTtl,
NegativeTimeout: entryTtl,
Debug: VerboseTest(),
}
me.pathfs = pathfs.NewPathNodeFs(me.fs, nil)
me.state, me.connector, err = nodefs.MountRoot(me.dir, me.pathfs.Root(), opts)
if err != nil {
t.Fatalf("MountNodeFileSystem failed: %v", err)
}
go me.state.Serve()
if err := me.state.WaitMount(); err != nil {
t.Fatal("WaitMount", err)
}
return me
}
开发者ID:Richardphp,项目名称:noms,代码行数:28,代码来源:notify_linux_test.go
示例11: TestDefaultXAttr
func TestDefaultXAttr(t *testing.T) {
dir := testutil.TempDir()
defer os.RemoveAll(dir)
root := &xattrNode{
Node: nodefs.NewDefaultNode(),
}
opts := nodefs.NewOptions()
opts.Debug = testutil.VerboseTest()
s, _, err := nodefs.MountRoot(dir, root, opts)
if err != nil {
t.Fatalf("MountRoot: %v", err)
}
go s.Serve()
if err := s.WaitMount(); err != nil {
t.Fatal("WaitMount", err)
}
defer s.Unmount()
var data [1024]byte
sz, err := syscall.Getxattr(filepath.Join(dir, "child"), "attr", data[:])
if err != nil {
t.Fatalf("Getxattr: %v", err)
} else if val := string(data[:sz]); val != "value" {
t.Fatalf("got %v, want 'value'", val)
}
}
开发者ID:jszwedko,项目名称:ec2-metadatafs,代码行数:29,代码来源:xattr_test.go
示例12: setup
func setup(t *testing.T) (workdir string, cleanup func()) {
wd, _ := ioutil.TempDir("", "")
err := os.Mkdir(wd+"/mnt", 0700)
if err != nil {
t.Fatalf("Mkdir failed: %v", err)
}
err = os.Mkdir(wd+"/store", 0700)
if err != nil {
t.Fatalf("Mkdir failed: %v", err)
}
os.Mkdir(wd+"/ro", 0700)
if err != nil {
t.Fatalf("Mkdir failed: %v", err)
}
WriteFile(t, wd+"/ro/file1", "file1")
WriteFile(t, wd+"/ro/file2", "file2")
fs := NewAutoUnionFs(wd+"/store", testAOpts)
nfs := pathfs.NewPathNodeFs(fs, nil)
state, _, err := nodefs.MountRoot(wd+"/mnt", nfs.Root(), &testAOpts.Options)
if err != nil {
t.Fatalf("MountNodeFileSystem failed: %v", err)
}
fs.SetDebug(VerboseTest())
go state.Serve()
return wd, func() {
state.Unmount()
os.RemoveAll(wd)
}
}
开发者ID:eliq,项目名称:go-fuse,代码行数:34,代码来源:autounion_test.go
示例13: defaultReadTest
func defaultReadTest(t *testing.T) (root string, cleanup func()) {
fs := &DefaultReadFS{
FileSystem: pathfs.NewDefaultFileSystem(),
size: 22,
}
var err error
dir, err := ioutil.TempDir("", "go-fuse")
if err != nil {
t.Fatalf("TempDir failed: %v", err)
}
pathfs := pathfs.NewPathNodeFs(fs, nil)
opts := nodefs.NewOptions()
opts.Debug = VerboseTest()
state, _, err := nodefs.MountRoot(dir, pathfs.Root(), opts)
if err != nil {
t.Fatalf("MountNodeFileSystem failed: %v", err)
}
go state.Serve()
if err := state.WaitMount(); err != nil {
t.Fatal("WaitMount", err)
}
return dir, func() {
state.Unmount()
os.Remove(dir)
}
}
开发者ID:Richardphp,项目名称:noms,代码行数:28,代码来源:defaultread_test.go
示例14: setupMulti
func setupMulti() (*testCase, error) {
dir, err := ioutil.TempDir("", "fs_test")
if err != nil {
return nil, err
}
repo, err := setupRepo(filepath.Join(dir, "repo"))
if err != nil {
return nil, err
}
root := NewMultiGitFSRoot(nil)
if err != nil {
return nil, err
}
mnt := filepath.Join(dir, "mnt")
if err := os.Mkdir(mnt, 0755); err != nil {
return nil, err
}
server, _, err := nodefs.MountRoot(mnt, root, nil)
go server.Serve()
if err != nil {
return nil, err
}
return &testCase{
repo,
server,
mnt,
}, nil
}
开发者ID:hanwen,项目名称:gitfs,代码行数:33,代码来源:fs_test.go
示例15: setupBasic
func setupBasic(opts *GitFSOptions) (*testCase, error) {
dir, err := ioutil.TempDir("", "fs_test")
if err != nil {
return nil, err
}
repo, err := setupRepo(filepath.Join(dir, "repo"))
if err != nil {
return nil, err
}
root, err := NewTreeFSRoot(repo, "refs/heads/master", nil)
if err != nil {
return nil, err
}
mnt := filepath.Join(dir, "mnt")
if err := os.Mkdir(mnt, 0755); err != nil {
return nil, err
}
server, _, err := nodefs.MountRoot(mnt, root, nil)
server.SetDebug(true)
go server.Serve()
if err != nil {
return nil, err
}
return &testCase{
repo,
server,
mnt,
}, nil
}
开发者ID:hanwen,项目名称:gitfs,代码行数:34,代码来源:fs_test.go
示例16: TestNonseekable
func TestNonseekable(t *testing.T) {
fs := &nonseekFs{FileSystem: pathfs.NewDefaultFileSystem()}
fs.Length = 200 * 1024
dir := testutil.TempDir()
defer os.RemoveAll(dir)
nfs := pathfs.NewPathNodeFs(fs, nil)
opts := nodefs.NewOptions()
opts.Debug = testutil.VerboseTest()
state, _, err := nodefs.MountRoot(dir, nfs.Root(), opts)
if err != nil {
t.Fatalf("failed: %v", err)
}
defer state.Unmount()
go state.Serve()
if err := state.WaitMount(); err != nil {
t.Fatal("WaitMount", err)
}
f, err := os.Open(dir + "/file")
if err != nil {
t.Fatalf("failed: %v", err)
}
defer f.Close()
b := make([]byte, 200)
n, err := f.ReadAt(b, 20)
if err == nil || n > 0 {
t.Errorf("file was opened nonseekable, but seek successful")
}
}
开发者ID:jszwedko,项目名称:ec2-metadatafs,代码行数:32,代码来源:cache_test.go
示例17: setupCacheTest
func setupCacheTest(t *testing.T) (string, *pathfs.PathNodeFs, func()) {
dir := testutil.TempDir()
os.Mkdir(dir+"/mnt", 0755)
os.Mkdir(dir+"/orig", 0755)
fs := &cacheFs{
pathfs.NewLoopbackFileSystem(dir + "/orig"),
}
pfs := pathfs.NewPathNodeFs(fs, &pathfs.PathNodeFsOptions{Debug: testutil.VerboseTest()})
opts := nodefs.NewOptions()
opts.Debug = testutil.VerboseTest()
state, _, err := nodefs.MountRoot(dir+"/mnt", pfs.Root(), opts)
if err != nil {
t.Fatalf("MountNodeFileSystem failed: %v", err)
}
go state.Serve()
if err := state.WaitMount(); err != nil {
t.Fatal("WaitMount", err)
}
return dir, pfs, func() {
err := state.Unmount()
if err == nil {
os.RemoveAll(dir)
}
}
}
开发者ID:jszwedko,项目名称:ec2-metadatafs,代码行数:27,代码来源:cache_test.go
示例18: setupFAttrTest
func setupFAttrTest(t *testing.T, fs pathfs.FileSystem) (dir string, clean func()) {
dir, err := ioutil.TempDir("", "go-fuse-fsetattr_test")
if err != nil {
t.Fatalf("TempDir failed: %v", err)
}
nfs := pathfs.NewPathNodeFs(fs, nil)
opts := nodefs.NewOptions()
opts.Debug = VerboseTest()
state, _, err := nodefs.MountRoot(dir, nfs.Root(), opts)
if err != nil {
t.Fatalf("MountNodeFileSystem failed: %v", err)
}
go state.Serve()
if err := state.WaitMount(); err != nil {
t.Fatal("WaitMount", err)
}
if state.KernelSettings().Flags&fuse.CAP_FILE_OPS == 0 {
t.Skip("Mount does not support file operations")
}
return dir, func() {
if err := state.Unmount(); err != nil {
t.Errorf("cleanup: Unmount: %v", err)
} else {
os.RemoveAll(dir)
}
}
}
开发者ID:Richardphp,项目名称:noms,代码行数:31,代码来源:fsetattr_test.go
示例19: setupFAttrTest
func setupFAttrTest(t *testing.T, fs pathfs.FileSystem) (dir string, clean func()) {
dir, err := ioutil.TempDir("", "go-fuse-fsetattr_test")
if err != nil {
t.Fatalf("TempDir failed: %v", err)
}
nfs := pathfs.NewPathNodeFs(fs, nil)
state, _, err := nodefs.MountRoot(dir, nfs.Root(), nil)
if err != nil {
t.Fatalf("MountNodeFileSystem failed: %v", err)
}
state.SetDebug(VerboseTest())
go state.Serve()
// Trigger INIT.
os.Lstat(dir)
if state.KernelSettings().Flags&fuse.CAP_FILE_OPS == 0 {
t.Log("Mount does not support file operations")
}
return dir, func() {
if state.Unmount() == nil {
os.RemoveAll(dir)
}
}
}
开发者ID:yeonsh,项目名称:go-fuse,代码行数:26,代码来源:fsetattr_test.go
示例20: TestOriginalIsSymlink
func TestOriginalIsSymlink(t *testing.T) {
tmpDir := testutil.TempDir()
defer os.RemoveAll(tmpDir)
orig := tmpDir + "/orig"
err := os.Mkdir(orig, 0755)
if err != nil {
t.Fatalf("Mkdir failed: %v", err)
}
link := tmpDir + "/link"
mnt := tmpDir + "/mnt"
if err := os.Mkdir(mnt, 0755); err != nil {
t.Fatalf("Mkdir failed: %v", err)
}
if err := os.Symlink("orig", link); err != nil {
t.Fatalf("Symlink failed: %v", err)
}
fs := pathfs.NewLoopbackFileSystem(link)
nfs := pathfs.NewPathNodeFs(fs, nil)
state, _, err := nodefs.MountRoot(mnt, nfs.Root(), nil)
if err != nil {
t.Fatalf("MountNodeFileSystem failed: %v", err)
}
defer state.Unmount()
go state.Serve()
if err := state.WaitMount(); err != nil {
t.Fatal("WaitMount", err)
}
if _, err := os.Lstat(mnt); err != nil {
t.Fatalf("Lstat failed: %v", err)
}
}
开发者ID:rfjakob,项目名称:go-fuse,代码行数:34,代码来源:loopback_test.go
注:本文中的github.com/hanwen/go-fuse/fuse/nodefs.MountRoot函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论