From c4e6907c83da22fa03bf04ff18b1446072567f17 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sat, 20 Dec 2008 10:03:36 +0000 Subject: [PATCH] 20Dec08 kes Correct typo in Win32 Makefile editing kes Correct typos in debug output. kes Improved error detection in creating bsrs. kes Add debug code to Win32 restore 19Dec08 kes Fix Win32 build. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8196 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/dird/job.c | 13 ++++++--- bacula/src/filed/job.c | 14 ++++----- bacula/src/findlib/bfile.c | 15 ++++++++-- bacula/src/lib/message.c | 2 +- bacula/src/stored/parse_bsr.c | 16 +++++----- bacula/src/version.h | 6 ++-- bacula/src/win32/Makefile | 4 +-- bacula/src/win32/cats/bacula_cats.def | 1 + bacula/src/win32/compat/compat.cpp | 42 ++++++++++++++++++++------- bacula/technotes-2.5 | 6 ++++ 10 files changed, 81 insertions(+), 38 deletions(-) diff --git a/bacula/src/dird/job.c b/bacula/src/dird/job.c index 5ca2141e3d..8a88516bb1 100644 --- a/bacula/src/dird/job.c +++ b/bacula/src/dird/job.c @@ -1364,20 +1364,25 @@ bool create_restore_bootstrap_file(JCR *jcr) rx.JobIds = (char *)""; rx.bsr->JobId = jcr->previous_jr.JobId; ua = new_ua_context(jcr); - complete_bsr(ua, rx.bsr); + if (!complete_bsr(ua, rx.bsr)) { + goto bail_out; + } rx.bsr->fi = new_findex(); rx.bsr->fi->findex = 1; rx.bsr->fi->findex2 = jcr->previous_jr.JobFiles; jcr->ExpectedFiles = write_bsr_file(ua, rx); if (jcr->ExpectedFiles == 0) { - free_ua_context(ua); - free_bsr(rx.bsr); - return false; + goto bail_out; } free_ua_context(ua); free_bsr(rx.bsr); jcr->needs_sd = true; return true; + +bail_out: + free_ua_context(ua); + free_bsr(rx.bsr); + return false; } /* TODO: redirect command ouput to job log */ diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index e258fce8ad..62dc2d22ed 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -1437,7 +1437,7 @@ static int backup_cmd(JCR *jcr) } dir->fsend(OKbackup); - Dmsg1(110, "bfiled>dird: %s", dir->msg); + Dmsg1(110, "filed>dird: %s", dir->msg); /* * Send Append Open Session to Storage daemon @@ -1629,7 +1629,7 @@ static int verify_cmd(JCR *jcr) generate_plugin_event(jcr, bEventLevel, (void *)jcr->get_JobLevel()); generate_plugin_event(jcr, bEventStartVerifyJob); - Dmsg1(110, "bfiled>dird: %s", dir->msg); + Dmsg1(110, "filed>dird: %s", dir->msg); switch (jcr->get_JobLevel()) { case L_VERIFY_INIT: @@ -1647,7 +1647,7 @@ static int verify_cmd(JCR *jcr) * Send Close session command to Storage daemon */ sd->fsend(read_close, jcr->Ticket); - Dmsg1(130, "bfiled>stored: %s", sd->msg); + Dmsg1(130, "filed>stored: %s", sd->msg); /* ****FIXME**** check response */ bget_msg(sd); /* get OK */ @@ -1725,7 +1725,7 @@ static int restore_cmd(JCR *jcr) jcr->prefix_links = prefix_links; dir->fsend(OKrestore); - Dmsg1(110, "bfiled>dird: %s", dir->msg); + Dmsg1(110, "filed>dird: %s", dir->msg); jcr->set_JobType(JT_RESTORE); @@ -1756,7 +1756,7 @@ static int restore_cmd(JCR *jcr) * Send Close session command to Storage daemon */ sd->fsend(read_close, jcr->Ticket); - Dmsg1(130, "bfiled>stored: %s", sd->msg); + Dmsg1(130, "filed>stored: %s", sd->msg); bget_msg(sd); /* get OK */ @@ -1797,12 +1797,12 @@ static int open_sd_read_session(JCR *jcr) * Get ticket number */ if (bget_msg(sd) >= 0) { - Dmsg1(110, "bfiledmsg); + Dmsg1(110, "filedmsg); if (sscanf(sd->msg, OK_open, &jcr->Ticket) != 1) { Jmsg(jcr, M_FATAL, 0, _("Bad response to SD read open: %s\n"), sd->msg); return 0; } - Dmsg1(110, "bfiled: got Ticket=%d\n", jcr->Ticket); + Dmsg1(110, "filed: got Ticket=%d\n", jcr->Ticket); } else { Jmsg(jcr, M_FATAL, 0, _("Bad response from stored to read open command\n")); return 0; diff --git a/bacula/src/findlib/bfile.c b/bacula/src/findlib/bfile.c index f7a65f0b2b..03597b4cd6 100644 --- a/bacula/src/findlib/bfile.c +++ b/bacula/src/findlib/bfile.c @@ -473,13 +473,16 @@ int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode) free_pool_memory(win32_fname); return bfd->mode == BF_CLOSED ? -1 : 1; } - Dmsg0(50, "=== NOT plugin\n"); + Dmsg0(50, "=== NO plugin\n"); - if (!(p_CreateFileA || p_CreateFileW)) + if (!(p_CreateFileA || p_CreateFileW)) { + Dmsg0(50, "No CreateFileA and no CreateFileW!!!!!\n"); return 0; + } - if (p_CreateFileW && p_MultiByteToWideChar) + if (p_CreateFileW && p_MultiByteToWideChar) { make_win32_path_UTF8_2_wchar(&win32_fname_wchar, fname); + } if (flags & O_CREAT) { /* Create */ if (bfd->use_backup_api) { @@ -492,6 +495,7 @@ int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode) if (p_CreateFileW && p_MultiByteToWideChar) { // unicode open for create write + Dmsg1(100, "Create CreateFileW=%s\n", win32_fname); bfd->fh = p_CreateFileW((LPCWSTR)win32_fname_wchar, dwaccess, /* Requested access */ 0, /* Shared mode */ @@ -501,6 +505,7 @@ int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode) NULL); /* TemplateFile */ } else { // ascii open + Dmsg1(100, "Create CreateFileA=%s\n", win32_fname); bfd->fh = p_CreateFileA(win32_fname, dwaccess, /* Requested access */ 0, /* Shared mode */ @@ -523,6 +528,7 @@ int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode) if (p_CreateFileW && p_MultiByteToWideChar) { // unicode open for open existing write + Dmsg1(100, "Write only CreateFileW=%s\n", win32_fname); bfd->fh = p_CreateFileW((LPCWSTR)win32_fname_wchar, dwaccess, /* Requested access */ 0, /* Shared mode */ @@ -532,6 +538,7 @@ int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode) NULL); /* TemplateFile */ } else { // ascii open + Dmsg1(100, "Write only CreateFileA=%s\n", win32_fname); bfd->fh = p_CreateFileA(win32_fname, dwaccess, /* Requested access */ 0, /* Shared mode */ @@ -558,6 +565,7 @@ int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode) if (p_CreateFileW && p_MultiByteToWideChar) { // unicode open for open existing read + Dmsg1(100, "Read CreateFileW=%s\n", win32_fname); bfd->fh = p_CreateFileW((LPCWSTR)win32_fname_wchar, dwaccess, /* Requested access */ dwshare, /* Share modes */ @@ -567,6 +575,7 @@ int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode) NULL); /* TemplateFile */ } else { // ascii open + Dmsg1(100, "Read CreateFileA=%s\n", win32_fname); bfd->fh = p_CreateFileA(win32_fname, dwaccess, /* Requested access */ dwshare, /* Share modes */ diff --git a/bacula/src/lib/message.c b/bacula/src/lib/message.c index 1371bbc05f..24a25f32d8 100644 --- a/bacula/src/lib/message.c +++ b/bacula/src/lib/message.c @@ -889,7 +889,7 @@ d_msg(const char *file, int line, int level, const char *fmt,...) if (trace) { if (!trace_fd) { char fn[200]; - bsnprintf(fn, sizeof(fn), "%s/%s.trace", working_directory ? working_directory : ".", my_name); + bsnprintf(fn, sizeof(fn), "%s/%s.trace", working_directory ? working_directory : "./", my_name); trace_fd = fopen(fn, "a+b"); } if (trace_fd) { diff --git a/bacula/src/stored/parse_bsr.c b/bacula/src/stored/parse_bsr.c index b2790e7f6a..3798435217 100644 --- a/bacula/src/stored/parse_bsr.c +++ b/bacula/src/stored/parse_bsr.c @@ -1,14 +1,7 @@ -/* - * Parse a Bootstrap Records (used for restores) - * - * Kern Sibbald, June MMII - * - * Version $Id$ - */ /* Bacula® - The Network Backup Solution - Copyright (C) 2002-2006 Free Software Foundation Europe e.V. + Copyright (C) 2002-2008 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -32,6 +25,13 @@ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, Switzerland, email:ftf@fsfeurope.org. */ +/* + * Parse a Bootstrap Records (used for restores) + * + * Kern Sibbald, June MMII + * + * Version $Id$ + */ #include "bacula.h" diff --git a/bacula/src/version.h b/bacula/src/version.h index 68dfa653bf..11feae3fe4 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -3,9 +3,9 @@ */ #undef VERSION -#define VERSION "2.5.24" -#define BDATE "16 December 2008" -#define LSMDATE "16Dec08" +#define VERSION "2.5.25" +#define BDATE "20 December 2008" +#define LSMDATE "20Dec08" #define PROG_COPYRIGHT "Copyright (C) %d-2008 Free Software Foundation Europe e.V.\n" #define BYEAR "2008" /* year for copyright messages in progs */ diff --git a/bacula/src/win32/Makefile b/bacula/src/win32/Makefile index e5eba0a37a..1762c8f895 100644 --- a/bacula/src/win32/Makefile +++ b/bacula/src/win32/Makefile @@ -28,7 +28,7 @@ $(DIRS): fi ; \ fi -Makefile.inc: Makefile.inc.in +Makefile.inc: Makefile.inc.in Makefile @echo Creating $@ $(ECHO_CMD)TOPDIR=`(cd ../../..;pwd)`; \ if test -e ../../../cross-tools/mingw32/bin/mingw32-gcc; then \ @@ -47,7 +47,7 @@ Makefile.inc: Makefile.inc.in $(ECHO_CMD)BUILDDIR=`(pwd)`; \ $(ECHO_CMD)MAINDIR=`(cd ../..;pwd)`; \ sed \ - -e "s^@WIN3wBUILDDIR@^$${BUILDDIR}^" \ + -e "s^@WIN32BUILDDIR@^$${BUILDDIR}^" \ -e "s^@WIN32MAINDIR@^$${MAINDIR}^" \ -e "s^@WIN32TOPDIR@^$${TOPDIR}^" \ -e "s^@WIN32BINDIR@^$${BINDIR}^" \ diff --git a/bacula/src/win32/cats/bacula_cats.def b/bacula/src/win32/cats/bacula_cats.def index 3111e529d2..8a0d7c954a 100644 --- a/bacula/src/win32/cats/bacula_cats.def +++ b/bacula/src/win32/cats/bacula_cats.def @@ -79,6 +79,7 @@ _Z20db_list_pool_recordsP3JCRP4B_DBP8POOL_DBRPFvPvPKcES5_11e_list_type _Z21db_list_files_for_jobP3JCRP4B_DBjPFvPvPKcES3_ _Z21db_list_media_recordsP3JCRP4B_DBP9MEDIA_DBRPFvPvPKcES5_11e_list_type _Z22db_list_client_recordsP3JCRP4B_DBPFvPvPKcES3_11e_list_type +_Z22db_list_joblog_recordsP3JCRP4B_DBjPFvPvPKcES3_11e_list_type _Z24db_list_jobmedia_recordsP3JCRP4B_DBjPFvPvPKcES3_11e_list_type ; sql_update.o diff --git a/bacula/src/win32/compat/compat.cpp b/bacula/src/win32/compat/compat.cpp index a6491a81d8..799ea54db8 100644 --- a/bacula/src/win32/compat/compat.cpp +++ b/bacula/src/win32/compat/compat.cpp @@ -651,6 +651,7 @@ statDir(const char *file, struct stat *sb) POOLMEM* pwszBuf = get_pool_memory (PM_FNAME); make_win32_path_UTF8_2_wchar(&pwszBuf, file); + Dmsg1(100, "FindFirstFileW=%s\n", file); h = p_FindFirstFileW((LPCWSTR)pwszBuf, &info_w); free_pool_memory(pwszBuf); @@ -664,6 +665,7 @@ statDir(const char *file, struct stat *sb) // use ASCII } else if (p_FindFirstFileA) { + Dmsg1(100, "FindFirstFileA=%s\n", file); h = p_FindFirstFileA(file, &info_a); pdwFileAttributes = &info_a.dwFileAttributes; @@ -673,11 +675,17 @@ statDir(const char *file, struct stat *sb) pftLastAccessTime = &info_a.ftLastAccessTime; pftLastWriteTime = &info_a.ftLastWriteTime; pftCreationTime = &info_a.ftCreationTime; + } else { + Dmsg0(100, "No findFirstFile A or W found\n"); } if (h == INVALID_HANDLE_VALUE) { const char *err = errorString(); - Dmsg2(99, "FindFirstFile(%s):%s\n", file, err); + /* + * Note, in creating leading paths, it is normal that + * the file does not exist. + */ + Dmsg2(2099, "FindFirstFile(%s):%s\n", file, err); LocalFree((void *)err); errno = b_errno_win32; return -1; @@ -731,7 +739,7 @@ fstat(int fd, struct stat *sb) if (!GetFileInformationByHandle((HANDLE)fd, &info)) { const char *err = errorString(); - Dmsg1(99, "GetfileInformationByHandle: %s\n", err); + Dmsg1(2099, "GetfileInformationByHandle: %s\n", err); LocalFree((void *)err); errno = b_errno_win32; return -1; @@ -777,7 +785,7 @@ fstat(int fd, struct stat *sb) static int stat2(const char *file, struct stat *sb) { - HANDLE h; + HANDLE h = INVALID_HANDLE_VALUE; int rval = 0; char tmpbuf[5000]; conv_unix_to_win32_path(file, tmpbuf, 5000); @@ -789,25 +797,31 @@ stat2(const char *file, struct stat *sb) make_win32_path_UTF8_2_wchar(&pwszBuf, tmpbuf); attr = p_GetFileAttributesW((LPCWSTR) pwszBuf); + if (p_CreateFileW) { + h = CreateFileW((LPCWSTR)pwszBuf, GENERIC_READ, + FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); + } free_pool_memory(pwszBuf); } else if (p_GetFileAttributesA) { attr = p_GetFileAttributesA(tmpbuf); + h = CreateFileA(tmpbuf, GENERIC_READ, + FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); } if (attr == (DWORD)-1) { const char *err = errorString(); - Dmsg2(99, "GetFileAttributes(%s): %s\n", tmpbuf, err); + Dmsg2(2099, "GetFileAttributes(%s): %s\n", tmpbuf, err); LocalFree((void *)err); + if (h != INVALID_HANDLE_VALUE) { + CloseHandle(h); + } errno = b_errno_win32; return -1; } - h = CreateFileA(tmpbuf, GENERIC_READ, - FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); - if (h == INVALID_HANDLE_VALUE) { const char *err = errorString(); - Dmsg2(99, "Cannot open file for stat (%s):%s\n", tmpbuf, err); + Dmsg2(2099, "Cannot open file for stat (%s):%s\n", tmpbuf, err); LocalFree((void *)err); errno = b_errno_win32; return -1; @@ -818,9 +832,8 @@ stat2(const char *file, struct stat *sb) if (attr & FILE_ATTRIBUTE_DIRECTORY && file[1] == ':' && file[2] != 0) { - statDir(file, sb); + rval = statDir(file, sb); } - return rval; } @@ -1355,6 +1368,7 @@ int win32_chmod(const char *path, mode_t mode) { DWORD attr = (DWORD)-1; + Dmsg1(100, "Enter win32_chmod. path=%s\n", path); if (p_GetFileAttributesW) { POOLMEM* pwszBuf = get_pool_memory(PM_FNAME); make_win32_path_UTF8_2_wchar(&pwszBuf, path); @@ -1380,6 +1394,7 @@ int win32_chmod(const char *path, mode_t mode) attr = p_SetFileAttributesW((LPCWSTR)pwszBuf, attr); } free_pool_memory(pwszBuf); + Dmsg0(100, "Leave win32_chmod. AttributesW\n"); } else if (p_GetFileAttributesA) { if (mode & (S_IRUSR|S_IRGRP|S_IROTH)) { attr |= FILE_ATTRIBUTE_READONLY; @@ -1400,7 +1415,11 @@ int win32_chmod(const char *path, mode_t mode) if (attr != INVALID_FILE_ATTRIBUTES) { attr = p_SetFileAttributesA(path, attr); } + Dmsg0(100, "Leave win32_chmod did AttributesA\n"); + } else { + Dmsg0(100, "Leave win32_chmod did nothing\n"); } + if (attr == (DWORD)-1) { const char *err = errorString(); @@ -1443,15 +1462,18 @@ win32_chdir(const char *dir) int win32_mkdir(const char *dir) { + Dmsg1(100, "enter win32_mkdir. dir=%s\n", dir); if (p_wmkdir){ POOLMEM* pwszBuf = get_pool_memory(PM_FNAME); make_win32_path_UTF8_2_wchar(&pwszBuf, dir); int n = p_wmkdir((LPCWSTR)pwszBuf); free_pool_memory(pwszBuf); + Dmsg0(100, "Leave win32_mkdir did wmkdir\n"); return n; } + Dmsg0(100, "Leave win32_mkdir did _mkdir\n"); return _mkdir(dir); } diff --git a/bacula/technotes-2.5 b/bacula/technotes-2.5 index b57b9ecaaa..a2b6607762 100644 --- a/bacula/technotes-2.5 +++ b/bacula/technotes-2.5 @@ -10,7 +10,13 @@ filepattern (restore with regex in bsr) mixed priorities General: +20Dec08 +kes Correct typo in Win32 Makefile editing +kes Correct typos in debug output. +kes Improved error detection in creating bsrs. +kes Add debug code to Win32 restore 19Dec08 +kes Fix Win32 build. ebl Cleanup director VolParam struct 18Dec08 ebl Replace File:Block in BSR by Address to fix #1190 -- 2.39.5