r23798: updated old Temple Place FSF addresses to new URL
[samba.git] / source3 / include / smb_share_modes.h
1 /*
2    Samba share mode database library.
3
4    Copyright (C) Jeremy Allison 2005.
5
6    This library is free software; you can redistribute it and/or
7    modify it under the terms of the GNU Lesser General Public
8    License as published by the Free Software Foundation; either
9    version 3 of the License, or (at your option) any later version.
10
11    This library is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14    Lesser General Public License for more details.
15
16    You should have received a copy of the GNU Lesser General Public
17    License along with this library; if not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef _SMB_SHARE_MODES_H_
21 #define _SMB_STATE_MODES_H_
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 #if HAVE_INTTYPES_H
28 # include <inttypes.h>
29 #else
30 # if HAVE_STDINT_H
31 #  include <stdint.h>
32 # endif
33 #endif
34
35 /* Opaque database context handle. */
36 struct smbdb_ctx;
37
38 /* Share mode entry. */
39 /*
40  We use 64 bit types for device and inode as
41  we don't know what size mode Samba has been
42  compiled in - dev/ino may be 32, may be 64
43  bits. This interface copes with either.
44 */
45   
46 struct smb_share_mode_entry {
47         uint64_t dev;
48         uint64_t ino;
49         uint32_t share_access;
50         uint32_t access_mask;
51         struct timeval open_time;
52         uint32_t file_id;
53         struct server_id pid;
54 };
55
56 /*
57  * open/close sharemode database.
58  */
59
60 struct smbdb_ctx *smb_share_mode_db_open(const char *db_path);
61 int smb_share_mode_db_close(struct smbdb_ctx *db_ctx);
62
63 /*
64  * lock/unlock entry in sharemode database.
65  */
66
67 int smb_lock_share_mode_entry(struct smbdb_ctx *db_ctx,
68                                 uint64_t dev,
69                                 uint64_t ino);
70
71 int smb_unlock_share_mode_entry(struct smbdb_ctx *db_ctx,
72                                 uint64_t dev,
73                                 uint64_t ino);
74
75 /*
76  * Share mode database accessor functions.
77  */
78
79 int smb_get_share_mode_entries(struct smbdb_ctx *db_ctx,
80                                 uint64_t dev,
81                                 uint64_t ino,
82                                 struct smb_share_mode_entry **pp_list,
83                                 unsigned char *p_delete_on_close);
84
85 int smb_create_share_mode_entry(struct smbdb_ctx *db_ctx,
86                                 uint64_t dev,
87                                 uint64_t ino,
88                                 const struct smb_share_mode_entry *set_entry,
89                                 const char *path);
90
91 int smb_delete_share_mode_entry(struct smbdb_ctx *db_ctx,
92                                 uint64_t dev,
93                                 uint64_t ino,
94                                 const struct smb_share_mode_entry *set_entry);
95
96 int smb_change_share_mode_entry(struct smbdb_ctx *db_ctx,
97                                 uint64_t dev,
98                                 uint64_t ino,
99                                 const struct smb_share_mode_entry *set_entry,
100                                 const struct smb_share_mode_entry *new_entry);
101
102 #ifdef __cplusplus
103 }
104 #endif
105 #endif