2022-02-14 11:14:34 +08:00
|
|
|
package mount
|
|
|
|
|
2022-03-13 14:38:14 +08:00
|
|
|
import (
|
|
|
|
"github.com/hanwen/go-fuse/v2/fuse"
|
2022-07-29 15:17:28 +08:00
|
|
|
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
|
2024-09-17 12:02:21 +08:00
|
|
|
"github.com/seaweedfs/seaweedfs/weed/util"
|
2022-03-13 14:38:14 +08:00
|
|
|
)
|
2022-02-14 11:14:34 +08:00
|
|
|
|
2024-09-04 17:25:07 +08:00
|
|
|
func (wfs *WFS) AcquireHandle(inode uint64, flags, uid, gid uint32) (fileHandle *FileHandle, status fuse.Status) {
|
2022-03-13 14:38:14 +08:00
|
|
|
var entry *filer_pb.Entry
|
2024-09-17 12:02:21 +08:00
|
|
|
var path util.FullPath
|
|
|
|
path, _, entry, status = wfs.maybeReadEntry(inode)
|
2022-02-14 11:14:34 +08:00
|
|
|
if status == fuse.OK {
|
2024-09-17 12:02:21 +08:00
|
|
|
if wfs.wormEnabledForEntry(path, entry) && flags&fuse.O_ANYWRITE != 0 {
|
|
|
|
return nil, fuse.EPERM
|
2024-09-04 17:25:07 +08:00
|
|
|
}
|
2022-06-06 07:44:07 +08:00
|
|
|
// need to AcquireFileHandle again to ensure correct handle counter
|
2024-09-13 13:45:30 +08:00
|
|
|
fileHandle = wfs.fhMap.AcquireFileHandle(wfs, inode, entry)
|
2022-02-14 11:14:34 +08:00
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (wfs *WFS) ReleaseHandle(handleId FileHandleId) {
|
2024-09-13 13:45:30 +08:00
|
|
|
wfs.fhMap.ReleaseByHandle(handleId)
|
2022-02-14 11:14:34 +08:00
|
|
|
}
|
2022-02-14 14:50:44 +08:00
|
|
|
|
|
|
|
func (wfs *WFS) GetHandle(handleId FileHandleId) *FileHandle {
|
2024-09-13 13:45:30 +08:00
|
|
|
return wfs.fhMap.GetFileHandle(handleId)
|
2022-02-14 14:50:44 +08:00
|
|
|
}
|