From 85edec7105dd653ed1d8046b69b8262281e97bba Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Thu, 10 Mar 2011 17:59:39 -0600 Subject: [PATCH] vol: Handle large volume IDs in VLockFile VLockVolumeByIdNB currently cannot handle volume IDs larger than 2^31-1. Fix this by using struct flock64, F_SETLKW64, and F_SETLK64 in the VLockFile functions where possible. Thanks to Simon Wilkinson for pointing out F_SETLK64. Change-Id: I422c685aec035716e2f42d13bd97541425ead6a2 Reviewed-on: http://gerrit.openafs.org/4198 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- src/vol/vutil.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/vol/vutil.c b/src/vol/vutil.c index 92aaad237..55e60a6fa 100644 --- a/src/vol/vutil.c +++ b/src/vol/vutil.c @@ -66,6 +66,18 @@ #include #endif +#ifndef AFS_NT40_ENV +# ifdef O_LARGEFILE +# define AFS_SETLKW F_SETLKW64 +# define AFS_SETLK F_SETLK64 +# define afs_st_flock flock64 +# else +# define AFS_SETLKW F_SETLKW +# define AFS_SETLK F_SETLK +# define afs_st_flock flock +# endif +#endif + /* Note: the volume creation functions herein leave the destroyMe flag in the volume header ON: this means that the volumes will not be attached by the file server and WILL BE DESTROYED the next time a system salvage is performed */ @@ -968,14 +980,14 @@ static_inline int _VLockFd(FD_t fd, afs_uint32 offset, int locktype, int nonblock) { int l_type = F_WRLCK; - int cmd = F_SETLKW; - struct flock sf; + int cmd = AFS_SETLKW; + struct afs_st_flock sf; if (locktype == READ_LOCK) { l_type = F_RDLCK; } if (nonblock) { - cmd = F_SETLK; + cmd = AFS_SETLK; } sf.l_start = offset; @@ -1032,14 +1044,14 @@ _VCloseFd(FD_t fd) static_inline void _VUnlockFd(FD_t fd, afs_uint32 offset) { - struct flock sf; + struct afs_st_flock sf; sf.l_start = offset; sf.l_len = 1; sf.l_type = F_UNLCK; sf.l_whence = SEEK_SET; - if (fcntl(fd, F_SETLK, &sf)) { + if (fcntl(fd, AFS_SETLK, &sf)) { Log("_VUnlockFd: fcntl failed with error %d when trying to unlock " "fd %d\n", errno, fd); } -- 2.39.5