fsrvp: add server state storage back-end
[samba.git] / source3 / rpc_server / fss / srv_fss_private.h
1 /*
2  * File Server Remote VSS Protocol (FSRVP) server state
3  *
4  * Copyright (C) David Disseldorp       2012-2015
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program 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
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19
20 #ifndef _SRV_FSS_PRIVATE_H_
21 #define _SRV_FSS_PRIVATE_H_
22
23 #define FSS_DB_NAME "srv_fss.tdb"
24
25 struct fss_sc_smap {
26         struct fss_sc_smap *next, *prev;
27         char *share_name;               /* name of the base file share */
28         char *sc_share_name;            /* share exposing the shadow copy */
29         char *sc_share_comment;
30         bool is_exposed;                /* whether shadow copy is exposed */
31 };
32
33 struct fss_sc {
34         struct fss_sc *next, *prev;
35         struct GUID id;                 /* GUID of the shadow copy */
36         char *id_str;
37         char *volume_name;              /* name uniquely identifying on the
38                                          * server object store on which this
39                                          * shadow copy is created. */
40         char *sc_path;                  /* path exposing the shadow copy */
41         time_t create_ts;               /* timestamp of client initiation */
42         struct fss_sc_smap *smaps;      /* shares mapped to this shadow copy */
43         uint32_t smaps_count;
44         struct fss_sc_set *sc_set;      /* parent shadow copy set */
45 };
46
47 /*
48  * 3.1.1.2: Per ShadowCopySet
49  * The status of the shadow copy set. This MUST be one of "Started", "Added",
50  * "CreationInProgress", "Committed", "Exposed", or "Recovered".
51  */
52 enum fss_sc_state {
53         FSS_SC_STARTED,
54         FSS_SC_ADDED,
55         FSS_SC_CREATING,
56         FSS_SC_COMMITED,
57         FSS_SC_EXPOSED,
58         FSS_SC_RECOVERED,
59 };
60 struct fss_sc_set {
61         struct fss_sc_set *next, *prev;
62         struct GUID id;                 /* GUID of the shadow copy set. */
63         char *id_str;
64         enum fss_sc_state state;        /* status of the shadow copy set */
65         uint32_t context;               /* attributes used for set creation */
66         struct fss_sc *scs;             /* list of ShadowCopy objects */
67         uint32_t scs_count;
68 };
69
70 struct fss_global {
71         TALLOC_CTX *mem_ctx;            /* parent mem ctx for sc sets */
72         char *db_path;
73         uint32_t min_vers;
74         uint32_t max_vers;
75         bool ctx_set;                   /* whether client has set context */
76         uint32_t cur_ctx;
77         struct fss_sc_set *sc_sets;
78         uint32_t sc_sets_count;
79         struct tevent_timer *seq_tmr;   /* time to wait between client reqs */
80 };
81
82 NTSTATUS fss_state_store(TALLOC_CTX *mem_ctx,
83                          struct fss_sc_set *sc_sets,
84                          uint32_t sc_sets_count,
85                          const char *db_path);
86
87 NTSTATUS fss_state_retrieve(TALLOC_CTX *mem_ctx,
88                             struct fss_sc_set **sc_sets,
89                             uint32_t *sc_sets_count,
90                             const char *db_path);
91
92 #endif /*_SRV_FSS_PRIVATE_H_ */