]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/win32/compat/vss.h
f3726ada87712af27fea26794b6f98b04fe4cb89
[bacula/bacula] / bacula / src / win32 / compat / vss.h
1 /*                               -*- Mode: C -*-
2  * vss.h --
3  */
4 //
5 // Copyright transferred from MATRIX-Computer GmbH to
6 //   Kern Sibbald by express permission.
7 //
8 //  Copyright (C) 2005 Kern Sibbald
9 //
10 //  This program is free software; you can redistribute it and/or
11 //  modify it under the terms of the GNU General Public License
12 //  version 2 as amended with additional clauses defined in the
13 //  file LICENSE in the main source directory.
14 //
15 //  This program is distributed in the hope that it will be useful,
16 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
17 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
18 //  the file LICENSE for additional details.
19 //
20
21 /*
22  *
23  * Author          : Thorsten Engel
24  * Created On      : Fri May 06 21:44:00 2006 
25  */
26
27 #ifndef __VSS_H_
28 #define __VSS_H_
29
30 #ifndef b_errno_win32
31 #define b_errno_win32 (1<<29)
32 #endif
33  
34 #ifdef WIN32_VSS
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     const BOOL  IsInitialized() { return m_bBackupIsInitialized; };
56          
57 private:
58     virtual BOOL Initialize(DWORD dwContext, BOOL bDuringRestore = FALSE) = 0;
59     virtual void WaitAndCheckForAsyncOperation(IVssAsync*  pAsync) = 0;
60     virtual void QuerySnapshotSet(GUID snapshotSetID) = 0;
61
62 protected:
63     HMODULE                         m_hLib;
64
65     BOOL                            m_bCoInitializeCalled;
66     DWORD                           m_dwContext;
67
68     IUnknown*                       m_pVssObject;
69     GUID                            m_uidCurrentSnapshotSet;
70     // TRUE if we are during restore
71     BOOL                            m_bDuringRestore;
72     BOOL                            m_bBackupIsInitialized;
73
74     // drive A will be stored on position 0,Z on pos. 25
75     WCHAR                           m_wszUniqueVolumeName[26][MAX_PATH]; // approx. 7 KB
76     char /* in utf-8 */             m_szShadowCopyName[26][MAX_PATH*2]; // approx. 7 KB
77
78     void*                           m_pVectorWriterStates;
79     void*                           m_pVectorWriterInfo;
80 };
81
82 class VSSClientXP:public VSSClient
83 {
84 public:
85    VSSClientXP();
86    virtual ~VSSClientXP();
87    virtual BOOL CreateSnapshots(char* szDriveLetters);
88    virtual BOOL CloseBackup();
89    virtual const char* GetDriverName() { return "VSS WinXP"; };
90 private:
91    virtual BOOL Initialize(DWORD dwContext, BOOL bDuringRestore);
92    virtual void WaitAndCheckForAsyncOperation(IVssAsync* pAsync);
93    virtual void QuerySnapshotSet(GUID snapshotSetID);
94    BOOL CheckWriterStatus();   
95 };
96
97 class VSSClient2003:public VSSClient
98 {
99 public:
100    VSSClient2003();
101    virtual ~VSSClient2003();
102    virtual BOOL CreateSnapshots(char* szDriveLetters);
103    virtual BOOL CloseBackup();   
104    virtual const char* GetDriverName() { return "VSS Win 2003"; };
105 private:
106    virtual BOOL Initialize(DWORD dwContext, BOOL bDuringRestore);
107    virtual void WaitAndCheckForAsyncOperation(IVssAsync*  pAsync);
108    virtual void QuerySnapshotSet(GUID snapshotSetID);
109    BOOL CheckWriterStatus();
110 };
111
112 #endif /* WIN32_VSS */
113
114 #endif /* __VSS_H_ */