]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/win32/filed/vss.h
Update Win32 build to include new files, new symbols, and
[bacula/bacula] / bacula / src / win32 / filed / 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  *
9  * Author          : Thorsten Engel
10  * Created On      : Fri May 06 21:44:00 2006 
11  */
12 /*
13    Bacula® - The Network Backup Solution
14
15    Copyright (C) 2006-2006 Free Software Foundation Europe e.V.
16
17    The main author of Bacula is Kern Sibbald, with contributions from
18    many others, a complete list can be found in the file AUTHORS.
19    This program is Free Software; you can redistribute it and/or
20    modify it under the terms of version two of the GNU General Public
21    License as published by the Free Software Foundation plus additions
22    that are listed in the file LICENSE.
23
24    This program is distributed in the hope that it will be useful, but
25    WITHOUT ANY WARRANTY; without even the implied warranty of
26    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27    General Public License for more details.
28
29    You should have received a copy of the GNU General Public License
30    along with this program; if not, write to the Free Software
31    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
32    02110-1301, USA.
33
34    Bacula® is a registered trademark of John Walker.
35    The licensor of Bacula is the Free Software Foundation Europe
36    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
37    Switzerland, email:ftf@fsfeurope.org.
38 */
39
40 #ifndef __VSS_H_
41 #define __VSS_H_
42
43 #ifndef b_errno_win32
44 #define b_errno_win32 (1<<29)
45 #endif
46  
47 #ifdef WIN32_VSS
48
49 // some forward declarations
50 struct IVssAsync;
51
52 class VSSClient
53 {
54 public:
55     VSSClient();
56     virtual ~VSSClient();
57
58     // Backup Process
59     BOOL InitializeForBackup();
60     virtual BOOL CreateSnapshots(char* szDriveLetters) = 0;
61     virtual BOOL CloseBackup() = 0;
62     virtual const char* GetDriverName() = 0;
63     BOOL GetShadowPath  (const char* szFilePath, char* szShadowPath, int nBuflen);
64     BOOL GetShadowPathW (const wchar_t* szFilePath, wchar_t* szShadowPath, int nBuflen); /* nBuflen in characters */
65
66     const size_t GetWriterCount();
67     const char* GetWriterInfo(int nIndex);
68     const int   GetWriterState(int nIndex);
69     void DestroyWriterInfo();
70     void AppendWriterInfo(int nState, const char* pszInfo);
71     const BOOL  IsInitialized() { return m_bBackupIsInitialized; };
72          
73 private:
74     virtual BOOL Initialize(DWORD dwContext, BOOL bDuringRestore = FALSE) = 0;
75     virtual BOOL WaitAndCheckForAsyncOperation(IVssAsync*  pAsync) = 0;
76     virtual void QuerySnapshotSet(GUID snapshotSetID) = 0;
77
78 protected:
79     HMODULE                         m_hLib;
80
81     BOOL                            m_bCoInitializeCalled;
82     BOOL                            m_bCoInitializeSecurityCalled;
83     DWORD                           m_dwContext;
84
85     IUnknown*                       m_pVssObject;
86     GUID                            m_uidCurrentSnapshotSet;
87     // TRUE if we are during restore
88     BOOL                            m_bDuringRestore;
89     BOOL                            m_bBackupIsInitialized;
90
91     // drive A will be stored on position 0,Z on pos. 25
92     wchar_t                           m_wszUniqueVolumeName[26][MAX_PATH]; // approx. 7 KB
93     wchar_t                           m_szShadowCopyName[26][MAX_PATH]; // approx. 7 KB
94     
95     void*                           m_pAlistWriterState;
96     void*                           m_pAlistWriterInfoText;
97 };
98
99 class VSSClientXP:public VSSClient
100 {
101 public:
102    VSSClientXP();
103    virtual ~VSSClientXP();
104    virtual BOOL CreateSnapshots(char* szDriveLetters);
105    virtual BOOL CloseBackup();
106    virtual const char* GetDriverName() { return "VSS WinXP"; };
107 private:
108    virtual BOOL Initialize(DWORD dwContext, BOOL bDuringRestore);
109    virtual BOOL WaitAndCheckForAsyncOperation(IVssAsync* pAsync);
110    virtual void QuerySnapshotSet(GUID snapshotSetID);
111    BOOL CheckWriterStatus();   
112 };
113
114 class VSSClient2003:public VSSClient
115 {
116 public:
117    VSSClient2003();
118    virtual ~VSSClient2003();
119    virtual BOOL CreateSnapshots(char* szDriveLetters);
120    virtual BOOL CloseBackup();   
121    virtual const char* GetDriverName() { return "VSS Win 2003"; };
122 private:
123    virtual BOOL Initialize(DWORD dwContext, BOOL bDuringRestore);
124    virtual BOOL WaitAndCheckForAsyncOperation(IVssAsync*  pAsync);
125    virtual void QuerySnapshotSet(GUID snapshotSetID);
126    BOOL CheckWriterStatus();
127 };
128
129 extern VSSClient *g_pVSSClient;
130
131 #endif /* WIN32_VSS */
132
133 #endif /* __VSS_H_ */