You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
871 B

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