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.
26 /* $Id: disk_history.c,v 1.13 2006/05/25 01:47:19 johnfranks Exp $
28 * functions for obtaining backup history
32 #include "disk_history.h"
34 static DUMP_ITEM *disk_hist = NULL;
39 DUMP_ITEM *item, *this;
46 amfree(this->hostname);
47 while(this->tapes != NULL) {
48 tapelist_t *tapes = this->tapes;
49 this->tapes = tapes->next;
59 /* add item, maintain list ordered by oldest date last */
71 DUMP_ITEM *new, *item, *before;
75 isafile = 1; /* XXX kludgey, like this whole thing */
77 /* See if we already have partnum=partnum-1 */
79 for(item = disk_hist, before = NULL; item;
80 before = item, item = item->next) {
81 if (!strcmp(item->date, date) &&
82 item->level == level && item->is_split) {
83 item->tapes = append_to_tapelist(item->tapes, tape, file,
85 if (maxpart > item->maxpart)
86 item->maxpart = maxpart;
93 new = (DUMP_ITEM *)alloc(SIZEOF(DUMP_ITEM));
94 strncpy(new->date, date, SIZEOF(new->date)-1);
95 new->date[SIZEOF(new->date)-1] = '\0';
97 strncpy(new->tape, tape, SIZEOF(new->tape)-1);
98 new->tape[SIZEOF(new->tape)-1] = '\0';
100 new->maxpart = maxpart;
106 new->hostname = stralloc(hostname);
108 new->tapes = append_to_tapelist(new->tapes, tape, file, partnum, isafile);
110 if (disk_hist == NULL)
117 /* prepend this item to the history list, if it's newer */
118 /* XXX this should probably handle them being on the same date with
119 datestamp_uax or something */
120 if (strcmp(disk_hist->date, new->date) <= 0)
122 new->next = disk_hist;
127 /* append this item to the history list, if it's older */
129 item = disk_hist->next;
130 while ((item != NULL) && (strcmp(item->date, new->date) > 0))
142 DUMP_ITEM *item, *before;
144 /* check if the maxpart part is avaliable */
145 for(item = disk_hist, before = NULL; item;
146 before = item, item = item->next) {
147 int found_maxpart = 0;
148 tapelist_t *cur_tape;
150 if (item->maxpart > 1) {
151 for (cur_tape = item->tapes; cur_tape; cur_tape = cur_tape->next) {
153 for(files=0; files<cur_tape->numfiles; files++) {
154 if (cur_tape->partnum[files] == item->maxpart) {
159 if (found_maxpart == 0) {
160 DUMP_ITEM *myitem = item;
163 before->next = item->next;
165 disk_hist = item->next;
168 free_tapelist(myitem->tapes);
169 amfree(myitem->hostname);