コード例 #1
0
ファイル: unionfs.go プロジェクト: kicool/go-fuse
func (me *UnionFs) Open(name string, flags uint32, context *fuse.Context) (fuseFile fuse.File, status fuse.Status) {
	if name == _DROP_CACHE {
		if flags&fuse.O_ANYWRITE != 0 {
			log.Println("Forced cache drop on", me)
			me.DropBranchCache(nil)
			me.DropDeletionCache()
			me.DropSubFsCaches()
			me.nodeFs.ForgetClientInodes()
		}
		return fuse.NewDevNullFile(), fuse.OK
	}
	r := me.getBranch(name)
	if r.branch < 0 {
		// This should not happen, as a GetAttr() should have
		// already verified existence.
		log.Println("UnionFs: open of non-existent file:", name)
		return nil, fuse.ENOENT
	}
	if flags&fuse.O_ANYWRITE != 0 && r.branch > 0 {
		code := me.Promote(name, r, context)
		if code != fuse.OK {
			return nil, code
		}
		r.branch = 0
		now := time.Now()
		r.attr.SetTimes(nil, &now, nil)
		me.branchCache.Set(name, r)
	}
	fuseFile, status = me.fileSystems[r.branch].Open(name, uint32(flags), context)
	if fuseFile != nil {
		fuseFile = me.newUnionFsFile(fuseFile, r.branch)
	}
	return fuseFile, status
}
コード例 #2
0
ファイル: devnullfs.go プロジェクト: lht/termite
func (me *EntryFs) Open(name string, flags uint32, context *fuse.Context) (file fuse.File, code fuse.Status) {
	if name == me.FileInfo.Name {
		return fuse.NewDevNullFile(), fuse.OK
	}

	return nil, fuse.ENOENT
}
コード例 #3
0
ファイル: unionfs.go プロジェクト: andradeandrey/go-fuse
func (me *UnionFs) Open(name string, flags uint32) (fuseFile fuse.File, status fuse.Status) {
	if name == _DROP_CACHE {
		if flags&fuse.O_ANYWRITE != 0 {
			log.Println("Forced cache drop on", me.Name())
			me.DropBranchCache(nil)
			me.DropDeletionCache()
			me.DropSubFsCaches()
		}
		return fuse.NewDevNullFile(), fuse.OK
	}
	r := me.getBranch(name)
	if r.branch < 0 {
		// This should not happen, as a GetAttr() should have
		// already verified existence.
		log.Println("UnionFs: open of non-existent file:", name)
		return nil, fuse.ENOENT
	}
	if flags&fuse.O_ANYWRITE != 0 && r.branch > 0 {
		code := me.Promote(name, r)
		if code != fuse.OK {
			return nil, code
		}
		r.branch = 0
		r.attr.Mtime_ns = time.Nanoseconds()
		me.branchCache.Set(name, r)
	}
	return me.fileSystems[r.branch].Open(name, uint32(flags))
}
コード例 #4
0
ファイル: autounion.go プロジェクト: CloudLife/go-fuse
func (me *AutoUnionFs) Open(path string, flags uint32, context *fuse.Context) (fuse.File, fuse.Status) {
	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 {
			me.updateKnownFses()
		}
		return fuse.NewDevNullFile(), fuse.OK
	}
	return nil, fuse.ENOENT
}
コード例 #5
0
ファイル: unionfs.go プロジェクト: jravasi/go-fuse
func (me *UnionFs) Open(name string, flags uint32) (fuseFile fuse.File, status fuse.Status) {
	if name == _DROP_CACHE {
		if flags&fuse.O_ANYWRITE != 0 {
			me.DropCaches()
		}
		return fuse.NewDevNullFile(), fuse.OK
	}
	r := me.getBranch(name)
	if flags&fuse.O_ANYWRITE != 0 && r.branch > 0 {
		code := me.Promote(name, r)
		if code != fuse.OK {
			return nil, code
		}
		r.branch = 0
		r.attr.Mtime_ns = time.Nanoseconds()
		me.branchCache.Set(name, r)
	}
	return me.fileSystems[r.branch].Open(name, uint32(flags))
}
コード例 #6
0
ファイル: devnullfs.go プロジェクト: janneke/termite
func (me *devNullNode) Open(flags uint32, context *fuse.Context) (file fuse.File, code fuse.Status) {
	return fuse.NewDevNullFile(), fuse.OK
}