本文整理汇总了Golang中github.com/hanwen/go-fuse/fuse/pathfs.NewLoopbackFileSystem函数的典型用法代码示例。如果您正苦于以下问题:Golang NewLoopbackFileSystem函数的具体用法?Golang NewLoopbackFileSystem怎么用?Golang NewLoopbackFileSystem使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewLoopbackFileSystem函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: 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
示例2: New
func New(root, hostport string) (pathfs.FileSystem, error) {
return &cloudFileSystem{
root: root,
hostport: hostport,
meta: pathfs.NewLoopbackFileSystem(path.Join(root, metaName)),
staging: pathfs.NewLoopbackFileSystem(path.Join(root, stagingName)),
remote: blkstore.NewMemStore()
}, nil
}
开发者ID:shaladdle,项目名称:goaaw,代码行数:9,代码来源:cloudfs.go
示例3: 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
示例4: 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
示例5: NewFS
// Encrypted FUSE overlay filesystem
func NewFS(args Args) *FS {
return &FS{
CryptFS: cryptfs.NewCryptFS(args.Masterkey, args.OpenSSL, args.PlaintextNames, args.GCMIV128),
FileSystem: pathfs.NewLoopbackFileSystem(args.Cipherdir),
args: args,
}
}
开发者ID:cautio,项目名称:gocryptfs,代码行数:8,代码来源:fs.go
示例6: NewFS
// Encrypted FUSE overlay filesystem
func NewFS(key []byte, backing string, useOpenssl bool) *FS {
return &FS{
CryptFS: cryptfs.NewCryptFS(key, useOpenssl),
FileSystem: pathfs.NewLoopbackFileSystem(backing),
backing: backing,
}
}
开发者ID:theit8514,项目名称:gocryptfs,代码行数:8,代码来源:fs.go
示例7: 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
示例8: NewTestCase
// Create and mount filesystem.
func NewTestCase(t *testing.T) *testCase {
tc := &testCase{}
tc.tester = t
// Make sure system setting does not affect test.
syscall.Umask(0)
const name string = "hello.txt"
const subdir string = "subdir"
var err error
tc.tmpDir, err = ioutil.TempDir("", "go-fuse")
if err != nil {
t.Fatalf("TempDir failed: %v", err)
}
tc.orig = tc.tmpDir + "/orig"
tc.mnt = tc.tmpDir + "/mnt"
tc.Mkdir(tc.orig, 0700)
tc.Mkdir(tc.mnt, 0700)
tc.mountFile = filepath.Join(tc.mnt, name)
tc.mountSubdir = filepath.Join(tc.mnt, subdir)
tc.origFile = filepath.Join(tc.orig, name)
tc.origSubdir = filepath.Join(tc.orig, subdir)
var pfs pathfs.FileSystem
pfs = pathfs.NewLoopbackFileSystem(tc.orig)
pfs = pathfs.NewLockingFileSystem(pfs)
tc.pathFs = pathfs.NewPathNodeFs(pfs, &pathfs.PathNodeFsOptions{
ClientInodes: true})
tc.connector = nodefs.NewFileSystemConnector(tc.pathFs.Root(),
&nodefs.Options{
EntryTimeout: testTtl,
AttrTimeout: testTtl,
NegativeTimeout: 0.0,
Debug: VerboseTest(),
})
tc.state, err = fuse.NewServer(
fuse.NewRawFileSystem(tc.connector.RawFS()), tc.mnt, &fuse.MountOptions{
SingleThreaded: true,
Debug: VerboseTest(),
})
if err != nil {
t.Fatal("NewServer:", err)
}
go tc.state.Serve()
if err := tc.state.WaitMount(); err != nil {
t.Fatal("WaitMount", err)
}
return tc
}
开发者ID:Richardphp,项目名称:noms,代码行数:55,代码来源:loopback_test.go
示例9: NewTestCase
// Create and mount filesystem.
func NewTestCase(t *testing.T) *testCase {
me := &testCase{}
me.tester = t
// Make sure system setting does not affect test.
syscall.Umask(0)
const name string = "hello.txt"
const subdir string = "subdir"
var err error
me.tmpDir, err = ioutil.TempDir("", "go-fuse")
if err != nil {
t.Fatalf("TempDir failed: %v", err)
}
me.orig = me.tmpDir + "/orig"
me.mnt = me.tmpDir + "/mnt"
os.Mkdir(me.orig, 0700)
os.Mkdir(me.mnt, 0700)
me.mountFile = filepath.Join(me.mnt, name)
me.mountSubdir = filepath.Join(me.mnt, subdir)
me.origFile = filepath.Join(me.orig, name)
me.origSubdir = filepath.Join(me.orig, subdir)
var pfs pathfs.FileSystem
pfs = pathfs.NewLoopbackFileSystem(me.orig)
pfs = pathfs.NewLockingFileSystem(pfs)
me.pathFs = pathfs.NewPathNodeFs(pfs, &pathfs.PathNodeFsOptions{
ClientInodes: true})
me.connector = nodefs.NewFileSystemConnector(me.pathFs.Root(),
&nodefs.Options{
EntryTimeout: testTtl,
AttrTimeout: testTtl,
NegativeTimeout: 0.0,
})
me.connector.SetDebug(VerboseTest())
me.state, err = fuse.NewServer(
fuse.NewRawFileSystem(me.connector.RawFS()), me.mnt, &fuse.MountOptions{SingleThreaded: true})
if err != nil {
t.Fatal("NewServer:", err)
}
me.state.SetDebug(VerboseTest())
// Unthreaded, but in background.
go me.state.Serve()
me.state.WaitMount()
return me
}
开发者ID:hoffoo,项目名称:go-fuse,代码行数:54,代码来源:loopback_test.go
示例10: NewFS
// NewFS returns a new encrypted FUSE overlay filesystem.
func NewFS(args Args) *FS {
cryptoCore := cryptocore.New(args.Masterkey, args.CryptoBackend, contentenc.DefaultIVBits)
contentEnc := contentenc.New(cryptoCore, contentenc.DefaultBS)
nameTransform := nametransform.New(cryptoCore, args.LongNames, args.Raw64)
return &FS{
FileSystem: pathfs.NewLoopbackFileSystem(args.Cipherdir),
args: args,
nameTransform: nameTransform,
contentEnc: contentEnc,
}
}
开发者ID:rfjakob,项目名称:gocryptfs,代码行数:13,代码来源:fs.go
示例11: startLoopbackServer
func startLoopbackServer(root string) (*loopbackServer, error) {
l, err := net.Listen("tcp", "127.0.0.1:0")
if err != nil {
return nil, err
}
s := grpc.NewServer()
nfs := pathfs.NewLoopbackFileSystem(root)
pb.RegisterPathFSServer(s, server.New(nfs))
go s.Serve(l)
return &loopbackServer{
Server: s,
Addr: l.Addr().String(),
}, nil
}
开发者ID:LK4D4,项目名称:grfuse,代码行数:14,代码来源:paths_test.go
示例12: TestMountRename
func TestMountRename(t *testing.T) {
ts := NewTestCase(t)
defer ts.Cleanup()
fs := pathfs.NewPathNodeFs(pathfs.NewLoopbackFileSystem(ts.orig), nil)
code := ts.connector.Mount(ts.rootNode(), "mnt", fs.Root(), nil)
if !code.Ok() {
t.Fatal("mount should succeed")
}
err := os.Rename(ts.mnt+"/mnt", ts.mnt+"/foobar")
if fuse.ToStatus(err) != fuse.EBUSY {
t.Fatal("rename mount point should fail with EBUSY:", err)
}
ts.pathFs.Unmount("mnt")
}
开发者ID:yeonsh,项目名称:go-fuse,代码行数:15,代码来源:mount_test.go
示例13: TestGetAttrRace
func TestGetAttrRace(t *testing.T) {
dir, err := ioutil.TempDir("", "go-fuse-cache_test")
if err != nil {
t.Fatalf("failed: %v", err)
}
defer os.RemoveAll(dir)
os.Mkdir(dir+"/mnt", 0755)
os.Mkdir(dir+"/orig", 0755)
fs := pathfs.NewLoopbackFileSystem(dir + "/orig")
pfs := pathfs.NewPathNodeFs(fs, nil)
state, conn, err := nodefs.MountRoot(dir+"/mnt", pfs.Root(),
&nodefs.Options{})
if err != nil {
t.Fatalf("MountNodeFileSystem failed: %v", err)
}
state.SetDebug(VerboseTest())
conn.SetDebug(VerboseTest())
pfs.SetDebug(VerboseTest())
go state.Serve()
defer state.Unmount()
var wg sync.WaitGroup
n := 100
wg.Add(n)
var statErr error
for i := 0; i < n; i++ {
go func() {
defer wg.Done()
fn := dir + "/mnt/file"
err := ioutil.WriteFile(fn, []byte{42}, 0644)
if err != nil {
statErr = err
return
}
_, err = os.Lstat(fn)
if err != nil {
statErr = err
}
}()
}
wg.Wait()
if statErr != nil {
t.Error(statErr)
}
}
开发者ID:freakmac,项目名称:adbfs,代码行数:48,代码来源:cache_test.go
示例14: TestRecursiveMount
func TestRecursiveMount(t *testing.T) {
ts := NewTestCase(t)
defer ts.Cleanup()
err := ioutil.WriteFile(ts.orig+"/hello.txt", []byte("blabla"), 0644)
if err != nil {
t.Fatalf("WriteFile failed: %v", err)
}
fs := pathfs.NewPathNodeFs(pathfs.NewLoopbackFileSystem(ts.orig), nil)
code := ts.connector.Mount(ts.rootNode(), "mnt", fs.Root(), nil)
if !code.Ok() {
t.Fatal("mount should succeed")
}
submnt := ts.mnt + "/mnt"
_, err = os.Lstat(submnt)
if err != nil {
t.Fatalf("Lstat failed: %v", err)
}
_, err = os.Lstat(filepath.Join(submnt, "hello.txt"))
if err != nil {
t.Fatalf("Lstat failed: %v", err)
}
f, err := os.Open(filepath.Join(submnt, "hello.txt"))
if err != nil {
t.Fatalf("Open failed: %v", err)
}
code = ts.pathFs.Unmount("mnt")
if code != fuse.EBUSY {
t.Error("expect EBUSY")
}
if err := f.Close(); err != nil {
t.Errorf("close: %v", err)
}
// We can't avoid a sleep here: the file handle release is not
// synchronized.
t.Log("Waiting for kernel to flush file-close to fuse...")
time.Sleep(testTtl)
code = ts.pathFs.Unmount("mnt")
if code != fuse.OK {
t.Error("umount failed.", code)
}
}
开发者ID:Richardphp,项目名称:noms,代码行数:48,代码来源:mount_test.go
示例15: NewHookFs
// Instantiate a new HookFS object
func NewHookFs(original string, mountpoint string, hook Hook) (*HookFs, error) {
log.WithFields(log.Fields{
"original": original,
"mountpoint": mountpoint,
}).Debug("Hooking a fs")
loopbackfs := pathfs.NewLoopbackFileSystem(original)
hookfs := &HookFs{
Original: original,
Mountpoint: mountpoint,
FsName: "hookfs",
fs: loopbackfs,
hook: hook,
}
return hookfs, nil
}
开发者ID:osrg,项目名称:hookfs,代码行数:17,代码来源:fs.go
示例16: TestCachingFs
func TestCachingFs(t *testing.T) {
wd := testutil.TempDir()
defer os.RemoveAll(wd)
fs := pathfs.NewLoopbackFileSystem(wd)
cfs := NewCachingFileSystem(fs, 0)
os.Mkdir(wd+"/orig", 0755)
fi, code := cfs.GetAttr("orig", nil)
if !code.Ok() {
t.Fatal("GetAttr failure", code)
}
if !fi.IsDir() {
t.Error("unexpected attr", fi)
}
os.Symlink("orig", wd+"/symlink")
val, code := cfs.Readlink("symlink", nil)
if val != "orig" {
t.Error("unexpected readlink", val)
}
if !code.Ok() {
t.Error("code !ok ", code)
}
stream, code := cfs.OpenDir("", nil)
if !code.Ok() {
t.Fatal("Readdir fail", code)
}
results := make(map[string]uint32)
for _, v := range stream {
results[v.Name] = v.Mode &^ 07777
}
expected := map[string]uint32{
"symlink": syscall.S_IFLNK,
"orig": fuse.S_IFDIR,
}
if !modeMapEq(results, expected) {
t.Error("Unexpected readdir result", results, expected)
}
}
开发者ID:rfjakob,项目名称:go-fuse,代码行数:43,代码来源:cachingfs_test.go
示例17: TestMountReaddir
func TestMountReaddir(t *testing.T) {
ts := NewTestCase(t)
defer ts.Cleanup()
fs := pathfs.NewPathNodeFs(pathfs.NewLoopbackFileSystem(ts.orig), nil)
code := ts.connector.Mount(ts.rootNode(), "mnt", fs.Root(), nil)
if !code.Ok() {
t.Fatal("mount should succeed")
}
entries, err := ioutil.ReadDir(ts.mnt)
if err != nil {
t.Fatalf("ReadDir failed: %v", err)
}
if len(entries) != 1 || entries[0].Name() != "mnt" {
t.Error("wrong readdir result", entries)
}
ts.pathFs.Unmount("mnt")
}
开发者ID:yeonsh,项目名称:go-fuse,代码行数:19,代码来源:mount_test.go
示例18: Symlink
func (n *configNode) Symlink(name string, content string, context *fuse.Context) (*nodefs.Inode, fuse.Status) {
dir := content
components := strings.Split(content, ":")
if len(components) > 2 || len(components) == 0 {
return nil, fuse.Status(syscall.EINVAL)
}
var root nodefs.Node
if len(components) == 2 {
dir = components[0]
}
if fi, err := os.Lstat(dir); err != nil {
return nil, fuse.ToStatus(err)
} else if !fi.IsDir() {
return nil, fuse.Status(syscall.ENOTDIR)
}
var opts *nodefs.Options
if len(components) == 1 {
root = pathfs.NewPathNodeFs(pathfs.NewLoopbackFileSystem(content), nil).Root()
} else {
var err error
root, err = NewGitFSRoot(content, n.fs.opts)
if err != nil {
log.Printf("NewGitFSRoot(%q): %v", content, err)
return nil, fuse.ENOENT
}
opts = &nodefs.Options{
EntryTimeout: time.Hour,
NegativeTimeout: time.Hour,
AttrTimeout: time.Hour,
PortableInodes: true,
}
}
if code := n.fs.fsConn.Mount(n.corresponding.Inode(), name, root, opts); !code.Ok() {
return nil, code
}
linkNode := newGitConfigNode(content)
return n.Inode().NewChild(name, false, linkNode), fuse.OK
}
开发者ID:hanwen,项目名称:gitfs,代码行数:43,代码来源:multifs.go
示例19: main
func main() {
// Scans the arg list and sets up flags
debug := flag.Bool("debug", false, "print debugging messages.")
other := flag.Bool("allow-other", false, "mount with -o allowother.")
flag.Parse()
if flag.NArg() < 2 {
// TODO - where to get program name?
fmt.Println("usage: main MOUNTPOINT ORIGINAL")
os.Exit(2)
}
var finalFs pathfs.FileSystem
orig := flag.Arg(1)
loopbackfs := pathfs.NewLoopbackFileSystem(orig)
finalFs = loopbackfs
opts := &nodefs.Options{
// These options are to be compatible with libfuse defaults,
// making benchmarking easier.
NegativeTimeout: time.Second,
AttrTimeout: time.Second,
EntryTimeout: time.Second,
}
pathFs := pathfs.NewPathNodeFs(finalFs, nil)
conn := nodefs.NewFileSystemConnector(pathFs.Root(), opts)
mountPoint := flag.Arg(0)
origAbs, _ := filepath.Abs(orig)
mOpts := &fuse.MountOptions{
AllowOther: *other,
Name: "loopbackfs",
FsName: origAbs,
}
state, err := fuse.NewServer(conn.RawFS(), mountPoint, mOpts)
if err != nil {
fmt.Printf("Mount fail: %v\n", err)
os.Exit(1)
}
state.SetDebug(*debug)
fmt.Println("Mounted!")
state.Serve()
}
开发者ID:eliq,项目名称:go-fuse,代码行数:42,代码来源:main.go
示例20: NewFS
// NewFS returns an encrypted FUSE overlay filesystem.
// In this case (reverse mode) the backing directory is plain-text and
// ReverseFS provides an encrypted view.
func NewFS(args fusefrontend.Args) *ReverseFS {
if args.CryptoBackend != cryptocore.BackendAESSIV {
log.Panic("reverse mode must use AES-SIV, everything else is insecure")
}
initLongnameCache()
cryptoCore := cryptocore.New(args.Masterkey, args.CryptoBackend, contentenc.DefaultIVBits)
contentEnc := contentenc.New(cryptoCore, contentenc.DefaultBS)
nameTransform := nametransform.New(cryptoCore, args.LongNames, args.Raw64)
return &ReverseFS{
// pathfs.defaultFileSystem returns ENOSYS for all operations
FileSystem: pathfs.NewDefaultFileSystem(),
loopbackfs: pathfs.NewLoopbackFileSystem(args.Cipherdir),
args: args,
nameTransform: nameTransform,
contentEnc: contentEnc,
inoGen: newInoGen(),
inoMap: map[fusefrontend.DevInoStruct]uint64{},
}
}
开发者ID:rfjakob,项目名称:gocryptfs,代码行数:23,代码来源:rfs.go
注:本文中的github.com/hanwen/go-fuse/fuse/pathfs.NewLoopbackFileSystem函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论