From dfcb79084e79d874727845ada959f363eabec3b6 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Thu, 21 Jun 2007 21:45:36 +0000 Subject: [PATCH] kes Don't print clock skew message in FD if less than 3 seconds diff. kes Add a bit of VSS info to status client. kes Make a gross first cut of Vista VSS, using Win2003 code. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@5062 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/filed/job.c | 3 +- bacula/src/filed/status.c | 2 +- bacula/src/version.h | 6 +-- bacula/src/win32/compat/Makefile | 3 +- bacula/src/win32/compat/compat.cpp | 2 +- bacula/src/win32/compat/winapi.c | 17 ++++---- bacula/src/win32/filed/Makefile | 1 + bacula/src/win32/filed/vss.cpp | 28 +++++++++---- bacula/src/win32/filed/vss.h | 40 ++++++++++++------ bacula/src/win32/filed/vss_W2K3.cpp | 12 +++--- bacula/src/win32/filed/vss_generic.cpp | 57 +++++++++++++++++--------- bacula/src/win32/winapi.h | 1 + bacula/technotes-2.1 | 6 +++ 13 files changed, 118 insertions(+), 60 deletions(-) diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index 4a09522812..ad0d4d68bd 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -1217,7 +1217,8 @@ static int level_cmd(JCR *jcr) Dmsg2(100, "rt=%s adj=%s\n", edit_uint64(rt, ed1), edit_uint64(bt_adj, ed2)); adj = btime_to_utime(bt_adj); since_time += adj; /* adjust for clock difference */ - if (adj != 0) { + /* Don't notify if time within 3 seconds */ + if (adj > 3 || adj < -3) { int type; if (adj > 600 || adj < -600) { type = M_WARNING; diff --git a/bacula/src/filed/status.c b/bacula/src/filed/status.c index 497c7cc215..00549fe0e0 100644 --- a/bacula/src/filed/status.c +++ b/bacula/src/filed/status.c @@ -86,7 +86,7 @@ void output_status(void sendit(const char *msg, int len, void *sarg), void *arg) if (!privs) { privs = enable_backup_privileges(NULL, 1); } - len = Mmsg(msg, "Priv 0x%x\n", privs); + len = Mmsg(msg, "VSS=%s Priv 0x%x\n", g_pVSSClient?"yes":"no", privs); sendit(msg.c_str(), len, arg); len = Mmsg(msg, "APIs=%sOPT,%sATP,%sLPV,%sCFA,%sCFW,\n", p_OpenProcessToken?"":"!", diff --git a/bacula/src/version.h b/bacula/src/version.h index fc544442a1..ddd9938c56 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -3,9 +3,9 @@ */ #undef VERSION -#define VERSION "2.1.20" -#define BDATE "20 June 2007" -#define LSMDATE "20Jun07" +#define VERSION "2.1.21" +#define BDATE "21 June 2007" +#define LSMDATE "21Jun07" #define PROG_COPYRIGHT "Copyright (C) %d-2007 Free Software Foundation Europe e.V.\n" #define BYEAR "2007" /* year for copyright messages in progs */ diff --git a/bacula/src/win32/compat/Makefile b/bacula/src/win32/compat/Makefile index 9b5f5d3c00..e42f55a9b4 100644 --- a/bacula/src/win32/compat/Makefile +++ b/bacula/src/win32/compat/Makefile @@ -31,7 +31,8 @@ LIB_OBJS = \ $(OBJDIR)/print.o \ $(OBJDIR)/vss.o \ $(OBJDIR)/vss_XP.o \ - $(OBJDIR)/vss_W2K3.o + $(OBJDIR)/vss_W2K3.o \ + $(OBJDIR)/vss_Vista.o ###################################################################### diff --git a/bacula/src/win32/compat/compat.cpp b/bacula/src/win32/compat/compat.cpp index 90a4a7dbb0..88918b4ba7 100644 --- a/bacula/src/win32/compat/compat.cpp +++ b/bacula/src/win32/compat/compat.cpp @@ -1508,7 +1508,7 @@ winver::winver(void) osvinfo.dwMajorVersion, osvinfo.dwMinorVersion); snprintf(WIN_RAWVERSION, sizeof(WIN_RAWVERSION), "Windows %#08x", ver); - switch (ver) + switch (ver) { case MS_WINDOWS_95: (version = "Windows 95"); break; case MS_WINDOWS_98: (version = "Windows 98"); break; diff --git a/bacula/src/win32/compat/winapi.c b/bacula/src/win32/compat/winapi.c index a723835caf..ed75483388 100644 --- a/bacula/src/win32/compat/winapi.c +++ b/bacula/src/win32/compat/winapi.c @@ -1,10 +1,3 @@ -/* - * Windows APIs that are different for each system. - * We use pointers to the entry points so that a - * single binary will run on all Windows systems. - * - * Kern Sibbald MMIII - */ /* Bacula® - The Network Backup Solution @@ -32,12 +25,20 @@ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, Switzerland, email:ftf@fsfeurope.org. */ +/* + * Windows APIs that are different for each system. + * We use pointers to the entry points so that a + * single binary will run on all Windows systems. + * + * Kern Sibbald MMIII + */ #include "bacula.h" // init with win9x, but maybe set to NT in InitWinAPI DWORD g_platform_id = VER_PLATFORM_WIN32_WINDOWS; DWORD g_MinorVersion = 0; +DWORD g_MajorVersion = 0; /* API Pointers */ @@ -95,10 +96,10 @@ InitWinAPIWrapper() // Get the current OS version if (!GetVersionEx(&osversioninfo)) { g_platform_id = 0; - g_MinorVersion = 0; } else { g_platform_id = osversioninfo.dwPlatformId; g_MinorVersion = osversioninfo.dwMinorVersion; + g_MajorVersion = osversioninfo.dwMajorVersion; } HMODULE hLib = LoadLibraryA("KERNEL32.DLL"); diff --git a/bacula/src/win32/filed/Makefile b/bacula/src/win32/filed/Makefile index 6e2cab8bb0..72f778f549 100644 --- a/bacula/src/win32/filed/Makefile +++ b/bacula/src/win32/filed/Makefile @@ -42,6 +42,7 @@ FILED_OBJS = \ $(OBJDIR)/vss.o \ $(OBJDIR)/vss_XP.o \ $(OBJDIR)/vss_W2K3.o \ + $(OBJDIR)/vss_Vista.o \ $(OBJDIR)/winabout.o \ $(OBJDIR)/winservice.o \ $(OBJDIR)/winstat.o \ diff --git a/bacula/src/win32/filed/vss.cpp b/bacula/src/win32/filed/vss.cpp index 7e33725ad6..a8a0837e9c 100644 --- a/bacula/src/win32/filed/vss.cpp +++ b/bacula/src/win32/filed/vss.cpp @@ -9,7 +9,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2005-2006 Free Software Foundation Europe e.V. + Copyright (C) 2005-2007 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. @@ -46,26 +46,40 @@ VSSClient *g_pVSSClient; +// {b5946137-7b9f-4925-af80-51abd60b20d5} + +static const GUID VSS_SWPRV_ProviderID = + { 0xb5946137, 0x7b9f, 0x4925, { 0xaf, 0x80, 0x51, 0xab, 0xd6, 0x0b, 0x20, 0xd5 } }; + + void VSSCleanup() { - if (g_pVSSClient) + if (g_pVSSClient) { delete (g_pVSSClient); + } } -void -VSSInit() +void VSSInit() { /* decide which vss class to initialize */ - switch (g_MinorVersion) { + if (g_MajorVersion == 5) { + switch (g_MinorVersion) { case 1: g_pVSSClient = new VSSClientXP(); atexit(VSSCleanup); - break; + return; case 2: g_pVSSClient = new VSSClient2003(); atexit(VSSCleanup); - break; + return; + } + /* Vista or Longhorn */ + } else if (g_MajorVersion == 6 && g_MinorVersion == 0) { + /* Probably will not work */ + g_pVSSClient = new VSSClientVista(); + atexit(VSSCleanup); + return; } } diff --git a/bacula/src/win32/filed/vss.h b/bacula/src/win32/filed/vss.h index 4540758004..4e7c57a3df 100644 --- a/bacula/src/win32/filed/vss.h +++ b/bacula/src/win32/filed/vss.h @@ -1,18 +1,7 @@ -/* -*- Mode: C -*- - * vss.h -- - */ -// -// Copyright transferred from MATRIX-Computer GmbH to -// Kern Sibbald by express permission. -/* - * - * Author : Thorsten Engel - * Created On : Fri May 06 21:44:00 2006 - */ /* Bacula® - The Network Backup Solution - Copyright (C) 2006-2006 Free Software Foundation Europe e.V. + Copyright (C) 2006-2007 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. @@ -36,6 +25,17 @@ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, Switzerland, email:ftf@fsfeurope.org. */ +/* -*- Mode: C -*- + * vss.h -- + */ +// +// Copyright transferred from MATRIX-Computer GmbH to +// Kern Sibbald by express permission. +/* + * + * Author : Thorsten Engel + * Created On : Fri May 06 21:44:00 2006 + */ #ifndef __VSS_H_ #define __VSS_H_ @@ -126,6 +126,22 @@ private: BOOL CheckWriterStatus(); }; +class VSSClientVista:public VSSClient +{ +public: + VSSClientVista(); + virtual ~VSSClientVista(); + virtual BOOL CreateSnapshots(char* szDriveLetters); + virtual BOOL CloseBackup(); + virtual const char* GetDriverName() { return "VSS Vista"; }; +private: + virtual BOOL Initialize(DWORD dwContext, BOOL bDuringRestore); + virtual BOOL WaitAndCheckForAsyncOperation(IVssAsync* pAsync); + virtual void QuerySnapshotSet(GUID snapshotSetID); + BOOL CheckWriterStatus(); +}; + + extern VSSClient *g_pVSSClient; #endif /* WIN32_VSS */ diff --git a/bacula/src/win32/filed/vss_W2K3.cpp b/bacula/src/win32/filed/vss_W2K3.cpp index 68914d0f9c..1c397dada7 100644 --- a/bacula/src/win32/filed/vss_W2K3.cpp +++ b/bacula/src/win32/filed/vss_W2K3.cpp @@ -1,10 +1,10 @@ /* -we need one class per OS as Microsofts API -differs only by calling convention and some -function we don't use. - -vss_generic will handle all versions and -switch between different headers to include. + * We need one class per OS as Microsofts API + * differs only by calling convention and some + * function we don't use. + * + * vss_generic will handle all versions and + * switch between different headers to include. */ #ifdef WIN32_VSS diff --git a/bacula/src/win32/filed/vss_generic.cpp b/bacula/src/win32/filed/vss_generic.cpp index 2521fafe6d..3f4e8b4238 100644 --- a/bacula/src/win32/filed/vss_generic.cpp +++ b/bacula/src/win32/filed/vss_generic.cpp @@ -1,15 +1,7 @@ -// -*- Mode: C++ -*- -// vss.cpp -- Interface to Volume Shadow Copies (VSS) -// -// Copyright transferred from MATRIX-Computer GmbH to -// Kern Sibbald by express permission. -// -// Author : Thorsten Engel -// Created On : Fri May 06 21:44:00 2005 /* Bacula® - The Network Backup Solution - Copyright (C) 2005-2006 Free Software Foundation Europe e.V. + Copyright (C) 2005-2007 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. @@ -33,6 +25,14 @@ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, Switzerland, email:ftf@fsfeurope.org. */ +// -*- Mode: C++ -*- +// vss.cpp -- Interface to Volume Shadow Copies (VSS) +// +// Copyright transferred from MATRIX-Computer GmbH to +// Kern Sibbald by express permission. +// +// Author : Thorsten Engel +// Created On : Fri May 06 21:44:00 2005 #ifdef WIN32_VSS @@ -52,6 +52,18 @@ using namespace std; #include "ms_atl.h" #include +/* + * Kludges to get Vista code to compile. + * KES - June 2007 + */ +#define __in IN +#define __out OUT +#define __RPC_unique_pointer +#define __RPC_string +#define __RPC__out_ecount_part(x, y) +#define __RPC__deref_inout_opt +#define __RPC__out + #if !defined(ENABLE_NLS) #define setlocale(p, d) #endif @@ -68,6 +80,9 @@ BOOL VSSPathConvertW(const wchar_t *szFilePath, wchar_t *szShadowPath, int nBufl class IXMLDOMDocument; #endif +/* Reduce compiler warnings from Windows vss code */ +#define uuid(x) + #ifdef B_VSS_XP #pragma message("compile VSS for Windows XP") #define VSSClientGeneric VSSClientXP @@ -75,15 +90,7 @@ class IXMLDOMDocument; #include "inc/WinXP/vss.h" #include "inc/WinXP/vswriter.h" #include "inc/WinXP/vsbackup.h" - - /* In VSSAPI.DLL */ - typedef HRESULT (STDAPICALLTYPE* t_CreateVssBackupComponents)(OUT IVssBackupComponents **); - typedef void (APIENTRY* t_VssFreeSnapshotProperties)(IN VSS_SNAPSHOT_PROP*); - - static t_CreateVssBackupComponents p_CreateVssBackupComponents = NULL; - static t_VssFreeSnapshotProperties p_VssFreeSnapshotProperties = NULL; - #define VSSVBACK_ENTRY "?CreateVssBackupComponents@@YGJPAPAVIVssBackupComponents@@@Z" #endif #ifdef B_VSS_W2K3 @@ -93,6 +100,16 @@ class IXMLDOMDocument; #include "inc/Win2003/vss.h" #include "inc/Win2003/vswriter.h" #include "inc/Win2003/vsbackup.h" +#endif + +#ifdef B_VSS_VISTA + #pragma message("compile VSS for Vista") + #define VSSClientGeneric VSSClientVista + + #include "inc/Win2003/vss.h" + #include "inc/Win2003/vswriter.h" + #include "inc/Win2003/vsbackup.h" +#endif /* In VSSAPI.DLL */ typedef HRESULT (STDAPICALLTYPE* t_CreateVssBackupComponents)(OUT IVssBackupComponents **); @@ -102,7 +119,7 @@ class IXMLDOMDocument; static t_VssFreeSnapshotProperties p_VssFreeSnapshotProperties = NULL; #define VSSVBACK_ENTRY "?CreateVssBackupComponents@@YGJPAPAVIVssBackupComponents@@@Z" -#endif + #include "vss.h" @@ -266,7 +283,7 @@ BOOL VSSClientGeneric::Initialize(DWORD dwContext, BOOL bDuringRestore) return FALSE; } -#ifdef B_VSS_W2K3 +#if defined(B_VSS_W2K3) || defined(B_VSS_VISTA) if (dwContext != VSS_CTX_BACKUP) { hr = ((IVssBackupComponents*) m_pVssObject)->SetContext(dwContext); if (FAILED(hr)) { @@ -614,7 +631,7 @@ BOOL VSSClientGeneric::CheckWriterStatus() case VSS_WS_FAILED_AT_BACKUP_COMPLETE: case VSS_WS_FAILED_AT_PRE_RESTORE: case VSS_WS_FAILED_AT_POST_RESTORE: - #ifdef B_VSS_W2K3 + #if defined(B_VSS_W2K3) || defined(B_VSS_VISTA) case VSS_WS_FAILED_AT_BACKUPSHUTDOWN: #endif /* failed */ diff --git a/bacula/src/win32/winapi.h b/bacula/src/win32/winapi.h index 6098904a78..72039378c6 100644 --- a/bacula/src/win32/winapi.h +++ b/bacula/src/win32/winapi.h @@ -73,6 +73,7 @@ int make_win32_path_UTF8_2_wchar(POOLMEM **pszUCS, const char *pszUTF, BOOL* pBI // init with win9x, but maybe set to NT in InitWinAPI extern DWORD DLL_IMP_EXP g_platform_id; extern DWORD DLL_IMP_EXP g_MinorVersion; +extern DWORD DLL_IMP_EXP g_MajorVersion; /* In ADVAPI32.DLL */ typedef BOOL (WINAPI * t_OpenProcessToken)(HANDLE, DWORD, PHANDLE); diff --git a/bacula/technotes-2.1 b/bacula/technotes-2.1 index a21830100d..d47a1ada9e 100644 --- a/bacula/technotes-2.1 +++ b/bacula/technotes-2.1 @@ -1,6 +1,12 @@ Technical notes on version 2.1 General: +21Jun07 +kes Don't print clock skew message in FD if less than 3 seconds diff. +kes Add a bit of VSS info to status client. +kes Make a gross first cut of Vista VSS, using Win2003 code. + +Release: 2.1.18 beta 20Jun07 kes Fixed bug #886 (multidrive autochanger: SD doesn't use drive with loaded tape but uses first drive). -- 2.39.5