]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/win32/compat/vss.cpp
small vss improvement (more complete shutdown and startup after each backup instead...
[bacula/bacula] / bacula / src / win32 / compat / vss.cpp
index 4dfd5351761da77dfb53721edac58aefe4c24a9e..8234aad31794e88bcfc6bf0bcc77eef2c17dc3f5 100644 (file)
@@ -1,26 +1,22 @@
-//                              -*- Mode: C++ -*-
+
 // vss.cpp -- Interface to Volume Shadow Copies (VSS)
 //
 // Copyright transferred from MATRIX-Computer GmbH to
 //   Kern Sibbald by express permission.
 //
-// Copyright (C) 2005 Kern Sibbald
-//
-//   This program is free software; you can redistribute it and/or
-//   modify it under the terms of the GNU General Public License as
-//   published by the Free Software Foundation; either version 2 of
-//   the License, or (at your option) any later version.
+//  Copyright (C) 2005 Kern Sibbald
 //
-//   This program is distributed in the hope that it will be useful,
-//   but WITHOUT ANY WARRANTY; without even the implied warranty of
-//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-//   General Public License for more details.
+//  This program is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU General Public License
+//  version 2 as amended with additional clauses defined in the
+//  file LICENSE in the main source directory.
 //
-//   You should have received a copy of the GNU General Public
-//   License along with this program; if not, write to the Free
-//   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-//   MA 02111-1307, USA.
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
+//  the file LICENSE for additional details.
 //
+//  
 // Author          : Thorsten Engel
 // Created On      : Fri May 06 21:44:00 2005
 
@@ -76,6 +72,7 @@ using namespace std;
 VSSClient::VSSClient()
 {
     m_bCoInitializeCalled = false;
+    m_bCoInitializeSecurityCalled = false;
     m_dwContext = 0; // VSS_CTX_BACKUP;
     m_bDuringRestore = false;
     m_bBackupIsInitialized = false;
@@ -83,8 +80,8 @@ VSSClient::VSSClient()
     m_pVectorWriterStates = new vector<int>;
     m_pVectorWriterInfo = new vector<string>;
     m_uidCurrentSnapshotSet = GUID_NULL;
-    memset (m_wszUniqueVolumeName,0,sizeof (m_wszUniqueVolumeName));
-    memset (m_szShadowCopyName,0,sizeof (m_szShadowCopyName));
+    memset(m_wszUniqueVolumeName,0, sizeof(m_wszUniqueVolumeName));
+    memset(m_szShadowCopyName,0, sizeof(m_szShadowCopyName));
 }
 
 // Destructor
@@ -111,13 +108,13 @@ VSSClient::~VSSClient()
 BOOL VSSClient::InitializeForBackup()
 {
     //return Initialize (VSS_CTX_BACKUP);
-   return Initialize (0);
+   return Initialize(0);
 }
 
 
 
 
-BOOL VSSClient::GetShadowPath (const char* szFilePath, char* szShadowPath, int nBuflen)
+BOOL VSSClient::GetShadowPath(const char *szFilePath, char *szShadowPath, int nBuflen)
 {
    if (!m_bBackupIsInitialized)
       return FALSE;
@@ -125,24 +122,24 @@ BOOL VSSClient::GetShadowPath (const char* szFilePath, char* szShadowPath, int n
    /* check for valid pathname */
    BOOL bIsValidName;
    
-   bIsValidName = strlen (szFilePath) > 3;
+   bIsValidName = strlen(szFilePath) > 3;
    if (bIsValidName)
       bIsValidName &= isalpha (szFilePath[0]) &&
                       szFilePath[1]==':' && 
-                      szFilePath[2]=='\\';
+                      szFilePath[2] == '\\';
 
    if (bIsValidName) {
       int nDriveIndex = toupper(szFilePath[0])-'A';
       if (m_szShadowCopyName[nDriveIndex][0] != 0) {
-         strncpy (szShadowPath, m_szShadowCopyName[nDriveIndex], nBuflen);
-         nBuflen -= (int) strlen (m_szShadowCopyName[nDriveIndex]);
-         strncat (szShadowPath, szFilePath+2,nBuflen);
-
+         strncpy(szShadowPath, m_szShadowCopyName[nDriveIndex], nBuflen);
+         nBuflen -= (int)strlen(m_szShadowCopyName[nDriveIndex]);
+         strncat(szShadowPath, szFilePath+2, nBuflen);
          return TRUE;
       }
    }
    
-   strncpy (szShadowPath,  szFilePath, nBuflen);
+   strncpy(szShadowPath,  szFilePath, nBuflen);
+   errno = EINVAL;
    return FALSE;   
 }