From: Kern Sibbald Date: Thu, 20 Nov 2008 12:22:06 +0000 (+0000) Subject: kes Since the user has been warned, allow console purge command X-Git-Tag: Release-7.0.0~3712 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=369cc6d5931f1715652a571f122ca94cefb74039;p=bacula%2Fbacula kes Since the user has been warned, allow console purge command to purge volumes that are in use. kes Fix Win32 build to add new sd_plugins.c git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8070 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/dird/protos.h b/bacula/src/dird/protos.h index 123350f673..3509ed4a92 100644 --- a/bacula/src/dird/protos.h +++ b/bacula/src/dird/protos.h @@ -286,10 +286,10 @@ int get_prune_list_for_volume(UAContext *ua, MEDIA_DBR *mr, del_ctx *del); int exclude_running_jobs_from_list(del_ctx *prune_list); /* ua_purge.c */ -bool is_volume_purged(UAContext *ua, MEDIA_DBR *mr); +bool is_volume_purged(UAContext *ua, MEDIA_DBR *mr, bool force=false); bool mark_media_purged(UAContext *ua, MEDIA_DBR *mr); -void purge_files_from_volume(UAContext *ua, MEDIA_DBR *mr ); -bool purge_jobs_from_volume(UAContext *ua, MEDIA_DBR *mr); +void purge_files_from_volume(UAContext *ua, MEDIA_DBR *mr); +bool purge_jobs_from_volume(UAContext *ua, MEDIA_DBR *mr, bool force=false); void purge_files_from_jobs(UAContext *ua, char *jobs); void purge_jobs_from_catalog(UAContext *ua, char *jobs); void purge_job_list_from_catalog(UAContext *ua, del_ctx &del); diff --git a/bacula/src/dird/ua_purge.c b/bacula/src/dird/ua_purge.c index d34c07baaf..9d2276801f 100644 --- a/bacula/src/dird/ua_purge.c +++ b/bacula/src/dird/ua_purge.c @@ -132,7 +132,9 @@ int purgecmd(UAContext *ua, const char *cmd) return 1; case 1: /* Volume */ if (select_media_dbr(ua, &mr)) { - purge_jobs_from_volume(ua, &mr); + purge_jobs_from_volume(ua, &mr, /*force*/true); + +purge_jobs_from_volume(ua, &mr); } return 1; } @@ -140,7 +142,7 @@ int purgecmd(UAContext *ua, const char *cmd) case 2: while ((i=find_arg(ua, NT_("volume"))) >= 0) { if (select_media_dbr(ua, &mr)) { - purge_jobs_from_volume(ua, &mr); + purge_jobs_from_volume(ua, &mr, /*force*/true); } *ua->argk[i] = 0; /* zap keyword already seen */ ua->send_msg("\n"); @@ -164,7 +166,7 @@ int purgecmd(UAContext *ua, const char *cmd) break; case 2: /* Volume */ if (select_media_dbr(ua, &mr)) { - purge_jobs_from_volume(ua, &mr); + purge_jobs_from_volume(ua, &mr, /*force*/true); } break; } @@ -389,7 +391,7 @@ void purge_files_from_volume(UAContext *ua, MEDIA_DBR *mr ) * Returns: 1 if Volume purged * 0 if Volume not purged */ -bool purge_jobs_from_volume(UAContext *ua, MEDIA_DBR *mr) +bool purge_jobs_from_volume(UAContext *ua, MEDIA_DBR *mr, bool force) { POOL_MEM query(PM_MESSAGE); struct del_ctx del; @@ -440,7 +442,7 @@ bool purge_jobs_from_volume(UAContext *ua, MEDIA_DBR *mr) ua->info_msg(_("%d File%s on Volume \"%s\" purged from catalog.\n"), del.num_del, del.num_del==1?"":"s", mr->VolumeName); - purged = is_volume_purged(ua, mr); + purged = is_volume_purged(ua, mr, force); bail_out: if (del.JobId) { @@ -455,17 +457,24 @@ bail_out: * * Returns: true if volume purged * false if not + * + * Note, we normally will not purge a volume that has Firstor LastWritten + * zero, because it means the volume is most likely being written + * however, if the user manually purges using the purge command in + * the console, he has been warned, and we go ahead and purge + * the volume anyway, if possible). */ -bool is_volume_purged(UAContext *ua, MEDIA_DBR *mr) +bool is_volume_purged(UAContext *ua, MEDIA_DBR *mr, bool force) { POOL_MEM query(PM_MESSAGE); struct s_count_ctx cnt; bool purged = false; char ed1[50]; - if (mr->FirstWritten == 0 || mr->LastWritten == 0) { + if (!force && (mr->FirstWritten == 0 || mr->LastWritten == 0)) { goto bail_out; /* not written cannot purge */ } + if (strcmp(mr->VolStatus, "Purged") == 0) { purged = true; goto bail_out; diff --git a/bacula/src/stored/sd_plugins.c b/bacula/src/stored/sd_plugins.c index ef0b8fde79..93be186474 100644 --- a/bacula/src/stored/sd_plugins.c +++ b/bacula/src/stored/sd_plugins.c @@ -110,7 +110,7 @@ static void dump_sd_plugin(Plugin *plugin, FILE *fp) fprintf(fp, "\tdescription=%s\n", NPRTB(info->plugin_description)); } -void load_dir_plugins(const char *plugin_dir) +void load_sd_plugins(const char *plugin_dir) { if (!plugin_dir) { return; @@ -247,7 +247,7 @@ int main(int argc, char *argv[]) strcpy(my_name, "test-dir"); getcwd(plugin_dir, sizeof(plugin_dir)-1); - load_dir_plugins(plugin_dir); + load_sd_plugins(plugin_dir); jcr1->JobId = 111; new_plugins(jcr1); diff --git a/bacula/src/stored/sd_plugins.h b/bacula/src/stored/sd_plugins.h index 5974fc9ff3..f581d17e38 100644 --- a/bacula/src/stored/sd_plugins.h +++ b/bacula/src/stored/sd_plugins.h @@ -130,7 +130,7 @@ typedef struct s_baculaFuncs { } bFuncs; /* Bacula Subroutines */ -void load_dir_plugins(const char *plugin_dir); +void load_sd_plugins(const char *plugin_dir); void new_plugins(JCR *jcr); void free_plugins(JCR *jcr); void generate_plugin_event(JCR *jcr, bEventType event, void *value=NULL); diff --git a/bacula/src/stored/stored.c b/bacula/src/stored/stored.c index a14f1431cd..0d1c388b22 100644 --- a/bacula/src/stored/stored.c +++ b/bacula/src/stored/stored.c @@ -259,7 +259,7 @@ int main (int argc, char *argv[]) create_pid_file(me->pid_directory, "bacula-sd", get_first_port_host_order(me->sdaddrs)); read_state_file(me->working_directory, "bacula-sd", get_first_port_host_order(me->sdaddrs)); - load_dir_plugins(me->plugin_directory); + load_sd_plugins(me->plugin_directory); drop(uid, gid); diff --git a/bacula/src/version.h b/bacula/src/version.h index 8714af4460..d0707cf330 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -4,8 +4,8 @@ #undef VERSION #define VERSION "2.5.20" -#define BDATE "18 November 2008" -#define LSMDATE "18Nov08" +#define BDATE "20 November 2008" +#define LSMDATE "20Nov08" #define PROG_COPYRIGHT "Copyright (C) %d-2008 Free Software Foundation Europe e.V.\n" #define BYEAR "2008" /* year for copyright messages in progs */ diff --git a/bacula/technotes-2.5 b/bacula/technotes-2.5 index 928c2b214b..9991d9cddf 100644 --- a/bacula/technotes-2.5 +++ b/bacula/technotes-2.5 @@ -11,6 +11,9 @@ mixed priorities General: 20Nov08 +kes Since the user has been warned, allow console purge command + to purge volumes that are in use. +kes Fix Win32 build to add new sd_plugins.c ebl Apply patch from bug #1175 that reset the Slot and the Inchanger flag in db_make_inchanger_unique(). ebl Remove a Emsg() after recieving a Fatal signal that can lock