src/filed/job.c
static int restore_object_cmd(JCR *jcr)
{
   BSOCK *dir = jcr->dir_bsock;
   int32_t FileIndex;
   restore_object_pkt rop;

   memset(&rop, 0, sizeof(rop));
   rop.pkt_size = sizeof(rop);
   rop.pkt_end = sizeof(rop);

   Dmsg1(100, "Enter restoreobject_cmd: %s", dir->msg);
   if (strcmp(dir->msg, endrestoreobjectcmd) == 0) {
      Dmsg0(20, "Got endrestoreobject\n");
      generate_plugin_event(jcr, bEventRestoreObject, NULL);
      return dir->fsend(OKRestoreObject);
   }

   rop.plugin_name = (char *)malloc(dir->msglen);
   *rop.plugin_name = 0;

   if (sscanf(dir->msg, restoreobjcmd, &rop.JobId, &rop.object_len,
              &rop.object_full_len, &rop.object_index,
              &rop.object_type, &rop.object_compression, &FileIndex,
              rop.plugin_name) != 8) {

      /* Old version, no plugin_name */
      if (sscanf(dir->msg, restoreobjcmd1, &rop.JobId, &rop.object_len,
                 &rop.object_full_len, &rop.object_index,
                 &rop.object_type, &rop.object_compression, &FileIndex) != 7) {
         Dmsg0(5, "Bad restore object command\n");
         pm_strcpy(jcr->errmsg, dir->msg);
         Jmsg1(jcr, M_FATAL, 0, _("Bad RestoreObject command: %s\n"), jcr->errmsg);
         goto bail_out;
      }
   }

   unbash_spaces(rop.plugin_name);

   Dmsg7(100, "Recv object: JobId=%u objlen=%d full_len=%d objinx=%d objtype=%d "
         "FI=%d plugin_name=%s\n",
         rop.JobId, rop.object_len, rop.object_full_len,
         rop.object_index, rop.object_type, FileIndex, rop.plugin_name);
   /* Read Object name */
   if (dir->recv() < 0) {
      goto bail_out;
   }
   Dmsg2(100, "Recv Oname object: len=%d Oname=%s\n", dir->msglen, dir->msg);
   rop.object_name = bstrdup(dir->msg);

   /* Read Object */
   if (dir->recv() < 0) {
      goto bail_out;
   }
   /* Transfer object from message buffer, and get new message buffer */
   rop.object = dir->msg;
   dir->msg = get_pool_memory(PM_MESSAGE);

   /* If object is compressed, uncompress it */
   if (rop.object_compression == 1) {   /* zlib level 9 */
      int stat;
      int out_len = rop.object_full_len + 100;
      POOLMEM *obj = get_memory(out_len);
      Dmsg2(100, "Inflating from %d to %d\n", rop.object_len, rop.object_full_len);
      stat = Zinflate(rop.object, rop.object_len, obj, out_len);
      Dmsg1(100, "Zinflate stat=%d\n", stat);
      if (out_len != rop.object_full_len) {
         Jmsg3(jcr, M_ERROR, 0, ("Decompression failed. Len wanted=%d got=%d. Object=%s\n"),
            rop.object_full_len, out_len, rop.object_name);
      }
      free_pool_memory(rop.object);   /* release compressed object */
      rop.object = obj;               /* new uncompressed object */
      rop.object_len = out_len;
   }
   Dmsg2(100, "Recv Object: len=%d Object=%s\n", rop.object_len, rop.object);
   /* we still need to do this to detect a vss restore */
   if (strcmp(rop.object_name, "job_metadata.xml") == 0) {
      Dmsg0(100, "got job metadata\n");
      jcr->got_metadata = true;
   }

   generate_plugin_event(jcr, bEventRestoreObject, (void *)&rop);

   if (rop.object_name) {
      free(rop.object_name);
   }
   if (rop.object) {
      free_pool_memory(rop.object);
   }
   if (rop.plugin_name) {
      free(rop.plugin_name);
   }

   Dmsg1(100, "Send: %s", OKRestoreObject);
   return 1;

bail_out:
   dir->fsend(_("2909 Bad RestoreObject command.\n"));
   return 0;

}
/*
 * This reads data sent from the Director from the
 *   RestoreObject table that allows us to get objects
 *   that were backed up (VSS .xml data) and are needed
 *   before starting the restore.
 */
This reads data sent from the Director from the
RestoreObject table that allows us to get objects
that were backed up (VSS .xml data) and are needed
before starting the restore.
This reads data sent from the Director from the RestoreObject table that allows us to get objects that were backed up ( VSS . xml data ) and are needed before starting the restore .
static int restore_object_cmd(JCR *jcr)
{
   BSOCK *dir = jcr->dir_bsock;
   int32_t FileIndex;
   restore_object_pkt rop;
   memset(&rop, 0, sizeof(rop));
   rop.pkt_size = sizeof(rop);
   rop.pkt_end = sizeof(rop);
   Dmsg1(100, "Enter restoreobject_cmd: %s", dir->msg);
   if (strcmp(dir->msg, endrestoreobjectcmd) == 0) {
      Dmsg0(20, "Got endrestoreobject\n");
      generate_plugin_event(jcr, bEventRestoreObject, NULL);
      return dir->fsend(OKRestoreObject);
   }
   rop.plugin_name = (char *)malloc(dir->msglen);
   *rop.plugin_name = 0;
   if (sscanf(dir->msg, restoreobjcmd, &rop.JobId, &rop.object_len,
              &rop.object_full_len, &rop.object_index,
              &rop.object_type, &rop.object_compression, &FileIndex,
              rop.plugin_name) != 8) {
      if (sscanf(dir->msg, restoreobjcmd1, &rop.JobId, &rop.object_len,
                 &rop.object_full_len, &rop.object_index,
                 &rop.object_type, &rop.object_compression, &FileIndex) != 7) {
         Dmsg0(5, "Bad restore object command\n");
         pm_strcpy(jcr->errmsg, dir->msg);
         Jmsg1(jcr, M_FATAL, 0, _("Bad RestoreObject command: %s\n"), jcr->errmsg);
         goto bail_out;
      }
   }
   unbash_spaces(rop.plugin_name);
   Dmsg7(100, "Recv object: JobId=%u objlen=%d full_len=%d objinx=%d objtype=%d "
         "FI=%d plugin_name=%s\n",
         rop.JobId, rop.object_len, rop.object_full_len,
         rop.object_index, rop.object_type, FileIndex, rop.plugin_name);
   if (dir->recv() < 0) {
      goto bail_out;
   }
   Dmsg2(100, "Recv Oname object: len=%d Oname=%s\n", dir->msglen, dir->msg);
   rop.object_name = bstrdup(dir->msg);
   if (dir->recv() < 0) {
      goto bail_out;
   }
   rop.object = dir->msg;
   dir->msg = get_pool_memory(PM_MESSAGE);
   if (rop.object_compression == 1) {   
      int stat;
      int out_len = rop.object_full_len + 100;
      POOLMEM *obj = get_memory(out_len);
      Dmsg2(100, "Inflating from %d to %d\n", rop.object_len, rop.object_full_len);
      stat = Zinflate(rop.object, rop.object_len, obj, out_len);
      Dmsg1(100, "Zinflate stat=%d\n", stat);
      if (out_len != rop.object_full_len) {
         Jmsg3(jcr, M_ERROR, 0, ("Decompression failed. Len wanted=%d got=%d. Object=%s\n"),
            rop.object_full_len, out_len, rop.object_name);
      }
      free_pool_memory(rop.object);   
      rop.object = obj;               
      rop.object_len = out_len;
   }
   Dmsg2(100, "Recv Object: len=%d Object=%s\n", rop.object_len, rop.object);
   if (strcmp(rop.object_name, "job_metadata.xml") == 0) {
      Dmsg0(100, "got job metadata\n");
      jcr->got_metadata = true;
   }
   generate_plugin_event(jcr, bEventRestoreObject, (void *)&rop);
   if (rop.object_name) {
      free(rop.object_name);
   }
   if (rop.object) {
      free_pool_memory(rop.object);
   }
   if (rop.plugin_name) {
      free(rop.plugin_name);
   }
   Dmsg1(100, "Send: %s", OKRestoreObject);
   return 1;
bail_out:
   dir->fsend(_("2909 Bad RestoreObject command.\n"));
   return 0;
}
static int restore_object_cmd ( JCR * jcr ) { BSOCK * dir = jcr -> dir_bsock ; int32_t FileIndex ; restore_object_pkt rop ; memset ( & rop , 0 , sizeof ( rop ) ) ; rop . pkt_size = sizeof ( rop ) ; rop . pkt_end = sizeof ( rop ) ; Dmsg1 ( 100 , " " , dir -> msg ) ; if ( strcmp ( dir -> msg , endrestoreobjectcmd ) == 0 ) { Dmsg0 ( 20 , " \n " ) ; generate_plugin_event ( jcr , bEventRestoreObject , NULL ) ; return dir -> fsend ( OKRestoreObject ) ; } rop . plugin_name = ( char * ) malloc ( dir -> msglen ) ; * rop . plugin_name = 0 ; if ( sscanf ( dir -> msg , restoreobjcmd , & rop . JobId , & rop . object_len , & rop . object_full_len , & rop . object_index , & rop . object_type , & rop . object_compression , & FileIndex , rop . plugin_name ) != 8 ) { if ( sscanf ( dir -> msg , restoreobjcmd1 , & rop . JobId , & rop . object_len , & rop . object_full_len , & rop . object_index , & rop . object_type , & rop . object_compression , & FileIndex ) != 7 ) { Dmsg0 ( 5 , " \n " ) ; pm_strcpy ( jcr -> errmsg , dir -> msg ) ; Jmsg1 ( jcr , M_FATAL , 0 , _ ( " \n " ) , jcr -> errmsg ) ; goto bail_out ; } } unbash_spaces ( rop . plugin_name ) ; Dmsg7 ( 100 , " " " \n " , rop . JobId , rop . object_len , rop . object_full_len , rop . object_index , rop . object_type , FileIndex , rop . plugin_name ) ; if ( dir -> recv ( ) < 0 ) { goto bail_out ; } Dmsg2 ( 100 , " \n " , dir -> msglen , dir -> msg ) ; rop . object_name = bstrdup ( dir -> msg ) ; if ( dir -> recv ( ) < 0 ) { goto bail_out ; } rop . object = dir -> msg ; dir -> msg = get_pool_memory ( PM_MESSAGE ) ; if ( rop . object_compression == 1 ) { int stat ; int out_len = rop . object_full_len + 100 ; POOLMEM * obj = get_memory ( out_len ) ; Dmsg2 ( 100 , " \n " , rop . object_len , rop . object_full_len ) ; stat = Zinflate ( rop . object , rop . object_len , obj , out_len ) ; Dmsg1 ( 100 , " \n " , stat ) ; if ( out_len != rop . object_full_len ) { Jmsg3 ( jcr , M_ERROR , 0 , ( " \n " ) , rop . object_full_len , out_len , rop . object_name ) ; } free_pool_memory ( rop . object ) ; rop . object = obj ; rop . object_len = out_len ; } Dmsg2 ( 100 , " \n " , rop . object_len , rop . object ) ; if ( strcmp ( rop . object_name , " " ) == 0 ) { Dmsg0 ( 100 , " \n " ) ; jcr -> got_metadata = true ; } generate_plugin_event ( jcr , bEventRestoreObject , ( void * ) & rop ) ; if ( rop . object_name ) { free ( rop . object_name ) ; } if ( rop . object ) { free_pool_memory ( rop . object ) ; } if ( rop . plugin_name ) { free ( rop . plugin_name ) ; } Dmsg1 ( 100 , " " , OKRestoreObject ) ; return 1 ; bail_out : dir -> fsend ( _ ( " \n " ) ) ; return 0 ; }
This reads data sent from the Director from the
   RestoreObject table that allows us to get objects
   that were backed up (VSS .xml data) and are needed
   before starting the restore.
This reads data sent from the Director from the RestoreObject table that allows us to get objects that were backed up ( VSS . xml data ) and are needed before starting the restore .
/* Old version, no plugin_name */ /* Read Object name */ /* Read Object */ /* Transfer object from message buffer, and get new message buffer */ /* If object is compressed, uncompress it */ /* zlib level 9 */ /* release compressed object */ /* new uncompressed object */ /* we still need to do this to detect a vss restore */