Imported Upstream version 3.2.0
[debian/amanda] / server-src / holding.h
index 75284d5e39c74e8c521a8751c588dd5289de2757..d8f992ac219e7a8f914d0be2fe1efb5357d9dfb9 100644 (file)
  * file named AUTHORS, in the root directory of this distribution.
  */
 /*
- * $Id: holding.h,v 1.22 2005/10/11 01:17:01 vectro Exp $
+ * $Id: holding.h,v 1.23 2006/05/25 01:47:20 johnfranks Exp $
+ *
+ * Terminology:
+ *
+ * Holding disk: a top-level directory given in amanda.conf
+ * Holding directory: a subdirectory of a holding disk, usually named by 
+ *  datestamp.  These are not accessible through this API.
+ * Holding file: one or more os-level files in a holding directory, together
+ *  representing a single dump
+ * Holding file chunks: the individual os-level files (continuations) of
+ *  a holding file.
+ *
+ * Example:
+ *
+ * /data/holding                                       <-- holding disk
+ * /data/holding/20070306123456                        <-- holding dir
+ * /data/holding/20070306123456/videoserver._video_a   <-- holding file,
+                                                           holding file chunk
+ * /data/holding/20070306123456/videoserver._video_a.1 <-- holding file chunk
  *
  */
 
 #define HOLDING_H
 
 #include "amanda.h"
-#include "diskfile.h"
 #include "fileheader.h"
-#include "sl.h"
-
-/* local functions */
-int is_dir P((char *fname));
-int is_emptyfile P((char *fname));
-int is_datestr P((char *fname));
-int non_empty P((char *fname));
-void free_holding_list P(( sl_t *holding_list));
-sl_t *get_flush(sl_t *dateargs, char *datestamp, int amflush, int verbose);
-sl_t *pick_datestamp P((int verbose));
-sl_t *pick_all_datestamp P((int verbose));
-filetype_t get_amanda_names P((char *fname,
-                              char **hostname,
-                              char **diskname,
-                              int *level));
-void get_dumpfile P((char *fname, dumpfile_t *file));
-long size_holding_files P((char *holding_file, int strip_headers));
-int unlink_holding_files P((char *holding_file));
-int rename_tmp_holding P((char *holding_file, int complete));
-void cleanup_holdingdisk P((char *diskdir, int verbose));
-int mkholdingdir P((char *diskdir));
 
+/* Get a list of holding disks.  This is equivalent to 
+ * getconf_holdingdisks() with holdingdisk_get_diskdir().
+ *
+ * @returns: newly allocated GSList of matching disks
+ */
+GSList *
+holding_get_disks(void);
+
+/* Get a list of holding files, optionally limited to a single holding
+ * directory.  Can return a list either of full pathnames or of
+ * bare file names.
+ *
+ * @param hdir: holding directory to enumerate, or NULL for all
+ * @param fullpaths: if true, return full pathnames
+ * @returns: newly allocated GSList of matching files
+ */
+GSList *
+holding_get_files(char *hdir,
+                  int fullpaths);
+
+/* Get a list of holding files chunks in the given holding
+ * file.  Always returns full paths.
+ *
+ * @param hfile: holding file to enumerate
+ * @returns: newly allocated GSList of matching holding file chunks
+ */
+GSList *
+holding_get_file_chunks(char *hfile);
+
+/* Get a list of holding files that should be flushed, optionally
+ * matching only certain datestamps.  This function does *not*
+ * match the dumps against the disklist.
+ *
+ * @param dateargs: GSList of datestamps expressions to dump, or NULL 
+ * for all
+ * @returns: a newly allocated GSList listing all matching holding
+ * files
+ */
+GSList *
+holding_get_files_for_flush(GSList *dateargs);
+
+/* Get a list of all datestamps for which dumps are in the holding
+ * disk.  This scans all dumps and takes the union of their
+ * datestamps (some/all of which may actually be timestamps, 
+ * depending on the setting of config option usetimestamps)
+ *
+ * @returns: a newly allocated GSList listing all datestamps
+ */
+GSList *
+holding_get_all_datestamps(void);
+
+/* Get the total size of a holding file, including all holding
+ * file chunks, in kilobytes.
+ *
+ * @param holding_file: full pathname of holding file
+ * @param strip_headers: if true, don't count the headers in the
+ * total size
+ * @returns: total size in kbytes of the holding file, or -1 in an error
+ */
+off_t
+holding_file_size(char *holding_file,
+                  int strip_headers);
+
+/* Unlink a holding file, including all holding file chunks.
+ *
+ * @param holding_file: full pathname of holding file
+ * @returns: 1 on success, else 0
+ */
+int
+holding_file_unlink(char *holding_file);
+
+/* Given a pathname of a holding file, read the file header.
+ * the result parameter may be altered even if an error is
+ * returned.
+ *
+ * @param fname: full pathname of holding file
+ * @param file: (result) dumpfile_t structure
+ * @returns: 1 on success, else 0
+ */
+int
+holding_file_get_dumpfile(char *fname,
+                          dumpfile_t *file);
+
+/*
+ * Maintenance
+ */
+
+/* Clean up all holding disks, restoring from a possible crash or
+ * other errors.  This function is intentionally opaque, as the
+ * details of holding disk are hidden from other applications.
+ *
+ * All error and warning messages go to the debug log.
+ *
+ * @param corrupt_dle: function that is called for any DLEs for
+ * which corrupt dumps are found.
+ * @param verbose_output: if non-NULL, send progress messages to
+ * this file.
+ */
+typedef void (*corrupt_dle_fn)(char *hostname, char *disk);
+void
+holding_cleanup(corrupt_dle_fn corrupt_dle,
+    FILE *verbose_output);
+
+/*
+ * application-specific support
+ */
+
+/* Set the orig_size in the header
+ *
+ * @param holding_file: full pathname of holding file.
+ * @param orig_size: the size.
+ */
+void
+holding_set_origsize(char *holding_file, off_t orig_size);
+
+/* Rename holding files from the temporary names used during
+ * creation.
+ *
+ * This is currently called by driver.c, but will disappear when
+ * holding is fully converted to the device API
+ *
+ * @param holding_file: full pathname of holding file,
+ * without '.tmp'
+ * @param complete: if 0, set 'is_partial' to 1 in each file
+ * @returns: 1 on success, else 0
+ */
+int
+rename_tmp_holding(char *holding_file,
+                   int complete);
+
+/* Set up a holding directory and do basic permission
+ * checks on it
+ *
+ * @param diskdir: holding directory to set up
+ * @returns: 1 on success, else 0
+ */
+int
+mkholdingdir(char *diskdir);
 
 #endif /* HOLDING_H */