| 1 |
/* |
| 2 |
* Amanda, The Advanced Maryland Automatic Network Disk Archiver |
| 3 |
* Copyright (c) 2009-2012 Zmanda, Inc. All Rights Reserved. |
| 4 |
* Copyright (c) 2013-2016 Carbonite, Inc. All Rights Reserved. |
| 5 |
* |
| 6 |
* This program is free software; you can redistribute it and/or |
| 7 |
* modify it under the terms of the GNU General Public License |
| 8 |
* as published by the Free Software Foundation; either version 2 |
| 9 |
* of the License, or (at your option) any later version. |
| 10 |
* |
| 11 |
* This program is distributed in the hope that it will be useful, but |
| 12 |
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 13 |
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 14 |
* for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU General Public License along |
| 17 |
* with this program; if not, write to the Free Software Foundation, Inc., |
| 18 |
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 |
* |
| 20 |
* Contact information: Carbonite Inc., 756 N Pastoria Ave |
| 21 |
* Sunnyvale, CA 94085, or: http://www.zmanda.com |
| 22 |
*/ |
| 23 |
|
| 24 |
#include "amanda.h" |
| 25 |
#include "xfer-device.h" |
| 26 |
|
| 27 |
static GObjectClass *parent_class = NULL; |
| 28 |
|
| 29 |
/* |
| 30 |
* Method implementation |
| 31 |
*/ |
| 32 |
|
| 33 |
static void |
| 34 |
cache_inform_impl( |
| 35 |
XferDestTaper *self G_GNUC_UNUSED, |
| 36 |
const char *filename G_GNUC_UNUSED, |
| 37 |
off_t offset G_GNUC_UNUSED, |
| 38 |
off_t length G_GNUC_UNUSED) |
| 39 |
{ |
| 40 |
/* do nothing */ |
| 41 |
} |
| 42 |
|
| 43 |
static void |
| 44 |
instance_init( |
| 45 |
XferElement *elt) |
| 46 |
{ |
| 47 |
elt->can_generate_eof = FALSE; |
| 48 |
} |
| 49 |
|
| 50 |
static void |
| 51 |
class_init( |
| 52 |
XferDestTaperClass * selfc) |
| 53 |
{ |
| 54 |
XferElementClass *klass = XFER_ELEMENT_CLASS(selfc); |
| 55 |
|
| 56 |
selfc->cache_inform = cache_inform_impl; |
| 57 |
|
| 58 |
klass->perl_class = "Amanda::Xfer::Dest::Taper"; |
| 59 |
|
| 60 |
parent_class = g_type_class_peek_parent(selfc); |
| 61 |
} |
| 62 |
|
| 63 |
GType |
| 64 |
xfer_dest_taper_get_type (void) |
| 65 |
{ |
| 66 |
static GType type = 0; |
| 67 |
|
| 68 |
if (G_UNLIKELY(type == 0)) { |
| 69 |
static const GTypeInfo info = { |
| 70 |
sizeof (XferDestTaperClass), |
| 71 |
(GBaseInitFunc) NULL, |
| 72 |
(GBaseFinalizeFunc) NULL, |
| 73 |
(GClassInitFunc) class_init, |
| 74 |
(GClassFinalizeFunc) NULL, |
| 75 |
NULL /* class_data */, |
| 76 |
sizeof (XferDestTaper), |
| 77 |
0 /* n_preallocs */, |
| 78 |
(GInstanceInitFunc) instance_init, |
| 79 |
NULL |
| 80 |
}; |
| 81 |
|
| 82 |
type = g_type_register_static (XFER_ELEMENT_TYPE, "XferDestTaper", &info, 0); |
| 83 |
} |
| 84 |
|
| 85 |
return type; |
| 86 |
} |
| 87 |
|
| 88 |
/* |
| 89 |
* Method stubs |
| 90 |
*/ |
| 91 |
|
| 92 |
void |
| 93 |
xfer_dest_taper_start_part( |
| 94 |
XferElement *elt, |
| 95 |
gboolean retry_part, |
| 96 |
dumpfile_t *header) |
| 97 |
{ |
| 98 |
XferDestTaperClass *klass; |
| 99 |
g_assert(IS_XFER_DEST_TAPER(elt)); |
| 100 |
|
| 101 |
klass = XFER_DEST_TAPER_GET_CLASS(elt); |
| 102 |
klass->start_part(XFER_DEST_TAPER(elt), retry_part, header); |
| 103 |
} |
| 104 |
|
| 105 |
void |
| 106 |
xfer_dest_taper_use_device( |
| 107 |
XferElement *elt, |
| 108 |
Device *device) |
| 109 |
{ |
| 110 |
XferDestTaperClass *klass; |
| 111 |
g_assert(IS_XFER_DEST_TAPER(elt)); |
| 112 |
|
| 113 |
klass = XFER_DEST_TAPER_GET_CLASS(elt); |
| 114 |
klass->use_device(XFER_DEST_TAPER(elt), device); |
| 115 |
} |
| 116 |
|
| 117 |
void |
| 118 |
xfer_dest_taper_cache_inform( |
| 119 |
XferElement *elt, |
| 120 |
const char *filename, |
| 121 |
off_t offset, |
| 122 |
off_t length) |
| 123 |
{ |
| 124 |
XferDestTaperClass *klass; |
| 125 |
g_assert(IS_XFER_DEST_TAPER(elt)); |
| 126 |
|
| 127 |
klass = XFER_DEST_TAPER_GET_CLASS(elt); |
| 128 |
klass->cache_inform(XFER_DEST_TAPER(elt), filename, offset, length); |
| 129 |
} |
| 130 |
|
| 131 |
guint64 |
| 132 |
xfer_dest_taper_get_part_bytes_written( |
| 133 |
XferElement *elt G_GNUC_UNUSED) |
| 134 |
{ |
| 135 |
XferDestTaperClass *klass; |
| 136 |
g_assert(IS_XFER_DEST_TAPER(elt)); |
| 137 |
|
| 138 |
klass = XFER_DEST_TAPER_GET_CLASS(elt); |
| 139 |
if (klass->get_part_bytes_written) |
| 140 |
return klass->get_part_bytes_written(XFER_DEST_TAPER(elt)); |
| 141 |
else |
| 142 |
return 0; |
| 143 |
} |
| 144 |
|
| 145 |
void |
| 146 |
xfer_dest_taper_new_space_available( |
| 147 |
XferElement *elt, |
| 148 |
int made_space) |
| 149 |
{ |
| 150 |
XferDestTaperClass *klass; |
| 151 |
g_assert(IS_XFER_DEST_TAPER(elt)); |
| 152 |
|
| 153 |
klass = XFER_DEST_TAPER_GET_CLASS(elt); |
| 154 |
if (klass->new_space_available) |
| 155 |
klass->new_space_available(XFER_DEST_TAPER(elt), made_space); |
| 156 |
} |