From 4d9bbcc9e0d1ddd04dd322d8236baaf75c8f1bb7 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Wed, 19 Nov 2008 16:59:23 +0000 Subject: [PATCH] Use doubly linked bsr list so that consumed bsrs may be removed. Removing not yet implemented. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8060 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/stored/bsr.h | 20 +++++++++-------- bacula/src/stored/parse_bsr.c | 42 ++++++++++++++++++++++++++++------- bacula/technotes-2.5 | 3 +++ 3 files changed, 48 insertions(+), 17 deletions(-) diff --git a/bacula/src/stored/bsr.h b/bacula/src/stored/bsr.h index 4782aec87e..9e594dedfe 100644 --- a/bacula/src/stored/bsr.h +++ b/bacula/src/stored/bsr.h @@ -1,15 +1,7 @@ -/* - * BootStrap record definition -- for restoring files. - * - * Kern Sibbald, June 2002 - * - * Version $Id$ - * - */ /* Bacula® - The Network Backup Solution - Copyright (C) 2002-2006 Free Software Foundation Europe e.V. + Copyright (C) 2002-2008 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -33,6 +25,14 @@ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, Switzerland, email:ftf@fsfeurope.org. */ +/* + * BootStrap record definition -- for restoring files. + * + * Kern Sibbald, June 2002 + * + * Version $Id$ + * + */ #ifndef __BSR_H @@ -142,7 +142,9 @@ struct BSR_STREAM { }; struct BSR { + /* NOTE!!! next must be the first item */ BSR *next; /* pointer to next one */ + BSR *prev; /* pointer to previous one */ BSR *root; /* root bsr */ bool reposition; /* set when any bsr is marked done */ bool mount_next_volume; /* set when next volume should be mounted */ diff --git a/bacula/src/stored/parse_bsr.c b/bacula/src/stored/parse_bsr.c index 595b1fea73..ceeaba618e 100644 --- a/bacula/src/stored/parse_bsr.c +++ b/bacula/src/stored/parse_bsr.c @@ -235,6 +235,7 @@ static BSR *store_vol(LEX *lc, BSR *bsr) } if (bsr->volume) { bsr->next = new_bsr(); + bsr->next->prev = bsr; bsr = bsr->next; } /* This may actually be more than one volume separated by a | @@ -828,11 +829,11 @@ static void free_bsr_item(BSR *bsr) } } -void free_bsr(BSR *bsr) +/* + * Remove a single item from the bsr tree + */ +void remove_bsr(BSR *bsr) { - if (!bsr) { - return; - } free_bsr_item((BSR *)bsr->volume); free_bsr_item((BSR *)bsr->client); free_bsr_item((BSR *)bsr->sessid); @@ -844,17 +845,42 @@ void free_bsr(BSR *bsr) free_bsr_item((BSR *)bsr->FileIndex); free_bsr_item((BSR *)bsr->JobType); free_bsr_item((BSR *)bsr->JobLevel); - if (bsr->fileregex) bfree(bsr->fileregex); + if (bsr->fileregex) { + bfree(bsr->fileregex); + } if (bsr->fileregex_re) { regfree(bsr->fileregex_re); free(bsr->fileregex_re); } - if (bsr->attr) free_attr(bsr->attr); - - free_bsr(bsr->next); + if (bsr->attr) { + free_attr(bsr->attr); + } + if (bsr->next) { + bsr->next->prev = bsr->prev; + } + if (bsr->prev) { + bsr->prev->next = bsr->next; + } free(bsr); } +/* + * Free all bsrs in chain + */ +void free_bsr(BSR *bsr) +{ + BSR *next_bsr; + + if (!bsr) { + return; + } + next_bsr = bsr->next; + /* Remove (free) current bsr */ + remove_bsr(bsr); + /* Now get the next one */ + free_bsr(next_bsr); +} + /***************************************************************** * Routines for handling volumes */ diff --git a/bacula/technotes-2.5 b/bacula/technotes-2.5 index 905a4d9ab7..f520f76771 100644 --- a/bacula/technotes-2.5 +++ b/bacula/technotes-2.5 @@ -10,6 +10,9 @@ filepattern (restore with regex in bsr) mixed priorities General: +19Nov08 +kes Use doubly linked bsr list so that consumed bsrs may be + removed. Removing not yet implemented. 18Nov08 kes Implement a fix that very likely fixes the undesired volume purge reported by Graham Keeling. -- 2.39.5