Imported Upstream version 2.5.2p1
[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, named by datestamp
33  * Holding file: one or more os-level files in a holding directory, together
34  *  representing a single dump
35  * Holding file chunks: the individual os-level files (continuations) of
36  *  a holding file.
37  *
38  * Example:
39  *
40  * /data/holding                                     <-- holding disk
41  * /data/holding/200703061234                        <-- holding dir
42  * /data/holding/200703061234/videoserver._video_a   <-- holding file, 
43                                                          holding file chunk
44  * /data/holding/200703061234/videoserver._video_a.1 <-- holding file chunk
45  *
46  */
47
48 #ifndef HOLDING_H
49 #define HOLDING_H
50
51 #include "amanda.h"
52 #include "diskfile.h"
53 #include "fileheader.h"
54 #include "sl.h"
55
56 /*
57  * Verbosity
58  */
59
60 /* Set verbose flag for holding-disk functions
61  *
62  * @param verbose: if true, log verbosely to stdout
63  * @returns: old verbosity
64  */
65 int
66 holding_set_verbosity(int verbose);
67
68 /*
69  * Holding disks
70  *
71  * Use getconf_holdingdisks() to access the list of holding disks.
72  */
73
74 /*
75  * Holding directories
76  */
77
78 /* Get a list of holding directories, optionally limited to a single
79  * holding disk.  Can return a list either of full pathnames or of
80  * bare directory names (datestamps).
81  *
82  * @param hdisk: holding disk to enumerate, or NULL for all
83  * @param date_list: Limit to thes timestamps.
84  * @param fullpaths: if true, return full pathnames
85  * @returns: newly allocated sl_t of matching directories
86  */
87 sl_t *
88 holding_get_directories(char *hdisk,
89                         sl_t *date_list,
90                         int fullpaths);
91
92 /*
93  * Holding files
94  */
95
96 /* Get a list of holding files, optionally limited to a single holding
97  * directory.  Can return a list either of full pathnames or of
98  * bare file names.
99  *
100  * @param hdir: holding directory to enumerate, or NULL for all
101  * @param date_list: Limit to thes timestamps.
102  * @param fullpaths: if true, return full pathnames
103  * @returns: newly allocated sl_t of matching files
104  */
105 sl_t *
106 holding_get_files(char *hdir,
107                   sl_t *date_list,
108                   int fullpaths);
109
110 /* Get a list of holding files that should be flushed, optionally
111  * matching only certain datestamps.  This function filters out
112  * files for host/disks that are no longer in the disklist.
113  *
114  * @param dateargs: sl_t of datestamps to dump, or NULL for all
115  * @param interactive: if true, be interactive
116  * @returns: a newly allocated sl_t listing all matching holding 
117  * files
118  */
119 sl_t *
120 holding_get_files_for_flush(sl_t *dateargs, 
121                             int interactive);
122
123 /* Get the total size of a holding file, including all holding 
124  * file chunks, in kilobytes.
125  *
126  * @param holding_file: full pathname of holding file
127  * @param strip_headers: if true, don't count the headers in the
128  * total size
129  * @returns: total size of the holding file, or -1 in an error
130  */
131 off_t 
132 holding_file_size(char *holding_file, 
133                   int strip_headers);
134
135 /* Unlink a holding file, including all holding file chunks.
136  *
137  * @param holding_file: full pathname of holding file
138  * @returns: 1 on success, else 0
139  */
140 int 
141 holding_file_unlink(char *holding_file);
142
143 /* Given a pathname of a holding file, extract the hostname, diskname,
144  * level, and filetype from the header.
145  *
146  * Caller is responsible for freeing memory for hostname and diskname.
147  * None of the result parameters can be NULL.
148  *
149  * @param fname: full pathname of holding file
150  * @param hostname: (result) hostname
151  * @param diskname: (result) diskname
152  * @param level: (result) level
153  * @param datestamp: (result) datestamp of the dump
154  * @returns: filetype (see common-src/fileheader.h)
155  */
156 filetype_t 
157 holding_file_read_header(char *fname,
158                          char **hostname,
159                          char **diskname,
160                          int *level,
161                          char **datestamp);
162
163 /* Given a pathname of a holding file, read the file header.
164  * the result parameter may be altered even if an error is
165  * returned.
166  *
167  * @param fname: full pathname of holding file
168  * @param file: (result) dumpfile_t structure
169  * @returns: 1 on success, else 0
170  */
171 int 
172 holding_file_get_dumpfile(char *fname, 
173                           dumpfile_t *file);
174
175 /*
176  * Holding file chunks
177  */
178
179 /* Get a list of holding files chunks in the given holding 
180  * file.  Always returns full paths.
181  *
182  * @param hfile: holding file to enumerate
183  * @returns: newly allocated sl_t of matching holding file chunks
184  */
185 sl_t *
186 holding_get_file_chunks(char *hfile);
187
188 /*
189  * application-specific support
190  */
191
192 /* Allow the user to select a set of datestamps from those in
193  * holding disks.
194  *
195  * @param verbose: verbose logging to stdout
196  * @returns: a new sl_t listing all matching datestamps
197  */
198 sl_t *
199 pick_datestamp(int verbose);
200
201 /* Similar to pick_datestamp, but always select all available
202  * datestamps.  Non-interactive, but outputs progress to stdout.
203  *
204  * @param verbose: verbose logging to stdout
205  * @returns: a new sl_t listing all matching datestamps
206  */
207 sl_t *
208 pick_all_datestamp(int verbose);
209
210 /* Rename holding files from the temporary names used during
211  * creation.
212  *
213  * @param holding_file: full pathname of holding file,
214  * without '.tmp'
215  * @param complete: if 0, set 'is_partial' to 1 in each file
216  * @returns: 1 on success, else 0
217  */
218 int 
219 rename_tmp_holding(char *holding_file, 
220                    int complete);
221
222 /* Remove any empty datestamp directories.
223  *
224  * @param diskdir: holding directory to clean
225  * @param verbose: verbose logging to stdout
226  */
227 void 
228 cleanup_holdingdisk(char *diskdir, 
229                     int verbose);
230
231 /* Set up a holding directory and do basic permission
232  * checks on it
233  *
234  * @param diskdir: holding directory to set up
235  * @returns: 1 on success, else 0
236  */
237 int 
238 mkholdingdir(char *diskdir);
239
240 #endif /* HOLDING_H */