summaryrefslogtreecommitdiff
path: root/source3/locking
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2001-09-06 01:19:35 +0000
committerAndrew Tridgell <tridge@samba.org>2001-09-06 01:19:35 +0000
commit9ef7a6c7865c14480139188c30744914c5b7af43 (patch)
tree61be92b85a5b9eb70fcfe426c5c6e3ddaaae4ce1 /source3/locking
parent851e60c3825c6d3398973b20374feb1806a22238 (diff)
downloadsamba-9ef7a6c7865c14480139188c30744914c5b7af43.tar.gz
samba-9ef7a6c7865c14480139188c30744914c5b7af43.tar.bz2
samba-9ef7a6c7865c14480139188c30744914c5b7af43.zip
use NTSTATUS not BOOL in do_lock()
(This used to be commit b1b2a5fa5d084dad8ae47777419ab75db1e51eff)
Diffstat (limited to 'source3/locking')
-rw-r--r--source3/locking/brlock.c24
-rw-r--r--source3/locking/locking.c21
2 files changed, 24 insertions, 21 deletions
diff --git a/source3/locking/brlock.c b/source3/locking/brlock.c
index e21effe6eb..f4c41d0349 100644
--- a/source3/locking/brlock.c
+++ b/source3/locking/brlock.c
@@ -278,15 +278,16 @@ static int lock_compare(struct lock_struct *lck1,
Lock a range of bytes.
****************************************************************************/
-BOOL brl_lock(SMB_DEV_T dev, SMB_INO_T ino, int fnum,
- uint16 smbpid, pid_t pid, uint16 tid,
- br_off start, br_off size,
- enum brl_type lock_type)
+NTSTATUS brl_lock(SMB_DEV_T dev, SMB_INO_T ino, int fnum,
+ uint16 smbpid, pid_t pid, uint16 tid,
+ br_off start, br_off size,
+ enum brl_type lock_type)
{
TDB_DATA kbuf, dbuf;
int count, i;
struct lock_struct lock, *locks;
char *tp;
+ NTSTATUS status = NT_STATUS_OK;
kbuf = locking_key(dev,ino);
@@ -295,7 +296,7 @@ BOOL brl_lock(SMB_DEV_T dev, SMB_INO_T ino, int fnum,
#if !ZERO_ZERO
if (start == 0 && size == 0) {
DEBUG(0,("client sent 0/0 lock - please report this\n"));
- return False;
+ return NT_STATUS_INVALID_PARAMETER;
}
#endif
@@ -316,6 +317,7 @@ BOOL brl_lock(SMB_DEV_T dev, SMB_INO_T ino, int fnum,
count = dbuf.dsize / sizeof(*locks);
for (i=0; i<count; i++) {
if (brl_conflict(&locks[i], &lock)) {
+ status = NT_STATUS_LOCK_NOT_GRANTED;
goto fail;
}
#if ZERO_ZERO
@@ -329,8 +331,12 @@ BOOL brl_lock(SMB_DEV_T dev, SMB_INO_T ino, int fnum,
/* no conflicts - add it to the list of locks */
tp = Realloc(dbuf.dptr, dbuf.dsize + sizeof(*locks));
- if (!tp) goto fail;
- else dbuf.dptr = tp;
+ if (!tp) {
+ status = NT_STATUS_NO_MEMORY;
+ goto fail;
+ } else {
+ dbuf.dptr = tp;
+ }
memcpy(dbuf.dptr + dbuf.dsize, &lock, sizeof(lock));
dbuf.dsize += sizeof(lock);
@@ -343,12 +349,12 @@ BOOL brl_lock(SMB_DEV_T dev, SMB_INO_T ino, int fnum,
free(dbuf.dptr);
tdb_chainunlock(tdb, kbuf);
- return True;
+ return NT_STATUS_OK;
fail:
if (dbuf.dptr) free(dbuf.dptr);
tdb_chainunlock(tdb, kbuf);
- return False;
+ return status;
}
/****************************************************************************
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index d2bfc08dd3..a1e4ba6d6c 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -102,7 +102,7 @@ BOOL is_locked(files_struct *fsp,connection_struct *conn,
NTSTATUS do_lock(files_struct *fsp,connection_struct *conn, uint16 lock_pid,
SMB_BIG_UINT count,SMB_BIG_UINT offset,enum brl_type lock_type)
{
- BOOL ok = False;
+ NTSTATUS status;
if (!lp_locking(SNUM(conn)))
return NT_STATUS_OK;
@@ -114,12 +114,12 @@ NTSTATUS do_lock(files_struct *fsp,connection_struct *conn, uint16 lock_pid,
lock_type_name(lock_type), (double)offset, (double)count, fsp->fsp_name ));
if (OPEN_FSP(fsp) && fsp->can_lock && (fsp->conn == conn)) {
- ok = brl_lock(fsp->dev, fsp->inode, fsp->fnum,
- lock_pid, sys_getpid(), conn->cnum,
- offset, count,
- lock_type);
+ status = brl_lock(fsp->dev, fsp->inode, fsp->fnum,
+ lock_pid, sys_getpid(), conn->cnum,
+ offset, count,
+ lock_type);
- if (ok && lp_posix_locking(SNUM(conn))) {
+ if (NT_STATUS_IS_OK(status) && lp_posix_locking(SNUM(conn))) {
/*
* Try and get a POSIX lock on this range.
@@ -127,9 +127,8 @@ NTSTATUS do_lock(files_struct *fsp,connection_struct *conn, uint16 lock_pid,
* overlapping on a different fd. JRA.
*/
- ok = set_posix_lock(fsp, offset, count, lock_type);
-
- if (!ok) {
+ if (!set_posix_lock(fsp, offset, count, lock_type)) {
+ status = NT_STATUS_LOCK_NOT_GRANTED;
/*
* We failed to map - we must now remove the brl
* lock entry.
@@ -141,9 +140,7 @@ NTSTATUS do_lock(files_struct *fsp,connection_struct *conn, uint16 lock_pid,
}
}
- if (!ok) return NT_STATUS_FILE_LOCK_CONFLICT;
-
- return NT_STATUS_OK; /* Got lock */
+ return status;
}
/****************************************************************************