summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/vfs/lock.go
diff options
context:
space:
mode:
authorDean Deng <deandeng@google.com>2021-01-20 16:51:59 -0800
committergVisor bot <gvisor-bot@google.com>2021-01-20 16:55:07 -0800
commit55332aca95a55378957f89a10f21d9d1714070a5 (patch)
tree409f45199da64097861facecf65db3f5621ce27b /pkg/sentry/vfs/lock.go
parentca9a45f282a08a88df19c93d5968d720b5153c41 (diff)
Move Lock/UnlockPOSIX into LockFD util.
PiperOrigin-RevId: 352904728
Diffstat (limited to 'pkg/sentry/vfs/lock.go')
-rw-r--r--pkg/sentry/vfs/lock.go16
1 files changed, 4 insertions, 12 deletions
diff --git a/pkg/sentry/vfs/lock.go b/pkg/sentry/vfs/lock.go
index 1ff202f2a..bcff35792 100644
--- a/pkg/sentry/vfs/lock.go
+++ b/pkg/sentry/vfs/lock.go
@@ -61,12 +61,8 @@ func (fl *FileLocks) UnlockBSD(uid fslock.UniqueID) {
}
// LockPOSIX tries to acquire a POSIX-style lock on a file region.
-func (fl *FileLocks) LockPOSIX(ctx context.Context, fd *FileDescription, uid fslock.UniqueID, t fslock.LockType, start, length uint64, whence int16, block fslock.Blocker) error {
- rng, err := computeRange(ctx, fd, start, length, whence)
- if err != nil {
- return err
- }
- if fl.posix.LockRegion(uid, t, rng, block) {
+func (fl *FileLocks) LockPOSIX(ctx context.Context, uid fslock.UniqueID, t fslock.LockType, r fslock.LockRange, block fslock.Blocker) error {
+ if fl.posix.LockRegion(uid, t, r, block) {
return nil
}
@@ -82,12 +78,8 @@ func (fl *FileLocks) LockPOSIX(ctx context.Context, fd *FileDescription, uid fsl
//
// This operation is always successful, even if there did not exist a lock on
// the requested region held by uid in the first place.
-func (fl *FileLocks) UnlockPOSIX(ctx context.Context, fd *FileDescription, uid fslock.UniqueID, start, length uint64, whence int16) error {
- rng, err := computeRange(ctx, fd, start, length, whence)
- if err != nil {
- return err
- }
- fl.posix.UnlockRegion(uid, rng)
+func (fl *FileLocks) UnlockPOSIX(ctx context.Context, uid fslock.UniqueID, r fslock.LockRange) error {
+ fl.posix.UnlockRegion(uid, r)
return nil
}