6628575: (fc) lock/tryLock methods do not work with NFS servers that limit lock range to max file size
Reviewed-by: sherman
--- a/jdk/src/solaris/native/sun/nio/ch/FileChannelImpl.c Tue Mar 11 14:49:53 2008 +0000
+++ b/jdk/src/solaris/native/sun/nio/ch/FileChannelImpl.c Thu Mar 13 19:29:41 2008 +0000
@@ -31,6 +31,7 @@
#include <sys/stat.h>
#include "sun_nio_ch_FileChannelImpl.h"
#include "java_lang_Integer.h"
+#include "java_lang_Long.h"
#include "nio.h"
#include "nio_util.h"
#include <dlfcn.h>
@@ -291,7 +292,11 @@
struct flock64 fl;
fl.l_whence = SEEK_SET;
- fl.l_len = (off64_t)size;
+ if (size == (jlong)java_lang_Long_MAX_VALUE) {
+ fl.l_len = (off64_t)0;
+ } else {
+ fl.l_len = (off64_t)size;
+ }
fl.l_start = (off64_t)pos;
if (shared == JNI_TRUE) {
fl.l_type = F_RDLCK;
@@ -325,7 +330,11 @@
int cmd = F_SETLK64;
fl.l_whence = SEEK_SET;
- fl.l_len = (off64_t)size;
+ if (size == (jlong)java_lang_Long_MAX_VALUE) {
+ fl.l_len = (off64_t)0;
+ } else {
+ fl.l_len = (off64_t)size;
+ }
fl.l_start = (off64_t)pos;
fl.l_type = F_UNLCK;
lockResult = fcntl(fd, cmd, &fl);