From: Kern S. <ke...@us...> - 2010-02-26 12:39:48
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Bacula". The branch, master has been updated via 54ebeb759b94f301baec6e9165c2e9aebf09d235 (commit) via 989cd3649dabec4aadfdb9a2d833ea30ceffc0af (commit) from 6eabdfd11fcf0b560b7d2909bf576ff1d10b20f6 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 54ebeb759b94f301baec6e9165c2e9aebf09d235 Author: Kern Sibbald <ke...@si...> Date: Fri Feb 26 13:39:26 2010 +0100 Pass jcr to VSS class + minor clean up of VSS code commit 989cd3649dabec4aadfdb9a2d833ea30ceffc0af Author: Kern Sibbald <ke...@si...> Date: Fri Feb 26 11:59:00 2010 +0100 Tweak comments ----------------------------------------------------------------------- Summary of changes: diff --git a/bacula/src/filed/backup.c b/bacula/src/filed/backup.c index d9753d0..c033342 100644 --- a/bacula/src/filed/backup.c +++ b/bacula/src/filed/backup.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2000-2009 Free Software Foundation Europe e.V. + Copyright (C) 2000-2010 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -31,8 +31,6 @@ * * Kern Sibbald, March MM * - * Version $Id$ - * */ #include "bacula.h" @@ -64,7 +62,7 @@ static bool crypto_session_start(JCR *jcr); static void crypto_session_end(JCR *jcr); static bool crypto_session_send(JCR *jcr, BSOCK *sd); -/* +/** * Find all the requested files and send them * to the Storage daemon. * @@ -104,7 +102,8 @@ bool blast_data_to_storage_daemon(JCR *jcr, char *addr) } jcr->buf_size = sd->msglen; - /* Adjust for compression so that output buffer is + /** + * Adjust for compression so that output buffer is * 12 bytes + 0.1% larger than input buffer plus 18 bytes. * This gives a bit extra plus room for the sparse addr if any. * Note, we adjust the read size to be smaller so that the @@ -216,7 +215,7 @@ static bool crypto_session_start(JCR *jcr) { crypto_cipher_t cipher = CRYPTO_CIPHER_AES_128_CBC; - /* + /** * Create encryption session data and a cached, DER-encoded session data * structure. We use a single session key for each backup, so we'll encode * the session data only once. @@ -287,7 +286,7 @@ static bool crypto_session_send(JCR *jcr, BSOCK *sd) } -/* +/** * Called here by find() for each file included. * This is a callback. The original is find_files() above. * @@ -425,7 +424,7 @@ int save_file(JCR *jcr, FF_PKT *ff_pkt, bool top_level) /* Digests and encryption are only useful if there's file data */ if (has_file_data) { - /* + /** * Setup for digest handling. If this fails, the digest will be set to NULL * and not used. Note, the digest (file hash) can be any one of the four * algorithms below. @@ -459,7 +458,7 @@ int save_file(JCR *jcr, FF_PKT *ff_pkt, bool top_level) stream_to_ascii(digest_stream)); } - /* + /** * Set up signature digest handling. If this fails, the signature digest * will be set to NULL and not used. */ @@ -750,7 +749,7 @@ bail_out: return rtnstat; } -/* +/** * Send data read from an already open file descriptor. * * We return 1 on sucess and 0 on errors. @@ -802,7 +801,7 @@ static int send_data(JCR *jcr, int stream, FF_PKT *ff_pkt, DIGEST *digest, wbuf = jcr->compress_buf; /* compressed output here */ cipher_input = (uint8_t *)jcr->compress_buf; /* encrypt compressed data */ - /* + /** * Only change zlib parameters if there is no pending operation. * This should never happen as deflatereset is called after each * deflate. @@ -835,7 +834,7 @@ static int send_data(JCR *jcr, int stream, FF_PKT *ff_pkt, DIGEST *digest, goto err; } - /* + /** * Grow the crypto buffer, if necessary. * crypto_cipher_update() will buffer up to (cipher_block_size - 1). * We grow crypto_buf to the maximum number of blocks that @@ -849,7 +848,7 @@ static int send_data(JCR *jcr, int stream, FF_PKT *ff_pkt, DIGEST *digest, wbuf = jcr->crypto.crypto_buf; /* Encrypted, possibly compressed output here. */ } - /* + /** * Send Data header to Storage daemon * <file-index> <stream> <info> */ @@ -862,7 +861,7 @@ static int send_data(JCR *jcr, int stream, FF_PKT *ff_pkt, DIGEST *digest, } Dmsg1(300, ">stored: datahdr %s\n", sd->msg); - /* + /** * Make space at beginning of buffer for fileAddr because this * same buffer will be used for writing if compression is off. */ @@ -884,7 +883,7 @@ static int send_data(JCR *jcr, int stream, FF_PKT *ff_pkt, DIGEST *digest, rsize = (rsize/512) * 512; #endif - /* + /** * Read the file data */ while ((sd->msglen=(uint32_t)bread(&ff_pkt->bfd, rbuf, rsize)) > 0) { @@ -956,7 +955,7 @@ static int send_data(JCR *jcr, int stream, FF_PKT *ff_pkt, DIGEST *digest, cipher_input_len = compress_len; } #endif - /* + /** * Note, here we prepend the current record length to the beginning * of the encrypted data. This is because both sparse and compression * restore handling want records returned to them with exactly the @@ -1176,7 +1175,7 @@ bool encode_and_send_attributes(JCR *jcr, FF_PKT *ff_pkt, int &data_stream) return true; } -/* +/** * Do in place strip of path */ static bool do_strip(int count, char *in) @@ -1213,7 +1212,7 @@ static bool do_strip(int count, char *in) return stripped==count && numsep>count; } -/* +/** * If requested strip leading components of the path so that we can * save file as if it came from a subdirectory. This is most useful * for dealing with snapshots, by removing the snapshot directory, or @@ -1238,7 +1237,7 @@ void strip_path(FF_PKT *ff_pkt) sm_check(__FILE__, __LINE__, true); } - /* + /** * Strip path. If it doesn't succeed put it back. If * it does, and there is a different link string, * attempt to strip the link. If it fails, back them @@ -1250,7 +1249,7 @@ void strip_path(FF_PKT *ff_pkt) unstrip_path(ff_pkt); goto rtn; } - /* Strip links but not symlinks */ + /** Strip links but not symlinks */ if (ff_pkt->type != FT_LNK && ff_pkt->fname != ff_pkt->link) { if (!do_strip(ff_pkt->strip_path, ff_pkt->link)) { unstrip_path(ff_pkt); diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index 3e193de..b7671bf 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2000-2009 Free Software Foundation Europe e.V. + Copyright (C) 2000-2010 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -30,8 +30,6 @@ * * Kern Sibbald, October MM * - * Version $Id$ - * */ #include "bacula.h" @@ -44,7 +42,7 @@ static pthread_mutex_t vss_mutex = PTHREAD_MUTEX_INITIALIZER; static int enable_vss = 0; #endif -/* +/** * As Windows saves ACLs as part of the standard backup stream * we just pretend here that is has implicit acl support. */ @@ -101,7 +99,7 @@ struct s_cmds { int monitoraccess; /* specify if monitors have access to this function */ }; -/* +/** * The following are the recognized commands from the Director. */ static struct s_cmds cmds[] = { @@ -187,7 +185,7 @@ static char read_open[] = "read open session = %s %ld %ld %ld %ld %ld %ld\n"; static char read_data[] = "read data %d\n"; static char read_close[] = "read close session %d\n"; -/* +/** * Accept requests from a Director * * NOTE! We are running as a separate thread @@ -393,7 +391,7 @@ void *handle_client_request(void *dirp) return NULL; } -/* +/** * Hello from Director he must identify himself and provide his * password. */ @@ -408,7 +406,7 @@ static int hello_cmd(JCR *jcr) return 1; } -/* +/** * Cancel a Job */ static int cancel_cmd(JCR *jcr) @@ -439,7 +437,7 @@ static int cancel_cmd(JCR *jcr) } -/* +/** * Set debug level as requested by the Director * */ @@ -478,7 +476,7 @@ static int estimate_cmd(JCR *jcr) return 1; } -/* +/** * Get JobId and Storage Daemon Authorization key from Director */ static int job_cmd(JCR *jcr) @@ -664,7 +662,7 @@ static findFOPTS *start_options(FF_PKT *ff) } -/* +/** * Add fname to include/exclude fileset list. First check for * | and < and if necessary perform command. */ @@ -774,7 +772,7 @@ static void add_fileset(JCR *jcr, const char *item) return; } - /* + /** * The switch tests the code for validity. * The subcode is always good if it is a space, otherwise we must confirm. * We set state to state_error first assuming the subcode is invalid, @@ -1008,7 +1006,7 @@ static bool term_fileset(JCR *jcr) } -/* +/** * As an optimization, we should do this during * "compile" time in filed/job.c, and keep only a bit mask * and the Verify options. @@ -1172,7 +1170,7 @@ static void set_options(findFOPTS *fo, const char *opts) } -/* +/** * Director is passing his Fileset */ static int fileset_cmd(JCR *jcr) @@ -1213,9 +1211,11 @@ static void free_bootstrap(JCR *jcr) static pthread_mutex_t bsr_mutex = PTHREAD_MUTEX_INITIALIZER; static uint32_t bsr_uniq = 0; -/* +/** * The Director sends us the bootstrap file, which * we will in turn pass to the SD. + * Deprecated. The bsr is now sent directly from the + * Director to the SD. */ static int bootstrap_cmd(JCR *jcr) { @@ -1260,7 +1260,7 @@ static int bootstrap_cmd(JCR *jcr) } -/* +/** * Get backup level from Director * */ @@ -1378,8 +1378,9 @@ bail_out: return 0; } -/* +/** * Get session parameters from Director -- this is for a Restore command + * This is deprecated. It is now passed via the bsr. */ static int session_cmd(JCR *jcr) { @@ -1413,7 +1414,8 @@ static void set_storage_auth_key(JCR *jcr, char *key) jcr->store_bsock = NULL; } - /* We can be contacting multiple storage daemons. + /** + * We can be contacting multiple storage daemons. * So, make sure that any old jcr->sd_auth_key is cleaned up. */ if (jcr->sd_auth_key) { @@ -1428,7 +1430,7 @@ static void set_storage_auth_key(JCR *jcr, char *key) jcr->sd_auth_key = bstrdup(key); } -/* +/** * Get address of storage daemon from Director * */ @@ -1444,11 +1446,9 @@ static int storage_cmd(JCR *jcr) Dmsg1(100, "StorageCmd: %s", dir->msg); sd_auth_key.check_size(dir->msglen); if (sscanf(dir->msg, storaddr, &jcr->stored_addr, &stored_port, - &enable_ssl, sd_auth_key.c_str()) != 4) - { + &enable_ssl, sd_auth_key.c_str()) != 4) { if (sscanf(dir->msg, storaddr_v1, &jcr->stored_addr, - &stored_port, &enable_ssl) != 3) - { + &stored_port, &enable_ssl) != 3) { pm_strcpy(jcr->errmsg, dir->msg); Jmsg(jcr, M_FATAL, 0, _("Bad storage command: %s"), jcr->errmsg); goto bail_out; @@ -1497,7 +1497,7 @@ bail_out: } -/* +/** * Do a backup. */ static int backup_cmd(JCR *jcr) @@ -1518,7 +1518,7 @@ static int backup_cmd(JCR *jcr) } #endif - /* + /** * Validate some options given to the backup make sense for the compiled in * options of this filed. */ @@ -1544,12 +1544,12 @@ static int backup_cmd(JCR *jcr) dir->fsend(OKbackup); Dmsg1(110, "filed>dird: %s", dir->msg); - /* + /** * Send Append Open Session to Storage daemon */ sd->fsend(append_open); Dmsg1(110, ">stored: %s", sd->msg); - /* + /** * Expect to receive back the Ticket number */ if (bget_msg(sd) >= 0) { @@ -1564,13 +1564,13 @@ static int backup_cmd(JCR *jcr) goto cleanup; } - /* + /** * Send Append data command to Storage daemon */ sd->fsend(append_data, jcr->Ticket); Dmsg1(110, ">stored: %s", sd->msg); - /* + /** * Expect to get OK data */ Dmsg1(110, "<stored: %s", sd->msg); @@ -1584,7 +1584,7 @@ static int backup_cmd(JCR *jcr) #if defined(WIN32_VSS) /* START VSS ON WIN32 */ if (jcr->VSS) { - if (g_pVSSClient->InitializeForBackup()) { + if (g_pVSSClient->InitializeForBackup(jcr)) { /* tell vss which drives to snapshot */ char szWinDriveLetters[27]; if (get_win32_driveletters(jcr->ff, szWinDriveLetters)) { @@ -1619,7 +1619,7 @@ static int backup_cmd(JCR *jcr) } #endif - /* + /** * Send Files to Storage daemon */ Dmsg1(110, "begin blast ff=%p\n", (FF_PKT *)jcr->ff); @@ -1635,7 +1635,7 @@ static int backup_cmd(JCR *jcr) bnet_suppress_error_messages(sd, 1); goto cleanup; /* bail out now */ } - /* + /** * Expect to get response to append_data from Storage daemon */ if (!response(jcr, sd, OK_append, "Append Data")) { @@ -1643,7 +1643,7 @@ static int backup_cmd(JCR *jcr) goto cleanup; } - /* + /** * Send Append End Data to Storage daemon */ sd->fsend(append_end, jcr->Ticket); @@ -1653,7 +1653,7 @@ static int backup_cmd(JCR *jcr) goto cleanup; } - /* + /** * Send Append Close to Storage daemon */ sd->fsend(append_close, jcr->Ticket); @@ -1698,7 +1698,7 @@ cleanup: return 0; /* return and stop command loop */ } -/* +/** * Do a Verify for Director * */ @@ -1775,7 +1775,7 @@ static int verify_cmd(JCR *jcr) return 0; /* return and terminate command loop */ } -/* +/** * Do a Restore for Director * */ @@ -1788,7 +1788,7 @@ static int restore_cmd(JCR *jcr) int prefix_links; char replace; - /* + /** * Scan WHERE (base directory for restore) from command */ Dmsg0(150, "restore command\n"); @@ -1844,7 +1844,7 @@ static int restore_cmd(JCR *jcr) set_jcr_job_status(jcr, JS_Running); - /* + /** * Do restore of files and data */ start_dir_heartbeat(jcr); @@ -1858,7 +1858,7 @@ static int restore_cmd(JCR *jcr) bnet_suppress_error_messages(sd, 1); } - /* + /** * Send Close session command to Storage daemon */ sd->fsend(read_close, jcr->Ticket); @@ -1950,7 +1950,7 @@ static int open_sd_read_session(JCR *jcr) return 1; } -/* +/** * Destroy the Job Control Record and associated * resources (sockets). */ @@ -1972,7 +1972,7 @@ static void filed_free_jcr(JCR *jcr) return; } -/* +/** * Get response from Storage daemon to a command we * sent. Check that the response is OK. * diff --git a/bacula/src/win32/filed/vss.cpp b/bacula/src/win32/filed/vss.cpp index 7a73c32..5e78ef8 100644 --- a/bacula/src/win32/filed/vss.cpp +++ b/bacula/src/win32/filed/vss.cpp @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2005-2008 Free Software Foundation Europe e.V. + Copyright (C) 2005-2010 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -74,7 +74,6 @@ void VSSInit() return; } /* Vista or Longhorn or later */ -// } else if (g_MajorVersion == 6 && g_MinorVersion == 0) { } else if (g_MajorVersion >= 6) { g_pVSSClient = new VSSClientVista(); atexit(VSSCleanup); @@ -121,30 +120,31 @@ VSSClient::~VSSClient() } DestroyWriterInfo(); - delete (alist*)m_pAlistWriterState; - delete (alist*)m_pAlistWriterInfoText; + delete m_pAlistWriterState; + delete m_pAlistWriterInfoText; // Call CoUninitialize if the CoInitialize was performed successfully if (m_bCoInitializeCalled) CoUninitialize(); } -BOOL VSSClient::InitializeForBackup() +bool VSSClient::InitializeForBackup(JCR *jcr) { //return Initialize (VSS_CTX_BACKUP); + m_jcr = jcr; 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; + return false; /* check for valid pathname */ - BOOL bIsValidName; + bool bIsValidName; bIsValidName = strlen(szFilePath) > 3; if (bIsValidName) @@ -159,23 +159,23 @@ BOOL VSSClient::GetShadowPath(const char *szFilePath, char *szShadowPath, int nB if (WideCharToMultiByte(CP_UTF8,0,m_szShadowCopyName[nDriveIndex],-1,szShadowPath,nBuflen-1,NULL,NULL)) { nBuflen -= (int)strlen(szShadowPath); bstrncat(szShadowPath, szFilePath+2, nBuflen); - return TRUE; + return true; } } } bstrncpy(szShadowPath, szFilePath, nBuflen); errno = EINVAL; - return FALSE; + return false; } -BOOL VSSClient::GetShadowPathW(const wchar_t *szFilePath, wchar_t *szShadowPath, int nBuflen) +bool VSSClient::GetShadowPathW(const wchar_t *szFilePath, wchar_t *szShadowPath, int nBuflen) { if (!m_bBackupIsInitialized) - return FALSE; + return false; /* check for valid pathname */ - BOOL bIsValidName; + bool bIsValidName; bIsValidName = wcslen(szFilePath) > 3; if (bIsValidName) @@ -189,39 +189,39 @@ BOOL VSSClient::GetShadowPathW(const wchar_t *szFilePath, wchar_t *szShadowPath, wcsncpy(szShadowPath, m_szShadowCopyName[nDriveIndex], nBuflen); nBuflen -= (int)wcslen(m_szShadowCopyName[nDriveIndex]); wcsncat(szShadowPath, szFilePath+2, nBuflen); - return TRUE; + return true; } } wcsncpy(szShadowPath, szFilePath, nBuflen); errno = EINVAL; - return FALSE; + return false; } const size_t VSSClient::GetWriterCount() { - alist* pV = (alist*)m_pAlistWriterInfoText; + alist* pV = m_pAlistWriterInfoText; return pV->size(); } const char* VSSClient::GetWriterInfo(int nIndex) { - alist* pV = (alist*)m_pAlistWriterInfoText; + alist* pV = m_pAlistWriterInfoText; return (char*)pV->get(nIndex); } const int VSSClient::GetWriterState(int nIndex) { - alist* pV = (alist*)m_pAlistWriterState; - return (intptr_t)pV->get(nIndex); + alist* pV = m_pAlistWriterState; + return (int64_t)pV->get(nIndex); } void VSSClient::AppendWriterInfo(int nState, const char* pszInfo) { - alist* pT = (alist*) m_pAlistWriterInfoText; - alist* pS = (alist*) m_pAlistWriterState; + alist* pT = m_pAlistWriterInfoText; + alist* pS = m_pAlistWriterState; pT->push(bstrdup(pszInfo)); pS->push((void*)nState); @@ -229,8 +229,8 @@ void VSSClient::AppendWriterInfo(int nState, const char* pszInfo) void VSSClient::DestroyWriterInfo() { - alist* pT = (alist*)m_pAlistWriterInfoText; - alist* pS = (alist*)m_pAlistWriterState; + alist* pT = m_pAlistWriterInfoText; + alist* pS = m_pAlistWriterState; while (!pT->empty()) free(pT->pop()); diff --git a/bacula/src/win32/filed/vss.h b/bacula/src/win32/filed/vss.h index 25709a6..e25de09 100644 --- a/bacula/src/win32/filed/vss.h +++ b/bacula/src/win32/filed/vss.h @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2006-2007 Free Software Foundation Europe e.V. + Copyright (C) 2006-2010 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -56,44 +56,45 @@ public: virtual ~VSSClient(); // Backup Process - BOOL InitializeForBackup(); - virtual BOOL CreateSnapshots(char* szDriveLetters) = 0; - virtual BOOL CloseBackup() = 0; + bool InitializeForBackup(JCR *jcr); + virtual bool CreateSnapshots(char* szDriveLetters) = 0; + virtual bool CloseBackup() = 0; virtual const char* GetDriverName() = 0; - BOOL GetShadowPath (const char* szFilePath, char* szShadowPath, int nBuflen); - BOOL GetShadowPathW (const wchar_t* szFilePath, wchar_t* szShadowPath, int nBuflen); /* nBuflen in characters */ + bool GetShadowPath (const char* szFilePath, char* szShadowPath, int nBuflen); + bool GetShadowPathW (const wchar_t* szFilePath, wchar_t* szShadowPath, int nBuflen); /* nBuflen in characters */ const size_t GetWriterCount(); const char* GetWriterInfo(int nIndex); const int GetWriterState(int nIndex); void DestroyWriterInfo(); void AppendWriterInfo(int nState, const char* pszInfo); - const BOOL IsInitialized() { return m_bBackupIsInitialized; }; + const bool IsInitialized() { return m_bBackupIsInitialized; }; private: - virtual BOOL Initialize(DWORD dwContext, BOOL bDuringRestore = FALSE) = 0; - virtual BOOL WaitAndCheckForAsyncOperation(IVssAsync* pAsync) = 0; + virtual bool Initialize(DWORD dwContext, bool bDuringRestore = FALSE) = 0; + virtual bool WaitAndCheckForAsyncOperation(IVssAsync* pAsync) = 0; virtual void QuerySnapshotSet(GUID snapshotSetID) = 0; protected: - HMODULE m_hLib; + HMODULE m_hLib; + JCR *m_jcr; - BOOL m_bCoInitializeCalled; - BOOL m_bCoInitializeSecurityCalled; - DWORD m_dwContext; + DWORD m_dwContext; - IUnknown* m_pVssObject; - GUID m_uidCurrentSnapshotSet; - // TRUE if we are during restore - BOOL m_bDuringRestore; - BOOL m_bBackupIsInitialized; + IUnknown* m_pVssObject; + GUID m_uidCurrentSnapshotSet; // drive A will be stored on position 0,Z on pos. 25 - wchar_t m_wszUniqueVolumeName[26][MAX_PATH]; // approx. 7 KB - wchar_t m_szShadowCopyName[26][MAX_PATH]; // approx. 7 KB + wchar_t m_wszUniqueVolumeName[26][MAX_PATH]; // approx. 7 KB + wchar_t m_szShadowCopyName[26][MAX_PATH]; // approx. 7 KB - void* m_pAlistWriterState; - void* m_pAlistWriterInfoText; + alist *m_pAlistWriterState; + alist *m_pAlistWriterInfoText; + + bool m_bCoInitializeCalled; + bool m_bCoInitializeSecurityCalled; + bool m_bDuringRestore; /* true if we are doing a restore */ + bool m_bBackupIsInitialized; }; class VSSClientXP:public VSSClient @@ -101,14 +102,14 @@ class VSSClientXP:public VSSClient public: VSSClientXP(); virtual ~VSSClientXP(); - virtual BOOL CreateSnapshots(char* szDriveLetters); - virtual BOOL CloseBackup(); + virtual bool CreateSnapshots(char* szDriveLetters); + virtual bool CloseBackup(); virtual const char* GetDriverName() { return "VSS WinXP"; }; private: - virtual BOOL Initialize(DWORD dwContext, BOOL bDuringRestore); - virtual BOOL WaitAndCheckForAsyncOperation(IVssAsync* pAsync); + virtual bool Initialize(DWORD dwContext, bool bDuringRestore); + virtual bool WaitAndCheckForAsyncOperation(IVssAsync* pAsync); virtual void QuerySnapshotSet(GUID snapshotSetID); - BOOL CheckWriterStatus(); + bool CheckWriterStatus(); }; class VSSClient2003:public VSSClient @@ -116,14 +117,14 @@ class VSSClient2003:public VSSClient public: VSSClient2003(); virtual ~VSSClient2003(); - virtual BOOL CreateSnapshots(char* szDriveLetters); - virtual BOOL CloseBackup(); + virtual bool CreateSnapshots(char* szDriveLetters); + virtual bool CloseBackup(); virtual const char* GetDriverName() { return "VSS Win 2003"; }; private: - virtual BOOL Initialize(DWORD dwContext, BOOL bDuringRestore); - virtual BOOL WaitAndCheckForAsyncOperation(IVssAsync* pAsync); + virtual bool Initialize(DWORD dwContext, bool bDuringRestore); + virtual bool WaitAndCheckForAsyncOperation(IVssAsync* pAsync); virtual void QuerySnapshotSet(GUID snapshotSetID); - BOOL CheckWriterStatus(); + bool CheckWriterStatus(); }; class VSSClientVista:public VSSClient @@ -131,14 +132,14 @@ class VSSClientVista:public VSSClient public: VSSClientVista(); virtual ~VSSClientVista(); - virtual BOOL CreateSnapshots(char* szDriveLetters); - virtual BOOL CloseBackup(); + virtual bool CreateSnapshots(char* szDriveLetters); + virtual bool CloseBackup(); virtual const char* GetDriverName() { return "VSS Vista"; }; private: - virtual BOOL Initialize(DWORD dwContext, BOOL bDuringRestore); - virtual BOOL WaitAndCheckForAsyncOperation(IVssAsync* pAsync); + virtual bool Initialize(DWORD dwContext, bool bDuringRestore); + virtual bool WaitAndCheckForAsyncOperation(IVssAsync* pAsync); virtual void QuerySnapshotSet(GUID snapshotSetID); - BOOL CheckWriterStatus(); + bool CheckWriterStatus(); }; diff --git a/bacula/src/win32/filed/vss_generic.cpp b/bacula/src/win32/filed/vss_generic.cpp index cdcf288..7aa6f03 100644 --- a/bacula/src/win32/filed/vss_generic.cpp +++ b/bacula/src/win32/filed/vss_generic.cpp @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2005-2008 Free Software Foundation Europe e.V. + Copyright (C) 2005-2010 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -232,12 +232,12 @@ VSSClientGeneric::~VSSClientGeneric() } // Initialize the COM infrastructure and the internal pointers -BOOL VSSClientGeneric::Initialize(DWORD dwContext, BOOL bDuringRestore) +bool VSSClientGeneric::Initialize(DWORD dwContext, bool bDuringRestore) { if (!(p_CreateVssBackupComponents && p_VssFreeSnapshotProperties)) { Dmsg2(0, "VSSClientGeneric::Initialize: p_CreateVssBackupComponents = 0x%08X, p_VssFreeSnapshotProperties = 0x%08X\n", p_CreateVssBackupComponents, p_VssFreeSnapshotProperties); errno = ENOSYS; - return FALSE; + return false; } HRESULT hr; @@ -247,7 +247,7 @@ BOOL VSSClientGeneric::Initialize(DWORD dwContext, BOOL bDuringRestore) if (FAILED(hr)) { Dmsg1(0, "VSSClientGeneric::Initialize: CoInitialize returned 0x%08X\n", hr); errno = b_errno_win32; - return FALSE; + return false; } m_bCoInitializeCalled = true; } @@ -270,7 +270,7 @@ BOOL VSSClientGeneric::Initialize(DWORD dwContext, BOOL bDuringRestore) if (FAILED(hr)) { Dmsg1(0, "VSSClientGeneric::Initialize: CoInitializeSecurity returned 0x%08X\n", hr); errno = b_errno_win32; - return FALSE; + return false; } m_bCoInitializeSecurityCalled = true; } @@ -288,7 +288,7 @@ BOOL VSSClientGeneric::Initialize(DWORD dwContext, BOOL bDuringRestore) Dmsg2(0, "VSSClientGeneric::Initialize: CreateVssBackupComponents returned 0x%08X. ERR=%s\n", hr, be.bstrerror(b_errno_win32)); errno = b_errno_win32; - return FALSE; + return false; } #if defined(B_VSS_W2K3) || defined(B_VSS_VISTA) @@ -297,7 +297,7 @@ BOOL VSSClientGeneric::Initialize(DWORD dwContext, BOOL bDuringRestore) if (FAILED(hr)) { Dmsg1(0, "VSSClientGeneric::Initialize: IVssBackupComponents->SetContext returned 0x%08X\n", hr); errno = b_errno_win32; - return FALSE; + return false; } } #endif @@ -308,7 +308,7 @@ BOOL VSSClientGeneric::Initialize(DWORD dwContext, BOOL bDuringRestore) if (FAILED(hr)) { Dmsg1(0, "VSSClientGeneric::Initialize: IVssBackupComponents->InitializeForBackup returned 0x%08X\n", hr); errno = b_errno_win32; - return FALSE; + return false; } // 2. SetBackupState @@ -316,7 +316,7 @@ BOOL VSSClientGeneric::Initialize(DWORD dwContext, BOOL bDuringRestore) if (FAILED(hr)) { Dmsg1(0, "VSSClientGeneric::Initialize: IVssBackupComponents->SetBackupState returned 0x%08X\n", hr); errno = b_errno_win32; - return FALSE; + return false; } CComPtr<IVssAsync> pAsync1; @@ -325,7 +325,7 @@ BOOL VSSClientGeneric::Initialize(DWORD dwContext, BOOL bDuringRestore) if (FAILED(hr)) { Dmsg1(0, "VSSClientGeneric::Initialize: IVssBackupComponents->GatherWriterMetadata returned 0x%08X\n", hr); errno = b_errno_win32; - return FALSE; + return false; } // Waits for the async operation to finish and checks the result WaitAndCheckForAsyncOperation(pAsync1.p); @@ -337,11 +337,11 @@ BOOL VSSClientGeneric::Initialize(DWORD dwContext, BOOL bDuringRestore) // Keep the context m_dwContext = dwContext; - return TRUE; + return true; } -BOOL VSSClientGeneric::WaitAndCheckForAsyncOperation(IVssAsync* pAsync) +bool VSSClientGeneric::WaitAndCheckForAsyncOperation(IVssAsync* pAsync) { // Wait until the async operation finishes // unfortunately we can't use a timeout here yet. @@ -368,7 +368,7 @@ BOOL VSSClientGeneric::WaitAndCheckForAsyncOperation(IVssAsync* pAsync) } while ((timeout-- > 0) && (hrReturned == VSS_S_ASYNC_PENDING)); if (hrReturned == VSS_S_ASYNC_FINISHED) - return TRUE; + return true; #ifdef xDEBUG @@ -389,10 +389,10 @@ BOOL VSSClientGeneric::WaitAndCheckForAsyncOperation(IVssAsync* pAsync) } #endif - return FALSE; + return false; } -BOOL VSSClientGeneric::CreateSnapshots(char* szDriveLetters) +bool VSSClientGeneric::CreateSnapshots(char* szDriveLetters) { /* szDriveLetters contains all drive letters in uppercase */ /* if a drive can not being added, it's converted to lowercase in szDriveLetters */ @@ -400,7 +400,7 @@ BOOL VSSClientGeneric::CreateSnapshots(char* szDriveLetters) if (!m_pVssObject || m_bBackupIsInitialized) { errno = ENOSYS; - return FALSE; + return false; } m_uidCurrentSnapshotSet = GUID_NULL; @@ -437,7 +437,7 @@ BOOL VSSClientGeneric::CreateSnapshots(char* szDriveLetters) /* PrepareForBackup */ if (FAILED(pVss->PrepareForBackup(&pAsync1.p))) { errno = b_errno_win32; - return FALSE; + return false; } // Waits for the async operation to finish and checks the result @@ -446,13 +446,13 @@ BOOL VSSClientGeneric::CreateSnapshots(char* szDriveLetters) /* get latest info about writer status */ if (!CheckWriterStatus()) { errno = b_errno_win32; - return FALSE; + return false; } /* DoSnapShotSet */ if (FAILED(pVss->DoSnapshotSet(&pAsync2.p))) { errno = b_errno_win32; - return FALSE; + return false; } // Waits for the async operation to finish and checks the result @@ -465,12 +465,12 @@ BOOL VSSClientGeneric::CreateSnapshots(char* szDriveLetters) m_bBackupIsInitialized = true; - return TRUE; + return true; } -BOOL VSSClientGeneric::CloseBackup() +bool VSSClientGeneric::CloseBackup() { - BOOL bRet = FALSE; + bool bRet = false; if (!m_pVssObject) errno = ENOSYS; else { @@ -484,7 +484,7 @@ BOOL VSSClientGeneric::CloseBackup() if (SUCCEEDED(pVss->BackupComplete(&pAsync.p))) { // Waits for the async operation to finish and checks the result WaitAndCheckForAsyncOperation(pAsync.p); - bRet = TRUE; + bRet = true; } else { errno = b_errno_win32; pVss->AbortBackup(); @@ -500,7 +500,7 @@ BOOL VSSClientGeneric::CloseBackup() pVss->DeleteSnapshots( m_uidCurrentSnapshotSet, VSS_OBJECT_SNAPSHOT_SET, - FALSE, + false, &lSnapshots, &idNonDeletedSnapshotID); @@ -578,7 +578,7 @@ void VSSClientGeneric::QuerySnapshotSet(GUID snapshotSetID) } // Check the status for all selected writers -BOOL VSSClientGeneric::CheckWriterStatus() +bool VSSClientGeneric::CheckWriterStatus() { /* http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vss/base/ivssbackupcomponents_startsnapshotset.asp @@ -592,7 +592,7 @@ BOOL VSSClientGeneric::CheckWriterStatus() HRESULT hr = pVss->GatherWriterStatus(&pAsync.p); if (FAILED(hr)) { errno = b_errno_win32; - return FALSE; + return false; } // Waits for the async operation to finish and checks the result @@ -603,7 +603,7 @@ BOOL VSSClientGeneric::CheckWriterStatus() hr = pVss->GetWriterStatusCount(&cWriters); if (FAILED(hr)) { errno = b_errno_win32; - return FALSE; + return false; } int nState; @@ -671,11 +671,11 @@ BOOL VSSClientGeneric::CheckWriterStatus() if (FAILED(hr)) { errno = b_errno_win32; - return FALSE; + return false; } errno = 0; - return TRUE; + return true; } #endif /* WIN32_VSS */ hooks/post-receive -- Bacula |