r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text
[abartlet/samba.git/.git] / source3 / include / locking.h
index 8eabb305f7f6e6c9a14666e3f3b97ac7762e7bbe..35d9f4846702930bed11251109dfedc697e86ce2 100644 (file)
@@ -6,7 +6,7 @@
    
    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/>.
 */
 
 #ifndef _LOCKING_H
 #define _LOCKING_H
 
 /* passed to br lock code - the UNLOCK_LOCK should never be stored into the tdb
-   and is used in calculating POSIX unlock ranges only. */
+   and is used in calculating POSIX unlock ranges only. We differentiate between
+   PENDING read and write locks to allow posix lock downgrades to trigger a lock
+   re-evaluation. */
 
-enum brl_type {READ_LOCK, WRITE_LOCK, PENDING_LOCK, UNLOCK_LOCK};
+enum brl_type {READ_LOCK, WRITE_LOCK, PENDING_READ_LOCK, PENDING_WRITE_LOCK, UNLOCK_LOCK};
 enum brl_flavour {WINDOWS_LOCK = 0, POSIX_LOCK = 1};
 
+#define IS_PENDING_LOCK(type) ((type) == PENDING_READ_LOCK || (type) == PENDING_WRITE_LOCK)
+
 /* This contains elements that differentiate locks. The smbpid is a
    client supplied pid, and is essentially the locking context for
    this client */
@@ -35,44 +38,29 @@ enum brl_flavour {WINDOWS_LOCK = 0, POSIX_LOCK = 1};
 struct lock_context {
        uint32 smbpid;
        uint16 tid;
-       struct process_id pid;
+       struct server_id pid;
 };
 
-/* The key used in the brlock database. */
+struct files_struct;
 
-struct lock_key {
-       SMB_DEV_T device;
-       SMB_INO_T inode;
+struct file_id {
+       /* we don't use SMB_DEV_T and SMB_INO_T as we want a fixed size here,
+          and we may be using file system specific code to fill in something
+          other than a dev_t for the device */
+       uint64_t devid;
+       uint64_t inode;
 };
 
-struct files_struct;
-
 struct byte_range_lock {
        struct files_struct *fsp;
        unsigned int num_locks;
        BOOL modified;
-       struct lock_key key;
-       void *lock_data;
+       BOOL read_only;
+       struct file_id key;
+       struct lock_struct *lock_data;
+       struct db_record *record;
 };
 
-#define BRLOCK_FN_CAST() \
-       void (*)(SMB_DEV_T dev, SMB_INO_T ino, struct process_id pid, \
-                                enum brl_type lock_type, \
-                                enum brl_flavour lock_flav, \
-                                br_off start, br_off size)
-
-#define BRLOCK_FN(fn) \
-       void (*fn)(SMB_DEV_T dev, SMB_INO_T ino, struct process_id pid, \
-                                enum brl_type lock_type, \
-                                enum brl_flavour lock_flav, \
-                                br_off start, br_off size)
-
-#define LOCKING_FN_CAST() \
-       void (*)(struct share_mode_entry *, const char *, const char *)
-
-#define LOCKING_FN(fn) \
-       void (*fn)(struct share_mode_entry *, const char *, const char *)
-
 /* 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