本文整理匯總了Golang中github.com/hanwen/go-fuse/fuse.MountNodeFileSystem函數的典型用法代碼示例。如果您正苦於以下問題:Golang MountNodeFileSystem函數的具體用法?Golang MountNodeFileSystem怎麽用?Golang MountNodeFileSystem使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了MountNodeFileSystem函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: setup
func setup(t *testing.T) (workdir string, cleanup func()) {
wd, _ := ioutil.TempDir("", "")
err := os.Mkdir(wd+"/mnt", 0700)
fuse.CheckSuccess(err)
err = os.Mkdir(wd+"/store", 0700)
fuse.CheckSuccess(err)
os.Mkdir(wd+"/ro", 0700)
fuse.CheckSuccess(err)
WriteFile(wd+"/ro/file1", "file1")
WriteFile(wd+"/ro/file2", "file2")
fs := NewAutoUnionFs(wd+"/store", testAOpts)
nfs := fuse.NewPathNodeFs(fs, nil)
state, conn, err := fuse.MountNodeFileSystem(wd+"/mnt", nfs, &testAOpts.FileSystemOptions)
CheckSuccess(err)
state.Debug = fuse.VerboseTest()
conn.Debug = fuse.VerboseTest()
go state.Loop()
return wd, func() {
state.Unmount()
os.RemoveAll(wd)
}
}
示例2: setupFs
func setupFs(fs fuse.FileSystem) (string, func()) {
opts := &fuse.FileSystemOptions{
EntryTimeout: 0.0,
AttrTimeout: 0.0,
NegativeTimeout: 0.0,
}
mountPoint, _ := ioutil.TempDir("", "stat_test")
nfs := fuse.NewPathNodeFs(fs, nil)
state, _, err := fuse.MountNodeFileSystem(mountPoint, nfs, opts)
if err != nil {
panic(fmt.Sprintf("cannot mount %v", err)) // ugh - benchmark has no error methods.
}
state.SetRecordStatistics(true)
// state.Debug = true
go state.Loop()
return mountPoint, func() {
lc, lns := state.Latencies().Get("LOOKUP")
gc, gns := state.Latencies().Get("GETATTR")
fmt.Printf("GETATTR %dus/call n=%d, LOOKUP %dus/call n=%d\n",
gns/int64(1000*lc), gc,
lns/int64(1000*lc), lc)
err := state.Unmount()
if err != nil {
log.Println("error during unmount", err)
} else {
os.RemoveAll(mountPoint)
}
}
}
示例3: main
func main() {
// Scans the arg list and sets up flags
debug := flag.Bool("debug", false, "print debugging messages.")
latencies := flag.Bool("latencies", false, "record operation latencies.")
flag.Parse()
if flag.NArg() < 2 {
fmt.Fprintf(os.Stderr, "usage: %s MOUNTPOINT ZIP-FILE\n", os.Args[0])
os.Exit(2)
}
var fs fuse.NodeFileSystem
fs, err := zipfs.NewArchiveFileSystem(flag.Arg(1))
if err != nil {
fmt.Fprintf(os.Stderr, "NewArchiveFileSystem failed: %v\n", err)
os.Exit(1)
}
state, _, err := fuse.MountNodeFileSystem(flag.Arg(0), fs, nil)
if err != nil {
fmt.Printf("Mount fail: %v\n", err)
os.Exit(1)
}
state.SetRecordStatistics(*latencies)
state.Debug = *debug
state.Loop()
}
示例4: main
func main() {
version := flag.Bool("version", false, "print version number")
debug := flag.Bool("debug", false, "debug on")
hardlinks := flag.Bool("hardlinks", false, "support hardlinks")
delcache_ttl := flag.Float64("deletion_cache_ttl", 5.0, "Deletion cache TTL in seconds.")
branchcache_ttl := flag.Float64("branchcache_ttl", 5.0, "Branch cache TTL in seconds.")
deldirname := flag.String(
"deletion_dirname", "GOUNIONFS_DELETIONS", "Directory name to use for deletions.")
flag.Parse()
if *version {
fmt.Println(fuse.Version())
os.Exit(0)
}
if len(flag.Args()) < 2 {
fmt.Println("Usage:\n main MOUNTPOINT BASEDIR")
os.Exit(2)
}
ufsOptions := unionfs.UnionFsOptions{
DeletionCacheTTL: time.Duration(*delcache_ttl * float64(time.Second)),
BranchCacheTTL: time.Duration(*branchcache_ttl * float64(time.Second)),
DeletionDirName: *deldirname,
}
options := unionfs.AutoUnionFsOptions{
UnionFsOptions: ufsOptions,
FileSystemOptions: fuse.FileSystemOptions{
EntryTimeout: time.Second,
AttrTimeout: time.Second,
NegativeTimeout: time.Second,
Owner: fuse.CurrentOwner(),
},
UpdateOnMount: true,
PathNodeFsOptions: fuse.PathNodeFsOptions{
ClientInodes: *hardlinks,
},
}
fmt.Printf("AutoUnionFs - Go-FUSE Version %v.\n", fuse.Version())
gofs := unionfs.NewAutoUnionFs(flag.Arg(1), options)
pathfs := fuse.NewPathNodeFs(gofs, nil)
state, conn, err := fuse.MountNodeFileSystem(flag.Arg(0), pathfs, nil)
if err != nil {
fmt.Printf("Mount fail: %v\n", err)
os.Exit(1)
}
pathfs.Debug = *debug
conn.Debug = *debug
state.Debug = *debug
gofs.SetMountState(state)
state.Loop()
}
示例5: newRpcFsTestCase
func newRpcFsTestCase(t *testing.T) (me *rpcFsTestCase) {
me = &rpcFsTestCase{tester: t}
me.tmp, _ = ioutil.TempDir("", "term-fss")
me.mnt = me.tmp + "/mnt"
me.orig = me.tmp + "/orig"
srvCache := me.tmp + "/server-cache"
os.Mkdir(me.mnt, 0700)
os.Mkdir(me.orig, 0700)
copts := cba.StoreOptions{
Dir: srvCache,
}
me.serverStore = cba.NewStore(&copts)
me.attr = attr.NewAttributeCache(
func(n string) *attr.FileAttr { return me.getattr(n) },
func(n string) *fuse.Attr {
return StatForTest(t, filepath.Join(me.orig, n))
})
me.attr.Paranoia = true
me.server = NewFsServer(me.attr, me.serverStore)
var err error
me.sockL, me.sockR, err = unixSocketpair()
if err != nil {
t.Fatal(err)
}
me.contentL, me.contentR, err = unixSocketpair()
if err != nil {
t.Fatal(err)
}
rpcServer := rpc.NewServer()
rpcServer.Register(me.server)
go rpcServer.ServeConn(me.sockL)
go me.serverStore.ServeConn(me.contentL)
rpcClient := rpc.NewClient(me.sockR)
cOpts := cba.StoreOptions{
Dir: me.tmp + "/client-cache",
}
me.clientStore = cba.NewStore(&cOpts)
me.rpcFs = NewRpcFs(rpcClient, me.clientStore, me.contentR)
me.rpcFs.id = "rpcfs_test"
nfs := fuse.NewPathNodeFs(me.rpcFs, nil)
me.state, _, err = fuse.MountNodeFileSystem(me.mnt, nfs, nil)
me.state.Debug = fuse.VerboseTest()
if err != nil {
t.Fatal("Mount", err)
}
go me.state.Loop()
return me
}
示例6: main
func main() {
flag.Parse()
if len(flag.Args()) < 1 {
log.Fatal("Usage:\n hello MOUNTPOINT")
}
nfs := fuse.NewPathNodeFs(&HelloFs{}, nil)
state, _, err := fuse.MountNodeFileSystem(flag.Arg(0), nfs, nil)
if err != nil {
log.Fatal("Mount fail: %v\n", err)
}
state.Loop()
}
示例7: setupUfs
// Creates 3 directories on a temporary dir: /mnt with the overlayed
// (unionfs) mount, rw with modifiable data, and ro on the bottom.
func setupUfs(t *testing.T) (workdir string, cleanup func()) {
// Make sure system setting does not affect test.
syscall.Umask(0)
wd, _ := ioutil.TempDir("", "unionfs")
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 []fuse.FileSystem
fses = append(fses, fuse.NewLoopbackFileSystem(wd+"/rw"))
fses = append(fses,
NewCachingFileSystem(fuse.NewLoopbackFileSystem(wd+"/ro"), 0))
ufs := NewUnionFs(fses, testOpts)
// We configure timeouts are smaller, so we can check for
// UnionFs's cache consistency.
opts := &fuse.FileSystemOptions{
EntryTimeout: entryTtl / 2,
AttrTimeout: entryTtl / 2,
NegativeTimeout: entryTtl / 2,
}
pathfs := fuse.NewPathNodeFs(ufs,
&fuse.PathNodeFsOptions{ClientInodes: true})
state, conn, err := fuse.MountNodeFileSystem(wd+"/mnt", pathfs, opts)
if err != nil {
t.Fatalf("MountNodeFileSystem failed: %v", err)
}
conn.Debug = fuse.VerboseTest()
state.Debug = fuse.VerboseTest()
go state.Loop()
return wd, func() {
err := state.Unmount()
if err != nil {
return
}
setRecursiveWritable(t, wd, true)
os.RemoveAll(wd)
}
}
示例8: setupZipfs
func setupZipfs() (mountPoint string, cleanup func()) {
zfs, err := NewArchiveFileSystem(testZipFile())
CheckSuccess(err)
mountPoint, _ = ioutil.TempDir("", "")
state, _, err := fuse.MountNodeFileSystem(mountPoint, zfs, nil)
state.Debug = true
go state.Loop()
return mountPoint, func() {
state.Unmount()
os.RemoveAll(mountPoint)
}
}
示例9: setupDevNullFs
func setupDevNullFs() (wd string, clean func()) {
fs := NewDevNullFs()
mountPoint, _ := ioutil.TempDir("", "termite")
state, _, err := fuse.MountNodeFileSystem(mountPoint, fs, nil)
if err != nil {
panic(err)
}
state.Debug = fuse.VerboseTest()
go state.Loop()
return mountPoint, func() {
state.Unmount()
os.RemoveAll(mountPoint)
}
}
示例10: main
func main() {
version := flag.Bool("version", false, "print version number")
debug := flag.Bool("debug", false, "debug on")
threaded := flag.Bool("threaded", true, "threading on")
delcache_ttl := flag.Float64("deletion_cache_ttl", 5.0, "Deletion cache TTL in seconds.")
branchcache_ttl := flag.Float64("branchcache_ttl", 5.0, "Branch cache TTL in seconds.")
deldirname := flag.String(
"deletion_dirname", "GOUNIONFS_DELETIONS", "Directory name to use for deletions.")
flag.Parse()
if *version {
fmt.Println(fuse.Version())
os.Exit(0)
}
if len(flag.Args()) < 2 {
fmt.Println("Usage:\n main MOUNTPOINT BASEDIR")
os.Exit(2)
}
ufsOptions := unionfs.UnionFsOptions{
DeletionCacheTTLSecs: *delcache_ttl,
BranchCacheTTLSecs: *branchcache_ttl,
DeletionDirName: *deldirname,
}
options := unionfs.AutoUnionFsOptions{
UnionFsOptions: ufsOptions,
FileSystemOptions: fuse.FileSystemOptions{
EntryTimeout: 1.0,
AttrTimeout: 1.0,
NegativeTimeout: 1.0,
Owner: fuse.CurrentOwner(),
},
UpdateOnMount: true,
}
gofs := unionfs.NewAutoUnionFs(flag.Arg(1), options)
pathfs := fuse.NewPathNodeFs(gofs)
state, conn, err := fuse.MountNodeFileSystem(flag.Arg(0), pathfs, nil)
if err != nil {
fmt.Printf("Mount fail: %v\n", err)
os.Exit(1)
}
pathfs.Debug = *debug
conn.Debug = *debug
state.Debug = *debug
state.Loop(*threaded)
}
示例11: setupZipfs
func setupZipfs(t *testing.T) (mountPoint string, cleanup func()) {
zfs, err := NewArchiveFileSystem(testZipFile())
if err != nil {
t.Fatalf("NewArchiveFileSystem failed: %v", err)
}
mountPoint, _ = ioutil.TempDir("", "")
state, _, err := fuse.MountNodeFileSystem(mountPoint, zfs, nil)
state.Debug = fuse.VerboseTest()
go state.Loop()
return mountPoint, func() {
state.Unmount()
os.RemoveAll(mountPoint)
}
}
示例12: setupMzfs
func setupMzfs() (mountPoint string, cleanup func()) {
fs := NewMultiZipFs()
mountPoint, _ = ioutil.TempDir("", "")
nfs := fuse.NewPathNodeFs(fs, nil)
state, _, err := fuse.MountNodeFileSystem(mountPoint, nfs, &fuse.FileSystemOptions{
EntryTimeout: testTtl,
AttrTimeout: testTtl,
NegativeTimeout: 0.0,
})
CheckSuccess(err)
state.Debug = fuse.VerboseTest()
go state.Loop()
return mountPoint, func() {
state.Unmount()
os.RemoveAll(mountPoint)
}
}
示例13: main
func main() {
debug := flag.Bool("debug", false, "debug on")
portable := flag.Bool("portable", false, "use 32 bit inodes")
entry_ttl := flag.Float64("entry_ttl", 1.0, "fuse entry cache TTL.")
negative_ttl := flag.Float64("negative_ttl", 1.0, "fuse negative entry cache TTL.")
delcache_ttl := flag.Float64("deletion_cache_ttl", 5.0, "Deletion cache TTL in seconds.")
branchcache_ttl := flag.Float64("branchcache_ttl", 5.0, "Branch cache TTL in seconds.")
deldirname := flag.String(
"deletion_dirname", "GOUNIONFS_DELETIONS", "Directory name to use for deletions.")
flag.Parse()
if len(flag.Args()) < 2 {
fmt.Println("Usage:\n unionfs MOUNTPOINT RW-DIRECTORY RO-DIRECTORY ...")
os.Exit(2)
}
ufsOptions := unionfs.UnionFsOptions{
DeletionCacheTTL: time.Duration(*delcache_ttl * float64(time.Second)),
BranchCacheTTL: time.Duration(*branchcache_ttl * float64(time.Second)),
DeletionDirName: *deldirname,
}
ufs, err := unionfs.NewUnionFsFromRoots(flag.Args()[1:], &ufsOptions, true)
if err != nil {
log.Fatal("Cannot create UnionFs", err)
os.Exit(1)
}
nodeFs := fuse.NewPathNodeFs(ufs, &fuse.PathNodeFsOptions{ClientInodes: true})
mOpts := fuse.FileSystemOptions{
EntryTimeout: time.Duration(*entry_ttl * float64(time.Second)),
AttrTimeout: time.Duration(*entry_ttl * float64(time.Second)),
NegativeTimeout: time.Duration(*negative_ttl * float64(time.Second)),
PortableInodes: *portable,
}
mountState, _, err := fuse.MountNodeFileSystem(flag.Arg(0), nodeFs, &mOpts)
if err != nil {
log.Fatal("Mount fail:", err)
}
mountState.Debug = *debug
mountState.Loop()
}
示例14: setupFs
func setupFs(fs fuse.FileSystem, opts *fuse.FileSystemOptions) (string, func()) {
mountPoint, _ := ioutil.TempDir("", "stat_test")
nfs := fuse.NewPathNodeFs(fs, nil)
state, _, err := fuse.MountNodeFileSystem(mountPoint, nfs, opts)
if err != nil {
panic(fmt.Sprintf("cannot mount %v", err)) // ugh - benchmark has no error methods.
}
// state.Debug = true
go state.Loop()
return mountPoint, func() {
err := state.Unmount()
if err != nil {
log.Println("error during unmount", err)
} else {
os.RemoveAll(mountPoint)
}
}
}
示例15: setupUfs
func setupUfs(t *testing.T) (workdir string, cleanup func()) {
// Make sure system setting does not affect test.
syscall.Umask(0)
wd, _ := ioutil.TempDir("", "")
err := os.Mkdir(wd+"/mnt", 0700)
fuse.CheckSuccess(err)
err = os.Mkdir(wd+"/rw", 0700)
fuse.CheckSuccess(err)
os.Mkdir(wd+"/ro", 0700)
fuse.CheckSuccess(err)
var fses []fuse.FileSystem
fses = append(fses, fuse.NewLoopbackFileSystem(wd+"/rw"))
fses = append(fses,
NewCachingFileSystem(fuse.NewLoopbackFileSystem(wd+"/ro"), 0))
ufs := NewUnionFs(fses, testOpts)
// We configure timeouts are smaller, so we can check for
// UnionFs's cache consistency.
opts := &fuse.FileSystemOptions{
EntryTimeout: .5 * entryTtl,
AttrTimeout: .5 * entryTtl,
NegativeTimeout: .5 * entryTtl,
}
pathfs := fuse.NewPathNodeFs(ufs,
&fuse.PathNodeFsOptions{ClientInodes: true})
state, conn, err := fuse.MountNodeFileSystem(wd+"/mnt", pathfs, opts)
CheckSuccess(err)
conn.Debug = fuse.VerboseTest()
state.Debug = fuse.VerboseTest()
go state.Loop()
return wd, func() {
state.Unmount()
os.RemoveAll(wd)
}
}