oops, need this patch file too
[debian/amanda] / server-src / holding.h
1 /*
2  * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3  * Copyright (c) 1991-1998 University of Maryland at College Park
4  * All Rights Reserved.
5  *
6  * Permission to use, copy, modify, distribute, and sell this software and its
7  * documentation for any purpose is hereby granted without fee, provided that
8  * the above copyright notice appear in all copies and that both that
9  * copyright notice and this permission notice appear in supporting
10  * documentation, and that the name of U.M. not be used in advertising or
11  * publicity pertaining to distribution of the software without specific,
12  * written prior permission.  U.M. makes no representations about the
13  * suitability of this software for any purpose.  It is provided "as is"
14  * without express or implied warranty.
15  *
16  * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
18  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
20  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
21  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22  *
23  * Authors: the Amanda Development Team.  Its members are listed in a
24  * file named AUTHORS, in the root directory of this distribution.
25  */
26 /*
27  * $Id: holding.h,v 1.23 2006/05/25 01:47:20 johnfranks Exp $
28  *
29  * Terminology:
30  *
31  * Holding disk: a top-level directory given in amanda.conf
32  * Holding directory: a subdirectory of a holding disk, usually named by 
33  *  datestamp.  These are not accessible through this API.
34  * Holding file: one or more os-level files in a holding directory, together
35  *  representing a single dump
36  * Holding file chunks: the individual os-level files (continuations) of
37  *  a holding file.
38  *
39  * Example:
40  *
41  * /data/holding                                       <-- holding disk
42  * /data/holding/20070306123456                        <-- holding dir
43  * /data/holding/20070306123456/videoserver._video_a   <-- holding file,
44                                                            holding file chunk
45  * /data/holding/20070306123456/videoserver._video_a.1 <-- holding file chunk
46  *
47  */
48
49 #ifndef HOLDING_H
50 #define HOLDING_H
51
52 #include "amanda.h"
53 #include "fileheader.h"
54
55 /* Get a list of holding disks.  This is equivalent to 
56  * getconf_holdingdisks() with holdingdisk_get_diskdir().
57  *
58  * @returns: newly allocated GSList of matching disks
59  */
60 GSList *
61 holding_get_disks(void);
62
63 /* Get a list of holding files, optionally limited to a single holding
64  * directory.  Can return a list either of full pathnames or of
65  * bare file names.
66  *
67  * @param hdir: holding directory to enumerate, or NULL for all
68  * @param fullpaths: if true, return full pathnames
69  * @returns: newly allocated GSList of matching files
70  */
71 GSList *
72 holding_get_files(char *hdir,
73                   int fullpaths);
74
75 /* Get a list of holding files chunks in the given holding
76  * file.  Always returns full paths.
77  *
78  * @param hfile: holding file to enumerate
79  * @returns: newly allocated GSList of matching holding file chunks
80  */
81 GSList *
82 holding_get_file_chunks(char *hfile);
83
84 /* Get a list of holding files that should be flushed, optionally
85  * matching only certain datestamps.  This function does *not*
86  * match the dumps against the disklist.
87  *
88  * @param dateargs: GSList of datestamps expressions to dump, or NULL 
89  * for all
90  * @returns: a newly allocated GSList listing all matching holding
91  * files
92  */
93 GSList *
94 holding_get_files_for_flush(GSList *dateargs);
95
96 /* Get a list of all datestamps for which dumps are in the holding
97  * disk.  This scans all dumps and takes the union of their
98  * datestamps (some/all of which may actually be timestamps, 
99  * depending on the setting of config option usetimestamps)
100  *
101  * @returns: a newly allocated GSList listing all datestamps
102  */
103 GSList *
104 holding_get_all_datestamps(void);
105
106 /* Get the total size of a holding file, including all holding
107  * file chunks, in kilobytes.
108  *
109  * @param holding_file: full pathname of holding file
110  * @param strip_headers: if true, don't count the headers in the
111  * total size
112  * @returns: total size in kbytes of the holding file, or -1 in an error
113  */
114 off_t
115 holding_file_size(char *holding_file,
116                   int strip_headers);
117
118 /* Unlink a holding file, including all holding file chunks.
119  *
120  * @param holding_file: full pathname of holding file
121  * @returns: 1 on success, else 0
122  */
123 int
124 holding_file_unlink(char *holding_file);
125
126 /* Given a pathname of a holding file, read the file header.
127  * the result parameter may be altered even if an error is
128  * returned.
129  *
130  * @param fname: full pathname of holding file
131  * @param file: (result) dumpfile_t structure
132  * @returns: 1 on success, else 0
133  */
134 int
135 holding_file_get_dumpfile(char *fname,
136                           dumpfile_t *file);
137
138 /*
139  * Maintenance
140  */
141
142 /* Clean up all holding disks, restoring from a possible crash or
143  * other errors.  This function is intentionally opaque, as the
144  * details of holding disk are hidden from other applications.
145  *
146  * All error and warning messages go to the debug log.
147  *
148  * @param corrupt_dle: function that is called for any DLEs for
149  * which corrupt dumps are found.
150  * @param verbose_output: if non-NULL, send progress messages to
151  * this file.
152  */
153 typedef void (*corrupt_dle_fn)(char *hostname, char *disk);
154 void
155 holding_cleanup(corrupt_dle_fn corrupt_dle,
156     FILE *verbose_output);
157
158 /*
159  * application-specific support
160  */
161
162 /* Set the orig_size in the header
163  *
164  * @param holding_file: full pathname of holding file.
165  * @param orig_size: the size.
166  */
167 void
168 holding_set_origsize(char *holding_file, off_t orig_size);
169
170 /* Rename holding files from the temporary names used during
171  * creation.
172  *
173  * This is currently called by driver.c, but will disappear when
174  * holding is fully converted to the device API
175  *
176  * @param holding_file: full pathname of holding file,
177  * without '.tmp'
178  * @param complete: if 0, set 'is_partial' to 1 in each file
179  * @returns: 1 on success, else 0
180  */
181 int
182 rename_tmp_holding(char *holding_file,
183                    int complete);
184
185 /* Set up a holding directory and do basic permission
186  * checks on it
187  *
188  * @param diskdir: holding directory to set up
189  * @returns: 1 on success, else 0
190  */
191 int
192 mkholdingdir(char *diskdir);
193
194 #endif /* HOLDING_H */