#include "bacula.h"
#include "filed.h"
-#ifdef WIN32_VSS
-#include "vss.h"
+
+#if defined(WIN32_VSS)
+#include "vss.h"
+
static pthread_mutex_t vss_mutex = PTHREAD_MUTEX_INITIALIZER;
+static int enable_vss;
#endif
extern CLIENT *me; /* our client resource */
-int enable_vss = 0; /* set to use vss */
-
/* Imported functions */
extern int status_cmd(JCR *jcr);
extern int qstatus_cmd(JCR *jcr);
BSOCK *dir = jcr->dir_bsock;
run_scripts(jcr, jcr->RunScripts, "ClientBeforeJob");
- return bnet_fsend(dir, OKRunBeforeNow);
+ if (job_canceled(jcr)) {
+ return bnet_fsend(dir, _("2905 Bad RunBeforeNow command.\n"));
+ } else {
+ return bnet_fsend(dir, OKRunBeforeNow);
+ }
}
static int runafter_cmd(JCR *jcr)
fn = get_pool_memory(PM_FNAME);
fn = edit_job_codes(jcr, fn, p, "");
bpipe = open_bpipe(fn, 0, "r");
- free_pool_memory(fn);
if (!bpipe) {
+ berrno be;
Jmsg(jcr, M_FATAL, 0, _("Cannot run program: %s. ERR=%s\n"),
- p, strerror(errno));
+ p, be.strerror());
+ free_pool_memory(fn);
return;
}
+ free_pool_memory(fn);
while (fgets(buf, sizeof(buf), bpipe->rfd)) {
strip_trailing_junk(buf);
fileset->incexe->name_list.append(bstrdup(buf));
}
if ((stat=close_bpipe(bpipe)) != 0) {
- Jmsg(jcr, M_FATAL, 0, _("Error running program: %s. RtnStat=%d ERR=%s\n"),
- p, stat, strerror(errno));
+ berrno be;
+ Jmsg(jcr, M_FATAL, 0, _("Error running program: %s. stat=%d: ERR=%s\n"),
+ p, be.code(stat), be.strerror(stat));
return;
}
break;
static int fileset_cmd(JCR *jcr)
{
BSOCK *dir = jcr->dir_bsock;
+
+#if defined(WIN32_VSS)
int vss = 0;
sscanf(dir->msg, "fileset vss=%d", &vss);
enable_vss = vss;
+#endif
if (!init_fileset(jcr)) {
return 0;
int SDJobStatus;
char ed1[50], ed2[50];
-#ifdef WIN32_VSS
+#if defined(WIN32_VSS)
// capture state here, if client is backed up by multiple directors
// and one enables vss and the other does not then enable_vss can change
// between here and where its evaluated after the job completes.
generate_daemon_event(jcr, "JobStart");
-#ifdef WIN32_VSS
+#if defined(WIN32_VSS)
/* START VSS ON WIN 32 */
if (bDoVSS) {
if (g_pVSSClient->InitializeForBackup()) {
} else {
/* tell user if snapshot creation of a specific drive failed */
int i;
- for (i=0; i < strlen(szWinDriveLetters); i++) {
+ for (i=0; i < (int)strlen(szWinDriveLetters); i++) {
if (islower(szWinDriveLetters[i])) {
Jmsg(jcr, M_WARNING, 0, _("Generate VSS snapshot of drive \"%c:\\\" failed. VSS support is disabled on this drive.\n"), szWinDriveLetters[i]);
jcr->Errors++;
}
}
/* inform user about writer states */
- for (i=0; i<g_pVSSClient->GetWriterCount(); i++)
+ for (i=0; i < (int)g_pVSSClient->GetWriterCount(); i++)
if (g_pVSSClient->GetWriterState(i) < 1) {
Jmsg(jcr, M_WARNING, 0, _("VSS Writer (PrepareForBackup): %s\n"), g_pVSSClient->GetWriterInfo(i));
jcr->Errors++;
bget_msg(sd); /* Read final response from append_data */
Dmsg0(110, "Error in blast_data.\n");
/* run shortly after end of data transmission */
- run_scripts(jcr, jcr->RunScripts, "ClientAfterJobShort");
+ run_scripts(jcr, jcr->RunScripts, "ClientAfterJob");
} else {
set_jcr_job_status(jcr, JS_Terminated);
/* run shortly after end of data transmission */
- run_scripts(jcr, jcr->RunScripts, "ClientAfterJobShort");
+ run_scripts(jcr, jcr->RunScripts, "ClientAfterJob");
if (jcr->JobStatus != JS_Terminated) {
bnet_suppress_error_messages(sd, 1);
}
cleanup:
-#ifdef WIN32_VSS
+#if defined(WIN32_VSS)
/* STOP VSS ON WIN 32 */
/* tell vss to close the backup session */
if (bDoVSS) {