From af6c657394f1151e7ea4d23dc631cd8953cb66f9 Mon Sep 17 00:00:00 2001 From: Thorsten Engel Date: Mon, 5 Sep 2005 14:39:22 +0000 Subject: [PATCH] added GetVolumePathW and GetVolumeNameForVolumeMountPointW to winapi. This allows 1 binary to be used from Win9x up to W2K3. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2381 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/filed/status.c | 6 ++++-- bacula/src/lib/winapi.c | 14 ++++++++++++++ bacula/src/lib/winapi.h | 6 ++++++ bacula/src/win32/compat/vss_generic.cpp | 10 ++++++---- 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/bacula/src/filed/status.c b/bacula/src/filed/status.c index daa6b15e32..755fe7254d 100755 --- a/bacula/src/filed/status.c +++ b/bacula/src/filed/status.c @@ -109,9 +109,11 @@ static void do_status(void sendit(const char *msg, int len, void *sarg), void *a p_SetCurrentDirectoryA?"":"!", p_SetCurrentDirectoryW?"":"!"); sendit(msg, len, arg); - len = Mmsg(msg, " %sGCDA,%sGCDW\n", + len = Mmsg(msg, " %sGCDA,%sGCDW,%sGVPNW,%sGVNFVMPW\n", p_GetCurrentDirectoryA?"":"!", - p_GetCurrentDirectoryW?"":"!"); + p_GetCurrentDirectoryW?"":"!", + p_GetVolumePathNameW?"":"!", + p_GetVolumeNameForVolumeMountPointW?"":"!"); sendit(msg, len, arg); } #endif diff --git a/bacula/src/lib/winapi.c b/bacula/src/lib/winapi.c index 45d382ad9e..c23d25f4cd 100644 --- a/bacula/src/lib/winapi.c +++ b/bacula/src/lib/winapi.c @@ -78,6 +78,9 @@ t_SetCurrentDirectoryW p_SetCurrentDirectoryW = NULL; t_GetCurrentDirectoryA p_GetCurrentDirectoryA = NULL; t_GetCurrentDirectoryW p_GetCurrentDirectoryW = NULL; +t_GetVolumePathNameW p_GetVolumePathNameW = NULL; +t_GetVolumeNameForVolumeMountPointW p_GetVolumeNameForVolumeMountPointW = NULL; + #ifdef WIN32_VSS void VSSCleanup() @@ -143,6 +146,14 @@ InitWinAPIWrapper() GetProcAddress(hLib, "GetCurrentDirectoryA"); p_GetCurrentDirectoryW = (t_GetCurrentDirectoryW) GetProcAddress(hLib, "GetCurrentDirectoryW"); + + /* some special stuff we need for VSS + but statically linkage doesn't work on Win 9x */ + p_GetVolumePathNameW = (t_GetVolumePathNameW) + GetProcAddress(hLib, "GetVolumePathNameW"); + p_GetVolumeNameForVolumeMountPointW = (t_GetVolumeNameForVolumeMountPointW) + GetProcAddress(hLib, "GetVolumeNameForVolumeMountPointW"); + FreeLibrary(hLib); } @@ -206,6 +217,9 @@ InitWinAPIWrapper() p_wunlink = NULL; p_wmkdir = NULL; p_wopen = NULL; + + p_GetVolumePathNameW = NULL; + p_GetVolumeNameForVolumeMountPointW = NULL; } /* decide which vss class to initialize */ diff --git a/bacula/src/lib/winapi.h b/bacula/src/lib/winapi.h index 1b815d51d9..a138f04f47 100644 --- a/bacula/src/lib/winapi.h +++ b/bacula/src/lib/winapi.h @@ -109,6 +109,9 @@ typedef BOOL (WINAPI * t_SetCurrentDirectoryW) (LPCWSTR); typedef DWORD (WINAPI * t_GetCurrentDirectoryA) (DWORD, LPSTR); typedef DWORD (WINAPI * t_GetCurrentDirectoryW) (DWORD, LPWSTR); +typedef BOOL (WINAPI * t_GetVolumePathNameW) (LPCWSTR, LPWSTR, DWORD); +typedef BOOL (WINAPI * t_GetVolumeNameForVolumeMountPointW) (LPCWSTR, LPWSTR, DWORD); + extern t_GetFileAttributesA p_GetFileAttributesA; extern t_GetFileAttributesW p_GetFileAttributesW; @@ -139,6 +142,9 @@ extern t_SetCurrentDirectoryW p_SetCurrentDirectoryW; extern t_GetCurrentDirectoryA p_GetCurrentDirectoryA; extern t_GetCurrentDirectoryW p_GetCurrentDirectoryW; +extern t_GetVolumePathNameW p_GetVolumePathNameW; +extern t_GetVolumeNameForVolumeMountPointW p_GetVolumeNameForVolumeMountPointW; + #ifdef WIN32_VSS class VSSClient; extern VSSClient* g_pVSSClient; diff --git a/bacula/src/win32/compat/vss_generic.cpp b/bacula/src/win32/compat/vss_generic.cpp index 54a2d3153d..75387df272 100644 --- a/bacula/src/win32/compat/vss_generic.cpp +++ b/bacula/src/win32/compat/vss_generic.cpp @@ -62,6 +62,8 @@ using namespace std; // Used for safe string manipulation #include +#include "../../lib/winapi.h" + #ifdef B_VSS_XP #pragma message("compile VSS for Windows XP") #define VSSClientGeneric VSSClientXP @@ -120,7 +122,7 @@ inline wstring AppendBackslash(wstring str) // Get the unique volume name for the given path inline wstring GetUniqueVolumeNameForPath(wstring path) { - _ASSERTE(path.length() > 0); + _ASSERTE(path.length() > 0); // Add the backslash termination, if needed path = AppendBackslash(path); @@ -130,15 +132,15 @@ inline wstring GetUniqueVolumeNameForPath(wstring path) WCHAR volumeName[MAX_PATH]; WCHAR volumeUniqueName[MAX_PATH]; - if (!GetVolumePathNameW((LPCWSTR)path.c_str(), volumeRootPath, MAX_PATH)) + if (!p_GetVolumePathNameW || !p_GetVolumePathNameW((LPCWSTR)path.c_str(), volumeRootPath, MAX_PATH)) return L""; // Get the volume name alias (might be different from the unique volume name in rare cases) - if (!GetVolumeNameForVolumeMountPointW(volumeRootPath, volumeName, MAX_PATH)) + if (!p_GetVolumeNameForVolumeMountPointW || !p_GetVolumeNameForVolumeMountPointW(volumeRootPath, volumeName, MAX_PATH)) return L""; // Get the unique volume name - if (!GetVolumeNameForVolumeMountPointW(volumeName, volumeUniqueName, MAX_PATH)) + if (!p_GetVolumeNameForVolumeMountPointW(volumeName, volumeUniqueName, MAX_PATH)) return L""; return volumeUniqueName; -- 2.39.5