]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/win32/filed/vss.h
Attempt to disactivate old exchange-fd.dll if no plugin= line in FileSet
[bacula/bacula] / bacula / src / win32 / filed / vss.h
1 /*
2    Bacula® - The Network Backup Solution
3
4    Copyright (C) 2006-2010 Free Software Foundation Europe e.V.
5
6    The main author of Bacula is Kern Sibbald, with contributions from
7    many others, a complete list can be found in the file AUTHORS.
8    This program is Free Software; you can redistribute it and/or
9    modify it under the terms of version three of the GNU Affero General Public
10    License as published by the Free Software Foundation and included
11    in the file LICENSE.
12
13    This program is distributed in the hope that it will be useful, but
14    WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16    General Public License for more details.
17
18    You should have received a copy of the GNU Affero General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21    02110-1301, USA.
22
23    Bacula® is a registered trademark of Kern Sibbald.
24    The licensor of Bacula is the Free Software Foundation Europe
25    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
26    Switzerland, email:ftf@fsfeurope.org.
27 */
28 /*                               -*- Mode: C -*-
29  * vss.h --
30  */
31 //
32 // Copyright transferred from MATRIX-Computer GmbH to
33 //   Kern Sibbald by express permission.
34 /*
35  *
36  * Author          : Thorsten Engel
37  * Created On      : Fri May 06 21:44:00 2006 
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 #define VSS_INIT_RESTORE_AFTER_INIT   1
50 #define VSS_INIT_RESTORE_AFTER_GATHER 2
51
52 // some forward declarations
53 struct IVssAsync;
54
55 class VSSClient
56 {
57 public:
58     VSSClient();
59     virtual ~VSSClient();
60
61     // Backup Process
62     bool InitializeForBackup(JCR *jcr);
63     bool InitializeForRestore(JCR *jcr, bool (*VssInitCallback)(JCR *, int) = NULL, WCHAR *job_metadata = NULL);
64     virtual bool CreateSnapshots(char* szDriveLetters) = 0;
65     virtual bool CloseBackup() = 0;
66     virtual bool CloseRestore() = 0;
67     virtual WCHAR *GetMetadata() = 0;
68     virtual const char* GetDriverName() = 0;
69     bool GetShadowPath  (const char* szFilePath, char* szShadowPath, int nBuflen);
70     bool GetShadowPathW (const wchar_t* szFilePath, wchar_t* szShadowPath, int nBuflen); /* nBuflen in characters */
71
72     const size_t GetWriterCount();
73     const char* GetWriterInfo(int nIndex);
74     const int   GetWriterState(int nIndex);
75     void DestroyWriterInfo();
76     void AppendWriterInfo(int nState, const char* pszInfo);
77     const bool  IsInitialized() { return m_bBackupIsInitialized; };
78     HMODULE GetVssDllHandle() { return m_hLib; };
79     IUnknown *GetVssObject() { return m_pVssObject; };
80          
81 private:
82     virtual bool Initialize(DWORD dwContext, bool bDuringRestore = FALSE, bool (*VssInitCallback)(JCR *, int) = NULL) = 0;
83     virtual bool WaitAndCheckForAsyncOperation(IVssAsync*  pAsync) = 0;
84     virtual void QuerySnapshotSet(GUID snapshotSetID) = 0;
85
86 protected:
87     HMODULE    m_hLib;
88     JCR       *m_jcr;
89
90     DWORD      m_dwContext;
91
92     IUnknown*  m_pVssObject;
93     GUID       m_uidCurrentSnapshotSet;
94
95     // drive A will be stored on position 0,Z on pos. 25
96     wchar_t    m_wszUniqueVolumeName[26][MAX_PATH]; // approx. 7 KB
97     wchar_t    m_szShadowCopyName[26][MAX_PATH]; // approx. 7 KB
98     
99     alist     *m_pAlistWriterState;
100     alist     *m_pAlistWriterInfoText;
101
102     bool       m_bCoInitializeCalled;
103     bool       m_bCoInitializeSecurityCalled;
104     bool       m_bDuringRestore;  /* true if we are doing a restore */
105     bool       m_bBackupIsInitialized;
106
107     WCHAR     *m_metadata;
108 };
109
110 class VSSClientXP:public VSSClient
111 {
112 public:
113    VSSClientXP();
114    virtual ~VSSClientXP();
115    virtual bool CreateSnapshots(char* szDriveLetters);
116    virtual bool CloseBackup();
117    virtual bool CloseRestore();
118    virtual WCHAR *GetMetadata();
119    virtual const char* GetDriverName() { return "VSS WinXP"; };
120 private:
121    virtual bool Initialize(DWORD dwContext, bool bDuringRestore, bool (*VssInitCallback)(JCR *, int) = NULL);
122    virtual bool WaitAndCheckForAsyncOperation(IVssAsync* pAsync);
123    virtual void QuerySnapshotSet(GUID snapshotSetID);
124    bool CheckWriterStatus();   
125 };
126
127 class VSSClient2003:public VSSClient
128 {
129 public:
130    VSSClient2003();
131    virtual ~VSSClient2003();
132    virtual bool CreateSnapshots(char* szDriveLetters);
133    virtual bool CloseBackup();   
134    virtual bool CloseRestore();
135    virtual WCHAR *GetMetadata();
136    virtual const char* GetDriverName() { return "VSS Win 2003"; };
137 private:
138    virtual bool Initialize(DWORD dwContext, bool bDuringRestore, bool (*VssInitCallback)(JCR *, int) = NULL);
139    virtual bool WaitAndCheckForAsyncOperation(IVssAsync*  pAsync);
140    virtual void QuerySnapshotSet(GUID snapshotSetID);
141    bool CheckWriterStatus();
142 };
143
144 class VSSClientVista:public VSSClient
145 {
146 public:
147    VSSClientVista();
148    virtual ~VSSClientVista();
149    virtual bool CreateSnapshots(char* szDriveLetters);
150    virtual bool CloseBackup();   
151    virtual bool CloseRestore();
152    virtual WCHAR *GetMetadata();
153    virtual const char* GetDriverName() { return "VSS Vista"; };
154 private:
155    virtual bool Initialize(DWORD dwContext, bool bDuringRestore, bool (*VssInitCallback)(JCR *, int) = NULL);
156    virtual bool WaitAndCheckForAsyncOperation(IVssAsync*  pAsync);
157    virtual void QuerySnapshotSet(GUID snapshotSetID);
158    bool CheckWriterStatus();
159 };
160
161
162 extern VSSClient *g_pVSSClient;
163
164 BOOL VSSPathConvert(const char *szFilePath, char *szShadowPath, int nBuflen);
165 BOOL VSSPathConvertW(const wchar_t *szFilePath, wchar_t *szShadowPath, int nBuflen);
166
167 #endif /* WIN32_VSS */
168
169 #endif /* __VSS_H_ */