| 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 |
#ifndef XFER_DEVICE_H |
| 25 |
#define XFER_DEVICE_H |
| 26 |
|
| 27 |
#include "amxfer.h" |
| 28 |
#include "device.h" |
| 29 |
#include "xfer-dest-taper.h" |
| 30 |
|
| 31 |
/* A transfer source that reads from a Device. The device must be positioned |
| 32 |
* at the start of a file before the transfer is started. The transfer will |
| 33 |
* continue until the end of the file. |
| 34 |
* |
| 35 |
* Implemented in xfer-source-device.c |
| 36 |
* |
| 37 |
* @param device: Device object to read from |
| 38 |
* @return: new element |
| 39 |
*/ |
| 40 |
XferElement *xfer_source_device( |
| 41 |
Device *device); |
| 42 |
|
| 43 |
/* A transfer destination that writes bytes to a Device. The device should have a |
| 44 |
* file started, ready for a device_write_block call. On completion of the transfer, |
| 45 |
* the file will be finished. If a device error occurs, the transfer will be cancelled. |
| 46 |
* |
| 47 |
* If cancel_at_leom is true, then the transfer will also be cancelled on LEOM, with |
| 48 |
* the error message containing the string "LEOM detected" (this is used by amtapetype). |
| 49 |
* |
| 50 |
* Implemented in xfer-dest-device.c |
| 51 |
* |
| 52 |
* @param device: the Device to write to, with a file started |
| 53 |
* @param canel_at_leom: if true, the element will cancel the transfer at LEOM. |
| 54 |
* @return: new element |
| 55 |
*/ |
| 56 |
XferElement *xfer_dest_device( |
| 57 |
Device *device, |
| 58 |
gboolean canel_at_leom); |
| 59 |
|
| 60 |
/* Constructor for XferDestTaperSplitter, which writes data to devices block by |
| 61 |
* block and splitting parts but no caching. |
| 62 |
* |
| 63 |
* @param first_device: the first device that will be used with this xfer, used |
| 64 |
* to calculate some internal parameters |
| 65 |
* @param max_memory: total amount of memory to use for buffers, or zero |
| 66 |
* for a reasonable default. |
| 67 |
* @param part_size: the desired size of each part |
| 68 |
* @param expect_cache_inform: TRUE if this element will get cache_inform messages |
| 69 |
* @return: new element |
| 70 |
*/ |
| 71 |
XferElement * |
| 72 |
xfer_dest_taper_splitter( |
| 73 |
Device *first_device, |
| 74 |
size_t max_memory, |
| 75 |
guint64 part_size, |
| 76 |
gboolean expect_cache_inform); |
| 77 |
|
| 78 |
/* Constructor for XferDestTaperCacher, which writes data to devices block by |
| 79 |
* block and handles caching and splitting parts. |
| 80 |
* |
| 81 |
* @param first_device: the first device that will be used with this xfer, used |
| 82 |
* to calculate some internal parameters |
| 83 |
* @param max_memory: total amount of memory to use for buffers, or zero |
| 84 |
* for a reasonable default. |
| 85 |
* @param part_size: the desired size of each part |
| 86 |
* @param use_mem_cache: if true, use the memory cache |
| 87 |
* @param disk_cache_dirname: if not NULL, this is the directory in which the disk |
| 88 |
* cache should be created |
| 89 |
* @return: new element |
| 90 |
*/ |
| 91 |
XferElement * |
| 92 |
xfer_dest_taper_cacher( |
| 93 |
Device *first_device, |
| 94 |
size_t max_memory, |
| 95 |
guint64 part_size, |
| 96 |
gboolean use_mem_cache, |
| 97 |
const char *disk_cache_dirname); |
| 98 |
|
| 99 |
/* Constructor for XferDestTaperDirectTCP, which uses DirectTCP to transfer data |
| 100 |
* to devices (which must support the feature). |
| 101 |
* |
| 102 |
* @param first_device: the first device that will be used with this xfer, used |
| 103 |
* to calculate some internal parameters |
| 104 |
* @param part_size: the desired size of each part |
| 105 |
* @return: new element |
| 106 |
*/ |
| 107 |
XferElement * |
| 108 |
xfer_dest_taper_directtcp( |
| 109 |
Device *first_device, |
| 110 |
guint64 part_size); |
| 111 |
|
| 112 |
/* |
| 113 |
* XferSourceRecovery |
| 114 |
*/ |
| 115 |
|
| 116 |
/* Create a new XferSourceRecovery object. Like XferDestTaper instances, this object |
| 117 |
* will not start transferring data until xfer_source_recovery_start_part is called to |
| 118 |
* give the device from which the data should flow. |
| 119 |
* |
| 120 |
* @param first device: teh first device that will be used with this xfer |
| 121 |
* @returns: new element |
| 122 |
*/ |
| 123 |
XferElement * |
| 124 |
xfer_source_recovery( |
| 125 |
Device *first_device); |
| 126 |
|
| 127 |
/* Start an XferSourceRecovery reading from a particular, pre-positioned device |
| 128 |
* |
| 129 |
* @param self: XferSourceRecovery object |
| 130 |
* @param device: device to read from |
| 131 |
*/ |
| 132 |
void |
| 133 |
xfer_source_recovery_start_part( |
| 134 |
XferElement *elt, |
| 135 |
Device *device); |
| 136 |
|
| 137 |
/* Prepare to read subsequent parts from the given device. The device must |
| 138 |
* not be started yet. It is not necessary to call this method for the first |
| 139 |
* device used in a transfer. |
| 140 |
* |
| 141 |
* @param self: the XferSourceRecovery object |
| 142 |
* @param device: the device |
| 143 |
*/ |
| 144 |
void xfer_source_recovery_use_device( |
| 145 |
XferElement *self, |
| 146 |
Device *device); |
| 147 |
|
| 148 |
guint64 |
| 149 |
xfer_source_recovery_get_bytes_read( |
| 150 |
XferElement *elt); |
| 151 |
|
| 152 |
gboolean |
| 153 |
xfer_source_recovery_cancel( |
| 154 |
XferElement *elt, |
| 155 |
gboolean expect_eof); |
| 156 |
|
| 157 |
#endif |