2 * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3 * Copyright (c) 1991-1998 University of Maryland at College Park
4 * Copyright (c) 2007-2012 Zmanda, Inc. All Rights Reserved.
7 * Permission to use, copy, modify, distribute, and sell this software and its
8 * documentation for any purpose is hereby granted without fee, provided that
9 * the above copyright notice appear in all copies and that both that
10 * copyright notice and this permission notice appear in supporting
11 * documentation, and that the name of U.M. not be used in advertising or
12 * publicity pertaining to distribution of the software without specific,
13 * written prior permission. U.M. makes no representations about the
14 * suitability of this software for any purpose. It is provided "as is"
15 * without express or implied warranty.
17 * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
19 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
20 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
21 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
22 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24 * Authors: the Amanda Development Team. Its members are listed in a
25 * file named AUTHORS, in the root directory of this distribution.
27 /* $Id: disk_history.c,v 1.13 2006/05/25 01:47:19 johnfranks Exp $
29 * functions for obtaining backup history
33 #include "disk_history.h"
35 static DUMP_ITEM *disk_hist = NULL;
40 DUMP_ITEM *item, *this;
47 amfree(this->hostname);
48 while(this->tapes != NULL) {
49 tapelist_t *tapes = this->tapes;
50 this->tapes = tapes->next;
60 /* add item, maintain list ordered by oldest date last */
72 DUMP_ITEM *new, *item, *before;
76 isafile = 1; /* XXX kludgey, like this whole thing */
78 /* See if we already have partnum=partnum-1 */
80 for(item = disk_hist, before = NULL; item;
81 before = item, item = item->next) {
82 if (!strcmp(item->date, date) &&
83 item->level == level && item->is_split) {
84 item->tapes = append_to_tapelist(item->tapes, tape, file,
86 if (maxpart > item->maxpart)
87 item->maxpart = maxpart;
94 new = (DUMP_ITEM *)alloc(SIZEOF(DUMP_ITEM));
95 strncpy(new->date, date, SIZEOF(new->date)-1);
96 new->date[SIZEOF(new->date)-1] = '\0';
98 strncpy(new->tape, tape, SIZEOF(new->tape)-1);
99 new->tape[SIZEOF(new->tape)-1] = '\0';
101 new->maxpart = maxpart;
107 new->hostname = stralloc(hostname);
109 new->tapes = append_to_tapelist(new->tapes, tape, file, partnum, isafile);
111 if (disk_hist == NULL)
118 /* prepend this item to the history list, if it's newer */
119 /* XXX this should probably handle them being on the same date with
120 datestamp_uax or something */
121 if (strcmp(disk_hist->date, new->date) <= 0)
123 new->next = disk_hist;
128 /* append this item to the history list, if it's older */
130 item = disk_hist->next;
131 while ((item != NULL) && (strcmp(item->date, new->date) > 0))
143 DUMP_ITEM *item, *before;
145 /* check if the maxpart part is avaliable */
146 for(item = disk_hist, before = NULL; item;
147 before = item, item = item->next) {
148 int found_maxpart = 0;
149 tapelist_t *cur_tape;
151 if (item->maxpart > 1) {
152 for (cur_tape = item->tapes; cur_tape; cur_tape = cur_tape->next) {
154 for(files=0; files<cur_tape->numfiles; files++) {
155 if (cur_tape->partnum[files] == item->maxpart) {
160 if (found_maxpart == 0) {
161 DUMP_ITEM *myitem = item;
164 before->next = item->next;
166 disk_hist = item->next;
169 free_tapelist(myitem->tapes);
170 amfree(myitem->hostname);