/* Responses received from File daemon */
static char OKinc[] = "2000 OK include\n";
static char OKexc[] = "2000 OK exclude\n";
-static char OKjob[] = "2000 OK Job\n";
+static char OKjob[] = "2000 OK Job";
/* Forward referenced functions */
*/
bnet_fsend(fd, jobcmd, jcr->JobId, jcr->Job, jcr->VolSessionId,
jcr->VolSessionTime, jcr->sd_auth_key);
- Dmsg1(10, ">filed: %s", fd->msg);
+ Dmsg1(110, ">filed: %s", fd->msg);
if (bnet_recv(fd) > 0) {
- Dmsg1(10, "<filed: %s", fd->msg);
- if (strcmp(fd->msg, OKjob) != 0) {
+ Dmsg1(110, "<filed: %s", fd->msg);
+ if (strncmp(fd->msg, OKjob, strlen(OKjob)) != 0) {
Jmsg(jcr, M_FATAL, 0, _("File daemon rejected Job command: %s\n"), fd->msg);
jcr->JobStatus = JS_ErrorTerminated;
return 0;
- }
+ } else {
+ /***** ***FIXME***** update Client Uname */
+ }
} else {
Jmsg(jcr, M_FATAL, 0, _("<filed: bad response to JobId command: %s\n"),
bnet_strerror(fd));
bnet_send(fd);
for (i=0; i < fileset->num_includes; i++) {
fd->msglen = strlen(fileset->include_array[i]);
- Dmsg1(20, "dird>filed: include file: %s\n", fileset->include_array[i]);
+ Dmsg1(120, "dird>filed: include file: %s\n", fileset->include_array[i]);
fd->msg = fileset->include_array[i];
if (!bnet_send(fd)) {
+ fd->msg = msgsave;
Emsg0(M_FATAL, 0, _(">filed: write error on socket\n"));
jcr->JobStatus = JS_ErrorTerminated;
return 0;
}
}
- bnet_sig(fd, BNET_EOF);
+ bnet_sig(fd, BNET_EOD); /* end of data */
fd->msg = msgsave;
if (!response(fd, OKinc, "Include")) {
jcr->JobStatus = JS_ErrorTerminated;
bnet_send(fd);
for (i=0; i < fileset->num_excludes; i++) {
fd->msglen = strlen(fileset->exclude_array[i]);
- Dmsg1(20, "dird>filed: exclude file: %s\n", fileset->exclude_array[i]);
+ Dmsg1(120, "dird>filed: exclude file: %s\n", fileset->exclude_array[i]);
fd->msg = fileset->exclude_array[i];
if (!bnet_send(fd)) {
Emsg0(M_FATAL, 0, _(">filed: write error on socket\n"));
return 0;
}
}
- bnet_sig(fd, BNET_EOF);
+ bnet_sig(fd, BNET_EOD);
fd->msg = msgsave;
if (!response(fd, OKexc, "Exclude")) {
jcr->JobStatus = JS_ErrorTerminated;
int get_attributes_and_put_in_catalog(JCR *jcr)
{
BSOCK *fd;
- int n;
+ int n = 0;
ATTR_DBR ar;
fd = jcr->file_bsock;
jcr->jr.FirstIndex = 1;
memset(&ar, 0, sizeof(ar));
+ jcr->FileIndex = 0;
- Dmsg0(20, "bdird: waiting to receive file attributes\n");
+ Dmsg0(120, "bdird: waiting to receive file attributes\n");
/* Pickup file attributes and signature */
while (!fd->errors && (n = bget_msg(fd, 0)) > 0) {
*fn = *p++; /* term filename and point to attribs */
attr = p;
- if (stream == STREAM_UNIX_ATTRIBUTES) {
+ if (stream == STREAM_UNIX_ATTRIBUTES || stream == STREAM_WIN32_ATTRIBUTES) {
jcr->JobFiles++;
+ jcr->FileIndex = file_index;
ar.attr = attr;
ar.fname = jcr->fname;
- ar.FileIndex = 0; /* used as mark field during compare */
+ ar.FileIndex = file_index;
ar.Stream = stream;
ar.link = NULL;
ar.JobId = jcr->JobId;
ar.PathId = 0;
ar.FilenameId = 0;
- Dmsg2(11, "dird<filed: stream=%d %s\n", stream, jcr->fname);
- Dmsg1(20, "dird<filed: attr=%s\n", attr);
+ Dmsg2(111, "dird<filed: stream=%d %s\n", stream, jcr->fname);
+ Dmsg1(120, "dird<filed: attr=%s\n", attr);
/* ***FIXME*** fix link field */
if (!db_create_file_attributes_record(jcr->db, &ar)) {
jcr->JobStatus = JS_Error;
continue;
}
- jcr->FileIndex = file_index;
jcr->FileId = ar.FileId;
} else if (stream == STREAM_MD5_SIGNATURE) {
if (jcr->FileIndex != (uint32_t)file_index) {
- Jmsg0(jcr, M_ERROR, 0, _("Got MD5 but not same block as attributes\n"));
+ Jmsg2(jcr, M_ERROR, 0, _("MD5 index %d not same as attributes %d\n"),
+ file_index, jcr->FileIndex);
jcr->JobStatus = JS_Error;
continue;
}
db_escape_string(MD5, Opts_MD5, strlen(Opts_MD5));
- Dmsg2(20, "MD5len=%d MD5=%s\n", strlen(MD5), MD5);
+ Dmsg2(120, "MD5len=%d MD5=%s\n", strlen(MD5), MD5);
if (!db_add_MD5_to_file_record(jcr->db, jcr->FileId, MD5)) {
Jmsg1(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db));
jcr->JobStatus = JS_Error;
jcr->jr.JobFiles = jcr->JobFiles = file_index;
jcr->jr.LastIndex = file_index;
}
- if (n < 0) {
+ if (is_bnet_error(fd)) {
Jmsg1(jcr, M_FATAL, 0, _("<filed: Network error getting attributes. ERR=%s\n"),
bnet_strerror(fd));
jcr->JobStatus = JS_ErrorTerminated;