X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Ffiled%2Fverify_vol.c;h=23940b0920a905a5e43ad1fc20f80533bd6dcac7;hb=cad283fcd2e639219d6c2fef3362bcc398d959c9;hp=fff1f556d9b1befe52e1ee030fd7b6c1f6091c27;hpb=bf5feaedbcd17bff3c30ef99d5e7291af8b5a6d5;p=bacula%2Fbacula diff --git a/bacula/src/filed/verify_vol.c b/bacula/src/filed/verify_vol.c index fff1f556d9..23940b0920 100644 --- a/bacula/src/filed/verify_vol.c +++ b/bacula/src/filed/verify_vol.c @@ -8,7 +8,7 @@ * */ /* - Copyright (C) 2000-2003 Kern Sibbald and John Walker + Copyright (C) 2000-2004 Kern Sibbald and John Walker This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -34,14 +34,11 @@ static char rec_header[] = "rechdr %ld %ld %ld %ld %ld"; /* Forward referenced functions */ -#ifdef needed -static void print_ls_output(JCR *jcr, char *fname, char *lname, int type, struct stat *statp); -#endif -/* +/* * Verify attributes of the requested files on the Volume - * + * */ void do_verify_volume(JCR *jcr) { @@ -53,7 +50,7 @@ void do_verify_volume(JCR *jcr) uint32_t VolSessionId, VolSessionTime, file_index; uint32_t record_file_index; int type, stat; - + sd = jcr->store_bsock; if (!sd) { Jmsg(jcr, M_FATAL, 0, _("Storage command not issued before Verify.\n")); @@ -63,7 +60,16 @@ void do_verify_volume(JCR *jcr) dir = jcr->dir_bsock; set_jcr_job_status(jcr, JS_Running); - if (!bnet_set_buffer_size(sd, MAX_NETWORK_BUFFER_SIZE, BNET_SETBUF_READ)) { + LockRes(); + CLIENT *client = (CLIENT *)GetNextRes(R_CLIENT, NULL); + UnlockRes(); + uint32_t buf_size; + if (client) { + buf_size = client->max_network_buffer_size; + } else { + buf_size = 0; /* use default */ + } + if (!bnet_set_buffer_size(sd, buf_size, BNET_SETBUF_WRITE)) { set_jcr_job_status(jcr, JS_FatalError); return; } @@ -72,12 +78,12 @@ void do_verify_volume(JCR *jcr) fname = get_pool_memory(PM_FNAME); lname = get_pool_memory(PM_FNAME); - /* + /* * Get a record from the Storage daemon */ - while (bnet_recv(sd) >= 0 && !job_cancelled(jcr)) { + while (bget_msg(sd) >= 0 && !job_canceled(jcr)) { /* - * First we expect a Stream Record Header + * First we expect a Stream Record Header */ if (sscanf(sd->msg, rec_header, &VolSessionId, &VolSessionTime, &file_index, &stream, &size) != 5) { @@ -86,10 +92,10 @@ void do_verify_volume(JCR *jcr) } Dmsg2(30, "Got hdr: FilInx=%d Stream=%d.\n", file_index, stream); - /* + /* * Now we expect the Stream Data */ - if (bnet_recv(sd) < 0 && !job_cancelled(jcr)) { + if (bget_msg(sd) < 0) { Jmsg1(jcr, M_FATAL, 0, _("Data record error. ERR=%s\n"), bnet_strerror(sd)); goto bail_out; } @@ -100,7 +106,9 @@ void do_verify_volume(JCR *jcr) Dmsg1(30, "Got stream data, len=%d\n", sd->msglen); /* File Attributes stream */ - if (stream == STREAM_UNIX_ATTRIBUTES || stream == STREAM_WIN32_ATTRIBUTES) { + switch (stream) { + case STREAM_UNIX_ATTRIBUTES: + case STREAM_UNIX_ATTRIBUTES_EX: char *ap, *lp, *fp; Dmsg0(400, "Stream=Unix Attributes.\n"); @@ -115,7 +123,7 @@ void do_verify_volume(JCR *jcr) *fname = 0; *lname = 0; - /* + /* * An Attributes record consists of: * File_index * Type (FT_types) @@ -142,7 +150,7 @@ void do_verify_volume(JCR *jcr) while (*ap++ != ' ') /* skip type */ ; /* Save filename and position to attributes */ - fp = fname; + fp = fname; while (*ap != 0) { *fp++ = *ap++; /* copy filename to fname */ } @@ -155,17 +163,17 @@ void do_verify_volume(JCR *jcr) while (*lp++ != 0) { ; } - strcat(lname, lp); /* "save" link name */ + pm_strcat(lname, lp); /* "save" link name */ } else { *lname = 0; } P(jcr->mutex); jcr->JobFiles++; jcr->num_files_examined++; - pm_strcpy(&jcr->last_fname, fname); /* last file examined */ + pm_strcpy(jcr->last_fname, fname); /* last file examined */ V(jcr->mutex); - /* + /* * Send file attributes to Director * File_index * Stream @@ -180,11 +188,11 @@ void do_verify_volume(JCR *jcr) Dmsg2(200, "send ATTR inx=%d fname=%s\n", jcr->JobFiles, fname); if (type == FT_LNK || type == FT_LNKSAVED) { stat = bnet_fsend(dir, "%d %d %s %s%c%s%c%s%c", jcr->JobFiles, - STREAM_UNIX_ATTRIBUTES, "pinsug5", fname, + STREAM_UNIX_ATTRIBUTES, "pinsug5", fname, 0, ap, 0, lname, 0); } else { stat = bnet_fsend(dir,"%d %d %s %s%c%s%c%c", jcr->JobFiles, - STREAM_UNIX_ATTRIBUTES, "pinsug5", fname, + STREAM_UNIX_ATTRIBUTES, "pinsug5", fname, 0, ap, 0, 0); } Dmsg2(200, "bfiled>bdird: attribs len=%d: msg=%s\n", dir->msglen, dir->msg); @@ -192,36 +200,48 @@ void do_verify_volume(JCR *jcr) Jmsg(jcr, M_FATAL, 0, _("Network error in send to Director: ERR=%s\n"), bnet_strerror(dir)); goto bail_out; } + break; - - /* Data stream */ - } else if (stream == STREAM_FILE_DATA || stream == STREAM_SPARSE_DATA) { - - /* Do nothing */ - - /* GZIP data stream */ - } else if (stream == STREAM_GZIP_DATA || stream == STREAM_SPARSE_GZIP_DATA) { + /* Data streams to ignore */ + case STREAM_FILE_DATA: + case STREAM_SPARSE_DATA: + case STREAM_WIN32_DATA: + case STREAM_WIN32_GZIP_DATA: + case STREAM_GZIP_DATA: + case STREAM_SPARSE_GZIP_DATA: /* Do nothing */ + break; - /* If MD5 stream */ - } else if (stream == STREAM_MD5_SIGNATURE) { + case STREAM_MD5_SIGNATURE: char MD5buf[30]; bin_to_base64(MD5buf, (char *)sd->msg, 16); /* encode 16 bytes */ Dmsg2(400, "send inx=%d MD5=%s\n", jcr->JobFiles, MD5buf); bnet_fsend(dir, "%d %d %s *MD5-%d*", jcr->JobFiles, STREAM_MD5_SIGNATURE, MD5buf, jcr->JobFiles); Dmsg2(20, "bfiled>bdird: MD5 len=%d: msg=%s\n", dir->msglen, dir->msg); - - } else if (stream != STREAM_MD5_SIGNATURE) { + break; + + case STREAM_SHA1_SIGNATURE: + char SHA1buf[30]; + bin_to_base64(SHA1buf, (char *)sd->msg, 20); /* encode 20 bytes */ + Dmsg2(400, "send inx=%d SHA1=%s\n", jcr->JobFiles, SHA1buf); + bnet_fsend(dir, "%d %d %s *SHA1-%d*", jcr->JobFiles, STREAM_SHA1_SIGNATURE, + SHA1buf, jcr->JobFiles); + Dmsg2(20, "bfiled>bdird: SHA1 len=%d: msg=%s\n", dir->msglen, dir->msg); + break; + + default: Pmsg2(0, "None of above!!! stream=%d data=%s\n", stream,sd->msg); - } - } + break; + } /* end switch */ + } /* end while bnet_get */ set_jcr_job_status(jcr, JS_Terminated); goto ok_out; bail_out: set_jcr_job_status(jcr, JS_ErrorTerminated); + ok_out: if (jcr->compress_buf) { free(jcr->compress_buf); @@ -231,46 +251,4 @@ ok_out: free_pool_memory(lname); Dmsg2(050, "End Verify-Vol. Files=%d Bytes=%" lld "\n", jcr->JobFiles, jcr->JobBytes); -} - -extern char *getuser(uid_t uid); -extern char *getgroup(gid_t gid); - -/* - * Print an ls style message, also send INFO - */ -#ifdef needed -static void print_ls_output(JCR *jcr, char *fname, char *lname, int type, struct stat *statp) -{ - char buf[2000]; - char ec1[30]; - char *p, *f; - int n; - - p = encode_mode(statp->st_mode, buf); - n = sprintf(p, " %2d ", (uint32_t)statp->st_nlink); - p += n; - n = sprintf(p, "%-8.8s %-8.8s", getuser(statp->st_uid), getgroup(statp->st_gid)); - p += n; - n = sprintf(p, "%8.8s ", edit_uint64(statp->st_size, ec1)); - p += n; - p = encode_time(statp->st_ctime, p); - *p++ = ' '; - *p++ = ' '; - for (f=fname; *f && (p-buf) < (int)sizeof(buf)-10; ) - *p++ = *f++; - if (type == FT_LNK) { - *p++ = ' '; - *p++ = '-'; - *p++ = '>'; - *p++ = ' '; - /* Copy link name */ - for (f=lname; *f && (p-buf) < (int)sizeof(buf)-10; ) - *p++ = *f++; - } - *p++ = '\n'; - *p = 0; - Dmsg0(20, buf); - Jmsg(jcr, M_INFO, 0, "%s", buf); } -#endif