opendb: pass down a pointer to the fd in odb_open_file()
[jelmer/samba4-debian.git] / source / ntvfs / common / opendb.h
1 /* 
2    Unix SMB/CIFS implementation.
3
4    open database code - common include
5
6    Copyright (C) Andrew Tridgell 2007
7    
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 3 of the License, or
11    (at your option) any later version.
12    
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17    
18    You should have received a copy of the GNU General Public License
19    along with this program.  If not, see <http://www.gnu.org/licenses/>.
20 */
21
22 struct opendb_ops {
23         struct odb_context *(*odb_init)(TALLOC_CTX *mem_ctx, 
24                                         struct ntvfs_context *ntvfs_ctx);
25         struct odb_lock *(*odb_lock)(TALLOC_CTX *mem_ctx,
26                                      struct odb_context *odb, DATA_BLOB *file_key);
27         DATA_BLOB (*odb_get_key)(TALLOC_CTX *mem_ctx, struct odb_lock *lck);
28         NTSTATUS (*odb_open_file)(struct odb_lock *lck,
29                                   void *file_handle, const char *path,
30                                   int *fd, bool allow_level_II_oplock,
31                                   uint32_t oplock_level, uint32_t *oplock_granted);
32         NTSTATUS (*odb_open_file_pending)(struct odb_lock *lck, void *private);
33         NTSTATUS (*odb_close_file)(struct odb_lock *lck, void *file_handle,
34                                    const char **delete_path);
35         NTSTATUS (*odb_remove_pending)(struct odb_lock *lck, void *private);
36         NTSTATUS (*odb_rename)(struct odb_lock *lck, const char *path);
37         NTSTATUS (*odb_get_path)(struct odb_lock *lck, const char **path);
38         NTSTATUS (*odb_set_delete_on_close)(struct odb_lock *lck, bool del_on_close);
39         NTSTATUS (*odb_get_delete_on_close)(struct odb_context *odb, 
40                                             DATA_BLOB *key, bool *del_on_close);
41         NTSTATUS (*odb_can_open)(struct odb_lock *lck,
42                                  uint32_t stream_id, uint32_t share_access,
43                                  uint32_t access_mask, bool delete_on_close,
44                                  uint32_t open_disposition, bool break_to_none);
45         NTSTATUS (*odb_update_oplock)(struct odb_lock *lck, void *file_handle,
46                                       uint32_t oplock_level);
47         NTSTATUS (*odb_break_oplocks)(struct odb_lock *lck);
48 };
49
50 struct opendb_oplock_break {
51         void *file_handle;
52         uint8_t level;
53 };
54
55 void odb_set_ops(const struct opendb_ops *new_ops);
56 void odb_tdb_init_ops(void);
57 void odb_ctdb_init_ops(void);