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