summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>2000-04-03 11:30:14 +0000
committerLuke Leighton <lkcl@samba.org>2000-04-03 11:30:14 +0000
commit70eedfacb2efa41aaaadbff355e11ee7f2f7c1bd (patch)
tree0decdd364b7c48b05992a1649da1e60c87d2d85e
parentbf1eb182cd5fad4225b85cbf9c06e0c0250fd1b4 (diff)
downloadsamba-70eedfacb2efa41aaaadbff355e11ee7f2f7c1bd.tar.gz
lock functions in wrong place (and static!)
-rw-r--r--source/lib/util_file.c254
-rw-r--r--source/smbd/reply.c254
2 files changed, 254 insertions, 254 deletions
diff --git a/source/lib/util_file.c b/source/lib/util_file.c
index b6bd73f0454..47069463ff4 100644
--- a/source/lib/util_file.c
+++ b/source/lib/util_file.c
@@ -109,6 +109,260 @@ BOOL file_unlock(int fd, int *plock_depth)
}
/****************************************************************************
+ Pathetically try and map a 64 bit lock offset into 31 bits. I hate Windows :-).
+****************************************************************************/
+uint32 map_lock_offset(uint32 high, uint32 low)
+{
+ unsigned int i;
+ uint32 mask = 0;
+ uint32 highcopy = high;
+
+ /*
+ * Try and find out how many significant bits there are in high.
+ */
+
+ for (i = 0; highcopy; i++)
+ highcopy >>= 1;
+
+ /*
+ * We use 31 bits not 32 here as POSIX
+ * lock offsets may not be negative.
+ */
+
+ mask = (~0) << (31 - i);
+
+ if (low & mask)
+ return 0; /* Fail. */
+
+ high <<= (31 - i);
+
+ return (high | low);
+}
+
+/****************************************************************************
+ Get a lock count, dealing with large count requests.
+****************************************************************************/
+
+SMB_OFF_T get_lock_count(char *data, int data_offset, BOOL large_file_format,
+ BOOL *err)
+{
+ SMB_OFF_T count = 0;
+
+ *err = False;
+
+ if (!large_file_format)
+ {
+ count = (SMB_OFF_T) IVAL(data, SMB_LKLEN_OFFSET(data_offset));
+ }
+ else
+ {
+
+#if defined(LARGE_SMB_OFF_T) && !defined(HAVE_BROKEN_FCNTL64_LOCKS)
+
+ count =
+ (((SMB_OFF_T)
+ IVAL(data,
+ SMB_LARGE_LKLEN_OFFSET_HIGH(data_offset))) <<
+ 32) | ((SMB_OFF_T) IVAL(data,
+ SMB_LARGE_LKLEN_OFFSET_LOW
+ (data_offset)));
+
+#else /* !LARGE_SMB_OFF_T || HAVE_BROKEN_FCNTL64_LOCKS */
+
+ /*
+ * NT4.x seems to be broken in that it sends large file
+ * lockingX calls even if the CAP_LARGE_FILES was *not*
+ * negotiated. For boxes without large file locks truncate the
+ * lock count by dropping the top 32 bits.
+ */
+
+ if (IVAL(data, SMB_LARGE_LKLEN_OFFSET_HIGH(data_offset)) != 0)
+ {
+ DEBUG(3,
+ ("get_lock_count: truncating lock count (high)0x%x (low)0x%x to just low count.\n",
+ (unsigned int)IVAL(data,
+ SMB_LARGE_LKLEN_OFFSET_HIGH
+ (data_offset)),
+ (unsigned int)IVAL(data,
+ SMB_LARGE_LKLEN_OFFSET_LOW
+ (data_offset))));
+ SIVAL(data, SMB_LARGE_LKLEN_OFFSET_HIGH(data_offset),
+ 0);
+ }
+
+ if (IVAL(data, SMB_LARGE_LKLEN_OFFSET_HIGH(data_offset)) != 0)
+ {
+ /*
+ * Before we error out, see if we can sensibly map the top bits
+ * down to the lower bits - or lose the top bits if they are all 1's.
+ * It seems that NT has this horrible bug where it will send 64 bit
+ * lock requests even if told not to. JRA.
+ */
+
+ if (IVAL
+ (data,
+ SMB_LARGE_LKLEN_OFFSET_LOW(data_offset)) ==
+ (uint32)0xFFFFFFFF)
+ count =
+ (SMB_OFF_T) IVAL(data,
+ SMB_LARGE_LKLEN_OFFSET_HIGH
+ (data_offset));
+ else
+ if (IVAL
+ (data,
+ SMB_LARGE_LKLEN_OFFSET_HIGH(data_offset))
+ == (uint32)0xFFFFFFFF)
+ count =
+ (SMB_OFF_T) IVAL(data,
+ SMB_LARGE_LKLEN_OFFSET_LOW
+ (data_offset));
+ else
+ {
+
+ DEBUG(0,
+ ("get_lock_count: Error : a large file count (%x << 32 | %x) was sent and we don't \
+support large counts.\n",
+ (unsigned int)IVAL(data,
+ SMB_LARGE_LKLEN_OFFSET_HIGH
+ (data_offset)),
+ (unsigned int)IVAL(data,
+ SMB_LARGE_LKLEN_OFFSET_LOW
+ (data_offset))));
+
+ *err = True;
+ return (SMB_OFF_T) - 1;
+ }
+ }
+ else
+ count =
+ (SMB_OFF_T) IVAL(data,
+ SMB_LARGE_LKLEN_OFFSET_LOW
+ (data_offset));
+
+#endif /* LARGE_SMB_OFF_T */
+ }
+ return count;
+}
+
+/****************************************************************************
+ Get a lock offset, dealing with large offset requests.
+****************************************************************************/
+
+SMB_OFF_T get_lock_offset(char *data, int data_offset, BOOL large_file_format,
+ BOOL *err)
+{
+ SMB_OFF_T offset = 0;
+
+ *err = False;
+
+ if (!large_file_format)
+ {
+ offset =
+ (SMB_OFF_T) IVAL(data, SMB_LKOFF_OFFSET(data_offset));
+ }
+ else
+ {
+
+#if defined(LARGE_SMB_OFF_T) && !defined(HAVE_BROKEN_FCNTL64_LOCKS)
+
+ offset =
+ (((SMB_OFF_T)
+ IVAL(data,
+ SMB_LARGE_LKOFF_OFFSET_HIGH(data_offset))) <<
+ 32) | ((SMB_OFF_T) IVAL(data,
+ SMB_LARGE_LKOFF_OFFSET_LOW
+ (data_offset)));
+
+#else /* !LARGE_SMB_OFF_T || HAVE_BROKEN_FCNTL64_LOCKS */
+
+ /*
+ * NT4.x seems to be broken in that it sends large file
+ * lockingX calls even if the CAP_LARGE_FILES was *not*
+ * negotiated. For boxes without large file locks mangle the
+ * lock offset by mapping the top 32 bits onto the lower 32.
+ */
+
+ if (IVAL(data, SMB_LARGE_LKOFF_OFFSET_HIGH(data_offset)) != 0)
+ {
+ uint32 low = IVAL(data,
+ SMB_LARGE_LKOFF_OFFSET_LOW
+ (data_offset));
+ uint32 high = IVAL(data,
+ SMB_LARGE_LKOFF_OFFSET_HIGH
+ (data_offset));
+ uint32 new_low = 0;
+
+ if ((new_low = map_lock_offset(high, low)) == 0)
+ {
+ *err = True;
+ return (SMB_OFF_T) - 1;
+ }
+
+ DEBUG(3,
+ ("get_lock_offset: truncating lock offset (high)0x%x (low)0x%x to offset 0x%x.\n",
+ (unsigned int)high, (unsigned int)low,
+ (unsigned int)new_low));
+ SIVAL(data, SMB_LARGE_LKOFF_OFFSET_HIGH(data_offset),
+ 0);
+ SIVAL(data, SMB_LARGE_LKOFF_OFFSET_LOW(data_offset),
+ new_low);
+ }
+
+ if (IVAL(data, SMB_LARGE_LKOFF_OFFSET_HIGH(data_offset)) != 0)
+ {
+ /*
+ * Before we error out, see if we can sensibly map the top bits
+ * down to the lower bits - or lose the top bits if they are all 1's.
+ * It seems that NT has this horrible bug where it will send 64 bit
+ * lock requests even if told not to. JRA.
+ */
+
+ if (IVAL
+ (data,
+ SMB_LARGE_LKOFF_OFFSET_LOW(data_offset)) ==
+ (uint32)0xFFFFFFFF)
+ offset =
+ (SMB_OFF_T) IVAL(data,
+ SMB_LARGE_LKOFF_OFFSET_HIGH
+ (data_offset));
+ else
+ if (IVAL
+ (data,
+ SMB_LARGE_LKOFF_OFFSET_HIGH(data_offset))
+ == (uint32)0xFFFFFFFF)
+ offset =
+ (SMB_OFF_T) IVAL(data,
+ SMB_LARGE_LKOFF_OFFSET_LOW
+ (data_offset));
+ else
+ {
+
+ DEBUG(0,
+ ("get_lock_count: Error : a large file offset (%x << 32 | %x) was sent and we don't \
+support large offsets.\n",
+ (unsigned int)IVAL(data,
+ SMB_LARGE_LKOFF_OFFSET_HIGH
+ (data_offset)),
+ (unsigned int)IVAL(data,
+ SMB_LARGE_LKOFF_OFFSET_LOW
+ (data_offset))));
+
+ *err = True;
+ return (SMB_OFF_T) - 1;
+ }
+ }
+ else
+ offset =
+ (SMB_OFF_T) IVAL(data,
+ SMB_LARGE_LKOFF_OFFSET_LOW
+ (data_offset));
+
+#endif /* LARGE_SMB_OFF_T */
+ }
+ return offset;
+}
+
+/****************************************************************************
routine to do file locking
****************************************************************************/
diff --git a/source/smbd/reply.c b/source/smbd/reply.c
index f0bffec69a3..16d03608d44 100644
--- a/source/smbd/reply.c
+++ b/source/smbd/reply.c
@@ -4244,260 +4244,6 @@ int reply_setdir(connection_struct * conn, char *inbuf, char *outbuf,
}
/****************************************************************************
- Get a lock count, dealing with large count requests.
-****************************************************************************/
-
-SMB_OFF_T get_lock_count(char *data, int data_offset, BOOL large_file_format,
- BOOL *err)
-{
- SMB_OFF_T count = 0;
-
- *err = False;
-
- if (!large_file_format)
- {
- count = (SMB_OFF_T) IVAL(data, SMB_LKLEN_OFFSET(data_offset));
- }
- else
- {
-
-#if defined(LARGE_SMB_OFF_T) && !defined(HAVE_BROKEN_FCNTL64_LOCKS)
-
- count =
- (((SMB_OFF_T)
- IVAL(data,
- SMB_LARGE_LKLEN_OFFSET_HIGH(data_offset))) <<
- 32) | ((SMB_OFF_T) IVAL(data,
- SMB_LARGE_LKLEN_OFFSET_LOW
- (data_offset)));
-
-#else /* !LARGE_SMB_OFF_T || HAVE_BROKEN_FCNTL64_LOCKS */
-
- /*
- * NT4.x seems to be broken in that it sends large file
- * lockingX calls even if the CAP_LARGE_FILES was *not*
- * negotiated. For boxes without large file locks truncate the
- * lock count by dropping the top 32 bits.
- */
-
- if (IVAL(data, SMB_LARGE_LKLEN_OFFSET_HIGH(data_offset)) != 0)
- {
- DEBUG(3,
- ("get_lock_count: truncating lock count (high)0x%x (low)0x%x to just low count.\n",
- (unsigned int)IVAL(data,
- SMB_LARGE_LKLEN_OFFSET_HIGH
- (data_offset)),
- (unsigned int)IVAL(data,
- SMB_LARGE_LKLEN_OFFSET_LOW
- (data_offset))));
- SIVAL(data, SMB_LARGE_LKLEN_OFFSET_HIGH(data_offset),
- 0);
- }
-
- if (IVAL(data, SMB_LARGE_LKLEN_OFFSET_HIGH(data_offset)) != 0)
- {
- /*
- * Before we error out, see if we can sensibly map the top bits
- * down to the lower bits - or lose the top bits if they are all 1's.
- * It seems that NT has this horrible bug where it will send 64 bit
- * lock requests even if told not to. JRA.
- */
-
- if (IVAL
- (data,
- SMB_LARGE_LKLEN_OFFSET_LOW(data_offset)) ==
- (uint32)0xFFFFFFFF)
- count =
- (SMB_OFF_T) IVAL(data,
- SMB_LARGE_LKLEN_OFFSET_HIGH
- (data_offset));
- else
- if (IVAL
- (data,
- SMB_LARGE_LKLEN_OFFSET_HIGH(data_offset))
- == (uint32)0xFFFFFFFF)
- count =
- (SMB_OFF_T) IVAL(data,
- SMB_LARGE_LKLEN_OFFSET_LOW
- (data_offset));
- else
- {
-
- DEBUG(0,
- ("get_lock_count: Error : a large file count (%x << 32 | %x) was sent and we don't \
-support large counts.\n",
- (unsigned int)IVAL(data,
- SMB_LARGE_LKLEN_OFFSET_HIGH
- (data_offset)),
- (unsigned int)IVAL(data,
- SMB_LARGE_LKLEN_OFFSET_LOW
- (data_offset))));
-
- *err = True;
- return (SMB_OFF_T) - 1;
- }
- }
- else
- count =
- (SMB_OFF_T) IVAL(data,
- SMB_LARGE_LKLEN_OFFSET_LOW
- (data_offset));
-
-#endif /* LARGE_SMB_OFF_T */
- }
- return count;
-}
-
-/****************************************************************************
- Pathetically try and map a 64 bit lock offset into 31 bits. I hate Windows :-).
-****************************************************************************/
-static uint32 map_lock_offset(uint32 high, uint32 low)
-{
- unsigned int i;
- uint32 mask = 0;
- uint32 highcopy = high;
-
- /*
- * Try and find out how many significant bits there are in high.
- */
-
- for (i = 0; highcopy; i++)
- highcopy >>= 1;
-
- /*
- * We use 31 bits not 32 here as POSIX
- * lock offsets may not be negative.
- */
-
- mask = (~0) << (31 - i);
-
- if (low & mask)
- return 0; /* Fail. */
-
- high <<= (31 - i);
-
- return (high | low);
-}
-
-/****************************************************************************
- Get a lock offset, dealing with large offset requests.
-****************************************************************************/
-
-SMB_OFF_T get_lock_offset(char *data, int data_offset, BOOL large_file_format,
- BOOL *err)
-{
- SMB_OFF_T offset = 0;
-
- *err = False;
-
- if (!large_file_format)
- {
- offset =
- (SMB_OFF_T) IVAL(data, SMB_LKOFF_OFFSET(data_offset));
- }
- else
- {
-
-#if defined(LARGE_SMB_OFF_T) && !defined(HAVE_BROKEN_FCNTL64_LOCKS)
-
- offset =
- (((SMB_OFF_T)
- IVAL(data,
- SMB_LARGE_LKOFF_OFFSET_HIGH(data_offset))) <<
- 32) | ((SMB_OFF_T) IVAL(data,
- SMB_LARGE_LKOFF_OFFSET_LOW
- (data_offset)));
-
-#else /* !LARGE_SMB_OFF_T || HAVE_BROKEN_FCNTL64_LOCKS */
-
- /*
- * NT4.x seems to be broken in that it sends large file
- * lockingX calls even if the CAP_LARGE_FILES was *not*
- * negotiated. For boxes without large file locks mangle the
- * lock offset by mapping the top 32 bits onto the lower 32.
- */
-
- if (IVAL(data, SMB_LARGE_LKOFF_OFFSET_HIGH(data_offset)) != 0)
- {
- uint32 low = IVAL(data,
- SMB_LARGE_LKOFF_OFFSET_LOW
- (data_offset));
- uint32 high = IVAL(data,
- SMB_LARGE_LKOFF_OFFSET_HIGH
- (data_offset));
- uint32 new_low = 0;
-
- if ((new_low = map_lock_offset(high, low)) == 0)
- {
- *err = True;
- return (SMB_OFF_T) - 1;
- }
-
- DEBUG(3,
- ("get_lock_offset: truncating lock offset (high)0x%x (low)0x%x to offset 0x%x.\n",
- (unsigned int)high, (unsigned int)low,
- (unsigned int)new_low));
- SIVAL(data, SMB_LARGE_LKOFF_OFFSET_HIGH(data_offset),
- 0);
- SIVAL(data, SMB_LARGE_LKOFF_OFFSET_LOW(data_offset),
- new_low);
- }
-
- if (IVAL(data, SMB_LARGE_LKOFF_OFFSET_HIGH(data_offset)) != 0)
- {
- /*
- * Before we error out, see if we can sensibly map the top bits
- * down to the lower bits - or lose the top bits if they are all 1's.
- * It seems that NT has this horrible bug where it will send 64 bit
- * lock requests even if told not to. JRA.
- */
-
- if (IVAL
- (data,
- SMB_LARGE_LKOFF_OFFSET_LOW(data_offset)) ==
- (uint32)0xFFFFFFFF)
- offset =
- (SMB_OFF_T) IVAL(data,
- SMB_LARGE_LKOFF_OFFSET_HIGH
- (data_offset));
- else
- if (IVAL
- (data,
- SMB_LARGE_LKOFF_OFFSET_HIGH(data_offset))
- == (uint32)0xFFFFFFFF)
- offset =
- (SMB_OFF_T) IVAL(data,
- SMB_LARGE_LKOFF_OFFSET_LOW
- (data_offset));
- else
- {
-
- DEBUG(0,
- ("get_lock_count: Error : a large file offset (%x << 32 | %x) was sent and we don't \
-support large offsets.\n",
- (unsigned int)IVAL(data,
- SMB_LARGE_LKOFF_OFFSET_HIGH
- (data_offset)),
- (unsigned int)IVAL(data,
- SMB_LARGE_LKOFF_OFFSET_LOW
- (data_offset))));
-
- *err = True;
- return (SMB_OFF_T) - 1;
- }
- }
- else
- offset =
- (SMB_OFF_T) IVAL(data,
- SMB_LARGE_LKOFF_OFFSET_LOW
- (data_offset));
-
-#endif /* LARGE_SMB_OFF_T */
- }
- return offset;
-}
-
-/****************************************************************************
reply to a lockingX request
****************************************************************************/
int reply_lockingX(connection_struct * conn, char *inbuf, char *outbuf,