*
*/
/*
- Copyright (C) 2000-2004 Kern Sibbald and John Walker
+ Copyright (C) 2000-2005 Kern Sibbald
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
{"read data", read_data_cmd},
{"read close", read_close_session},
{"bootstrap", bootstrap_cmd},
- {NULL, NULL} /* list terminator */
+ {NULL, NULL} /* list terminator */
};
/* Commands from the File daemon that require additional scanning */
/* Information sent to the Director */
static char Job_start[] = "3010 Job %s start\n";
-static char Job_end[] =
+static char Job_end[] =
"3099 Job %s end JobStatus=%d JobFiles=%d JobBytes=%s\n";
/*
jcr->start_time = time(NULL);
jcr->run_time = jcr->start_time;
set_jcr_job_status(jcr, JS_Running);
- dir_send_job_status(jcr); /* update director */
+ dir_send_job_status(jcr); /* update director */
for (quit=false; !quit;) {
int stat;
/* Read command coming from the File daemon */
stat = bnet_recv(fd);
- if (is_bnet_stop(fd)) { /* hardeof or error */
- break; /* connection terminated */
+ if (is_bnet_stop(fd)) { /* hardeof or error */
+ break; /* connection terminated */
}
if (stat <= 0) {
- continue; /* ignore signals and zero length msgs */
+ continue; /* ignore signals and zero length msgs */
}
Dmsg1(110, "<filed: %s", fd->msg);
found = false;
for (i=0; fd_cmds[i].cmd; i++) {
- if (strncmp(fd_cmds[i].cmd, fd->msg, strlen(fd_cmds[i].cmd)) == 0) {
- found = true; /* indicate command found */
- if (!fd_cmds[i].func(jcr)) { /* do command */
- set_jcr_job_status(jcr, JS_ErrorTerminated);
- quit = true;
- }
- break;
- }
+ if (strncmp(fd_cmds[i].cmd, fd->msg, strlen(fd_cmds[i].cmd)) == 0) {
+ found = true; /* indicate command found */
+ if (!fd_cmds[i].func(jcr)) { /* do command */
+ set_jcr_job_status(jcr, JS_ErrorTerminated);
+ quit = true;
+ }
+ break;
+ }
}
- if (!found) { /* command not found */
- Dmsg1(110, "<filed: Command not found: %s\n", fd->msg);
- bnet_fsend(fd, ferrmsg);
- break;
+ if (!found) { /* command not found */
+ Dmsg1(110, "<filed: Command not found: %s\n", fd->msg);
+ bnet_fsend(fd, ferrmsg);
+ break;
}
}
bnet_sig(fd, BNET_TERMINATE); /* signal to FD job is done */
jcr->end_time = time(NULL);
- dequeue_messages(jcr); /* send any queued messages */
+ dequeue_messages(jcr); /* send any queued messages */
set_jcr_job_status(jcr, JS_Terminated);
+ generate_daemon_event(jcr, "JobEnd");
bnet_fsend(dir, Job_end, jcr->Job, jcr->JobStatus, jcr->JobFiles,
edit_uint64(jcr->JobBytes, ec1));
- bnet_sig(dir, BNET_EOD); /* send EOD to Director daemon */
+ bnet_sig(dir, BNET_EOD); /* send EOD to Director daemon */
return;
}
Dmsg1(110, "<bfiled: %s", fd->msg);
jcr->JobType = JT_BACKUP;
if (do_append_data(jcr)) {
- return bnet_fsend(fd, OK_append);
+ return bnet_fsend(fd, OK_append);
} else {
- bnet_suppress_error_messages(fd, 1); /* ignore errors at this point */
- bnet_fsend(fd, ERROR_append);
+ bnet_suppress_error_messages(fd, 1); /* ignore errors at this point */
+ bnet_fsend(fd, ERROR_append);
}
} else {
bnet_fsend(fd, NOT_opened);
return false;
}
- Dmsg1(110, "Append open session: %s\n", dev_name(jcr->device->dev));
- jcr->session_opened = TRUE;
+ jcr->session_opened = true;
/* Send "Ticket" to File Daemon */
bnet_fsend(fd, OK_open, jcr->VolSessionId);
/*
* Append Close session command
- * Close the append session and send back Statistics
- * (need to fix statistics)
+ * Close the append session and send back Statistics
+ * (need to fix statistics)
*/
static bool append_close_session(JCR *jcr)
{
bnet_fsend(fd, OK_close, jcr->JobStatus);
Dmsg1(120, ">filed: %s", fd->msg);
- bnet_sig(fd, BNET_EOD); /* send EOD to File daemon */
-
- Dmsg1(110, "Append close session: %s\n", dev_name(jcr->device->dev));
+ bnet_sig(fd, BNET_EOD); /* send EOD to File daemon */
jcr->session_opened = false;
return true;
return false;
}
- if (sscanf(fd->msg, read_open, jcr->dcr->VolumeName, &jcr->read_VolSessionId,
- &jcr->read_VolSessionTime, &jcr->read_StartFile, &jcr->read_EndFile,
- &jcr->read_StartBlock, &jcr->read_EndBlock) == 7) {
+ if (sscanf(fd->msg, read_open, jcr->read_dcr->VolumeName, &jcr->read_VolSessionId,
+ &jcr->read_VolSessionTime, &jcr->read_StartFile, &jcr->read_EndFile,
+ &jcr->read_StartBlock, &jcr->read_EndBlock) == 7) {
if (jcr->session_opened) {
- bnet_fsend(fd, NOT_opened);
- return false;
+ bnet_fsend(fd, NOT_opened);
+ return false;
}
Dmsg4(100, "read_open_session got: JobId=%d Vol=%s VolSessId=%ld VolSessT=%ld\n",
- jcr->JobId, jcr->dcr->VolumeName, jcr->read_VolSessionId,
- jcr->read_VolSessionTime);
+ jcr->JobId, jcr->read_dcr->VolumeName, jcr->read_VolSessionId,
+ jcr->read_VolSessionTime);
Dmsg4(100, " StartF=%ld EndF=%ld StartB=%ld EndB=%ld\n",
- jcr->read_StartFile, jcr->read_EndFile, jcr->read_StartBlock,
- jcr->read_EndBlock);
+ jcr->read_StartFile, jcr->read_EndFile, jcr->read_StartBlock,
+ jcr->read_EndBlock);
}
- Dmsg1(110, "Read open session: %s\n", dev_name(jcr->device->dev));
-
- jcr->session_opened = TRUE;
+ jcr->session_opened = true;
jcr->JobType = JT_RESTORE;
/* Send "Ticket" to File Daemon */
bs = fopen(fname, "a+"); /* create file */
if (!bs) {
Jmsg(jcr, M_FATAL, 0, _("Could not create bootstrap file %s: ERR=%s\n"),
- jcr->RestoreBootstrap, strerror(errno));
+ jcr->RestoreBootstrap, strerror(errno));
goto bail_out;
}
while (bnet_recv(fd) >= 0) {
- Dmsg1(400, "stored<filed: bootstrap file %s\n", fd->msg);
+ Dmsg1(400, "stored<filed: bootstrap file %s", fd->msg);
fputs(fd->msg, bs);
}
fclose(bs);
/*
* Read Close session command
- * Close the read session
+ * Close the read session
*/
static bool read_close_session(JCR *jcr)
{
bnet_fsend(fd, OK_close);
Dmsg1(160, ">filed: %s\n", fd->msg);
- bnet_sig(fd, BNET_EOD); /* send EOD to File daemon */
+ bnet_sig(fd, BNET_EOD); /* send EOD to File daemon */
- jcr->session_opened = FALSE;
+ jcr->session_opened = false;
return true;
}