Fixes for HPUX only having limited POSIX lock range from Michael Steffens <michael...
authorJeremy Allison <jra@samba.org>
Wed, 12 Feb 2003 20:40:29 +0000 (20:40 +0000)
committerJeremy Allison <jra@samba.org>
Wed, 12 Feb 2003 20:40:29 +0000 (20:40 +0000)
Jeremy.
(This used to be commit e9b4fb8b9aedda9afc01af976264298002be3096)

source3/configure.in
source3/locking/posix.c

index d57495a67adae8bc162af5f4354ad82bd56b4d62..7952a5070f7ff45230145bb41799eb9653993a74 100644 (file)
@@ -247,7 +247,7 @@ case "$host_os" in
 #
       case `uname -r` in
                        *9*|*10*)
-                               CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_POSIX_SOURCE -D_ALIGNMENT_REQUIRED=1 -D_MAX_ALIGNMENT=4"
+                               CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_POSIX_SOURCE -D_ALIGNMENT_REQUIRED=1 -D_MAX_ALIGNMENT=4 -DMAX_POSITIVE_LOCK_OFFSET=0x1ffffffffffLL"
                                AC_DEFINE(USE_BOTH_CRYPT_CALLS, 1, [Whether to use both of HPUX' crypt calls])
                                AC_DEFINE(_HPUX_SOURCE, 1, [Whether to use HPUX extensions])
                                AC_DEFINE(_POSIX_SOURCE, 1, [Whether to use POSIX compatible functions])
@@ -255,7 +255,7 @@ case "$host_os" in
                                AC_DEFINE(_MAX_ALIGNMENT,4,[Maximum alignment])
                                ;;
                        *11*)
-                               CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_POSIX_SOURCE -D_LARGEFILE64_SOURCE -D_ALIGNMENT_REQUIRED=1 -D_MAX_ALIGNMENT=4"
+                               CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_POSIX_SOURCE -D_LARGEFILE64_SOURCE -D_ALIGNMENT_REQUIRED=1 -D_MAX_ALIGNMENT=4 -DMAX_POSITIVE_LOCK_OFFSET=0x1ffffffffffLL"
                                AC_DEFINE(USE_BOTH_CRYPT_CALLS, 1, [Whether to use both of HPUX' crypt calls])
                                AC_DEFINE(_HPUX_SOURCE, 1, [Whether to use HPUX extensions])
                                AC_DEFINE(_POSIX_SOURCE, 1, [Whether to use POSIX compatible functions])
index fcf19d21cfedfeb99ab269aac1bfcc999f653d02..2b64631d39afb629283027b10fdbc0ccfe78dd33 100644 (file)
@@ -552,7 +552,11 @@ static BOOL posix_lock_in_range(SMB_OFF_T *offset_out, SMB_OFF_T *count_out,
         * find the maximum positive lock offset as an SMB_OFF_T.
         */
 
-#if defined(LARGE_SMB_OFF_T) && !defined(HAVE_BROKEN_FCNTL64_LOCKS)
+#if defined(MAX_POSITIVE_LOCK_OFFSET) /* Some systems have arbitrary limits. */
+
+       SMB_OFF_T max_positive_lock_offset = (MAX_POSITIVE_LOCK_OFFSET);
+
+#elif defined(LARGE_SMB_OFF_T) && !defined(HAVE_BROKEN_FCNTL64_LOCKS)
 
        /*
         * In this case SMB_OFF_T is 64 bits,
@@ -598,19 +602,10 @@ static BOOL posix_lock_in_range(SMB_OFF_T *offset_out, SMB_OFF_T *count_out,
        }
 
        /*
-        * We must truncate the offset and count to less than max_positive_lock_offset.
-        */
-
-       offset &= max_positive_lock_offset;
-       count &= max_positive_lock_offset;
-
-
-       /*
-        * Deal with a very common case of count of all ones.
-        * (lock entire file).
+        * We must truncate the count to less than max_positive_lock_offset.
         */
 
-       if(count == (SMB_OFF_T)-1)
+       if (u_count & ~((SMB_BIG_UINT)max_positive_lock_offset))
                count = max_positive_lock_offset;
 
        /*