本文整理匯總了Golang中github.com/hanwen/go-fuse/fuse/pathfs.NewDefaultFileSystem函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewDefaultFileSystem函數的具體用法?Golang NewDefaultFileSystem怎麽用?Golang NewDefaultFileSystem使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了NewDefaultFileSystem函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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")
}
}
示例2: NewStatFS
func NewStatFS() *StatFS {
return &StatFS{
FileSystem: pathfs.NewDefaultFileSystem(),
entries: make(map[string]*fuse.Attr),
dirs: make(map[string][]fuse.DirEntry),
}
}
示例3: New
// New initializes a new TagsFs that uses the given AWS client
func New(client *ec2.EC2, instanceID string) *TagsFs {
return &TagsFs{
FileSystem: pathfs.NewReadonlyFileSystem(pathfs.NewDefaultFileSystem()),
Client: client,
InstanceID: instanceID,
}
}
示例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)
}
}
示例5: 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)
}
}
示例6: newNotifyFs
func newNotifyFs() *NotifyFs {
return &NotifyFs{
FileSystem: pathfs.NewDefaultFileSystem(),
sizeChan: make(chan uint64, 1),
existChan: make(chan bool, 1),
}
}
示例7: NewUnionFs
func NewUnionFs(fileSystems []pathfs.FileSystem, options UnionFsOptions) (pathfs.FileSystem, error) {
g := &unionFS{
options: &options,
fileSystems: fileSystems,
FileSystem: pathfs.NewDefaultFileSystem(),
}
writable := g.fileSystems[0]
code := g.createDeletionStore()
if !code.Ok() {
return nil, fmt.Errorf("could not create deletion path %v: %v", options.DeletionDirName, code)
}
g.deletionCache = newDirCache(writable, options.DeletionDirName, options.DeletionCacheTTL)
g.branchCache = NewTimedCache(
func(n string) (interface{}, bool) { return g.getBranchAttrNoCache(n), true },
options.BranchCacheTTL)
g.hiddenFiles = make(map[string]bool)
for _, name := range options.HiddenFiles {
g.hiddenFiles[name] = true
}
return g, nil
}
示例8: 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
}
示例9: New
// New initializes a new MetadataFs that uses the given endpoint as the
// target of metadata requests
func New(endpoint string) *MetadataFs {
return &MetadataFs{
FileSystem: pathfs.NewReadonlyFileSystem(pathfs.NewDefaultFileSystem()),
Client: &http.Client{},
Endpoint: endpoint,
}
}
示例10: start
func start(dataset string, mount mount) {
ds, err := spec.GetDataset(dataset)
if err != nil {
fmt.Fprintf(os.Stderr, "Could not create dataset: %s\n", err)
return
}
hv, ok := ds.MaybeHeadValue()
if ok {
if !types.IsSubtype(fsType, hv.Type()) {
fmt.Fprintf(os.Stderr, "Invalid dataset head: expected type '%s' but found type '%s'\n", fsType.Desc.(types.StructDesc).Name, hv.Type().Desc.(types.StructDesc).Name)
return
}
} else {
rootAttr := makeAttr(0777) // create the root directory with maximally permissive permissions
rootDir := types.NewStructWithType(directoryType, types.ValueSlice{types.NewMap()})
rootInode := types.NewStructWithType(inodeType, types.ValueSlice{rootAttr, rootDir})
hv = types.NewStructWithType(fsType, types.ValueSlice{rootInode})
}
mount(&nomsFS{
FileSystem: pathfs.NewDefaultFileSystem(),
ds: ds,
head: hv.(types.Struct),
mdLock: &sync.Mutex{},
nodes: make(map[hash.Hash]*nNode),
})
}
示例11: 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")
}
}
示例12: NewMultiZipFs
func NewMultiZipFs() *MultiZipFs {
m := &MultiZipFs{
zips: make(map[string]nodefs.Node),
dirZipFileMap: make(map[string]string),
FileSystem: pathfs.NewDefaultFileSystem(),
}
return m
}
示例13: NewDriver
func NewDriver(basepath, etcdendpoint string) dkvolume.Driver {
e := etcDriver{
etcdbackend: etcdfs.EtcdFs{FileSystem: pathfs.NewDefaultFileSystem(), EtcdEndpoint: etcdendpoint},
mountpoints: make(map[string]*etcdFuseServer),
basePath: basepath,
}
return &e
}
示例14: NewFs
// NewKeywhizFs readies a KeywhizFs struct and its parent filesystem objects.
func NewFs(client *api.Client, owner keywhizfs.Ownership) (*fs, nodefs.Node) {
defaultfs := pathfs.NewDefaultFileSystem() // Returns ENOSYS by default
readonlyfs := pathfs.NewReadonlyFileSystem(defaultfs) // R/W calls return EPERM
kwfs := &fs{readonlyfs, client, owner}
nfs := pathfs.NewPathNodeFs(kwfs, nil)
nfs.SetDebug(true)
return kwfs, nfs.Root()
}
示例15: MountFs
func MountFs(path string) {
LoadSession()
CacheInit()
nfs := pathfs.NewPathNodeFs(&DropboxFs{FileSystem: pathfs.NewDefaultFileSystem()}, nil)
server, _, err := nodefs.MountRoot(path, nfs.Root(), nil)
if err != nil {
log.Fatalf("Mount fail: %v\n", err)
}
server.Serve()
}