src/filed/backup.c
static bool do_snap_strip(FF_PKT *ff)
{
   /* if the string starts with the snapshot path name, we can replace
    * by the volume name. The volume_path is smaller than the snapshot_path
    * snapshot_path = volume_path + /.snapshots/job-xxxx
    */
   ASSERT(strlen(ff->snapshot_path) > strlen(ff->volume_path));
   int sp_first = strlen(ff->snapshot_path); /* point after snapshot_path in fname */
   if (strncmp(ff->fname, ff->snapshot_path, sp_first) == 0) {
      int last = pm_strcpy(ff->snap_fname, ff->volume_path);
      last = MAX(last - 1, 0);

      if (ff->snap_fname[last] == '/') {
         if (ff->fname[sp_first] == '/') { /* compare with the first character of the string (sp_first not sp_first-1) */
            ff->snap_fname[last] = 0;
         }
      } else {
         if (ff->fname[sp_first] != '/') {
            pm_strcat(ff->snap_fname, "/");
         }
      }

      pm_strcat(ff->snap_fname, ff->fname + sp_first);
      ASSERT(strlen(ff->fname) > strlen(ff->snap_fname));
      strcpy(ff->fname, ff->snap_fname);
      Dmsg2(DT_SNAPSHOT|20, "%s -> %s\n", ff->fname_save, ff->fname);
   }
   if (strncmp(ff->link, ff->snapshot_path, sp_first) == 0) {
      int last = pm_strcpy(ff->snap_fname, ff->volume_path);
      last = MAX(last - 1, 0);

      if (ff->snap_fname[last] == '/') {
         if (ff->link[sp_first] == '/') { /* compare with the first character of the string (sp_first not sp_first-1) */
            ff->snap_fname[last] = 0;
         }
      } else {
         if (ff->link[sp_first] != '/') {
            pm_strcat(ff->snap_fname, "/");
         }
      }

      pm_strcat(ff->snap_fname, ff->link + sp_first);
      ASSERT(strlen(ff->link) > strlen(ff->snap_fname));
      strcpy(ff->link, ff->snap_fname);
      Dmsg2(DT_SNAPSHOT|20, "%s -> %s\n", ff->link_save, ff->link);
   }

   return true;
}
/*
 * Do in place strip of path
 */
Do in place strip of path
Do in place strip of path
static bool do_snap_strip(FF_PKT *ff)
{
   ASSERT(strlen(ff->snapshot_path) > strlen(ff->volume_path));
   int sp_first = strlen(ff->snapshot_path); 
   if (strncmp(ff->fname, ff->snapshot_path, sp_first) == 0) {
      int last = pm_strcpy(ff->snap_fname, ff->volume_path);
      last = MAX(last - 1, 0);
      if (ff->snap_fname[last] == '/') {
         if (ff->fname[sp_first] == '/') { 
            ff->snap_fname[last] = 0;
         }
      } else {
         if (ff->fname[sp_first] != '/') {
            pm_strcat(ff->snap_fname, "/");
         }
      }
      pm_strcat(ff->snap_fname, ff->fname + sp_first);
      ASSERT(strlen(ff->fname) > strlen(ff->snap_fname));
      strcpy(ff->fname, ff->snap_fname);
      Dmsg2(DT_SNAPSHOT|20, "%s -> %s\n", ff->fname_save, ff->fname);
   }
   if (strncmp(ff->link, ff->snapshot_path, sp_first) == 0) {
      int last = pm_strcpy(ff->snap_fname, ff->volume_path);
      last = MAX(last - 1, 0);
      if (ff->snap_fname[last] == '/') {
         if (ff->link[sp_first] == '/') { 
            ff->snap_fname[last] = 0;
         }
      } else {
         if (ff->link[sp_first] != '/') {
            pm_strcat(ff->snap_fname, "/");
         }
      }
      pm_strcat(ff->snap_fname, ff->link + sp_first);
      ASSERT(strlen(ff->link) > strlen(ff->snap_fname));
      strcpy(ff->link, ff->snap_fname);
      Dmsg2(DT_SNAPSHOT|20, "%s -> %s\n", ff->link_save, ff->link);
   }
   return true;
}
static bool do_snap_strip ( FF_PKT * ff ) { ASSERT ( strlen ( ff -> snapshot_path ) > strlen ( ff -> volume_path ) ) ; int sp_first = strlen ( ff -> snapshot_path ) ; if ( strncmp ( ff -> fname , ff -> snapshot_path , sp_first ) == 0 ) { int last = pm_strcpy ( ff -> snap_fname , ff -> volume_path ) ; last = MAX ( last - 1 , 0 ) ; if ( ff -> snap_fname [ last ] == ' ' ) { if ( ff -> fname [ sp_first ] == ' ' ) { ff -> snap_fname [ last ] = 0 ; } } else { if ( ff -> fname [ sp_first ] != ' ' ) { pm_strcat ( ff -> snap_fname , " " ) ; } } pm_strcat ( ff -> snap_fname , ff -> fname + sp_first ) ; ASSERT ( strlen ( ff -> fname ) > strlen ( ff -> snap_fname ) ) ; strcpy ( ff -> fname , ff -> snap_fname ) ; Dmsg2 ( DT_SNAPSHOT | 20 , " \n " , ff -> fname_save , ff -> fname ) ; } if ( strncmp ( ff -> link , ff -> snapshot_path , sp_first ) == 0 ) { int last = pm_strcpy ( ff -> snap_fname , ff -> volume_path ) ; last = MAX ( last - 1 , 0 ) ; if ( ff -> snap_fname [ last ] == ' ' ) { if ( ff -> link [ sp_first ] == ' ' ) { ff -> snap_fname [ last ] = 0 ; } } else { if ( ff -> link [ sp_first ] != ' ' ) { pm_strcat ( ff -> snap_fname , " " ) ; } } pm_strcat ( ff -> snap_fname , ff -> link + sp_first ) ; ASSERT ( strlen ( ff -> link ) > strlen ( ff -> snap_fname ) ) ; strcpy ( ff -> link , ff -> snap_fname ) ; Dmsg2 ( DT_SNAPSHOT | 20 , " \n " , ff -> link_save , ff -> link ) ; } return true ; }
Do in place strip of path
Do in place strip of path
/* if the string starts with the snapshot path name, we can replace
    * by the volume name. The volume_path is smaller than the snapshot_path
    * snapshot_path = volume_path + /.snapshots/job-xxxx
    */ /* point after snapshot_path in fname */ /* compare with the first character of the string (sp_first not sp_first-1) */ /* compare with the first character of the string (sp_first not sp_first-1) */