]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
metaplugin: Update debugging logs.
authorRadosław Korzeniewski <radoslaw@korzeniewski.net>
Tue, 23 Mar 2021 15:02:11 +0000 (16:02 +0100)
committerEric Bollengier <eric@baculasystems.com>
Thu, 24 Mar 2022 08:03:00 +0000 (09:03 +0100)
bacula/src/plugins/fd/pluginlib/pluginlib.cpp
bacula/src/plugins/fd/pluginlib/ptcomm.cpp
bacula/src/plugins/fd/pluginlib/ptcomm.h
bacula/src/plugins/fd/pluginlib/test_metaplugin_backend.c

index 9ee2f460329af30405718b2ff9f5e7932760c97d..7d091a77a6a406a0123b1a4b56881c3681da71e1 100644 (file)
@@ -616,15 +616,3 @@ bool scan_parameter_str(const char * cmd, const char *prefix, POOL_MEM &param)
 
    return false;
 }
-
-void transcript_bin_data_to_display(char (&buf)[17], const char *data, int len)
-{
-   for (int a = 0; a < len && a < 16; a++) {
-      if (isalnum(data[a]) || isspace(data[a])){
-         buf[a] = data[a];
-      } else {
-         buf[a] = '.';
-      }
-      buf[a + 1] = 0;
-   }
-}
index b91219f869d9f265b917bca4d049d070ba87c832..01096624046ab03d49dd79a6e382e87269ac223b 100644 (file)
@@ -311,7 +311,7 @@ int32_t PTCOMM::recvbackend_header(bpContext *ctx, char cmd)
       // some packet commands require data
       header.length[6] = 0; /* end of string */
 
-      DMSG2(ctx, DDEBUG, "RECV: %c %s\n", header.status, header.length);
+      DMSG2(ctx, DDEBUG, "HEADERRECV: %c %s\n", header.status, header.length);
 
       /* check for protocol status */
       if (header.status == 'F'){
@@ -436,14 +436,15 @@ int32_t PTCOMM::handle_read_header(bpContext *ctx, char cmd)
 int32_t PTCOMM::handle_payload(bpContext *ctx, char *buf, int32_t nbytes)
 {
    // handle raw data read as payload
-   if(!recvbackend_data(ctx, buf, nbytes))
-   {
+   if(!recvbackend_data(ctx, buf, nbytes)){
       // error
       DMSG0(ctx, DERROR, "PTCOMM cannot get packet payload from backend.\n");
       JMSG0(ctx, is_fatal() ? M_FATAL : M_ERROR, "PTCOMM cannot get packet payload from backend.\n");
       f_eod = f_error = f_fatal = true;
       return -1;
    }
+   char bindata[17];
+   DMSG1(ctx, DDEBUG, "RECV> %s\n", asciidump(buf, nbytes, bindata, 17));
 
    return nbytes;
 }
@@ -504,8 +505,7 @@ int32_t PTCOMM::recvbackend_fixed(bpContext *ctx, char cmd, char *buf, int32_t b
 {
    int32_t length = remaininglen;
 
-   if (!f_cont)
-   {
+   if (!f_cont){
       // handle header
       length = handle_read_header(ctx, cmd);
       if (length < 0)
@@ -513,8 +513,7 @@ int32_t PTCOMM::recvbackend_fixed(bpContext *ctx, char cmd, char *buf, int32_t b
    }
 
    // handle data payload
-   if (length > 0)
-   {
+   if (length > 0){
       // we will need subsequent call to handle remaining data only when `buf` to short
       f_cont = length > bufsize;
       int32_t nbytes = f_cont * bufsize + (!f_cont) * length;
@@ -576,16 +575,17 @@ int32_t PTCOMM::sendbackend(bpContext *ctx, char cmd, POOLMEM *buf, int32_t len)
    header = &myheader;
 #endif
    header->status = cmd;
-   char bindata[17];
-   transcript_bin_data_to_display(bindata, buf, len);
-   DMSG2(ctx, DDEBUG, "SENT: %c %s\n", header->status, bindata);
-   if (bsnprintf(header->length, sizeof(PTHEADER), "%06i", len) != 6){
+
+   if (bsnprintf(header->length, sizeof(header->length), "%06i\n", len) != 7){
       /* problem rendering packet header */
       DMSG0(ctx, DERROR, "Problem rendering packet header for command.\n");
       JMSG0(ctx, M_FATAL, "Problem rendering packet header for command.\n");
       return -1;
    }
-   header->length[6] = '\n';
+   // header->length[6] = '\n';
+
+   char bindata[17];
+   DMSG3(ctx, DDEBUG, "SENT: %c %s %s\n", header->status, header->length, asciidump(buf, len, bindata, sizeof(bindata)));
 
 #ifdef NEED_REVIEW
    status = sendbackend_data(ctx, (char*)header, len + sizeof(PTHEADER));
index c869f46e78b4ab99c06593460107ddf36609b81f..5b8da78b3978ea1c99232e411730d65ba46eb79e 100644 (file)
@@ -172,7 +172,7 @@ public:
     *    -1 - when encountered any error
     *    <n> - the number of bytes sent, success
     */
-   inline int32_t signal_eod(bpContext *ctx) { return sendbackend(ctx, 'F', NULL, 0); }
+   inline int32_t signal_eod(bpContext *ctx) { return sendbackend(ctx, 'F', "000000", 0); }
 
    /**
     * @brief Signal end of communication to the backend.
@@ -183,7 +183,7 @@ public:
     *    -1 - when encountered any error
     *    <n> - the number of bytes sent, success
     */
-   inline int32_t signal_term(bpContext *ctx) { return sendbackend(ctx, 'T', NULL, 0); }
+   inline int32_t signal_term(bpContext *ctx) { return sendbackend(ctx, 'T', "000000", 0); }
 
    void terminate(bpContext *ctx);
 
index e4b5ca1bed311517e4b7a358b308a81a7abee500..9deaddceb77f0a2fe9997218b1d2bfa810df88be 100644 (file)
@@ -406,7 +406,21 @@ void perform_backup()
       write_plugin('A', "Some error...\n");
       return;
    }
-
+#if 0
+   snprintf(buf, BIGBUFLEN, "FNAME:%s/bucket/%d/directory\n", PLUGINPREFIX, mypid);
+   write_plugin('C', buf);
+   write_plugin('C', "STAT:D 1024 100 100 040755 1\n");
+   write_plugin('C', "TSTAMP:1504271937 1504271937 1504271937\n");
+   signal_eod();
+   write_plugin('I', "TEST15 - backup dir + xattrs");
+   write_plugin('C', "DATA\n");
+   write_plugin('D', "/* here comes a file data contents */");
+   write_plugin('D', "/* here comes another file line    */");
+   signal_eod();
+   write_plugin('C', "XATTR\n");
+   write_plugin('D', "bacula.custom.data=Inteos\nsystem.custom.data=Bacula\n");
+   signal_eod();
+#endif
    snprintf(buf, BIGBUFLEN, "FNAME:%s/bucket/%d/\n", PLUGINPREFIX, mypid);
    write_plugin('C', buf);
    write_plugin('C', "STAT:D 1024 100 100 040755 1\n");
@@ -699,6 +713,8 @@ void perform_restore(){
             /* empty file to restore */
             LOG("#> Empty file.");
             continue;
+         } else {
+            LOG("#> file data saved.");
          }
          loopgo = true;
          fsize = len;