//#define USE_WIN32_COMPAT_IO 1
#define USE_WIN32_32KPATHCONVERSION 1
-extern void d_msg(const char *file, int line, int level, const char *fmt,...);
extern DWORD g_platform_id;
extern DWORD g_MinorVersion;
const char *fname = name;
char *tname = win32_name;
+ Dmsg0(100, "Enter convert_unix_to_win32_path\n");
+
if ((name[0] == '/' || name[0] == '\\') &&
(name[1] == '/' || name[1] == '\\') &&
(name[2] == '.') &&
\\\\?\\GLOBALROOT\\Device\\HarddiskVolumeShadowCopy1\\bacula\\uninstall.exe
from c:\bacula\uninstall.exe
*/
+ Dmsg1(100, "path=%s\n", tname);
if (g_pVSSPathConvert != NULL) {
POOLMEM *pszBuf = get_pool_memory (PM_FNAME);
pszBuf = check_pool_memory_size(pszBuf, dwSize);
g_pVSSPathConvert(pszBuf, tname, dwSize);
free_pool_memory(pszBuf);
}
+ Dmsg1(100, "Leave cvt_u_to_win32_path path=%s\n", tname);
}
/* Conversion of a Unix filename to a Win32 filename */
make_wchar_win32_path(POOLMEM *pszUCSPath, BOOL *pBIsRawPath /*= NULL*/)
{
/* created 02/27/2006 Thorsten Engel
-
- This function expects an UCS-encoded standard wchar_t in pszUCSPath and
- will complete the input path to an absolue path of the form \\?\c:\path\file
-
- With this trick, it is possible to have 32K characters long paths.
-
- Optionally one can use pBIsRawPath to determine id pszUCSPath contains a path
- to a raw windows partition */
+ *
+ * This function expects an UCS-encoded standard wchar_t in pszUCSPath and
+ * will complete the input path to an absolue path of the form \\?\c:\path\file
+ *
+ * With this trick, it is possible to have 32K characters long paths.
+ *
+ * Optionally one can use pBIsRawPath to determine id pszUCSPath contains a path
+ * to a raw windows partition.
+ */
- if (pBIsRawPath)
- *pBIsRawPath = FALSE;
+ Dmsg0(100, "Enter wchar_win32_path\n");
+ if (pBIsRawPath) {
+ *pBIsRawPath = FALSE; /* Initialize, set later */
+ }
- if (!p_GetCurrentDirectoryW)
+ if (!p_GetCurrentDirectoryW) {
+ Dmsg0(100, "Leave wchar_win32_path no change \n");
return pszUCSPath;
+ }
- wchar_t *name = (wchar_t *) pszUCSPath;
+ wchar_t *name = (wchar_t *)pszUCSPath;
/* if it has already the desired form, exit without changes */
- if (wcslen(name) > 3 && wcsncmp(name, L"\\\\?\\", 4) == 0)
+ if (wcslen(name) > 3 && wcsncmp(name, L"\\\\?\\", 4) == 0) {
+ Dmsg0(100, "Leave wchar_win32_path no change \n");
return pszUCSPath;
+ }
POOLMEM *pwszBuf = get_pool_memory(PM_FNAME);
POOLMEM *pwszCurDirBuf = get_pool_memory(PM_FNAME);
/* is path relative to itself?, if yes, skip ./ */
if (wcslen(name) > 2 && ((wcsncmp(name, L"./", 2) == 0) || (wcsncmp(name, L".\\", 2) == 0))) {
- name+=2;
+ name += 2;
}
/* is path of form '//./'? */
bAddDrive = FALSE;
bAddCurrentPath = FALSE;
bAddPrefix = FALSE;
- if (pBIsRawPath)
+ if (pBIsRawPath) {
*pBIsRawPath = TRUE;
+ }
}
int nParseOffset = 0;
/* add 4 bytes header */
if (bAddPrefix) {
nParseOffset = 4;
- wcscpy ((wchar_t *) pwszBuf,L"\\\\?\\");
+ wcscpy((wchar_t *)pwszBuf, L"\\\\?\\");
}
/* get current path if needed */
/* get directory into own buffer as it may either return c:\... or \\?\C:\.... */
pwszCurDirBuf = check_pool_memory_size(pwszCurDirBuf, (dwCurDirPathSize+1)*sizeof(wchar_t));
p_GetCurrentDirectoryW(dwCurDirPathSize,(wchar_t *)pwszCurDirBuf);
- }
- else
- {
+ } else {
/* we have no info for doing so */
bAddDrive = FALSE;
bAddCurrentPath = FALSE;
if (bAddDrive && !bAddCurrentPath) {
wchar_t szDrive[3];
- if (dwCurDirPathSize > 3 && wcsncmp((LPCWSTR)pwszCurDirBuf, L"\\\\?\\", 4) == 0)
+ if (dwCurDirPathSize > 3 && wcsncmp((LPCWSTR)pwszCurDirBuf, L"\\\\?\\", 4) == 0) {
/* copy drive character */
- wcsncpy((wchar_t *) szDrive, (LPCWSTR)pwszCurDirBuf+4,2);
- else
+ wcsncpy((wchar_t *)szDrive, (LPCWSTR)pwszCurDirBuf+4, 2);
+ } else {
/* copy drive character */
- wcsncpy((wchar_t *) szDrive, (LPCWSTR)pwszCurDirBuf,2);
+ wcsncpy((wchar_t *)szDrive, (LPCWSTR)pwszCurDirBuf, 2);
+ }
szDrive[2] = 0;
- wcscat((wchar_t *) pwszBuf, szDrive);
+ wcscat((wchar_t *)pwszBuf, szDrive);
nParseOffset +=2;
}
pwszBuf = check_pool_memory_size(pwszBuf, dwBufCharsNeeded*sizeof(wchar_t));
/* get directory into own buffer as it may either return c:\... or \\?\C:\.... */
- if (dwCurDirPathSize > 3 && wcsncmp((LPCWSTR)pwszCurDirBuf, L"\\\\?\\", 4) == 0)
+ if (dwCurDirPathSize > 3 && wcsncmp((LPCWSTR)pwszCurDirBuf, L"\\\\?\\", 4) == 0) {
/* copy complete string */
- wcscpy((wchar_t *) pwszBuf, (LPCWSTR)pwszCurDirBuf);
- else
+ wcscpy((wchar_t *)pwszBuf, (LPCWSTR)pwszCurDirBuf);
+ } else {
/* append path */
- wcscat((wchar_t *) pwszBuf, (LPCWSTR)pwszCurDirBuf);
+ wcscat((wchar_t *)pwszBuf, (LPCWSTR)pwszCurDirBuf);
+ }
- nParseOffset = wcslen ((LPCWSTR) pwszBuf);
+ nParseOffset = wcslen((LPCWSTR) pwszBuf);
/* check if path ends with backslash, if not, add one */
- if (*((wchar_t *) pwszBuf+nParseOffset-1) != L'\\') {
- wcscat((wchar_t *) pwszBuf, L"\\");
+ if (*((wchar_t *)pwszBuf+nParseOffset-1) != L'\\') {
+ wcscat((wchar_t *)pwszBuf, L"\\");
nParseOffset++;
}
}
*win32_name++ = '\\'; /* convert char */
/* If Win32 separated that is "quoted", remove quote */
/* HELPME (Thorsten Engel): I don't understand the following part
- and it removes a backslash from e.g. "\\.\c:" which I need for
- RAW device access. So I took it out */
-/* } else if (*name == '\\' && name[1] == '\\') {
+ * and it removes a backslash from e.g. "\\.\c:" which I need for
+ * RAW device access. So I took it out.
+ */
+#ifdef needed
+ } else if (*name == '\\' && name[1] == '\\') {
*win32_name++ = '\\';
- name++; */ /* skip first \ */
+ name++; /* skip first \ */
+#endif
} else {
*win32_name++ = *name; /* copy character */
}
*win32_name = 0;
/* here we convert to VSS specific file name which
- can get longer because VSS will make something like
- \\\\?\\GLOBALROOT\\Device\\HarddiskVolumeShadowCopy1\\bacula\\uninstall.exe
- from c:\bacula\uninstall.exe
+ * can get longer because VSS will make something like
+ * \\\\?\\GLOBALROOT\\Device\\HarddiskVolumeShadowCopy1\\bacula\\uninstall.exe
+ * from c:\bacula\uninstall.exe
*/
if (g_pVSSPathConvertW != NULL) {
/* is output buffer large enough? */
nParseOffset = 4;
else
nParseOffset = 0;
- wcsncpy((wchar_t *) pszBuf, (wchar_t *) pwszBuf+nParseOffset, wcslen((wchar_t *)pwszBuf)+1-nParseOffset);
- g_pVSSPathConvertW((wchar_t *)pszBuf,(wchar_t *)pwszBuf,dwBufCharsNeeded+MAX_PATH);
+ wcsncpy((wchar_t *)pszBuf, (wchar_t *)pwszBuf+nParseOffset, wcslen((wchar_t *)pwszBuf)+1-nParseOffset);
+ g_pVSSPathConvertW((wchar_t *)pszBuf, (wchar_t *)pwszBuf, dwBufCharsNeeded+MAX_PATH);
free_pool_memory(pszBuf);
}
free_pool_memory(pszUCSPath);
free_pool_memory(pwszCurDirBuf);
+ Dmsg1(100, "Leave wchar_win32_path=%s\n", pwszBuf);
return pwszBuf;
}
FILETIME* pftCreationTime;
if (file[1] == ':' && file[2] == 0) {
- d_msg(__FILE__, __LINE__, 99, "faking ROOT attrs(%s).\n", file);
+ Dmsg1(99, "faking ROOT attrs(%s).\n", file);
sb->st_mode = S_IFDIR;
sb->st_mode |= S_IREAD|S_IEXEC|S_IWRITE;
time(&sb->st_ctime);
if (h == INVALID_HANDLE_VALUE) {
const char *err = errorString();
- d_msg(__FILE__, __LINE__, 99, "FindFirstFile(%s):%s\n", file, err);
+ Dmsg2(99, "FindFirstFile(%s):%s\n", file, err);
LocalFree((void *)err);
errno = b_errno_win32;
return -1;
if (!GetFileInformationByHandle((HANDLE)fd, &info)) {
const char *err = errorString();
- d_msg(__FILE__, __LINE__, 99,
- "GetfileInformationByHandle(%s): %s\n", tmpbuf, err);
+ Dmsg2(99, "GetfileInformationByHandle(%s): %s\n", tmpbuf, err);
LocalFree((void *)err);
errno = b_errno_win32;
return -1;
sb->st_ino |= info.nFileIndexLow;
sb->st_nlink = (short)info.nNumberOfLinks;
if (sb->st_nlink > 1) {
- d_msg(__FILE__, __LINE__, 99, "st_nlink=%d\n", sb->st_nlink);
+ Dmsg1(99, "st_nlink=%d\n", sb->st_nlink);
}
sb->st_mode = 0777; /* start with everything */
if (attr == (DWORD)-1) {
const char *err = errorString();
- d_msg(__FILE__, __LINE__, 99,
- "GetFileAttributes(%s): %s\n", tmpbuf, err);
+ Dmsg2(99, "GetFileAttributes(%s): %s\n", tmpbuf, err);
LocalFree((void *)err);
errno = b_errno_win32;
return -1;
if (h == INVALID_HANDLE_VALUE) {
const char *err = errorString();
- d_msg(__FILE__, __LINE__, 99,
- "Cannot open file for stat (%s):%s\n", tmpbuf, err);
+ Dmsg2(99, "Cannot open file for stat (%s):%s\n", tmpbuf, err);
LocalFree((void *)err);
errno = b_errno_win32;
return -1;
return NULL;
}
+ Dmsg1(100, "Opendir path=%s\n", path);
rval = (_dir *)malloc(sizeof(_dir));
memset (rval, 0, sizeof (_dir));
if (rval == NULL) return NULL;
#ifdef WIN32_VSS
/* will append \\?\ at front itself */
conv_unix_to_win32_path(path, tspec, max_len-4);
+ Dmsg1(100, "win32 path=%s\n", tspec);
#else
/* allow path to be 32767 bytes */
tspec[0] = '\\';
tspec[3] = '\\';
tspec[4] = 0;
conv_unix_to_win32_path(path, tspec+4, max_len-4);
+ Dmsg1(100, "win32 path=%s\n", tspec);
#endif
} else {
conv_unix_to_win32_path(path, tspec, max_len);
+ Dmsg1(100, "win32 path=%s\n", tspec);
}
// add backslash only if there is none yet (think of c:\)
// convert to wchar_t
if (p_FindFirstFileW) {
POOLMEM* pwcBuf = get_pool_memory(PM_FNAME);;
- make_win32_path_UTF8_2_wchar(&pwcBuf,rval->spec);
+ make_win32_path_UTF8_2_wchar(&pwcBuf, rval->spec);
rval->dirh = p_FindFirstFileW((LPCWSTR)pwcBuf, &rval->data_w);
} else goto err;
- d_msg(__FILE__, __LINE__,
- 99, "opendir(%s)\n\tspec=%s,\n\tFindFirstFile returns %d\n",
+ Dmsg3(99, "opendir(%s)\n\tspec=%s,\n\tFindFirstFile returns %d\n",
path, rval->spec, rval->dirh);
rval->offset = 0;
if (rval->dirh == INVALID_HANDLE_VALUE)
goto err;
- if (rval->valid_w)
- d_msg(__FILE__, __LINE__,
- 99, "\tFirstFile=%s\n", rval->data_w.cFileName);
+ if (rval->valid_w) {
+ Dmsg1(99, "\tFirstFile=%s\n", rval->data_w.cFileName);
+ }
- if (rval->valid_a)
- d_msg(__FILE__, __LINE__,
- 99, "\tFirstFile=%s\n", rval->data_a.cFileName);
+ if (rval->valid_a) {
+ Dmsg1(99, "\tFirstFile=%s\n", rval->data_a.cFileName);
+ }
return (DIR *)rval;
}
*result = entry; /* return entry address */
- d_msg(__FILE__, __LINE__,
- 99, "readdir_r(%p, { d_name=\"%s\", d_reclen=%d, d_off=%d\n",
+ Dmsg4(99, "readdir_r(%p, { d_name=\"%s\", d_reclen=%d, d_off=%d\n",
dirp, entry->d_name, entry->d_reclen, entry->d_off);
} else {
-// d_msg(__FILE__, __LINE__, 99, "readdir_r !valid\n");
+// Dmsg0(99, "readdir_r !valid\n");
errno = b_errno_win32;
return -1;
}
if (bFuncRetn == 0) {
ErrorExit("CreateProcess failed\n");
const char *err = errorString();
- d_msg(__FILE__, __LINE__, 99,
- "CreateProcess(%s, %s, ...)=%s\n", exeFile, cmdLine, err);
+ Dmsg3(99, "CreateProcess(%s, %s, ...)=%s\n", exeFile, cmdLine, err);
LocalFree((void *)err);
return INVALID_HANDLE_VALUE;
}
void
ErrorExit (LPCSTR lpszMessage)
{
- d_msg(__FILE__, __LINE__, 0, "%s", lpszMessage);
+ Dmsg1(0, "%s", lpszMessage);
}
if (!GetExitCodeProcess((HANDLE)bpipe->worker_pid, &exitCode)) {
const char *err = errorString();
rval = b_errno_win32;
- d_msg(__FILE__, __LINE__, 0,
- "GetExitCode error %s\n", err);
+ Dmsg1(0, "GetExitCode error %s\n", err);
LocalFree((void *)err);
break;
}
if (h == INVALID_HANDLE_VALUE) {
const char *err = errorString();
- d_msg(__FILE__, __LINE__, 99,
- "Cannot open file \"%s\" for utime(): ERR=%s", tmpbuf, err);
+ Dmsg2(99, "Cannot open file \"%s\" for utime(): ERR=%s", tmpbuf, err);
LocalFree((void *)err);
errno = b_errno_win32;
return -1;