summaryrefslogtreecommitdiffstats
path: root/xlators/features/cloudsync/src/cloudsync-plugins/src/cvlt/src/archivestore.h
blob: 7230ef77337e0e8d8fe806efa68064cbc57856b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
/*
  Copyright (c) 2018 Commvault Systems, Inc. <http://www.commvault.com>
  This file is part of GlusterFS.

  This file is licensed to you under your choice of the GNU Lesser
  General Public License, version 3 or any later version (LGPLv3 or
  later), or the GNU General Public License, version 2 (GPLv2), in all
  cases as published by the Free Software Foundation.
*/

#ifndef __ARCHIVESTORE_H__
#define __ARCHIVESTORE_H__

#include <stdlib.h>
#include <stddef.h>
#include <stdint.h>
#include <dlfcn.h>
#include <uuid/uuid.h>

#define CS_XATTR_ARCHIVE_UUID "trusted.cloudsync.uuid"
#define CS_XATTR_PRODUCT_ID "trusted.cloudsync.product-id"
#define CS_XATTR_STORE_ID "trusted.cloudsync.store-id"

struct _archstore_methods;
typedef struct _archstore_methods archstore_methods_t;

struct _archstore_desc {
    void *priv; /* Private field for store mgmt.   */
                /* To be used only by archive store*/
};
typedef struct _archstore_desc archstore_desc_t;

struct _archstore_info {
    char *id;         /* Identifier for the archivestore */
    uint32_t idlen;   /* Length of identifier string     */
    char *prod;       /* Name of the data mgmt. product  */
    uint32_t prodlen; /* Length of the product string    */
};
typedef struct _archstore_info archstore_info_t;

struct _archstore_fileinfo {
    uuid_t uuid;         /* uuid of the file                */
    char *path;          /* file path                       */
    uint32_t pathlength; /* length of file path             */
};
typedef struct _archstore_fileinfo archstore_fileinfo_t;

struct _app_callback_info {
    archstore_info_t *src_archstore;
    archstore_fileinfo_t *src_archfile;
    archstore_info_t *dest_archstore;
    archstore_fileinfo_t *dest_archfile;
};
typedef struct _app_callback_info app_callback_info_t;

typedef void (*app_callback_t)(archstore_desc_t *, app_callback_info_t *,
                               void *, int64_t, int32_t);

enum _archstore_scan_type { FULL = 1, INCREMENTAL = 2 };
typedef enum _archstore_scan_type archstore_scan_type_t;

typedef int32_t archstore_errno_t;

/*
 * Initialize archive store.
 * arg1  pointer to structure containing archive store information
 * arg2  error number if any generated during the initialization
 * arg3  name of the log file
 */
typedef int32_t (*init_archstore_t)(archstore_desc_t *, archstore_errno_t *,
                                    const char *);

/*
 * Clean up archive store.
 * arg1  pointer to structure containing archive store information
 * arg2  error number if any generated during the cleanup
 */
typedef int32_t (*term_archstore_t)(archstore_desc_t *, archstore_errno_t *);

/*
 * Read the contents of the file from archive store
 * arg1  pointer to structure containing archive store description
 * arg2  pointer to structure containing archive store information
 * arg3  pointer to structure containing information about file to be read
 * arg4  offset in the file from which data should be read
 * arg5  buffer where the data should be read
 * arg6  number of bytes of data to be read
 * arg7  error number if any generated during the read from file
 * arg8  callback handler to be invoked after the data is read
 * arg9  cookie to be passed when callback is invoked
 */
typedef int32_t (*read_archstore_t)(archstore_desc_t *, archstore_info_t *,
                                    archstore_fileinfo_t *, off_t, char *,
                                    size_t, archstore_errno_t *, app_callback_t,
                                    void *);

/*
 * Restore the contents of the file from archive store
 * This is basically in-place restore
 * arg1  pointer to structure containing archive store description
 * arg2  pointer to structure containing archive store information
 * arg3  pointer to structure containing information about file to be restored
 * arg4  error number if any generated during the file restore
 * arg5  callback to be invoked after the file is restored
 * arg6  cookie to be passed when callback is invoked
 */
typedef int32_t (*recall_archstore_t)(archstore_desc_t *, archstore_info_t *,
                                      archstore_fileinfo_t *,
                                      archstore_errno_t *, app_callback_t,
                                      void *);

/*
 * Restore the contents of the file from archive store to a different store
 * This is basically out-of-place restore
 * arg1  pointer to structure containing archive store description
 * arg2  pointer to structure containing source archive store information
 * arg3  pointer to structure containing information about file to be restored
 * arg4  pointer to structure containing destination archive store information
 * arg5  pointer to structure containing information about the location to
         which the file will be restored
 * arg6  error number if any generated during the file restore
 * arg7  callback to be invoked after the file is restored
 * arg8  cookie to be passed when callback is invoked
 */
typedef int32_t (*restore_archstore_t)(archstore_desc_t *, archstore_info_t *,
                                       archstore_fileinfo_t *,
                                       archstore_info_t *,
                                       archstore_fileinfo_t *,
                                       archstore_errno_t *, app_callback_t,
                                       void *);

/*
 * Archive the contents of the file to archive store
 * arg1  pointer to structure containing archive store description
 * arg2  pointer to structure containing source archive store information
 * arg3  pointer to structure containing information about files to be archived
 * arg4  pointer to structure containing destination archive store information
 * arg5  pointer to structure containing information about files that failed
 *       to be archived
 * arg6  error number if any generated during the file archival
 * arg7  callback to be invoked after the file is archived
 * arg8  cookie to be passed when callback is invoked
 */
typedef int32_t (*archive_archstore_t)(archstore_desc_t *, archstore_info_t *,
                                       archstore_fileinfo_t *,
                                       archstore_info_t *,
                                       archstore_fileinfo_t *,
                                       archstore_errno_t *, app_callback_t,
                                       void *);

/*
 * Backup list of files provided in the input file
 * arg1  pointer to structure containing archive store description
 * arg2  pointer to structure containing source archive store information
 * arg3  pointer to structure containing information about files to be backed up
 * arg4  pointer to structure containing destination archive store information
 * arg5  pointer to structure containing information about files that failed
 *       to be backed up
 * arg6  error number if any generated during the file archival
 * arg7  callback to be invoked after the file is archived
 * arg8  cookie to be passed when callback is invoked
 */
typedef int32_t (*backup_archstore_t)(archstore_desc_t *, archstore_info_t *,
                                      archstore_fileinfo_t *,
                                      archstore_info_t *,
                                      archstore_fileinfo_t *,
                                      archstore_errno_t *, app_callback_t,
                                      void *);

/*
 * Scan the contents of a store and determine the files which need to be
 * backed up.
 * arg1  pointer to structure containing archive store description
 * arg2  pointer to structure containing archive store information
 * arg3  type of scan whether full or incremental
 * arg4  path to file that contains list of files to be backed up
 * arg5  error number if any generated during scan operation
 */
typedef int32_t (*scan_archstore_t)(archstore_desc_t *, archstore_info_t *,
                                    archstore_scan_type_t, char *,
                                    archstore_errno_t *);

struct _archstore_methods {
    init_archstore_t init;
    term_archstore_t fini;
    backup_archstore_t backup;
    archive_archstore_t archive;
    scan_archstore_t scan;
    restore_archstore_t restore;
    recall_archstore_t recall;
    read_archstore_t read;
};

typedef int (*get_archstore_methods_t)(archstore_methods_t *);

/*
 * Single function that will be invoked by applications for extracting
 * the function pointers to all data management functions.
 */
int32_t
get_archstore_methods(archstore_methods_t *);

#endif /* End of __ARCHIVESTORE_H__ */