weedfs_filehandle.go 853 B

1234567891011121314151617181920212223242526272829
  1. package mount
  2. import (
  3. "github.com/hanwen/go-fuse/v2/fuse"
  4. "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
  5. "github.com/seaweedfs/seaweedfs/weed/util"
  6. )
  7. func (wfs *WFS) AcquireHandle(inode uint64, flags, uid, gid uint32) (fileHandle *FileHandle, status fuse.Status) {
  8. var entry *filer_pb.Entry
  9. var path util.FullPath
  10. path, _, entry, status = wfs.maybeReadEntry(inode)
  11. if status == fuse.OK {
  12. if wfs.wormEnabledForEntry(path, entry) && flags&fuse.O_ANYWRITE != 0 {
  13. return nil, fuse.EPERM
  14. }
  15. // need to AcquireFileHandle again to ensure correct handle counter
  16. fileHandle = wfs.fhMap.AcquireFileHandle(wfs, inode, entry)
  17. }
  18. return
  19. }
  20. func (wfs *WFS) ReleaseHandle(handleId FileHandleId) {
  21. wfs.fhMap.ReleaseByHandle(handleId)
  22. }
  23. func (wfs *WFS) GetHandle(handleId FileHandleId) *FileHandle {
  24. return wfs.fhMap.GetFileHandle(handleId)
  25. }