]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/win32/filed/vss.h
Update .cvsignore files
[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 //  Copyright (C) 2005-2006 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     virtual ~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     BOOL GetShadowPathW (const wchar_t* szFilePath, wchar_t* szShadowPath, int nBuflen); /* nBuflen in characters */
52
53     const size_t GetWriterCount();
54     const char* GetWriterInfo(int nIndex);
55     const int   GetWriterState(int nIndex);
56     void DestroyWriterInfo();
57     void AppendWriterInfo(int nState, const char* pszInfo);
58     const BOOL  IsInitialized() { return m_bBackupIsInitialized; };
59          
60 private:
61     virtual BOOL Initialize(DWORD dwContext, BOOL bDuringRestore = FALSE) = 0;
62     virtual BOOL WaitAndCheckForAsyncOperation(IVssAsync*  pAsync) = 0;
63     virtual void QuerySnapshotSet(GUID snapshotSetID) = 0;
64
65 protected:
66     HMODULE                         m_hLib;
67
68     BOOL                            m_bCoInitializeCalled;
69     BOOL                            m_bCoInitializeSecurityCalled;
70     DWORD                           m_dwContext;
71
72     IUnknown*                       m_pVssObject;
73     GUID                            m_uidCurrentSnapshotSet;
74     // TRUE if we are during restore
75     BOOL                            m_bDuringRestore;
76     BOOL                            m_bBackupIsInitialized;
77
78     // drive A will be stored on position 0,Z on pos. 25
79     wchar_t                           m_wszUniqueVolumeName[26][MAX_PATH]; // approx. 7 KB
80     wchar_t                           m_szShadowCopyName[26][MAX_PATH]; // approx. 7 KB
81     
82     void*                           m_pAlistWriterState;
83     void*                           m_pAlistWriterInfoText;
84 };
85
86 class VSSClientXP:public VSSClient
87 {
88 public:
89    VSSClientXP();
90    virtual ~VSSClientXP();
91    virtual BOOL CreateSnapshots(char* szDriveLetters);
92    virtual BOOL CloseBackup();
93    virtual const char* GetDriverName() { return "VSS WinXP"; };
94 private:
95    virtual BOOL Initialize(DWORD dwContext, BOOL bDuringRestore);
96    virtual BOOL WaitAndCheckForAsyncOperation(IVssAsync* pAsync);
97    virtual void QuerySnapshotSet(GUID snapshotSetID);
98    BOOL CheckWriterStatus();   
99 };
100
101 class VSSClient2003:public VSSClient
102 {
103 public:
104    VSSClient2003();
105    virtual ~VSSClient2003();
106    virtual BOOL CreateSnapshots(char* szDriveLetters);
107    virtual BOOL CloseBackup();   
108    virtual const char* GetDriverName() { return "VSS Win 2003"; };
109 private:
110    virtual BOOL Initialize(DWORD dwContext, BOOL bDuringRestore);
111    virtual BOOL WaitAndCheckForAsyncOperation(IVssAsync*  pAsync);
112    virtual void QuerySnapshotSet(GUID snapshotSetID);
113    BOOL CheckWriterStatus();
114 };
115
116 extern VSSClient *g_pVSSClient;
117
118 #endif /* WIN32_VSS */
119
120 #endif /* __VSS_H_ */