src/filed/backup.c
void strip_path(FF_PKT *ff_pkt)
{
   if (!ff_pkt->strip_snap_path        &&
       (!(ff_pkt->flags & FO_STRIPPATH) || ff_pkt->strip_path <= 0))
   {
      Dmsg1(200, "No strip for %s\n", ff_pkt->fname);
      return;
   }
   /* shared part between strip and snapshot */
   if (!ff_pkt->fname_save) {
     ff_pkt->fname_save = get_pool_memory(PM_FNAME);
     ff_pkt->link_save = get_pool_memory(PM_FNAME);
     *ff_pkt->link_save = 0;
   }
   pm_strcpy(ff_pkt->fname_save, ff_pkt->fname);
   if (ff_pkt->type != FT_LNK && ff_pkt->fname != ff_pkt->link) {
      pm_strcpy(ff_pkt->link_save, ff_pkt->link);
      Dmsg2(500, "strcpy link_save=%d link=%d\n", strlen(ff_pkt->link_save),
         strlen(ff_pkt->link));
      Dsm_check(200);
   }

   if (ff_pkt->strip_snap_path) {
      if (!do_snap_strip(ff_pkt)) {
         Dmsg1(0, "Something wrong with do_snap_strip(%s)\n", ff_pkt->fname);
         unstrip_path(ff_pkt);
         goto rtn;
      }
   }

   /* See if we want also to strip the path */
   if (!(ff_pkt->flags & FO_STRIPPATH) || ff_pkt->strip_path <= 0) {
      goto rtn;
   }

   /**
    * Strip path.  If it doesn't succeed put it back.  If
    *  it does, and there is a different link string,
    *  attempt to strip the link. If it fails, back them
    *  both back.
    * Do not strip symlinks.
    * I.e. if either stripping fails don't strip anything.
    */
   if (!do_strip(ff_pkt->strip_path, ff_pkt->fname)) {
      unstrip_path(ff_pkt);
      goto rtn;
   }
   /** Strip links but not symlinks */
   if (ff_pkt->type != FT_LNK && ff_pkt->fname != ff_pkt->link) {
      if (!do_strip(ff_pkt->strip_path, ff_pkt->link)) {
         unstrip_path(ff_pkt);
      }
   }

rtn:
   Dmsg3(10, "fname=%s stripped=%s link=%s\n", ff_pkt->fname_save, ff_pkt->fname,
       ff_pkt->link);
}
/**
 * If requested strip leading components of the path so that we can
 *   save file as if it came from a subdirectory.  This is most useful
 *   for dealing with snapshots, by removing the snapshot directory, or
 *   in handling vendor migrations where files have been restored with
 *   a vendor product into a subdirectory.
 *
 *   When we are using snapshots, we might need to convert the path
 *   back to the original one using the strip_snap_path option.
 */
If requested strip leading components of the path so that we can
save file as if it came from a subdirectory.  This is most useful
for dealing with snapshots, by removing the snapshot directory, or
in handling vendor migrations where files have been restored with
a vendor product into a subdirectory.

When we are using snapshots, we might need to convert the path
back to the original one using the strip_snap_path option.
If requested strip leading components of the path so that we can save file as if it came from a subdirectory . This is most useful for dealing with snapshots by removing the snapshot directory or in handling vendor migrations where files have been restored with a vendor product into a subdirectory . When we are using snapshots we might need to convert the path back to the original one using the strip_snap_path option .
void strip_path(FF_PKT *ff_pkt)
{
   if (!ff_pkt->strip_snap_path        &&
       (!(ff_pkt->flags & FO_STRIPPATH) || ff_pkt->strip_path <= 0))
   {
      Dmsg1(200, "No strip for %s\n", ff_pkt->fname);
      return;
   }
   if (!ff_pkt->fname_save) {
     ff_pkt->fname_save = get_pool_memory(PM_FNAME);
     ff_pkt->link_save = get_pool_memory(PM_FNAME);
     *ff_pkt->link_save = 0;
   }
   pm_strcpy(ff_pkt->fname_save, ff_pkt->fname);
   if (ff_pkt->type != FT_LNK && ff_pkt->fname != ff_pkt->link) {
      pm_strcpy(ff_pkt->link_save, ff_pkt->link);
      Dmsg2(500, "strcpy link_save=%d link=%d\n", strlen(ff_pkt->link_save),
         strlen(ff_pkt->link));
      Dsm_check(200);
   }
   if (ff_pkt->strip_snap_path) {
      if (!do_snap_strip(ff_pkt)) {
         Dmsg1(0, "Something wrong with do_snap_strip(%s)\n", ff_pkt->fname);
         unstrip_path(ff_pkt);
         goto rtn;
      }
   }
   if (!(ff_pkt->flags & FO_STRIPPATH) || ff_pkt->strip_path <= 0) {
      goto rtn;
   }
   if (!do_strip(ff_pkt->strip_path, ff_pkt->fname)) {
      unstrip_path(ff_pkt);
      goto rtn;
   }
   if (ff_pkt->type != FT_LNK && ff_pkt->fname != ff_pkt->link) {
      if (!do_strip(ff_pkt->strip_path, ff_pkt->link)) {
         unstrip_path(ff_pkt);
      }
   }
rtn:
   Dmsg3(10, "fname=%s stripped=%s link=%s\n", ff_pkt->fname_save, ff_pkt->fname,
       ff_pkt->link);
}
void strip_path ( FF_PKT * ff_pkt ) { if ( ! ff_pkt -> strip_snap_path && ( ! ( ff_pkt -> flags & FO_STRIPPATH ) || ff_pkt -> strip_path <= 0 ) ) { Dmsg1 ( 200 , " \n " , ff_pkt -> fname ) ; return ; } if ( ! ff_pkt -> fname_save ) { ff_pkt -> fname_save = get_pool_memory ( PM_FNAME ) ; ff_pkt -> link_save = get_pool_memory ( PM_FNAME ) ; * ff_pkt -> link_save = 0 ; } pm_strcpy ( ff_pkt -> fname_save , ff_pkt -> fname ) ; if ( ff_pkt -> type != FT_LNK && ff_pkt -> fname != ff_pkt -> link ) { pm_strcpy ( ff_pkt -> link_save , ff_pkt -> link ) ; Dmsg2 ( 500 , " \n " , strlen ( ff_pkt -> link_save ) , strlen ( ff_pkt -> link ) ) ; Dsm_check ( 200 ) ; } if ( ff_pkt -> strip_snap_path ) { if ( ! do_snap_strip ( ff_pkt ) ) { Dmsg1 ( 0 , " \n " , ff_pkt -> fname ) ; unstrip_path ( ff_pkt ) ; goto rtn ; } } if ( ! ( ff_pkt -> flags & FO_STRIPPATH ) || ff_pkt -> strip_path <= 0 ) { goto rtn ; } if ( ! do_strip ( ff_pkt -> strip_path , ff_pkt -> fname ) ) { unstrip_path ( ff_pkt ) ; goto rtn ; } if ( ff_pkt -> type != FT_LNK && ff_pkt -> fname != ff_pkt -> link ) { if ( ! do_strip ( ff_pkt -> strip_path , ff_pkt -> link ) ) { unstrip_path ( ff_pkt ) ; } } rtn : Dmsg3 ( 10 , " \n " , ff_pkt -> fname_save , ff_pkt -> fname , ff_pkt -> link ) ; }
If requested strip leading components of the path so that we can
   save file as if it came from a subdirectory.
If requested strip leading components of the path so that we can save file as if it came from a subdirectory .
/* shared part between strip and snapshot */ /* See if we want also to strip the path */ /**
    * Strip path.  If it doesn't succeed put it back.  If
    *  it does, and there is a different link string,
    *  attempt to strip the link. If it fails, back them
    *  both back.
    * Do not strip symlinks.
    * I.e. if either stripping fails don't strip anything.
    */ /** Strip links but not symlinks */