]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/win32/compat/vss.h
added VSS toggling by enable_vss
[bacula/bacula] / bacula / src / win32 / compat / vss.h
1 /*                               -*- Mode: C -*-
2  * vss.h --
3  */
4
5 //
6 // Copyright transferred from MATRIX-Computer GmbH to
7 //   Kern Sibbald by express permission.
8 //
9 // Copyright (C) 2004-2005 Kern Sibbald
10 //
11 //   This program is free software; you can redistribute it and/or
12 //   modify it under the terms of the GNU General Public License as
13 //   published by the Free Software Foundation; either version 2 of
14 //   the License, or (at your option) any later version.
15 //
16 //   This program is distributed in the hope that it will be useful,
17 //   but WITHOUT ANY WARRANTY; without even the implied warranty of
18 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 //   General Public License for more details.
20 //
21 //   You should have received a copy of the GNU General Public
22 //   License along with this program; if not, write to the Free
23 //   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
24 //   MA 02111-1307, USA.
25 //
26
27 /*
28  *
29  * Author          : Thorsten Engel
30  * Created On      : Fri May 06 21:44:00 2006 
31  */
32
33 #ifndef __VSS_H_
34 #define __VSS_H_
35
36 // some forward declarations
37 struct IVssAsync;
38
39 class VSSClient
40 {
41 public:
42     VSSClient();
43     ~VSSClient();
44
45     // Backup Process
46     BOOL InitializeForBackup();
47     virtual BOOL CreateSnapshots(char* szDriveLetters) = 0;
48     virtual BOOL CloseBackup() = 0;
49     virtual const char* GetDriverName() = 0;
50     BOOL GetShadowPath (const char* szFilePath, char* szShadowPath, int nBuflen);
51
52     const size_t GetWriterCount();
53     const char* GetWriterInfo(size_t nIndex);
54     const int   GetWriterState(size_t nIndex);
55          
56 private:
57     virtual BOOL Initialize(DWORD dwContext, BOOL bDuringRestore = FALSE) = 0;
58     virtual void WaitAndCheckForAsyncOperation(IVssAsync*  pAsync) = 0;
59     virtual void QuerySnapshotSet(GUID snapshotSetID) = 0;
60
61 protected:
62     HMODULE                         m_hLib;
63
64     BOOL                            m_bCoInitializeCalled;
65     DWORD                           m_dwContext;
66
67     IUnknown*                       m_pVssObject;
68     GUID                            m_uidCurrentSnapshotSet;
69     // TRUE if we are during restore
70     BOOL                            m_bDuringRestore;
71     BOOL                            m_bBackupIsInitialized;
72
73     // drive A will be stored on position 0,Z on pos. 25
74     WCHAR                           m_wszUniqueVolumeName[26][MAX_PATH]; // approx. 7 KB
75     char /* in utf-8 */             m_szShadowCopyName[26][MAX_PATH*2]; // approx. 7 KB
76
77     void*                           m_pVectorWriterStates;
78     void*                           m_pVectorWriterInfo;
79 };
80
81 class VSSClientXP:public VSSClient
82 {
83 public:
84    VSSClientXP();
85    virtual ~VSSClientXP();
86    virtual BOOL CreateSnapshots(char* szDriveLetters);
87    virtual BOOL CloseBackup();
88    virtual const char* GetDriverName() { return "VSS WinXP"; };
89 private:
90    virtual BOOL Initialize(DWORD dwContext, BOOL bDuringRestore);
91    virtual void WaitAndCheckForAsyncOperation(IVssAsync* pAsync);
92    virtual void QuerySnapshotSet(GUID snapshotSetID);
93    BOOL CheckWriterStatus();   
94 };
95
96 class VSSClient2003:public VSSClient
97 {
98 public:
99    VSSClient2003();
100    virtual ~VSSClient2003();
101    virtual BOOL CreateSnapshots(char* szDriveLetters);
102    virtual BOOL CloseBackup();   
103    virtual const char* GetDriverName() { return "VSS Win 2003"; };
104 private:
105    virtual BOOL Initialize(DWORD dwContext, BOOL bDuringRestore);
106    virtual void WaitAndCheckForAsyncOperation(IVssAsync*  pAsync);
107    virtual void QuerySnapshotSet(GUID snapshotSetID);
108    BOOL CheckWriterStatus();
109 };
110
111
112 #endif /* __VSS_H_ */