本文整理汇总了Golang中github.com/hanwen/go-fuse/fuse.FileSystem类的典型用法代码示例。如果您正苦于以下问题:Golang FileSystem类的具体用法?Golang FileSystem怎么用?Golang FileSystem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FileSystem类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: getAttr
func getAttr(fs fuse.FileSystem, name string) *attrResponse {
a, code := fs.GetAttr(name, nil)
return &attrResponse{
Attr: a,
Status: code,
}
}
开发者ID:eug48,项目名称:go-fuse,代码行数:7,代码来源:cachingfs.go
示例2: readLink
func readLink(fs fuse.FileSystem, name string) *linkResponse {
a, code := fs.Readlink(name, nil)
return &linkResponse{
linkContent: a,
Status: code,
}
}
开发者ID:eug48,项目名称:go-fuse,代码行数:7,代码来源:cachingfs.go
示例3: getXAttr
func getXAttr(fs fuse.FileSystem, nameAttr string) *xattrResponse {
ns := strings.SplitN(nameAttr, _XATTRSEP, 2)
a, code := fs.GetXAttr(ns[0], ns[1], nil)
return &xattrResponse{
data: a,
Status: code,
}
}
开发者ID:eug48,项目名称:go-fuse,代码行数:8,代码来源:cachingfs.go
示例4: readDir
func readDir(fs fuse.FileSystem, name string) *dirResponse {
origStream, code := fs.OpenDir(name, nil)
r := &dirResponse{nil, code}
if !code.Ok() {
return r
}
r.entries = origStream
return r
}
开发者ID:eug48,项目名称:go-fuse,代码行数:10,代码来源:cachingfs.go
示例5: newDirnameMap
// newDirnameMap reads the contents of the given directory. On error,
// returns a nil map. This forces reloads in the DirCache until we
// succeed.
func newDirnameMap(fs fuse.FileSystem, dir string) map[string]bool {
stream, code := fs.OpenDir(dir)
if !code.Ok() {
log.Printf("newDirnameMap(): %v %v", dir, code)
return nil
}
result := make(map[string]bool)
for e := range stream {
if e.Mode&fuse.S_IFREG != 0 {
result[e.Name] = true
}
}
return result
}
开发者ID:abneptis,项目名称:go-fuse,代码行数:18,代码来源:dircache.go
示例6: readDir
func readDir(fs fuse.FileSystem, name string) *dirResponse {
origStream, code := fs.OpenDir(name, nil)
r := &dirResponse{nil, code}
if code != fuse.OK {
return r
}
for {
d, ok := <-origStream
if !ok {
break
}
r.entries = append(r.entries, d)
}
return r
}
开发者ID:taruti,项目名称:go-fuse,代码行数:17,代码来源:cachingfs.go
示例7: newDirnameMap
// newDirnameMap reads the contents of the given directory. On error,
// returns a nil map. This forces reloads in the DirCache until we
// succeed.
func newDirnameMap(fs fuse.FileSystem, dir string) map[string]bool {
stream, code := fs.OpenDir(dir, nil)
if code == fuse.ENOENT {
// The directory not existing is not an error.
return map[string]bool{}
}
if !code.Ok() {
log.Printf("newDirnameMap(%v): %v %v", fs, dir, code)
return nil
}
result := make(map[string]bool)
for _, e := range stream {
if e.Mode&fuse.S_IFREG != 0 {
result[e.Name] = true
}
}
return result
}
开发者ID:eric-autoref,项目名称:go-fuse,代码行数:23,代码来源:dircache.go
示例8: openFile
func openFile(fs fuse.FileSystem, name string) (result *openResponse) {
result = &openResponse{}
flags := uint32(os.O_RDONLY)
f, code := fs.Open(name, flags)
if !code.Ok() {
result.Status = code
return
}
defer f.Release()
defer f.Flush()
buf := bytes.NewBuffer(nil)
input := fuse.ReadIn{
Offset: 0,
Size: 128 * (1 << 10),
Flags: flags,
}
bp := fuse.NewGcBufferPool()
for {
data, status := f.Read(&input, bp)
buf.Write(data)
if !status.Ok() {
result.Status = status
return
}
if len(data) < int(input.Size) {
break
}
input.Offset += uint64(len(data))
}
result.File = fuse.NewReadOnlyFile(buf.Bytes())
return
}
开发者ID:abneptis,项目名称:go-fuse,代码行数:36,代码来源:cachingfs.go
示例9: IsDir
func IsDir(fs fuse.FileSystem, name string) bool {
a, code := fs.GetAttr(name, nil)
return code.Ok() && a.IsDir()
}
开发者ID:kicool,项目名称:go-fuse,代码行数:4,代码来源:unionfs.go
示例10: newWorkerFuseFs
func newWorkerFuseFs(tmpDir string, rpcFs fuse.FileSystem, writableRoot string, nobody *User) (*workerFuseFs, error) {
tmpDir, err := ioutil.TempDir(tmpDir, "termite-task")
if err != nil {
return nil, err
}
me := &workerFuseFs{
tmpDir: tmpDir,
writableRoot: strings.TrimLeft(writableRoot, "/"),
tasks: map[*WorkerTask]bool{},
}
type dirInit struct {
dst *string
val string
}
tmpBacking := ""
for _, v := range []dirInit{
{&me.rwDir, "rw"},
{&me.mount, "mnt"},
{&tmpBacking, "tmp-backing"},
} {
*v.dst = filepath.Join(me.tmpDir, v.val)
err = os.Mkdir(*v.dst, 0700)
if err != nil {
return nil, err
}
}
fuseOpts := fuse.MountOptions{}
if os.Geteuid() == 0 {
fuseOpts.AllowOther = true
}
me.rpcNodeFs = fuse.NewPathNodeFs(rpcFs, nil)
ttl := 30 * time.Second
mOpts := fuse.FileSystemOptions{
EntryTimeout: ttl,
AttrTimeout: ttl,
NegativeTimeout: ttl,
// 32-bit programs have trouble with 64-bit inode
// numbers.
PortableInodes: true,
}
me.fsConnector = fuse.NewFileSystemConnector(me.rpcNodeFs, &mOpts)
me.MountState = fuse.NewMountState(me.fsConnector)
err = me.MountState.Mount(me.mount, &fuseOpts)
if err != nil {
return nil, err
}
go me.MountState.Loop()
me.unionFs = fs.NewMemUnionFs(
me.rwDir, &fuse.PrefixFileSystem{rpcFs, me.writableRoot})
me.procFs = fs.NewProcFs()
me.procFs.StripPrefix = me.mount
if nobody != nil {
me.procFs.Uid = nobody.Uid
}
type submount struct {
mountpoint string
fs fuse.NodeFileSystem
}
mounts := []submount{
{"proc", fuse.NewPathNodeFs(me.procFs, nil)},
{"sys", fuse.NewPathNodeFs(&fuse.ReadonlyFileSystem{fuse.NewLoopbackFileSystem("/sys")}, nil)},
{"tmp", fuse.NewMemNodeFs(tmpBacking + "/tmp")},
{"dev", fs.NewDevNullFs()},
{"var/tmp", fuse.NewMemNodeFs(tmpBacking + "/vartmp")},
}
for _, s := range mounts {
subOpts := &mOpts
if s.mountpoint == "proc" {
subOpts = nil
}
code := me.rpcNodeFs.Mount(s.mountpoint, s.fs, subOpts)
if !code.Ok() {
if err := me.MountState.Unmount(); err != nil {
log.Fatal("FUSE unmount error during cleanup:", err)
}
return nil, errors.New(fmt.Sprintf("submount error for %s: %v", s.mountpoint, code))
}
}
if strings.HasPrefix(me.writableRoot, "tmp/") {
parent, _ := filepath.Split(me.writableRoot)
err := os.MkdirAll(filepath.Join(me.mount, parent), 0755)
if err != nil {
if err := me.MountState.Unmount(); err != nil {
log.Fatal("FUSE unmount error during cleanup:", err)
}
return nil, errors.New(fmt.Sprintf("Mkdir of %q in /tmp fail: %v", parent, err))
}
// This is hackish, but we don't want rpcfs/fsserver
// getting confused by asking for tmp/foo/bar
// directly.
//.........这里部分代码省略.........
开发者ID:janneke,项目名称:termite,代码行数:101,代码来源:fuse.go
注:本文中的github.com/hanwen/go-fuse/fuse.FileSystem类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论