| 1 |
/* |
| 2 |
* Copyright (c) 2008-2012 Zmanda, Inc. All Rights Reserved. |
| 3 |
* Copyright (c) 2013-2016 Carbonite, Inc. All Rights Reserved. |
| 4 |
* |
| 5 |
* This program is free software; you can redistribute it and/or |
| 6 |
* modify it under the terms of the GNU General Public License |
| 7 |
* as published by the Free Software Foundation; either version 2 |
| 8 |
* of the License, or (at your option) any later version. |
| 9 |
* |
| 10 |
* This program is distributed in the hope that it will be useful, but |
| 11 |
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 12 |
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 13 |
* for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License along |
| 16 |
* with this program; if not, write to the Free Software Foundation, Inc., |
| 17 |
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 18 |
* |
| 19 |
* Contact information: Carbonite Inc., 756 N Pastoria Ave |
| 20 |
* Sunnyvale, CA 94085, or: http://www.zmanda.com |
| 21 |
*/ |
| 22 |
|
| 23 |
/* An S3 device uses Amazon's S3 service (http://www.amazon.com/s3) to store |
| 24 |
* data. It stores data in keys named with a user-specified prefix, inside a |
| 25 |
* user-specified bucket. Data is stored in the form of numbered (large) |
| 26 |
* blocks. |
| 27 |
*/ |
| 28 |
|
| 29 |
#ifndef __S3_DEVICE_H__ |
| 30 |
#define __S3_DEVICE_H__ |
| 31 |
|
| 32 |
#include "device.h" |
| 33 |
#include "s3.h" |
| 34 |
/* Type checking and casting macros |
| 35 |
*/ |
| 36 |
#define TYPE_S3_DEVICE (s3_device_get_type()) |
| 37 |
#define S3_DEVICE(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), s3_device_get_type(), S3Device) |
| 38 |
#define S3_DEVICE_CONST(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), s3_device_get_type(), S3Device const) |
| 39 |
#define S3_DEVICE_CLASS(klass) G_TYPE_CHECK_CLASS_CAST((klass), s3_device_get_type(), S3DeviceClass) |
| 40 |
#define IS_S3_DEVICE(obj) G_TYPE_CHECK_INSTANCE_TYPE((obj), s3_device_get_type ()) |
| 41 |
|
| 42 |
#define S3_DEVICE_GET_CLASS(obj) G_TYPE_INSTANCE_GET_CLASS((obj), s3_device_get_type(), S3DeviceClass) |
| 43 |
GType s3_device_get_type (void); |
| 44 |
|
| 45 |
extern DevicePropertyBase device_property_s3_access_key; |
| 46 |
extern DevicePropertyBase device_property_s3_secret_key; |
| 47 |
#define PROPERTY_S3_SECRET_KEY (device_property_s3_secret_key.ID) |
| 48 |
#define PROPERTY_S3_ACCESS_KEY (device_property_s3_access_key.ID) |
| 49 |
/* |
| 50 |
* Main object structure |
| 51 |
*/ |
| 52 |
typedef struct _S3MetadataFile S3MetadataFile; |
| 53 |
typedef struct _S3Device S3Device; |
| 54 |
|
| 55 |
typedef struct _S3_by_thread S3_by_thread; |
| 56 |
struct _S3_by_thread { |
| 57 |
S3Handle *s3; |
| 58 |
CurlBuffer curl_buffer; |
| 59 |
guint buffer_len; |
| 60 |
int idle; |
| 61 |
int eof; |
| 62 |
int done; |
| 63 |
char *filename; |
| 64 |
char *uploadId; |
| 65 |
int partNumber; |
| 66 |
guint64 range_min; |
| 67 |
guint64 range_max; |
| 68 |
DeviceStatusFlags errflags; /* device_status */ |
| 69 |
char *errmsg; /* device error message */ |
| 70 |
GMutex *now_mutex; |
| 71 |
guint64 dlnow, ulnow; |
| 72 |
time_t timeout; |
| 73 |
}; |
| 74 |
|
| 75 |
struct _S3Device { |
| 76 |
Device __parent__; |
| 77 |
|
| 78 |
char *catalog_filename; |
| 79 |
char *catalog_label; |
| 80 |
char *catalog_header; |
| 81 |
|
| 82 |
/* The "easy" curl handle we use to access Amazon S3 */ |
| 83 |
S3_by_thread *s3t; |
| 84 |
|
| 85 |
/* S3 access information */ |
| 86 |
char *bucket; |
| 87 |
char *prefix; |
| 88 |
|
| 89 |
/* The S3 access information. */ |
| 90 |
char *secret_key; |
| 91 |
char *access_key; |
| 92 |
char *session_token; |
| 93 |
char *user_token; |
| 94 |
|
| 95 |
/* The Openstack swift information. */ |
| 96 |
char *swift_account_id; |
| 97 |
char *swift_access_key; |
| 98 |
|
| 99 |
char *username; |
| 100 |
char *password; |
| 101 |
char *tenant_id; |
| 102 |
char *tenant_name; |
| 103 |
char *project_name; |
| 104 |
char *domain_name; |
| 105 |
|
| 106 |
char *bucket_location; |
| 107 |
char *storage_class; |
| 108 |
char *host; |
| 109 |
char *service_path; |
| 110 |
char *server_side_encryption; |
| 111 |
char *proxy; |
| 112 |
|
| 113 |
char *ca_info; |
| 114 |
|
| 115 |
/* a cache for unsuccessful reads (where we get the file but the caller |
| 116 |
* doesn't have space for it or doesn't want it), where we expect the |
| 117 |
* next call will request the same file. |
| 118 |
*/ |
| 119 |
char *cached_buf; |
| 120 |
char *cached_key; |
| 121 |
int cached_size; |
| 122 |
|
| 123 |
/* Produce verbose output? */ |
| 124 |
gboolean verbose; |
| 125 |
|
| 126 |
/* create the bucket? */ |
| 127 |
gboolean create_bucket; |
| 128 |
|
| 129 |
/* Use SSL? */ |
| 130 |
gboolean use_ssl; |
| 131 |
S3_api s3_api; |
| 132 |
|
| 133 |
/* Throttling */ |
| 134 |
guint64 max_send_speed; |
| 135 |
guint64 max_recv_speed; |
| 136 |
|
| 137 |
gboolean leom; |
| 138 |
guint64 volume_bytes; |
| 139 |
guint64 volume_limit; |
| 140 |
gboolean enforce_volume_limit; |
| 141 |
gboolean use_subdomain; |
| 142 |
gboolean use_s3_multi_delete; |
| 143 |
gboolean set_s3_multi_delete; |
| 144 |
char *uploadId; |
| 145 |
GTree *part_etag; |
| 146 |
char *filename; |
| 147 |
|
| 148 |
int nb_threads; |
| 149 |
int nb_threads_backup; |
| 150 |
int nb_threads_recovery; |
| 151 |
gboolean use_s3_multi_part_upload; |
| 152 |
GThreadPool *thread_pool_delete; |
| 153 |
GThreadPool *thread_pool_write; |
| 154 |
GThreadPool *thread_pool_read; |
| 155 |
GCond *thread_idle_cond; |
| 156 |
GMutex *thread_idle_mutex; |
| 157 |
gint64 last_byte_read; |
| 158 |
gint64 next_block_to_read; |
| 159 |
gint64 next_byte_to_read; |
| 160 |
GSList *objects; |
| 161 |
guint64 object_size; |
| 162 |
gboolean bucket_made; |
| 163 |
|
| 164 |
guint64 dltotal; |
| 165 |
guint64 ultotal; |
| 166 |
|
| 167 |
/* google OAUTH2 */ |
| 168 |
char *client_id; |
| 169 |
char *client_secret; |
| 170 |
char *refresh_token; |
| 171 |
char *project_id; |
| 172 |
|
| 173 |
gboolean reuse_connection; |
| 174 |
gboolean chunked; |
| 175 |
|
| 176 |
gboolean read_from_glacier; |
| 177 |
int transition_to_glacier; |
| 178 |
long timeout; |
| 179 |
|
| 180 |
/* CAStor */ |
| 181 |
char *reps; |
| 182 |
char *reps_bucket; |
| 183 |
}; |
| 184 |
|
| 185 |
/* |
| 186 |
* Class definition |
| 187 |
*/ |
| 188 |
typedef struct _S3DeviceClass S3DeviceClass; |
| 189 |
struct _S3DeviceClass { |
| 190 |
DeviceClass __parent__; |
| 191 |
}; |
| 192 |
|
| 193 |
#endif |
| 194 |
|