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