Beispiel #1
0
func (me *memNode) Open(flags uint32, context *fuse.Context) (fuseFile fuse.File, code fuse.Status) {
	if flags&fuse.O_ANYWRITE != 0 {
		return nil, fuse.EPERM
	}

	return fuse.NewDataFile(me.file.Data()), fuse.OK
}
Beispiel #2
0
func (me *ProcFs) Open(name string, flags uint32, context *fuse.Context) (fuse.File, fuse.Status) {
	p := me.LoopbackFileSystem.GetPath(name)
	content, err := ioutil.ReadFile(p)
	if err == nil {
		return fuse.NewDataFile(content), fuse.OK
	}
	return nil, fuse.ToStatus(err)
}
Beispiel #3
0
func (me *HelloFs) Open(name string, flags uint32, context *fuse.Context) (file fuse.File, code fuse.Status) {
	if name != "file.txt" {
		return nil, fuse.ENOENT
	}
	if flags&fuse.O_ANYWRITE != 0 {
		return nil, fuse.EPERM
	}
	return fuse.NewDataFile([]byte(name)), fuse.OK
}
Beispiel #4
0
func (self *BackupFs) Open(name string, flags uint32, context *fuse.Context) (file fuse.File, code fuse.Status) {
	child := self.getDescendantTree(name)
	if child == nil {
		return nil, fuse.ENOENT
	}
	if data, err := self.blobStorage.Get(child.ObjRef); err != nil {
		log.Fatalf("Internal error: ObjRef %s is a dangling pointer", child.ObjRef)
	} else {
		return fuse.NewDataFile(data), fuse.OK
	}
	return nil, fuse.ENOENT
}
Beispiel #5
0
func (fs *AutoUnionFs) Open(path string, flags uint32, context *fuse.Context) (fuse.File, fuse.Status) {
	if path == filepath.Join(_STATUS, _DEBUG) {
		if flags&fuse.O_ANYWRITE != 0 {
			return nil, fuse.EPERM
		}

		return fuse.NewDataFile([]byte(fs.DebugData())), fuse.OK
	}
	if path == filepath.Join(_STATUS, _VERSION) {
		if flags&fuse.O_ANYWRITE != 0 {
			return nil, fuse.EPERM
		}
		return fuse.NewDataFile([]byte(fuse.Version())), fuse.OK
	}
	if path == filepath.Join(_CONFIG, _SCAN_CONFIG) {
		if flags&fuse.O_ANYWRITE != 0 {
			fs.updateKnownFses()
		}
		return fuse.NewDevNullFile(), fuse.OK
	}
	return nil, fuse.ENOENT
}