本文整理汇总了Golang中github.com/hanwen/go-fuse/fuse/pathfs.NewPathNodeFs函数的典型用法代码示例。如果您正苦于以下问题:Golang NewPathNodeFs函数的具体用法?Golang NewPathNodeFs怎么用?Golang NewPathNodeFs使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewPathNodeFs函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: 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
示例2: 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
示例3: 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
示例4: 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
示例5: 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
示例6: 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
示例7: 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
示例8: Start
// Start takes a path to the directory where the goinfo file system
// should be mounted. If the directory does not exist, it will be
// created. Start will return an error if the directory cannot be
// created or if the file system cannot be mounted at this location
// for any reason.
func Start(mountpoint string) error {
//already mounted there
if _, found := servers[mountpoint]; found {
return nil
}
if _, err := os.Stat(mountpoint); os.IsNotExist(err) {
if err = os.Mkdir(mountpoint, 0755); err != nil {
return err
}
}
nfs := pathfs.NewPathNodeFs(gfs, nil)
conn := nodefs.NewFileSystemConnector(nfs.Root(), nil)
server, err := fuse.NewServer(conn.RawFS(), mountpoint, &fuse.MountOptions{AllowOther: true})
if err != nil {
return errors.New("Failed to mount monitoring fs at " + mountpoint + ": " + err.Error())
}
servers[mountpoint] = server
//start handling the fs calls
go server.Serve()
return nil
}
开发者ID:jmptrader,项目名称:goinfo,代码行数:31,代码来源:info.go
示例9: 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
示例10: 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
示例11: 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
示例12: 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
示例13: 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
示例14: 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
示例15: 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
示例16: 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
示例17: pathfsFrontend
func pathfsFrontend(key []byte, cipherdir string, mountpoint string, debug bool, openssl bool) *fuse.Server {
finalFs := pathfs_frontend.NewFS(key, cipherdir, openssl)
pathFsOpts := &pathfs.PathNodeFsOptions{ClientInodes: true}
pathFs := pathfs.NewPathNodeFs(finalFs, pathFsOpts)
fuseOpts := &nodefs.Options{
// These options are to be compatible with libfuse defaults,
// making benchmarking easier.
NegativeTimeout: time.Second,
AttrTimeout: time.Second,
EntryTimeout: time.Second,
}
conn := nodefs.NewFileSystemConnector(pathFs.Root(), fuseOpts)
var mOpts fuse.MountOptions
mOpts.AllowOther = false
// Set values shown in "df -T" and friends
// First column, "Filesystem"
mOpts.Options = append(mOpts.Options, "fsname="+cipherdir)
// Second column, "Type", will be shown as "fuse." + Name
mOpts.Name = "gocryptfs"
srv, err := fuse.NewServer(conn.RawFS(), mountpoint, &mOpts)
if err != nil {
fmt.Printf("Mount failed: %v", err)
os.Exit(ERREXIT_MOUNT)
}
srv.SetDebug(debug)
return srv
}
开发者ID:theit8514,项目名称:gocryptfs,代码行数:30,代码来源:main.go
示例18: newFuseFS
func newFuseFS(tmpDir string, rpcFS *RpcFs, writableRoot string) (*fuseFS, error) {
tmpDir, err := ioutil.TempDir(tmpDir, "termite-task")
if err != nil {
return nil, err
}
fs := &fuseFS{
writableRoot: strings.TrimLeft(writableRoot, "/"),
workers: map[string]*workerFS{},
rpcFS: rpcFS,
rpcNodeFS: pathfs.NewPathNodeFs(&multiRPCFS{rpcFS},
&pathfs.PathNodeFsOptions{ClientInodes: true}),
tmpDir: tmpDir,
mount: filepath.Join(tmpDir, "mnt"),
}
if err := os.Mkdir(fs.mount, 0755); err != nil {
return nil, err
}
fs.fsConnector = nodefs.NewFileSystemConnector(fs.rpcNodeFS.Root(),
nodeFSOptions())
fuseOpts := fuse.MountOptions{}
if os.Geteuid() == 0 {
fuseOpts.AllowOther = true
}
fs.server, err = fuse.NewServer(fs.fsConnector.RawFS(), fs.mount, &fuseOpts)
if err != nil {
return nil, err
}
go fs.server.Serve()
return fs, nil
}
开发者ID:hanwen,项目名称:termite,代码行数:33,代码来源:fuse.go
示例19: mount
func mount() error {
var err error
if fs != nil || server != nil {
// already mounting
return nil
}
// create mountpoint
os.Mkdir(TEST_MOUNTPOINT, 0777)
// config
config := &config.Config{
MountPoint: TEST_MOUNTPOINT,
ContainerName: TEST_CONTAINER_NAME,
CreateContainer: true,
Debug: true,
NoDaemon: true,
}
// swift
swift := openstack.NewSwift(config)
if err = swift.Auth(); err != nil {
return err
}
swift.DeleteContainer()
// mapper
mapper, err := mapper.NewObjectMapper(config)
if err != nil {
return err
}
// initialize filesystem
fs = NewObjectFileSystem(config, mapper)
path := pathfs.NewPathNodeFs(fs, nil)
con := nodefs.NewFileSystemConnector(path.Root(), &nodefs.Options{})
opts := &fuse.MountOptions{
Name: "test-filesystem",
FsName: "test-filesystem",
}
// create server and do mount with dedicated goroutine
server, err = fuse.NewServer(con.RawFS(), TEST_MOUNTPOINT, opts)
if err != nil {
return err
}
go func() {
server.Serve()
}()
server.WaitMount()
return nil
}
开发者ID:hironobu-s,项目名称:swiftfs,代码行数:58,代码来源:filesystem_test.go
示例20: setupUfs
// Creates a temporary dir "wd" with 3 directories:
// mnt ... overlayed (unionfs) mount
// rw .... modifiable data
// ro .... read-only data
func setupUfs(t *testing.T) (wd string, cleanup func()) {
// Make sure system setting does not affect test.
syscall.Umask(0)
wd = testutil.TempDir()
err := os.Mkdir(wd+"/mnt", 0700)
if err != nil {
t.Fatalf("Mkdir failed: %v", err)
}
err = os.Mkdir(wd+"/rw", 0700)
if err != nil {
t.Fatalf("Mkdir failed: %v", err)
}
os.Mkdir(wd+"/ro", 0700)
if err != nil {
t.Fatalf("Mkdir failed: %v", err)
}
var fses []pathfs.FileSystem
fses = append(fses, pathfs.NewLoopbackFileSystem(wd+"/rw"))
fses = append(fses,
NewCachingFileSystem(pathfs.NewLoopbackFileSystem(wd+"/ro"), 0))
ufs, err := NewUnionFs(fses, testOpts)
if err != nil {
t.Fatalf("NewUnionFs: %v", err)
}
// We configure timeouts are smaller, so we can check for
// UnionFs's cache consistency.
opts := &nodefs.Options{
EntryTimeout: entryTtl / 2,
AttrTimeout: entryTtl / 2,
NegativeTimeout: entryTtl / 2,
PortableInodes: true,
Debug: testutil.VerboseTest(),
}
pathfs := pathfs.NewPathNodeFs(ufs,
&pathfs.PathNodeFsOptions{ClientInodes: true,
Debug: opts.Debug,
})
state, _, err := nodefs.MountRoot(wd+"/mnt", pathfs.Root(), opts)
if err != nil {
t.Fatalf("MountNodeFileSystem failed: %v", err)
}
go state.Serve()
state.WaitMount()
return wd, func() {
err := state.Unmount()
if err != nil {
return
}
setRecursiveWritable(t, wd, true)
os.RemoveAll(wd)
}
}
开发者ID:rfjakob,项目名称:go-fuse,代码行数:62,代码来源:unionfs_test.go
注:本文中的github.com/hanwen/go-fuse/fuse/pathfs.NewPathNodeFs函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论