From e06acd00a42ff9dfe0e83649a437f0d92ea01b2c Mon Sep 17 00:00:00 2001 From: Marco van Wieringen Date: Wed, 14 May 2014 16:08:54 +0200 Subject: [PATCH] Fix root directory stat() call. --- src/win32/compat/compat.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/win32/compat/compat.c b/src/win32/compat/compat.c index 2001bade00f..0cc8a1c54c5 100644 --- a/src/win32/compat/compat.c +++ b/src/win32/compat/compat.c @@ -435,6 +435,8 @@ static POOLMEM *make_wchar_win32_path(POOLMEM *pszUCSPath, BOOL *pBIsRawPath /*= wchar_t *win32_name = &pwszBuf[nParseOffset]; wchar_t *name_start = name; + wchar_t previous_char = 0; + wchar_t next_char = 0; while (*name) { /* @@ -444,10 +446,12 @@ static POOLMEM *make_wchar_win32_path(POOLMEM *pszUCSPath, BOOL *pBIsRawPath /*= /* * Don't add a trailing slash. */ - if (!*(name + 1)) { + next_char = *(name + 1); + if (previous_char != ':' && next_char == '\0') { name++; continue; } + previous_char = '\\'; *win32_name++ = '\\'; /* convert char */ /* @@ -457,6 +461,7 @@ static POOLMEM *make_wchar_win32_path(POOLMEM *pszUCSPath, BOOL *pBIsRawPath /*= name++; } } else { + previous_char = *name; *win32_name++ = *name; /* copy character */ } name++; @@ -1159,8 +1164,8 @@ int fstat(intptr_t fd, struct stat *sb) Dmsg1(dbglvl, "st_nlink=%d\n", sb->st_nlink); } - sb->st_mode |= S_IFREG; sb->st_mode = 0777; + sb->st_mode |= S_IFREG; /* * See if we need to encode in the old Bacula compatible way.