2 * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3 * Copyright (c) 1991-1998 University of Maryland at College Park
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.
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.
23 * Authors: the Amanda Development Team. Its members are listed in a
24 * file named AUTHORS, in the root directory of this distribution.
27 * $Id: holding.h,v 1.23 2006/05/25 01:47:20 johnfranks Exp $
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
41 * /data/holding <-- holding disk
42 * /data/holding/20070306123456 <-- holding dir
43 * /data/holding/20070306123456/videoserver._video_a <-- holding file,
45 * /data/holding/20070306123456/videoserver._video_a.1 <-- holding file chunk
53 #include "fileheader.h"
55 /* Get a list of holding disks. This is equivalent to
56 * getconf_holdingdisks() with holdingdisk_get_diskdir().
58 * @returns: newly allocated GSList of matching disks
61 holding_get_disks(void);
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
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
72 holding_get_files(char *hdir,
75 /* Get a list of holding files chunks in the given holding
76 * file. Always returns full paths.
78 * @param hfile: holding file to enumerate
79 * @returns: newly allocated GSList of matching holding file chunks
82 holding_get_file_chunks(char *hfile);
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.
88 * @param dateargs: GSList of datestamps expressions to dump, or NULL
90 * @returns: a newly allocated GSList listing all matching holding
94 holding_get_files_for_flush(GSList *dateargs);
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)
101 * @returns: a newly allocated GSList listing all datestamps
104 holding_get_all_datestamps(void);
106 /* Get the total size of a holding file, including all holding
107 * file chunks, in kilobytes.
109 * @param holding_file: full pathname of holding file
110 * @param strip_headers: if true, don't count the headers in the
112 * @returns: total size in kbytes of the holding file, or -1 in an error
115 holding_file_size(char *holding_file,
118 /* Unlink a holding file, including all holding file chunks.
120 * @param holding_file: full pathname of holding file
121 * @returns: 1 on success, else 0
124 holding_file_unlink(char *holding_file);
126 /* Given a pathname of a holding file, read the file header.
127 * the result parameter may be altered even if an error is
130 * @param fname: full pathname of holding file
131 * @param file: (result) dumpfile_t structure
132 * @returns: 1 on success, else 0
135 holding_file_get_dumpfile(char *fname,
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.
146 * All error and warning messages go to the debug log.
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
153 typedef void (*corrupt_dle_fn)(char *hostname, char *disk);
155 holding_cleanup(corrupt_dle_fn corrupt_dle,
156 FILE *verbose_output);
159 * application-specific support
162 /* Set the orig_size in the header
164 * @param holding_file: full pathname of holding file.
165 * @param orig_size: the size.
168 holding_set_origsize(char *holding_file, off_t orig_size);
170 /* Rename holding files from the temporary names used during
173 * This is currently called by driver.c, but will disappear when
174 * holding is fully converted to the device API
176 * @param holding_file: full pathname of holding file,
178 * @param complete: if 0, set 'is_partial' to 1 in each file
179 * @returns: 1 on success, else 0
182 rename_tmp_holding(char *holding_file,
185 /* Set up a holding directory and do basic permission
188 * @param diskdir: holding directory to set up
189 * @returns: 1 on success, else 0
192 mkholdingdir(char *diskdir);
194 #endif /* HOLDING_H */