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 2 of the License, or
+ 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,
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, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
Revision History:
False if not.
****************************************************************************/
-static BOOL posix_lock_in_range(SMB_OFF_T *offset_out, SMB_OFF_T *count_out,
+static bool posix_lock_in_range(SMB_OFF_T *offset_out, SMB_OFF_T *count_out,
SMB_BIG_UINT u_offset, SMB_BIG_UINT u_count)
{
SMB_OFF_T offset = (SMB_OFF_T)u_offset;
broken NFS implementations.
****************************************************************************/
-static BOOL posix_fcntl_lock(files_struct *fsp, int op, SMB_OFF_T offset, SMB_OFF_T count, int type)
+static bool posix_fcntl_lock(files_struct *fsp, int op, SMB_OFF_T offset, SMB_OFF_T count, int type)
{
- BOOL ret;
+ bool ret;
DEBUG(8,("posix_fcntl_lock %d %d %.0f %.0f %d\n",fsp->fh->fd,op,(double)offset,(double)count,type));
DEBUG(0,("posix_fcntl_lock: WARNING: lock request at offset %.0f, length %.0f returned\n",
(double)offset,(double)count));
- DEBUG(0,("an %s error. This can happen when using 64 bit lock offsets\n", strerror(errno)));
- DEBUG(0,("on 32 bit NFS mounted file systems.\n"));
+ DEBUGADD(0,("an %s error. This can happen when using 64 bit lock offsets\n", strerror(errno)));
+ DEBUGADD(0,("on 32 bit NFS mounted file systems.\n"));
/*
* If the offset is > 0x7FFFFFFF then this will cause problems on
broken NFS implementations.
****************************************************************************/
-static BOOL posix_fcntl_getlock(files_struct *fsp, SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype)
+static bool posix_fcntl_getlock(files_struct *fsp, SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype)
{
pid_t pid;
- BOOL ret;
+ bool ret;
DEBUG(8,("posix_fcntl_getlock %d %.0f %.0f %d\n",
fsp->fh->fd,(double)*poffset,(double)*pcount,*ptype));
DEBUG(0,("posix_fcntl_getlock: WARNING: lock request at offset %.0f, length %.0f returned\n",
(double)*poffset,(double)*pcount));
- DEBUG(0,("an %s error. This can happen when using 64 bit lock offsets\n", strerror(errno)));
- DEBUG(0,("on 32 bit NFS mounted file systems.\n"));
+ DEBUGADD(0,("an %s error. This can happen when using 64 bit lock offsets\n", strerror(errno)));
+ DEBUGADD(0,("on 32 bit NFS mounted file systems.\n"));
/*
* If the offset is > 0x7FFFFFFF then this will cause problems on
region is locked, False otherwise.
****************************************************************************/
-BOOL is_posix_locked(files_struct *fsp,
+bool is_posix_locked(files_struct *fsp,
SMB_BIG_UINT *pu_offset,
SMB_BIG_UINT *pu_count,
enum brl_type *plock_type,
/* The key used in the in-memory POSIX databases. */
struct lock_ref_count_key {
- SMB_DEV_T device;
- SMB_INO_T inode;
+ struct file_id id;
char r;
};
-struct fd_key {
- SMB_DEV_T device;
- SMB_INO_T inode;
-};
-
/*******************************************************************
Form a static locking key for a dev/inode pair for the fd array.
******************************************************************/
-static TDB_DATA fd_array_key(SMB_DEV_T dev, SMB_INO_T inode)
+static TDB_DATA fd_array_key(struct file_id id)
{
- static struct fd_key key;
+ static struct file_id key;
TDB_DATA kbuf;
-
- memset(&key, '\0', sizeof(key));
- key.device = dev;
- key.inode = inode;
+ key = id;
kbuf.dptr = (uint8 *)&key;
kbuf.dsize = sizeof(key);
return kbuf;
Form a static locking key for a dev/inode pair for the lock ref count
******************************************************************/
-static TDB_DATA locking_ref_count_key(SMB_DEV_T dev, SMB_INO_T inode)
+static TDB_DATA locking_ref_count_key(struct file_id id)
{
static struct lock_ref_count_key key;
TDB_DATA kbuf;
memset(&key, '\0', sizeof(key));
- key.device = dev;
- key.inode = inode;
+ key.id = id;
key.r = 'r';
kbuf.dptr = (uint8 *)&key;
kbuf.dsize = sizeof(key);
static TDB_DATA fd_array_key_fsp(files_struct *fsp)
{
- return fd_array_key(fsp->dev, fsp->inode);
+ return fd_array_key(fsp->file_id);
}
/*******************************************************************
static TDB_DATA locking_ref_count_key_fsp(files_struct *fsp)
{
- return locking_ref_count_key(fsp->dev, fsp->inode);
+ return locking_ref_count_key(fsp->file_id);
}
/*******************************************************************
Create the in-memory POSIX lock databases.
********************************************************************/
-BOOL posix_locking_init(int read_only)
+bool posix_locking_init(int read_only)
{
if (posix_pending_close_tdb) {
return True;
Delete the in-memory POSIX lock databases.
********************************************************************/
-BOOL posix_locking_end(void)
+bool posix_locking_end(void)
{
if (posix_pending_close_tdb && tdb_close(posix_pending_close_tdb) != 0) {
return False;
if (dbuf.dptr == NULL) {
dbuf.dptr = (uint8 *)SMB_MALLOC_P(int);
if (!dbuf.dptr) {
- smb_panic("increment_windows_lock_ref_count: malloc fail.\n");
+ smb_panic("increment_windows_lock_ref_count: malloc fail");
}
memset(dbuf.dptr, '\0', sizeof(int));
dbuf.dsize = sizeof(int);
memcpy(dbuf.dptr, &lock_ref_count, sizeof(int));
if (tdb_store(posix_pending_close_tdb, kbuf, dbuf, TDB_REPLACE) == -1) {
- smb_panic("increment_windows_lock_ref_count: tdb_store_fail.\n");
+ smb_panic("increment_windows_lock_ref_count: tdb_store_fail");
}
SAFE_FREE(dbuf.dptr);
dbuf = tdb_fetch(posix_pending_close_tdb, kbuf);
if (!dbuf.dptr) {
- smb_panic("decrement_windows_lock_ref_count: logic error.\n");
+ smb_panic("decrement_windows_lock_ref_count: logic error");
}
memcpy(&lock_ref_count, dbuf.dptr, sizeof(int));
memcpy(dbuf.dptr, &lock_ref_count, sizeof(int));
if (lock_ref_count < 0) {
- smb_panic("decrement_windows_lock_ref_count: lock_count logic error.\n");
+ smb_panic("decrement_windows_lock_ref_count: lock_count logic error");
}
if (tdb_store(posix_pending_close_tdb, kbuf, dbuf, TDB_REPLACE) == -1) {
- smb_panic("decrement_windows_lock_ref_count: tdb_store_fail.\n");
+ smb_panic("decrement_windows_lock_ref_count: tdb_store_fail");
}
SAFE_FREE(dbuf.dptr);
lock_ref_count -= dcount;
if (lock_ref_count < 0) {
- smb_panic("reduce_windows_lock_ref_count: lock_count logic error.\n");
+ smb_panic("reduce_windows_lock_ref_count: lock_count logic error");
}
memcpy(dbuf.dptr, &lock_ref_count, sizeof(int));
if (tdb_store(posix_pending_close_tdb, kbuf, dbuf, TDB_REPLACE) == -1) {
- smb_panic("reduce_windows_lock_ref_count: tdb_store_fail.\n");
+ smb_panic("reduce_windows_lock_ref_count: tdb_store_fail");
}
SAFE_FREE(dbuf.dptr);
dbuf.dptr = (uint8 *)SMB_REALLOC(dbuf.dptr, dbuf.dsize + sizeof(int));
if (!dbuf.dptr) {
- smb_panic("add_fd_to_close_entry: Realloc fail !\n");
+ smb_panic("add_fd_to_close_entry: SMB_REALLOC failed");
}
memcpy(dbuf.dptr + dbuf.dsize, &fsp->fh->fd, sizeof(int));
dbuf.dsize += sizeof(int);
if (tdb_store(posix_pending_close_tdb, kbuf, dbuf, TDB_REPLACE) == -1) {
- smb_panic("add_fd_to_close_entry: tdb_store_fail.\n");
+ smb_panic("add_fd_to_close_entry: tdb_store_fail");
}
DEBUG(10,("add_fd_to_close_entry: added fd %d file %s\n",
TDB_DATA kbuf = fd_array_key_fsp(fsp);
if (tdb_delete(posix_pending_close_tdb, kbuf) == -1) {
- smb_panic("delete_close_entries: tdb_delete fail !\n");
+ smb_panic("delete_close_entries: tdb_delete failed");
}
}
*/
ret = SMB_VFS_CLOSE(fsp,fsp->fh->fd);
fsp->fh->fd = -1;
- return map_nt_error_from_unix(errno);
+ if (ret == -1) {
+ return map_nt_error_from_unix(errno);
+ }
+ return NT_STATUS_OK;
}
if (get_windows_lock_ref_count(fsp)) {
pstring msg;
slprintf(msg, sizeof(msg)-1, "logic flaw in cases: l_curr: start = %.0f, size = %.0f : \
-lock: start = %.0f, size = %.0f\n", (double)l_curr->start, (double)l_curr->size, (double)lock->start, (double)lock->size );
+lock: start = %.0f, size = %.0f", (double)l_curr->start, (double)l_curr->size, (double)lock->start, (double)lock->size );
smb_panic(msg);
}
lock could be granted, False if not.
****************************************************************************/
-BOOL set_posix_lock_windows_flavour(files_struct *fsp,
+bool set_posix_lock_windows_flavour(files_struct *fsp,
SMB_BIG_UINT u_offset,
SMB_BIG_UINT u_count,
enum brl_type lock_type,
SMB_OFF_T offset;
SMB_OFF_T count;
int posix_lock_type = map_posix_lock_type(fsp,lock_type);
- BOOL ret = True;
+ bool ret = True;
size_t lock_count;
TALLOC_CTX *l_ctx = NULL;
struct lock_list *llist = NULL;
lock could be released, False if not.
****************************************************************************/
-BOOL release_posix_lock_windows_flavour(files_struct *fsp,
+bool release_posix_lock_windows_flavour(files_struct *fsp,
SMB_BIG_UINT u_offset,
SMB_BIG_UINT u_count,
enum brl_type deleted_lock_type,
{
SMB_OFF_T offset;
SMB_OFF_T count;
- BOOL ret = True;
+ bool ret = True;
TALLOC_CTX *ul_ctx = NULL;
struct lock_list *ulist = NULL;
struct lock_list *ul = NULL;
upper layer would have refused it.
****************************************************************************/
-BOOL set_posix_lock_posix_flavour(files_struct *fsp,
+bool set_posix_lock_posix_flavour(files_struct *fsp,
SMB_BIG_UINT u_offset,
SMB_BIG_UINT u_count,
enum brl_type lock_type,
have a different lock context.
****************************************************************************/
-BOOL release_posix_lock_posix_flavour(files_struct *fsp,
+bool release_posix_lock_posix_flavour(files_struct *fsp,
SMB_BIG_UINT u_offset,
SMB_BIG_UINT u_count,
const struct lock_context *lock_ctx,
const struct lock_struct *plocks,
int num_locks)
{
- BOOL ret = True;
+ bool ret = True;
SMB_OFF_T offset;
SMB_OFF_T count;
TALLOC_CTX *ul_ctx = NULL;