From 2b82ddea166bf558664d9737b4739e99303d33a6 Mon Sep 17 00:00:00 2001 From: Pavel Semerad Date: Mon, 4 Jun 2001 23:29:00 +0000 Subject: [PATCH] linux24-use-flock64-instead-of-flock-20010604 "locking on linux 2.4.x does not work. 2.4.x uses internally 64bit offsets (start and end of lock) and end is set to 64 bit int max. When it converts to struct flock, len is set to 0xffffffff (cut off high 32 bits) and afs_lockctl decides it is byte-range locking. So on 2.4.x kernel there should be used flock64 instead of flock (flock64 is typedef to flock on 64bit systems such as sparc64 and ia64)" ==================== This delta was composed from multiple commits as part of the CVS->Git migration. The checkin message with each commit was inconsistent. The following are the additional commit messages. ==================== use flock64 for linux24 --- src/afs/LINUX/osi_vnodeops.c | 4 ++++ src/afs/VNOPS/afs_vnop_flock.c | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c index 8223ea992..c13010992 100644 --- a/src/afs/LINUX/osi_vnodeops.c +++ b/src/afs/LINUX/osi_vnodeops.c @@ -508,7 +508,11 @@ static int afs_linux_lock(struct file *fp, int cmd, struct file_lock *flp) int code = 0; struct vcache *vcp = (struct vcache*)FILE_INODE(fp); cred_t *credp = crref(); +#ifdef AFS_LINUX24_ENV + struct flock64 flock; +#else struct flock flock; +#endif /* Convert to a lock format afs_lockctl understands. */ memset((char*)&flock, 0, sizeof(flock)); diff --git a/src/afs/VNOPS/afs_vnop_flock.c b/src/afs/VNOPS/afs_vnop_flock.c index 35375b511..43869f77d 100644 --- a/src/afs/VNOPS/afs_vnop_flock.c +++ b/src/afs/VNOPS/afs_vnop_flock.c @@ -23,7 +23,7 @@ #if defined(AFS_HPUX102_ENV) #define AFS_FLOCK k_flock #else -#if defined(AFS_SUN56_ENV) +#if defined(AFS_SUN56_ENV) || defined(AFS_LINUX24_ENV) #define AFS_FLOCK flock64 #else #define AFS_FLOCK flock @@ -534,11 +534,16 @@ struct AFS_UCRED *acred; { with it in. However, they fail in race conditions. The question is what to do for people who don't have source to their application; this way at least, they can get work done */ +#ifdef AFS_LINUX24_ENV + if (af->l_len == OFFSET_MAX) + af->l_len = 0; /* since some systems indicate it as EOF */ +#else if (af->l_len == 0x7fffffff) af->l_len = 0; /* since some systems indicate it as EOF */ #ifdef AFS_LINUX_64BIT_KERNEL if (af->l_len == LONG_MAX) af->l_len = 0; /* since some systems indicate it as EOF */ +#endif #endif /* next line makes byte range locks always succeed, even when they should block */ -- 2.39.5