2 * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3 * Copyright (c) 2009, 2010 Zmanda, Inc. All Rights Reserved.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published
7 * by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * Contact information: Zmanda Inc., 465 S. Mathilda Ave., Suite 300
19 * Sunnyvale, CA 94085, USA, or: http://www.zmanda.com
28 /* A transfer source that reads from a Device. The device must be positioned
29 * at the start of a file before the transfer is started. The transfer will
30 * continue until the end of the file.
32 * Implemented in xfer-source-device.c
34 * @param device: Device object to read from
35 * @return: new element
37 XferElement *xfer_source_device(
40 /* A transfer destination that writes bytes to a Device. The device should have a
41 * file started, ready for a device_write_block call. On completion of the transfer,
42 * the file will be finished.
44 * Implemented in xfer-dest-device.c
46 * @param device: the Device to write to, with a file started
47 * @param max_memory: total amount of memory to use for buffers, or zero
48 * for a reasonable default.
49 * @return: new element
51 XferElement *xfer_dest_device(
56 * class declaration for XferDestTaper (an abstract base class)
59 GType xfer_dest_taper_get_type(void);
60 #define XFER_DEST_TAPER_TYPE (xfer_dest_taper_get_type())
61 #define XFER_DEST_TAPER(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), xfer_dest_taper_get_type(), XferDestTaper)
62 #define XFER_DEST_TAPER_CONST(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), xfer_dest_taper_get_type(), XferDestTaper const)
63 #define XFER_DEST_TAPER_CLASS(klass) G_TYPE_CHECK_CLASS_CAST((klass), xfer_dest_taper_get_type(), XferDestTaperClass)
64 #define IS_XFER_DEST_TAPER(obj) G_TYPE_CHECK_INSTANCE_TYPE((obj), xfer_dest_taper_get_type ())
65 #define XFER_DEST_TAPER_GET_CLASS(obj) G_TYPE_INSTANCE_GET_CLASS((obj), xfer_dest_taper_get_type(), XferDestTaperClass)
67 typedef struct XferDestTaper_ {
68 XferElement __parent__;
72 XferElementClass __parent__;
74 /* see xfer-device.h for details of these methods */
75 void (*start_part)(XferDestTaper *self, gboolean retry_part, dumpfile_t *header);
76 void (*use_device)(XferDestTaper *self, Device *device);
77 void (*cache_inform)(XferDestTaper *self, const char *filename, off_t offset,
79 guint64 (*get_part_bytes_written)(XferDestTaper *self);
82 /* Start writing the next part to the given device. The part will be written
83 * to the device given to use_device, which should be open and properly positioned.
84 * It should not have a file open yet.
86 * @param self: the XferDestTaper object
87 * @param retry_part: retry the previous (incomplete) part if true
88 * @param header: part header
90 void xfer_dest_taper_start_part(
95 /* Prepare to write subsequent parts to the given device. The device must
96 * not be started yet. It is not necessary to call this method for the first
97 * device used in a transfer.
99 * @param self: the XferDestTaper object
100 * @param device: the device
102 void xfer_dest_taper_use_device(
106 /* Add a slice of data to the cache for the element. This is used by the taper
107 * when reading from holding disk, to tell the element which holding disk files
108 * contain the data that might be needed when rewinding, but can be used in any
109 * situation where the part data is already on-disk. The order of calls to this
110 * function dictates the order in whch the files will be read, and no gaps or
111 * overlaps are supported. Note, too, that this must be called *before* any of
112 * the data in the new file is sent into the transfer.
114 * @param self: the XferDestTaper object
115 * @param filename: the fully qualified filename of the cache file
116 * @param offset: offset into the file at which data begins
117 * @param length: length of data in file
119 void xfer_dest_taper_cache_inform(
121 const char *filename,
125 /* Return the number of bytes written for the current part.
127 * @param self: the XferDestTaper object
129 guint64 xfer_dest_taper_get_part_bytes_written(
132 /* Constructor for XferDestTaperSplitter, which writes data to devices block by
133 * block and handles caching and splitting parts.
135 * @param first_device: the first device that will be used with this xfer, used
136 * to calculate some internal parameters
137 * @param max_memory: total amount of memory to use for buffers, or zero
138 * for a reasonable default.
139 * @param part_size: the desired size of each part
140 * @param use_mem_cache: if true, use the memory cache
141 * @param disk_cache_dirname: if not NULL, this is the directory in which the disk
142 * cache should be created
143 * @return: new element
146 xfer_dest_taper_splitter(
147 Device *first_device,
150 gboolean use_mem_cache,
151 const char *disk_cache_dirname);
153 /* Constructor for XferDestTaperDirectTCP, which uses DirectTCP to transfer data
154 * to devices (which must support the feature).
156 * @param first_device: the first device that will be used with this xfer, used
157 * to calculate some internal parameters
158 * @param part_size: the desired size of each part
159 * @return: new element
162 xfer_dest_taper_directtcp(
163 Device *first_device,
170 /* Create a new XferSourceRecovery object. Like XferDestTaper instances, this object
171 * will not start transferring data until xfer_source_recovery_start_part is called to
172 * give the device from which the data should flow.
174 * @param first device: teh first device that will be used with this xfer
175 * @returns: new element
178 xfer_source_recovery(
179 Device *first_device);
181 /* Start an XferSourceRecovery reading from a particular, pre-positioned device
183 * @param self: XferSourceRecovery object
184 * @param device: device to read from
187 xfer_source_recovery_start_part(
191 /* Prepare to read subsequent parts from the given device. The device must
192 * not be started yet. It is not necessary to call this method for the first
193 * device used in a transfer.
195 * @param self: the XferSourceRecovery object
196 * @param device: the device
198 void xfer_source_recovery_use_device(