From: Kern Sibbald Date: Tue, 25 Mar 2003 17:29:15 +0000 (+0000) Subject: Fix restore of symbolic links X-Git-Tag: Release-1.30~73 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=af31db266ec51da5f6aeefa97684b9704beff022;p=bacula%2Fbacula Fix restore of symbolic links git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@394 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/dird/backup.c b/bacula/src/dird/backup.c index 6960262d64..937efbe6a7 100644 --- a/bacula/src/dird/backup.c +++ b/bacula/src/dird/backup.c @@ -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); diff --git a/bacula/src/dird/restore.c b/bacula/src/dird/restore.c index 4ba3880c67..a3a9dd686c 100644 --- a/bacula/src/dird/restore.c +++ b/bacula/src/dird/restore.c @@ -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"); diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index c696ba285b..74532861d9 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -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; diff --git a/bacula/src/filed/restore.c b/bacula/src/filed/restore.c index bc946757a2..35e2497175 100644 --- a/bacula/src/filed/restore.c +++ b/bacula/src/filed/restore.c @@ -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 */ } }