From: Michael Stapelberg Date: Wed, 30 Sep 2009 16:45:26 +0000 (+0200) Subject: Implement action_on_purge command X-Git-Tag: Release-7.0.0~2599^2~16^2~9 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=dd435851a2f971aa3e8f20d96fb1143bc5db68bc;p=bacula%2Fbacula Implement action_on_purge command --- diff --git a/bacula/src/dird/ua_purge.c b/bacula/src/dird/ua_purge.c index c0276da19d..d9c967c504 100644 --- a/bacula/src/dird/ua_purge.c +++ b/bacula/src/dird/ua_purge.c @@ -583,18 +583,23 @@ bool mark_media_purged(UAContext *ua, MEDIA_DBR *mr) return false; } - /* Send the command to truncate the volume after purge. If this feature - * is disabled for the specific device, this will be a no-op. */ - BSOCK *sd; - if ((sd=open_sd_bsock(ua)) != NULL) { - sd->fsend("truncate_on_purge %s vol=%s", ua->jcr->wstore->dev_name(), mr->VolumeName); - - while (sd->recv() >= 0) - ua->send_msg("%s", sd->msg); - - sd->signal(BNET_TERMINATE); - sd->close(); - ua->jcr->store_bsock = NULL; + if (mr->ActionOnPurge > 0) { + /* Send the command to truncate the volume after purge. If this feature + * is disabled for the specific device, this will be a no-op. */ + BSOCK *sd; + if ((sd=open_sd_bsock(ua)) != NULL) { + sd->fsend("action_on_purge %s vol=%s action=%d", + ua->jcr->wstore->dev_name(), + mr->VolumeName, + mr->ActionOnPurge); + + while (sd->recv() >= 0) + ua->send_msg("%s", sd->msg); + + sd->signal(BNET_TERMINATE); + sd->close(); + ua->jcr->store_bsock = NULL; + } } pm_strcpy(jcr->VolumeName, mr->VolumeName); diff --git a/bacula/src/stored/dircmd.c b/bacula/src/stored/dircmd.c index ff2aa951e7..c7d564c6ec 100644 --- a/bacula/src/stored/dircmd.c +++ b/bacula/src/stored/dircmd.c @@ -83,7 +83,7 @@ static bool setdebug_cmd(JCR *jcr); static bool cancel_cmd(JCR *cjcr); static bool mount_cmd(JCR *jcr); static bool unmount_cmd(JCR *jcr); -static bool truncate_on_purge_cmd(JCR *jcr); +static bool action_on_purge_cmd(JCR *jcr); static bool bootstrap_cmd(JCR *jcr); static bool changer_cmd(JCR *sjcr); static bool do_label(JCR *jcr, int relabel); @@ -119,7 +119,7 @@ static struct s_cmds cmds[] = { {"status", status_cmd, 1}, {".status", qstatus_cmd, 1}, {"unmount", unmount_cmd, 0}, - {"truncate_on_purge", truncate_on_purge_cmd, 0}, + {"action_on_purge", action_on_purge_cmd, 0}, {"use storage=", use_cmd, 0}, {"run", run_cmd, 0}, // {"query", query_cmd, 0}, @@ -877,7 +877,7 @@ static bool unmount_cmd(JCR *jcr) * for File Storage, of course. * */ -static bool truncate_on_purge_cmd(JCR *jcr) +static bool action_on_purge_cmd(JCR *jcr) { POOL_MEM devname; POOL_MEM volumename; @@ -885,9 +885,11 @@ static bool truncate_on_purge_cmd(JCR *jcr) DEVICE *dev; DCR *dcr; int drive; + int action; - if (sscanf(dir->msg, "truncate_on_purge %127s vol=%s", devname.c_str(), volumename.c_str()) != 2) { - dir->fsend(_("3916 Error scanning truncate_on_purge command\n")); + if (sscanf(dir->msg, "action_on_purge_cmd %127s vol=%s action=%d", + devname.c_str(), volumename.c_str(), &action) != 3) { + dir->fsend(_("3916 Error scanning action_on_purge_cmd command\n")); goto done; } @@ -899,11 +901,6 @@ static bool truncate_on_purge_cmd(JCR *jcr) dev = dcr->dev; - if (!dev->truncate_on_purge) { - dir->fsend(_("3919 Truncate on purge not enabled, skipping\n")); - goto done; - } - /* Store the VolumeName for opening and re-labeling the volume */ bstrncpy(dcr->VolumeName, volumename.c_str(), sizeof(dcr->VolumeName)); bstrncpy(dev->VolHdr.VolumeName, volumename.c_str(), sizeof(dev->VolHdr.VolumeName));