-/*
+/*
Unix SMB/CIFS implementation.
SMB parameters and setup, plus a whole lot more.
-
+
Copyright (C) Jeremy Allison 2006
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
struct db_record *record;
};
-/* Internal structure in brlock.tdb.
+/* Internal structure in brlock.tdb.
The data in brlock records is an unsorted linear array of these
records. It is unnecessary to store the count as tdb provides the
size of the record */
-/*
+/*
Unix SMB/CIFS implementation.
byte range locking code
Updated to handle range splits/merges.
See if two locking contexts are equal.
****************************************************************************/
-bool brl_same_context(const struct lock_context *ctx1,
+bool brl_same_context(const struct lock_context *ctx1,
const struct lock_context *ctx2)
{
return (serverid_equal(&ctx1->pid, &ctx2->pid) &&
See if lock2 can be added when lock1 is in place.
****************************************************************************/
-static bool brl_conflict(const struct lock_struct *lck1,
+static bool brl_conflict(const struct lock_struct *lck1,
const struct lock_struct *lck2)
{
/* Ignore PENDING locks. */
}
return brl_overlap(lck1, lck2);
-}
+}
/****************************************************************************
See if lock2 can be added when lock1 is in place - when both locks are POSIX
know already match.
****************************************************************************/
-static bool brl_conflict_posix(const struct lock_struct *lck1,
+static bool brl_conflict_posix(const struct lock_struct *lck1,
const struct lock_struct *lck2)
{
#if defined(DEVELOPER)
/* One is read, the other write, or the context is different,
do they overlap ? */
return brl_overlap(lck1, lck2);
-}
+}
#if ZERO_ZERO
-static bool brl_conflict1(const struct lock_struct *lck1,
+static bool brl_conflict1(const struct lock_struct *lck1,
const struct lock_struct *lck2)
{
if (IS_PENDING_LOCK(lck1->lock_type) || IS_PENDING_LOCK(lck2->lock_type))
}
return True;
-}
+}
#endif
/****************************************************************************
if (IS_PENDING_LOCK(lck1->lock_type) || IS_PENDING_LOCK(lck2->lock_type))
return False;
- if (lck1->lock_type == READ_LOCK && lck2->lock_type == READ_LOCK)
+ if (lck1->lock_type == READ_LOCK && lck2->lock_type == READ_LOCK)
return False;
/* POSIX flavour locks never conflict here - this is only called
}
return brl_overlap(lck1, lck2);
-}
+}
/****************************************************************************
Check if an unlock overlaps a pending lock.
Compare two locks for sorting.
****************************************************************************/
-static int lock_compare(const struct lock_struct *lck1,
+static int lock_compare(const struct lock_struct *lck1,
const struct lock_struct *lck2)
{
if (lck1->start != lck2->start) {
return brl_lock_failed(fsp,plock,blocking_lock);
}
#if ZERO_ZERO
- if (plock->start == 0 && plock->size == 0 &&
+ if (plock->start == 0 && plock->size == 0 &&
locks[i].size == 0) {
break;
}
uint64_t smblctx,
struct server_id pid,
br_off start,
- br_off size,
+ br_off size,
enum brl_type lock_type,
enum brl_flavour lock_flav,
bool blocking_lock,
/* Actually delete the lock. */
if (i < br_lck->num_locks - 1) {
- memmove(&locks[i], &locks[i+1],
+ memmove(&locks[i], &locks[i+1],
sizeof(*locks)*((br_lck->num_locks-1) - i));
}
const struct lock_struct *plock)
{
VFS_FIND(brl_unlock_windows);
- return handle->fns->brl_unlock_windows_fn(handle, msg_ctx, br_lck,
+ return handle->fns->brl_unlock_windows_fn(handle, msg_ctx, br_lck,
plock);
}
uint64_t smblctx,
struct server_id pid,
br_off start,
- br_off size,
+ br_off size,
enum brl_type lock_type,
enum brl_flavour lock_flav)
{
uint64_t *psmblctx,
struct server_id pid,
br_off *pstart,
- br_off *psize,
+ br_off *psize,
enum brl_type *plock_type,
enum brl_flavour lock_flav)
{
if (exlock->lock_flav == WINDOWS_LOCK) {
conflict = brl_conflict(exlock, &lock);
- } else {
+ } else {
conflict = brl_conflict_posix(exlock, &lock);
}
if (i < br_lck->num_locks - 1) {
/* Found this particular pending lock - delete it */
- memmove(&locks[i], &locks[i+1],
+ memmove(&locks[i], &locks[i+1],
sizeof(*locks)*((br_lck->num_locks-1) - i));
}
return True;
}
- /*
+ /*
to account for unclean shutdowns by clients we need a
maximum timeout that we use for checking pending locks. If
we have any pending locks at all, then check if the pending
blr->lock_type = lock_type;
blr->offset = offset;
blr->count = count;
-
+
/* Specific brl_lock() implementations can fill this in. */
blr->blr_private = NULL;
}
/****************************************************************************
- Return a lock fail error for a lockingX call. Undo all the locks we have
+ Return a lock fail error for a lockingX call. Undo all the locks we have
obtained first.
*****************************************************************************/
data = discard_const_p(uint8_t, blr->req->buf)
+ ((large_file_format ? 20 : 10)*num_ulocks);
- /*
+ /*
* Data now points at the beginning of the list
* of smb_lkrng structs.
*/
data = discard_const_p(uint8_t, blr->req->buf)
+ ((large_file_format ? 20 : 10)*num_ulocks);
- /*
+ /*
* Data now points at the beginning of the list
* of smb_lkrng structs.
*/
if (ERROR_WAS_LOCK_DENIED(status)) {
/* Still can't get the lock, just keep waiting. */
return False;
- }
+ }
/*
* We have other than a "can't get lock"
* error. Send an error and return True so we get dequeued.