summaryrefslogtreecommitdiffstats
path: root/source/locking/locking.c
Commit message (Collapse)AuthorAgeFilesLines
* the first cut of the internal messaging system.Andrew Tridgell2000-09-111-1/+1
| | | | | The motivation for this system is to replace the UDP message for oplocks, but this commit only does the "set debug level" message.
* allow posix locking database to be opened read-only (for smbstatus)Andrew Tridgell2000-06-131-1/+1
|
* Using a structure for a tdb key can lead to insideous, hardHerb Lewis2000-05-101-0/+2
| | | | | | | | | | | | | | | | | to find bugs. On 64 bit IRIX, structure packing means that a struct { SMB_DEV_T dev /* 4 bytes */ SMB_INO_T ino /* 8 bytes */ } has 4 bytes of padding between the two members. If you don't null the memory before using it as a tdb key, you randomly can't find keys depending on what is in the padding. This caused me immense pain and was hard to track down.... :-) Jeremy.
* Fix for uninitialized memory read in brlock code. brl_locktest now needsJeremy Allison2000-05-051-1/+1
| | | | | to correctly set the fnum, as the brl_conflict code looks at it. Jeremy.
* Added sys_fork() and sys_getpid() functions to stop the overheadJeremy Allison2000-05-021-8/+8
| | | | | of doing a system call every time we want to just get our pid. Jeremy.
* Ok - this is the *third* implementation of this (third time's the charm :-).Jeremy Allison2000-04-281-628/+13
| | | | | | | | | | | | | | | | | This implementation keeps all POSIX lock records in a separate in memory tdb database only known about in locking/posix.c. In addition, the pending close fd's are also held in a tdb which has an array of fd's indexed by device and inode. The walk-split code uglyness has been moved to posix.c from brlock.c, which is the only place that needs to know about it, and the extra functions hacked into brlock to expose internal state have been removed. This implementation passes smbtorture locktest4, the only thing I need to check now for completeness is what to do about lock upgrade/downgrades which Win32 allows under some *very* strange circumstances. Jeremy.
* Forgot to close when "posix locking" is set to False.Jeremy Allison2000-04-281-2/+5
| | | | Jeremy.
* Added optimization where we are single opener (don't free POSIX locks).Jeremy Allison2000-04-281-1/+21
| | | | Jeremy.
* Made changes suggested by Andrew review.Jeremy Allison2000-04-281-37/+52
| | | | | | | fd_close now calls fd_close_posix() directly. set_posix_lock/release_posix_lock() now handle the reference counting. More changes due when this gets moved to the file locking/posix.c Jeremy.
* Ok - this is more subtle than it looks :-).Jeremy Allison2000-04-271-7/+13
| | | | | | | | | | | | | | | When a file is being closed, once it passes the fnum and tid tests then the locking context should be ignored when removing all locks. This is what is done in the brl close case, but when you have outstanding POSIX locks, then you cannot remove all the brl locks in one go, you have to get the lock list and call do_unlock individually. As this uses global_smbpid as the locking context, you need to make sure that this is set correctly for the specific lock being removed. I now do this by storing the smbpid in each entry in the unlock list returned from the query call. I removed the smbpid from fsp (not needed) and things seem ok (even with the stupid smbpid tricks that smbtorture plays :-). Jeremy.
* Fixed subtle unlocking bug when a file is closed. We need to store theJeremy Allison2000-04-271-6/+5
| | | | | | | | smbpid used when a file was opened in the files_struct. Else we use the wrong global_smbpid when we are closing the file and trying to remove the brl locks - this causes the brl locks to be left when the file is closed as the samba_context check fails. Jeremy.
* Did the rewrite Andrew wanted where all knowledge of POSIX locking isJeremy Allison2000-04-271-5/+179
| | | | | | | | | | removed from the smbd/open.c code. We now use a dlink list of structures indexed by dev/inode to store all pending fd's for close. This could be rewritten to use lib/hash.c if this is discovered to be too slow in use. Andrew, please take a look and let me know if this is what you had in mind. Jeremy.
* Fixed crash bugs Andrew pointed out with LOCK4 smbtortureJeremy Allison2000-04-271-10/+7
| | | | | | | test. Was miscounting posix locks, plus was not taking into account the case where other_fsp == fsp in the 'move locks' case. DOH ! This code will be re-written anyway :-). Jeremy.
* Added the hard code :-).Jeremy Allison2000-04-251-50/+121
| | | | | | | | | | HEAD should now map brl locks correctly into POSIX locks, including the really nasty case of large range unlock. There is a lot of pretty ASCII art in locking/brlock.c explaining exactly how this code works. If it is unclear, please ask me. Jeremy.
* Added the code that keeps fd's open across a close if there are other fsp'sJeremy Allison2000-04-241-36/+23
| | | | | | | | | | | | | | | open on the same dev/inode pair with existing POSIX locks. This is done at the smbd/open layer, so smbd just calls fd_close() and the transfer of any open fd's is done under the covers of fd_close(). When an fsp is closed and no other fsp's open on the same dev/inode pair have existing POSIX locks then all fd's associated with this fsp are closed. Now only the hard part of doing the POSIX range unlock code when read locks overlap remains for full POSIX/SMB lock integration.... Jeremy.
* fixed a locking database bug - it was actually harmless except thatAndrew Tridgell2000-04-231-2/+10
| | | | | smbstatus could display the wrong filename when files change dev/inum after a rename
* This is a *big* checkin that may break some things, but implements theJeremy Allison2000-04-221-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | new open mechanism Andrew & I discussed. config.sub: configure: Included the QNX patch. include/vfs.h: smbd/vfs-wrap.c: smbd/vfs.c: Added ftruncate vfs call (needed). Note that we will also need locking calls in the vfs (to be added). lib/util_unistr.c: nmbd/nmbd_processlogon.c: Fix for NT domain logons causing nmbd to core dump. Also fix for sidsize DOS bug. locking/locking.c: Check value of ret before using it for memdup. printing/printing.c: Convert print_fsp_open to return an allocated fsp. rpc_server/srv_lsa.c: Fix for NT domain logons. I have removed all use of lp_share_modes() from the code (although I left the parameter in the table for backwards compatibility). It no longer makes sense for this to exist. smbd/close.c: Removed lp_share_modes(). smbd/fileio.c: Fixed parameters to unlock_share_entry call in panic code. smbd/files.c: Correctly set the unix_ERR_code to ERRnofids on fsp allocation fail. smbd/nttrans.c: smbd/reply.c: smbd/trans2.c: Changed all occurrences of open_file_shared/open_directory/ open_file_stat to return an fsp from the call. smbd/open.c: Changed all occurrences of open_file_shared/open_directory/ open_file_stat to return an fsp from the call. In addition I have fixed a long standing race condition in the deny mode processing w.r.t. two smbd's creating a file. Andrew, please note that your original idea of using open with O_EXCL in this case would not work (I went over the races very carefully) and so we must re-check deny modes *after* the open() call returns. This is because there is a race between the open with O_EXCL and the lock of the share mode entry. Imagine the case where the first smbd does the open with O_EXCL and a deny mode of DENY_ALL, but is pre-empted before it locks the share modes and creates the deny mode entry for DENY_ALL. A second smbd could then come in with O_RDONLY and a deny mode of DENY_NONE and the two opens would be allowed. The *only* way to fix this race is to lock the share modes after the open and then do the deny mode checks *after* this lock in the case where the file did not originally exist. This code will need extensive testing but seems to initially work. Jeremy.
* locking/locking.c: Fixed placeholder code for POSIX locking.Jeremy Allison2000-04-181-17/+49
| | | | | | | | printing/printing.c: Cast tdb_delete to (tdb_traverse_func) to stop warning. tmpfile gives mirror warning. smbd/groupname.c: Remember to file_lines_free() on exit. tdb/tdb.h: Add tdb_traverse_func typedef. Jeremy
* Typo - missing '}'.Jeremy Allison2000-04-131-0/+1
| | | | Jeremy.
* Removed "ole locking compat" parameter (no longer used).Jeremy Allison2000-04-121-18/+113
| | | | | | We now get/set/check POSIX locks, but I still need to code up the close fd braindamage... Jeremy.
* Implmented mapping of lock offset/count from 64 bit MS rangesJeremy Allison2000-04-121-13/+157
| | | | | | to either 63 or 31 bit POSIX ranges. Code to get these locks not yet added. Jeremy.
* Code to map tdb locks onto POSIX. Mainly placeholder code at the moment,Jeremy Allison2000-04-121-9/+157
| | | | | | but the structure is done enough so that Andrew can look it over and give a yea/nay decision. Jeremy.
* include/byteorder.h: ALIGN4/ALIGN2 macros.Jeremy Allison2000-04-111-3/+3
| | | | | | | | | | | | include/includes.h: Added SMB_BIG_UINT_BITS. lib/util.c: Removed align2/align4 - use macros. libsmb/namequery.c: Use ALIGN2. locking/locking.c: Replace do_lock, do_unlock, args with SMB_BIG_UINT, not SMB_OFF_T. Needed to move to hiding POSIX locks at a lower layer. nmbd/nmbd_processlogon.c: Use ALIGN2/ALIGN4 macros. smbd/blocking.c: Replace do_lock, do_unlock, args with SMB_BIG_UINT, not SMB_OFF_T. smbd/reply.c: Replace do_lock, do_unlock, args with SMB_BIG_UINT, not SMB_OFF_T. Jeremy.
* the first of a bunch of changes to code with getting rid of the fd_ptrAndrew Tridgell2000-04-101-6/+23
| | | | | | element in the fsp pretty mechanical stuff, but it affects lots of files.
* Fixed compile warning in locking.c:traverse_fn()Tim Potter2000-02-071-1/+2
|
* 1) added void* state argument to tdb_traverse. guess what! there wereLuke Leighton2000-02-041-5/+5
| | | | | | | | | | | | | | | | | | two places i found where it was appropriate to _use_ that third argument, in locking.c and brlock.c! there was a static traverse_function and i removed the static variable, typecast it to a void*, passed it to tdb_traverse and re-cast it back to the traverse_function inside the tdb_traverse function. this makes the use of tdb_traverse() reentrant, which is never going to happen, i know, i just don't like to see statics lying about when there's no need for them. as i had to do in samba-tng, all uses of tdb_traverse modified to take the new void* state argument. 2) disabled rpcclient: referring people to use SAMBA_TNG rpcclient. i don't know how the other samba team members would react if i deleted rpcclient from cvs main. damn, that code's so old, it's unreal. 20 rpcclient commands, instead of about 70 in SAMBA_TNG.
* added code to allow traversal of the byte range lock databaseAndrew Tridgell2000-01-161-1/+1
| | | | this is used with "smbstatus -B" to dump the lock list
* damn, Solaris already has a "enum lock_type"Andrew Tridgell2000-01-141-2/+2
| | | | changed it to "enum brl_type"
* we now pass all byte range locking testsAndrew Tridgell2000-01-141-2/+15
| | | | | the last piece was to use a smb timeout slightly larger than the locking timeout in bloking locks to prevent a race
* some more work on the byte range lockingAndrew Tridgell2000-01-141-6/+8
| | | | | | | | note the ugly global_smbpid - I hope that won't bethere for long, I just didn't want to do two lots of major surgery at the one time. Using global_smbpid avoids the big change of getting rid of our inbuf/outbuf interface to reply routines. I'll do that once the locking stuff passes all tests.
* the bulk of the new byte range locking coodeAndrew Tridgell2000-01-131-45/+21
| | | | it doesn't map to posix locks yet, that will come later.
* added the unexpected packet database (unexpected.tdb)Andrew Tridgell2000-01-031-1/+1
| | | | | | | | | | | | this means "nmblookup -S" now always works, even with broken servers the database stores all unexpected replies and these can be accessed by any client. while doing this I cleaned up a couple of functions, and put in place a better trn_id generator. in most places the code got quite a bit simpler due to the addition of simple helper functions. I haven't yet put the code in to take advantage of this for pdc replies - that will be next. Jeremys pdc finding code will then work :)
* - added tdb_flags option to tdb_open()Andrew Tridgell2000-01-021-1/+1
| | | | | | | | | - added TDB_CLEAR_IF_FIRST flag to clear the database if this is the first attached process. Useful for non-persistent databases like our locking area (this will also make upgrades to new database layouts easier) - use lock_path() in a couple of places - leave connections database open while smbd running - cleaned up some tdb code a little, using macros for constants
* when no shares are returned the *shares pointer must be set to nullAndrew Tridgell1999-12-221-0/+2
|
* converted all our existing shared memory code to use a tdb databaseAndrew Tridgell1999-12-211-128/+295
| | | | | | | | | | | | | instead of either sysv or mmap shared memory or lock files. this means we can now completely remove locking_shm.c locking_slow.c shmem.c shmem_sysv.c and lots of other things also got simpler locking.c got a bit larger, but is much better compartmentalised now
* first pass at updating head branch to be to be the same as the SAMBA_2_0 branchAndrew Tridgell1999-12-131-22/+62
|
* Use VFS operations for file I/O.Tim Potter1999-04-041-4/+5
|
* don't core dump in smbstatus if we can't open the shmem systemAndrew Tridgell1998-10-311-0/+1
|
* Reasonably large change to give us *exactly* correct NT delete on close ↵Jeremy Allison1998-10-231-2/+43
| | | | | | | | | | | | | | semantics. This was trickier than it looks :-). Check out the new DELETE_ON_CLOSE flag in the share modes and the new code that iterates through all open files on the same device and inode in files.c and trans2.c Also changed the code that modifies share mode entries to take generic function pointers rather than doing a specific thing so this sort of change should be easier in the future. Jeremy.
* ahh, the joy of deleting large chunks of code that someone else hasAndrew Tridgell1998-09-051-10/+0
| | | | | | | | painstakingly put in :) This gets rid of most of the #ifdef LARGE_SMB_INO_T ifdefs around DEBUG() statements. We just use %.0f in all cases. Makes the code a bit easier to read :)
* More 64 bit stuff - now the fcntl locks are 64 bit clean.Jeremy Allison1998-09-041-16/+25
| | | | | | Nearly at the stage where I can expose the 64-bit-ness to the NT clients.... Jeremy.
* configure.in, configure: include/config.h.in: Added stropts and poll.Jeremy Allison1998-08-311-3/+3
| | | | | | | | | | | include/smb.h: Moved old typedefs of uint8 etc. into include/includes.h where all the other defines live (changed them from typedefs to defines). Other changes : changed from using uint32 to SMB_DEV_T and SMB_INO_T in preparation for moving to size independed (ie. 64 bit clean) device and inode access. Stat call wrapper comes next :-). Jeremy.
* Turning on blocking locking code. NB. Blocking lock requests that are notJeremy Allison1998-08-201-0/+6
| | | | | | | | | | | | | | | | | | the head of an SMB request (ie. are part of a chain) will not be queued - this will be fixed when we move to the new chain code. In practice, this doesn't seem to cause much of a problem (in my admittedly limited testing) bug a debug level zero message will be placed in the log when this happens to help determine how real the problem is. smbd/locking.c: New debug messages. smbd/blocking.c: New blocking code - handles SMBlock, SMBlockread and SMBlockingX smbd/chgpasswd.c: Fix for master fd leak. smbd/files.c: Tidyup comment. smbd/nttrans.c: Added fnum to debug message. smbd/process.c: Made chain_reply() use construct_reply_common(). Added blocking lock queue processing into idle loop. smbd/reply.c: Added queue pushes for SMBlock, SMBlockread and SMBlockingX. Jeremy.
* Makefile.in: Moved blocking lock code into smbd/blocking.c for link purposes.Jeremy Allison1998-08-191-290/+0
| | | | | | | | | | | include/includes.h: Added nterr.h. locking/locking.c: Moved blocking lock code into smbd/blocking.c for link purposes. smbd/close.c: Added blocking lock removal to file close. smbd/filename.c: Tidied up unix_convert() so I could read it (:-) in preparation for the stat_cache code. smbd/nttrans.c: Added WRITE_ATTRIBUTES check. smbd/reply.c: Fixed multibyte char problem in wildcard mask. Jeremy.
* smbd/nttrans.c: Fixed bug in split off pipe code.Jeremy Allison1998-08-171-4/+12
| | | | | locking/locking.c: More blocking lock changes. Jeremy.
* much cleaner chain pointer handling for both files and pipes.Andrew Tridgell1998-08-171-7/+6
| | | | | | the chain pointer is now stored as a static and is set whenever a handle is created or extracted. This also makes the code less error prone.
* server.c: fixed a bug in close_file() with the new files.c handling codeAndrew Tridgell1998-08-161-2/+0
| | | | | bitmap.c: added bitmap hanlding code in preparation for increasing the default max open files to several thousand
* this checkin gets rid of the global Files[] array and makes it localAndrew Tridgell1998-08-151-31/+25
| | | | | | | in files.c it should now be faily easy to expand the default MAX_OPEN_FILES to many thousands.
* this is the bug change to using connection_struct* instead of cnum.Andrew Tridgell1998-08-141-48/+39
| | | | | | | | Connections[] is now a local array in server.c I might have broken something with this change. In particular the oplock code is suspect and some .dll files aren't being oplocked when I expected them to be. I'll look at it after I've got some sleep.
* Makefile.in: Changed so that make proto will work with ldap & nisplus.Jeremy Allison1998-08-141-3/+3
| | | | | | | | locking/locking.c: Made #ifdef'ed out functions static for Make proto. lib/util.c: Re-instated old mask_match code for UNIX filesystem checks only. Client calls use the new mask_match code. Changed the name of the old function to unix_mask_match. Jeremy.