]> git.sur5r.net Git - bacula/bacula/commitdiff
Fix restore of symbolic links
authorKern Sibbald <kern@sibbald.com>
Tue, 25 Mar 2003 17:29:15 +0000 (17:29 +0000)
committerKern Sibbald <kern@sibbald.com>
Tue, 25 Mar 2003 17:29:15 +0000 (17:29 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@394 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/dird/backup.c
bacula/src/dird/restore.c
bacula/src/filed/job.c
bacula/src/filed/restore.c

index 6960262d64377fcd936c94b6bdf828ae74cf289b..937efbe6a74429f99e89195b4cd383657bbab6dd 100644 (file)
@@ -400,7 +400,7 @@ static void backup_cleanup(JCR *jcr, int TermCode, char *since)
         }
         break;
       case JS_Cancelled:
-         term_msg = _("Backup Cancelled");
+         term_msg = _("Backup Canceled");
         if (jcr->store_bsock) {
            bnet_sig(jcr->store_bsock, BNET_TERMINATE);
            pthread_cancel(jcr->SD_msg_chan);
index 4ba3880c675b3134b79da36bb7ed1a98d820c5e1..a3a9dd686cc68c00e1b0416ad3c89953fc3b2f4e 100644 (file)
@@ -181,7 +181,6 @@ int do_restore(JCR *jcr)
       return 0;
    }
 
-
    /* 
     * send Storage daemon address to the File daemon,
     *  then wait for File daemon to make connection
@@ -262,6 +261,13 @@ int do_restore(JCR *jcr)
       }
    }
 
+   if (is_bnet_error(fd)) {
+      Jmsg(jcr, M_FATAL, 0, _("Network error during RESTORE command. ERR=%s\n"),
+         bnet_strerror(fd));
+   }
+   bnet_sig(fd, BNET_TERMINATE);   /* tell Client we are terminating */
+
+
    restore_cleanup(jcr, ok?jcr->FDJobStatus:JS_ErrorTerminated);
 
    return 1;
@@ -275,7 +281,7 @@ static void restore_cleanup(JCR *jcr, int TermCode)
 {
    char sdt[MAX_TIME_LENGTH], edt[MAX_TIME_LENGTH];
    char ec1[30], ec2[30];
-   char term_code[100];
+   char term_code[100], fd_term_msg[100];
    char *term_msg;
    int msg_type;
    double kbps;
@@ -300,7 +306,7 @@ static void restore_cleanup(JCR *jcr, int TermCode)
         }
         break;
       case JS_Cancelled:
-         term_msg = _("Restore Cancelled");
+         term_msg = _("Restore Canceled");
         if (jcr->store_bsock) {
            bnet_sig(jcr->store_bsock, BNET_TERMINATE);
            pthread_cancel(jcr->SD_msg_chan);
@@ -314,6 +320,11 @@ static void restore_cleanup(JCR *jcr, int TermCode)
    bstrftime(sdt, sizeof(sdt), jcr->jr.StartTime);
    bstrftime(edt, sizeof(edt), jcr->jr.EndTime);
    kbps = (double)jcr->jr.JobBytes / (1000 * (jcr->jr.EndTime - jcr->jr.StartTime));
+   if (kbps < 0.05) {
+      kbps = 0;
+   }
+
+   jobstatus_to_ascii(jcr->FDJobStatus, fd_term_msg, sizeof(fd_term_msg));
 
    Jmsg(jcr, msg_type, 0, _("Bacula " VERSION " (" LSMDATE "): %s\n\
 JobId:                  %d\n\
@@ -324,6 +335,7 @@ End time:               %s\n\
 Files Restored:         %s\n\
 Bytes Restored:         %s\n\
 Rate:                   %.1f KB/s\n\
+FD termination status:  %s\n\
 Termination:            %s\n\n"),
        edt,
        jcr->jr.JobId,
@@ -334,6 +346,7 @@ Termination:            %s\n\n"),
        edit_uint64_with_commas((uint64_t)jcr->jr.JobFiles, ec1),
        edit_uint64_with_commas(jcr->jr.JobBytes, ec2),
        (float)kbps,
+       fd_term_msg,
        term_msg);
 
    Dmsg0(20, "Leaving restore_cleanup\n");
index c696ba285b4bd0b88a2fed9233962512e5d4f34a..74532861d91e51bc9210f8185ebc1127ae63bb19 100644 (file)
@@ -161,6 +161,7 @@ void *handle_client_request(void *dirp)
    jcr->last_fname = get_pool_memory(PM_FNAME);
    jcr->last_fname[0] = 0;
    jcr->client_name = get_memory(strlen(my_name) + 1);
+   jcr->prefix_links = 1;            /* default to prefix links */
    pm_strcpy(&jcr->client_name, my_name);
    dir->jcr = (void *)jcr;
 
index bc946757a22b101ecacba59f73468aa020e7fc18..35e2497175dde2a839d5d45afb7354dc1dfe8601 100644 (file)
@@ -232,18 +232,31 @@ void do_restore(JCR *jcr)
            /* Ensure where is terminated with a slash */
             if (jcr->where[wherelen-1] != '/' && fn[0] != '/') {
                strcat(ofile, "/");
-           }
+           }   
            strcat(ofile, fn);        /* copy rest of name */
-           /* Fixup link name */
-           if (type == FT_LNKSAVED || (type == FT_LNK && jcr->prefix_links)) {
-               if (lp[0] == '/') {      /* if absolute path */
+           /*
+            * Fixup link name -- add where only if requested
+            *   and if it is an absolute path
+            */
+           if (type == FT_LNKSAVED || type == FT_LNK) {
+              int add_link;
+               if (jcr->prefix_links && lp[0] == '/') {      /* if absolute path */
                  strcpy(lname, jcr->where);
-              }       
+                 add_link = 1;
+              } else {
+                 lname[0] = 0;
+                 add_link = 0;
+              }
                if (win32_client && lp[1] == ':') {
-                 strcat(lname, lp+2); /* copy rest of name */
+                 fn = lp+2;             /* skip over drive: */
               } else {
-                 strcat(lname, lp);   /* On Unix systems we take everything */
+                 fn = lp;               /* take whole name */
               }
+              /* Ensure where is terminated with a slash */
+               if (add_link && jcr->where[wherelen-1] != '/' && fn[0] != '/') {
+                  strcat(lname, "/");
+              }   
+              strcat(lname, fn);     /* copy rest of link */
            }
         }