From 623a18db4b0f46c80c29e93a0ad0a2fcbfec71dc Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 4 Sep 1998 00:23:28 +0000 Subject: More 64 bit stuff - now the fcntl locks are 64 bit clean. Nearly at the stage where I can expose the 64-bit-ness to the NT clients.... Jeremy. (This used to be commit 422f1dd45074c0e28203aca5952e57bbe56676b6) --- source3/locking/locking.c | 41 +++++++++++++++++++++++++---------------- source3/locking/locking_slow.c | 6 +++--- source3/locking/shmem.c | 8 ++++---- 3 files changed, 32 insertions(+), 23 deletions(-) (limited to 'source3/locking') diff --git a/source3/locking/locking.c b/source3/locking/locking.c index 856b7cfcf6..bd484a18b6 100644 --- a/source3/locking/locking.c +++ b/source3/locking/locking.c @@ -71,7 +71,7 @@ static int map_lock_type( files_struct *fsp, int lock_type) Utility function called to see if a file region is locked. ****************************************************************************/ BOOL is_locked(files_struct *fsp,connection_struct *conn, - uint32 count,uint32 offset, int lock_type) + SMB_OFF_T count,SMB_OFF_T offset, int lock_type) { int snum = SNUM(conn); @@ -87,7 +87,7 @@ BOOL is_locked(files_struct *fsp,connection_struct *conn, * fd. So we don't need to use map_lock_type here. */ - return(fcntl_lock(fsp->fd_ptr->fd,F_GETLK,offset,count,lock_type)); + return(fcntl_lock(fsp->fd_ptr->fd,SMB_F_GETLK,offset,count,lock_type)); } @@ -95,7 +95,7 @@ BOOL is_locked(files_struct *fsp,connection_struct *conn, Utility function called by locking requests. ****************************************************************************/ BOOL do_lock(files_struct *fsp,connection_struct *conn, - uint32 count,uint32 offset,int lock_type, + SMB_OFF_T count,SMB_OFF_T offset,int lock_type, int *eclass,uint32 *ecode) { BOOL ok = False; @@ -109,11 +109,16 @@ BOOL do_lock(files_struct *fsp,connection_struct *conn, return False; } +#ifdef LARGE_SMB_OFF_T + DEBUG(10,("do_lock: lock type %d start=%.0f len=%.0f requested for file %s\n", + lock_type, (double)offset, (double)count, fsp->fsp_name )); +#else /* LARGE_SMB_OFF_T */ DEBUG(10,("do_lock: lock type %d start=%d len=%d requested for file %s\n", lock_type, (int)offset, (int)count, fsp->fsp_name )); +#endif /* LARGE_SMB_OFF_T */ if (OPEN_FSP(fsp) && fsp->can_lock && (fsp->conn == conn)) - ok = fcntl_lock(fsp->fd_ptr->fd,F_SETLK,offset,count, + ok = fcntl_lock(fsp->fd_ptr->fd,SMB_F_SETLK,offset,count, map_lock_type(fsp,lock_type)); if (!ok) { @@ -129,18 +134,23 @@ BOOL do_lock(files_struct *fsp,connection_struct *conn, Utility function called by unlocking requests. ****************************************************************************/ BOOL do_unlock(files_struct *fsp,connection_struct *conn, - uint32 count,uint32 offset,int *eclass,uint32 *ecode) + SMB_OFF_T count,SMB_OFF_T offset,int *eclass,uint32 *ecode) { BOOL ok = False; if (!lp_locking(SNUM(conn))) return(True); +#ifdef LARGE_SMB_OFF_T + DEBUG(10,("do_unlock: unlock start=%.0f len=%.0f requested for file %s\n", + (double)offset, (double)count, fsp->fsp_name )); +#else DEBUG(10,("do_unlock: unlock start=%d len=%d requested for file %s\n", (int)offset, (int)count, fsp->fsp_name )); +#endif if (OPEN_FSP(fsp) && fsp->can_lock && (fsp->conn == conn)) - ok = fcntl_lock(fsp->fd_ptr->fd,F_SETLK,offset,count,F_UNLCK); + ok = fcntl_lock(fsp->fd_ptr->fd,SMB_F_SETLK,offset,count,F_UNLCK); if (!ok) { *eclass = ERRDOS; @@ -150,28 +160,27 @@ BOOL do_unlock(files_struct *fsp,connection_struct *conn, return True; /* Did unlock */ } - - /**************************************************************************** Initialise the locking functions. ****************************************************************************/ BOOL locking_init(int read_only) { - if (share_ops) return True; + if (share_ops) + return True; #ifdef FAST_SHARE_MODES - share_ops = locking_shm_init(read_only); + share_ops = locking_shm_init(read_only); #else - share_ops = locking_slow_init(read_only); + share_ops = locking_slow_init(read_only); #endif - if (!share_ops) { - DEBUG(0,("ERROR: Failed to initialise share modes!\n")); - return False; - } + if (!share_ops) { + DEBUG(0,("ERROR: Failed to initialise share modes!\n")); + return False; + } - return True; + return True; } /******************************************************************* diff --git a/source3/locking/locking_slow.c b/source3/locking/locking_slow.c index c242baec4a..c9b8d2a687 100644 --- a/source3/locking/locking_slow.c +++ b/source3/locking/locking_slow.c @@ -174,7 +174,7 @@ static BOOL slow_lock_share_entry(connection_struct *conn, /* At this point we have an open fd to the share mode file. Lock the first byte exclusively to signify a lock. */ - if(fcntl_lock(fd, F_SETLKW, 0, 1, F_WRLCK) == False) + if(fcntl_lock(fd, SMB_F_SETLKW, 0, 1, F_WRLCK) == False) { DEBUG(0,("ERROR lock_share_entry: fcntl_lock on file %s failed with %s\n", fname, strerror(errno))); @@ -251,7 +251,7 @@ static BOOL slow_unlock_share_entry(connection_struct *conn, /* token is the fd of the open share mode file. */ /* Unlock the first byte. */ - if(fcntl_lock(fd, F_SETLKW, 0, 1, F_UNLCK) == False) + if(fcntl_lock(fd, SMB_F_SETLKW, 0, 1, F_UNLCK) == False) { DEBUG(0,("ERROR unlock_share_entry: fcntl_lock failed with %s\n", strerror(errno))); @@ -980,7 +980,7 @@ static int slow_share_forall(void (*fn)(share_mode_entry *, char *)) /* Lock the share mode file while we read it. */ if(!read_only && - fcntl_lock(fd, F_SETLKW, 0, 1, F_WRLCK) == False) { + fcntl_lock(fd, SMB_F_SETLKW, 0, 1, F_WRLCK) == False) { close(fd); continue; } diff --git a/source3/locking/shmem.c b/source3/locking/shmem.c index 8a81d0efff..3cdcf82f73 100644 --- a/source3/locking/shmem.c +++ b/source3/locking/shmem.c @@ -107,7 +107,7 @@ static BOOL smb_shm_global_lock(void) return True; /* Do an exclusive wait lock on the first byte of the file */ - if (fcntl_lock(smb_shm_fd, F_SETLKW, 0, 1, F_WRLCK) == False) + if (fcntl_lock(smb_shm_fd, SMB_F_SETLKW, 0, 1, F_WRLCK) == False) { DEBUG(0,("ERROR smb_shm_global_lock : fcntl_lock failed with code %s\n",strerror(errno))); smb_shm_times_locked--; @@ -144,7 +144,7 @@ static BOOL smb_shm_global_unlock(void) return True; /* Do a wait unlock on the first byte of the file */ - if (fcntl_lock(smb_shm_fd, F_SETLKW, 0, 1, F_UNLCK) == False) + if (fcntl_lock(smb_shm_fd, SMB_F_SETLKW, 0, 1, F_UNLCK) == False) { DEBUG(0,("ERROR smb_shm_global_unlock : fcntl_lock failed with code %s\n",strerror(errno))); smb_shm_times_locked++; @@ -682,7 +682,7 @@ static BOOL smb_shm_lock_hash_entry( unsigned int entry) return True; /* Do an exclusive wait lock on the 4 byte region mapping into this entry */ - if (fcntl_lock(smb_shm_fd, F_SETLKW, start, sizeof(int), F_WRLCK) == False) + if (fcntl_lock(smb_shm_fd, SMB_F_SETLKW, start, sizeof(int), F_WRLCK) == False) { DEBUG(0,("ERROR smb_shm_lock_hash_entry : fcntl_lock failed with code %s\n",strerror(errno))); return False; @@ -709,7 +709,7 @@ static BOOL smb_shm_unlock_hash_entry( unsigned int entry ) return True; /* Do a wait lock on the 4 byte region mapping into this entry */ - if (fcntl_lock(smb_shm_fd, F_SETLKW, start, sizeof(int), F_UNLCK) == False) + if (fcntl_lock(smb_shm_fd, SMB_F_SETLKW, start, sizeof(int), F_UNLCK) == False) { DEBUG(0,("ERROR smb_shm_unlock_hash_entry : fcntl_lock failed with code %s\n",strerror(errno))); return False; -- cgit