Blame server-src/find.h

Packit 23ab03
#ifndef FIND_H
Packit 23ab03
#define FIND_H
Packit 23ab03
Packit 23ab03
#include "diskfile.h"
Packit 23ab03
Packit 23ab03
#define DEFAULT_SORT_ORDER      "hkdlspbfw"
Packit 23ab03
Packit 23ab03
typedef struct find_result_s {
Packit 23ab03
    struct find_result_s *next;
Packit 23ab03
    char *timestamp;		/* dump timestamp */
Packit 23ab03
    char *write_timestamp;
Packit 23ab03
    char *hostname;
Packit 23ab03
    char *diskname;
Packit 23ab03
    char *storage;
Packit 23ab03
    int   storage_id;
Packit 23ab03
    char *pool;
Packit 23ab03
    int level;
Packit 23ab03
    char *label;	/* holding filename for holding files */
Packit 23ab03
    off_t filenum;
Packit 23ab03
    char *status;	/* status of the part */
Packit 23ab03
    char *dump_status;	/* status of the dump; should be identical for all parts in dump */
Packit 23ab03
    char *message;	/* reason for dump_status; should be identical for all parts in dump */
Packit 23ab03
    int partnum;	/* -1 for holding files */
Packit 23ab03
    int totalparts;	/* -1 for holding files */
Packit 23ab03
    double sec;		/* may be 0.0 for older log files or holding files */
Packit 23ab03
    off_t bytes;	/* may be 0 for older log files, can be compressed */
Packit 23ab03
    off_t kb;		/* may be 0 for older log files, can be compressed */
Packit 23ab03
    off_t orig_kb;      /* native size */
Packit 23ab03
    crc_t native_crc;
Packit 23ab03
    crc_t client_crc;
Packit 23ab03
    crc_t server_crc;
Packit 23ab03
    void *user_ptr;
Packit 23ab03
} find_result_t;
Packit 23ab03
Packit 23ab03
/* Finds /all/ dumps still on a volume. If diskqp is not NULL, then dumps
Packit 23ab03
 * not matching any existing disklist entry will be added to diskqp and to
Packit 23ab03
 * the global disklist. If diskqp is NULL, disks not matching existing
Packit 23ab03
 * disklist entries will be skipped. See search_logfile below, which does
Packit 23ab03
 * the dirty work for find_dump. */
Packit 23ab03
find_result_t *find_dump(disklist_t* diskqp, int added_todo);
Packit 23ab03
Packit 23ab03
/* Return a list of unqualified filenames of logfiles for active
Packit 23ab03
 * tapes.  Filenames are relative to the logdir.
Packit 23ab03
 *
Packit 23ab03
 * @returns: dynamically allocated, null-terminated strv
Packit 23ab03
 */
Packit 23ab03
char **find_log(void);
Packit 23ab03
GHashTable *hash_find_log(void);
Packit 23ab03
Packit 23ab03
Packit 23ab03
void sort_find_result(char *sort_order, find_result_t **output_find);
Packit 23ab03
void sort_find_result_with_storage(char *sort_order, char **storage_list, find_result_t **output_find);
Packit 23ab03
void print_find_result(find_result_t *output_find);
Packit 23ab03
void free_find_result(find_result_t **output_find);
Packit 23ab03
find_result_t *dump_exist(find_result_t *output_find, char *hostname,
Packit 23ab03
                          char *diskname, char *datestamp, int level);
Packit 23ab03
find_result_t *dumps_match(find_result_t *output_find, char *hostname,
Packit 23ab03
                           char *diskname, char *datestamp, char *level,
Packit 23ab03
                           int ok);
Packit 23ab03
find_result_t *dumps_match_dumpspecs(find_result_t *output_find,
Packit 23ab03
				     GSList *dumpspecs,
Packit 23ab03
				     int ok);
Packit 23ab03
Packit 23ab03
/* This function looks in a particular log.xxx file for dumps. Returns TRUE
Packit 23ab03
 * if something was found. This function also skips dumps whose disklist
Packit 23ab03
 * entries are not marked 'todo'.
Packit 23ab03
 * * output_find      : Put found dumps here.
Packit 23ab03
 * * volume_label     : If not NULL, restrict the search to
Packit 23ab03
 *                      dumps matching the given volume details.
Packit 23ab03
 * * log_datestamp    : If not NULL, checks that this logfile is from this time.
Packit 23ab03
 * * logfile          : Name of logfile in config dir.
Packit 23ab03
 * * dynamic_disklist : If not NULL, adds disks not already in the global
Packit 23ab03
 *                      disklist to the given disklist (and the global one).
Packit 23ab03
 *                      If dynamic_disklist is NULL, skips disks not in the
Packit 23ab03
 *                      global disklist.
Packit 23ab03
 */
Packit 23ab03
gboolean search_logfile(find_result_t **output_find, const char *volume_label,
Packit 23ab03
                        const char *log_datestamp, const char *logfile,
Packit 23ab03
                        disklist_t * dynamic_disklist, int added_todo);
Packit 23ab03
Packit 23ab03
/* return all dumps on holding disk; not really a search at all.
Packit 23ab03
 *
Packit 23ab03
 * * output_find      : Put found dumps here.
Packit 23ab03
 * * dynamic_disklist : If not NULL, adds disks not already in the global
Packit 23ab03
 *                      disklist to the given disklist (and the global one).
Packit 23ab03
 *                      If dynamic_disklist is NULL, skips disks not in the
Packit 23ab03
 *                      global disklist.
Packit 23ab03
 */
Packit 23ab03
void search_holding_disk(
Packit 23ab03
	find_result_t **output_find,
Packit 23ab03
	disklist_t * dynamic_disklist,
Packit 23ab03
	int added_todo);
Packit 23ab03
Packit 23ab03
GHashTable *make_dump_hash(find_result_t *output_find);
Packit 23ab03
void free_dump_hash(GHashTable *dump_hash);
Packit 23ab03
find_result_t *dump_hash_exist(GHashTable *dump_hash, char *hostname, char *diskname,
Packit 23ab03
			       char *datestamp, int level);
Packit 23ab03
Packit 23ab03
Packit 23ab03
#endif	/* !FIND_H */