]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/win32/compat/vss.h
small vss improvement (more complete shutdown and startup after each backup instead...
[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     BOOL                            m_bCoInitializeSecurityCalled;
67     DWORD                           m_dwContext;
68
69     IUnknown*                       m_pVssObject;
70     GUID                            m_uidCurrentSnapshotSet;
71     // TRUE if we are during restore
72     BOOL                            m_bDuringRestore;
73     BOOL                            m_bBackupIsInitialized;
74
75     // drive A will be stored on position 0,Z on pos. 25
76     WCHAR                           m_wszUniqueVolumeName[26][MAX_PATH]; // approx. 7 KB
77     char /* in utf-8 */             m_szShadowCopyName[26][MAX_PATH*2]; // approx. 7 KB
78
79     void*                           m_pVectorWriterStates;
80     void*                           m_pVectorWriterInfo;
81 };
82
83 class VSSClientXP:public VSSClient
84 {
85 public:
86    VSSClientXP();
87    virtual ~VSSClientXP();
88    virtual BOOL CreateSnapshots(char* szDriveLetters);
89    virtual BOOL CloseBackup();
90    virtual const char* GetDriverName() { return "VSS WinXP"; };
91 private:
92    virtual BOOL Initialize(DWORD dwContext, BOOL bDuringRestore);
93    virtual void WaitAndCheckForAsyncOperation(IVssAsync* pAsync);
94    virtual void QuerySnapshotSet(GUID snapshotSetID);
95    BOOL CheckWriterStatus();   
96 };
97
98 class VSSClient2003:public VSSClient
99 {
100 public:
101    VSSClient2003();
102    virtual ~VSSClient2003();
103    virtual BOOL CreateSnapshots(char* szDriveLetters);
104    virtual BOOL CloseBackup();   
105    virtual const char* GetDriverName() { return "VSS Win 2003"; };
106 private:
107    virtual BOOL Initialize(DWORD dwContext, BOOL bDuringRestore);
108    virtual void WaitAndCheckForAsyncOperation(IVssAsync*  pAsync);
109    virtual void QuerySnapshotSet(GUID snapshotSetID);
110    BOOL CheckWriterStatus();
111 };
112
113 #endif /* WIN32_VSS */
114
115 #endif /* __VSS_H_ */