Skip to content

Commit

Permalink
check-sources: apply bareos-check-sources
Browse files Browse the repository at this point in the history
  • Loading branch information
sebsura authored and pstorz committed Jun 27, 2023
1 parent d2aae2a commit b6fbdf8
Show file tree
Hide file tree
Showing 18 changed files with 899 additions and 872 deletions.
8 changes: 4 additions & 4 deletions core/src/dird/dird_conf.cc
Expand Up @@ -688,10 +688,10 @@ struct s_kw ActionOnPurgeOptions[]
*
* name token
*/
struct s_kw VolumeStatus[] = {{"Append", 0}, {"Full", 0}, {"Used", 0},
{"Recycle", 0}, {"Purged", 0}, {"Cleaning", 0},
{"Error", 0}, {"Archive", 0}, {"Disabled", 0},
{NULL, 0}};
struct s_kw VolumeStatus[]
= {{"Append", 0}, {"Full", 0}, {"Used", 0}, {"Recycle", 0},
{"Purged", 0}, {"Cleaning", 0}, {"Error", 0}, {"Archive", 0},
{"Disabled", 0}, {NULL, 0}};

/**
* Keywords (RHS) permitted in Pool type records
Expand Down
47 changes: 24 additions & 23 deletions core/src/filed/dir_cmd.cc
Expand Up @@ -1812,25 +1812,26 @@ static bool BackupCmd(JobControlRecord* jcr)
// Plugin driver can return drive letters
GeneratePluginEvent(jcr, bEventVssPrepareSnapshot, szWinDriveLetters);

std::vector<std::wstring> volumes = get_win32_volumes(jcr->fd_impl->ff->fileset);
std::vector<std::wstring> volumes
= get_win32_volumes(jcr->fd_impl->ff->fileset);

{
char drive[] = "_:";
for (std::size_t i = 0; i < sizeof(szWinDriveLetters) && szWinDriveLetters[i]; ++i) {
drive[0] = szWinDriveLetters[i];
std::wstring wdrive = FromUtf8(drive);
if (GetDriveTypeW(wdrive.c_str()) == DRIVE_FIXED) {
volumes.emplace_back(std::move(wdrive));
}
}
char drive[] = "_:";
for (std::size_t i = 0;
i < sizeof(szWinDriveLetters) && szWinDriveLetters[i]; ++i) {
drive[0] = szWinDriveLetters[i];
std::wstring wdrive = FromUtf8(drive);
if (GetDriveTypeW(wdrive.c_str()) == DRIVE_FIXED) {
volumes.emplace_back(std::move(wdrive));
}
}
}

onefs_disabled = win32_onefs_is_disabled(jcr->fd_impl->ff->fileset);

volume_count = volumes.size();
if (volume_count > 0) {
Jmsg(jcr, M_INFO, 0,
_("Generate VSS snapshots. Driver=\"%s\"\n"),
Jmsg(jcr, M_INFO, 0, _("Generate VSS snapshots. Driver=\"%s\"\n"),
jcr->fd_impl->pVSSClient->GetDriverName());

if (!jcr->fd_impl->pVSSClient->CreateSnapshots(volumes,
Expand All @@ -1845,20 +1846,20 @@ static bool BackupCmd(JobControlRecord* jcr)
// Inform about VMPs if we have them
jcr->fd_impl->pVSSClient->ShowVolumeMountPointStats(jcr);

VSSClient* client = jcr->fd_impl->pVSSClient;
VSSClient* client = jcr->fd_impl->pVSSClient;

// Tell the user about the created shadow copies
for (auto [mount, vol] : client->mount_to_vol) {
if (auto found = client->vol_to_vss.find(vol);
found != client->vol_to_vss.end()) {
Jmsg(jcr, M_INFO, 0, "(%s)%s -> %s\n",
mount.c_str(), vol.c_str(), found->second.c_str());
} else {
Jmsg(jcr, M_FATAL, 0, "No snapshot for volume %s (aka. %s) was generated.\n",
mount.c_str(), vol.c_str());

}
}
for (auto [mount, vol] : client->mount_to_vol) {
if (auto found = client->vol_to_vss.find(vol);
found != client->vol_to_vss.end()) {
Jmsg(jcr, M_INFO, 0, "(%s)%s -> %s\n", mount.c_str(), vol.c_str(),
found->second.c_str());
} else {
Jmsg(jcr, M_FATAL, 0,
"No snapshot for volume %s (aka. %s) was generated.\n",
mount.c_str(), vol.c_str());
}
}

// Inform user about writer states
for (size_t i = 0; i < jcr->fd_impl->pVSSClient->GetWriterCount();
Expand Down
2 changes: 1 addition & 1 deletion core/src/findlib/attribs.cc
Expand Up @@ -524,7 +524,7 @@ int encode_attribsEx(JobControlRecord* jcr,
std::wstring utf16 = make_win32_path_UTF8_2_wchar(ff_pkt->fname);

if (!p_GetFileAttributesExW(utf16.c_str(), GetFileExInfoStandard,
(LPVOID)&atts)) {
(LPVOID)&atts)) {
WinError(jcr, "GetFileAttributesExW:", ff_pkt->sys_fname);
return STREAM_UNIX_ATTRIBUTES;
}
Expand Down
81 changes: 37 additions & 44 deletions core/src/findlib/bfile.cc
Expand Up @@ -517,8 +517,7 @@ static inline int BopenEncrypted(BareosFilePacket* bfd,

// Unicode open.
Dmsg1(100, "OpenEncryptedFileRawW=%s\n", FromUtf16(utf16).c_str());
if (p_OpenEncryptedFileRawW(utf16.c_str(), ulFlags,
&(bfd->pvContext))) {
if (p_OpenEncryptedFileRawW(utf16.c_str(), ulFlags, &(bfd->pvContext))) {
bfd->mode = BF_CLOSED;
}
} else {
Expand Down Expand Up @@ -584,25 +583,23 @@ static inline int BopenNonencrypted(BareosFilePacket* bfd,
if (p_CreateFileW && p_MultiByteToWideChar) {
std::wstring utf16 = make_win32_path_UTF8_2_wchar(fname);
Dmsg1(100, "Create CreateFileW=%s\n", FromUtf16(utf16).c_str());
bfd->fh = p_CreateFileW(utf16.c_str(),
dwaccess, /* Requested access */
0, /* Shared mode */
NULL, /* SecurityAttributes */
CREATE_ALWAYS, /* CreationDisposition */
dwflags, /* Flags and attributes */
NULL); /* TemplateFile */
bfd->fh = p_CreateFileW(utf16.c_str(), dwaccess, /* Requested access */
0, /* Shared mode */
NULL, /* SecurityAttributes */
CREATE_ALWAYS, /* CreationDisposition */
dwflags, /* Flags and attributes */
NULL); /* TemplateFile */
} else {
PoolMem ansi(PM_FNAME);
unix_name_to_win32(ansi.addr(), fname);
// ASCII open
Dmsg1(100, "Create CreateFileA=%s\n", ansi.c_str());
bfd->fh = p_CreateFileA(ansi.c_str(),
dwaccess, /* Requested access */
0, /* Shared mode */
NULL, /* SecurityAttributes */
CREATE_ALWAYS, /* CreationDisposition */
dwflags, /* Flags and attributes */
NULL); /* TemplateFile */
bfd->fh = p_CreateFileA(ansi.c_str(), dwaccess, /* Requested access */
0, /* Shared mode */
NULL, /* SecurityAttributes */
CREATE_ALWAYS, /* CreationDisposition */
dwflags, /* Flags and attributes */
NULL); /* TemplateFile */
}

bfd->mode = BF_WRITE;
Expand All @@ -624,25 +621,23 @@ static inline int BopenNonencrypted(BareosFilePacket* bfd,
// unicode open for open existing write
std::wstring utf16 = make_win32_path_UTF8_2_wchar(fname);
Dmsg1(100, "Write only CreateFileW=%s\n", FromUtf16(utf16).c_str());
bfd->fh = p_CreateFileW(utf16.c_str(),
dwaccess, /* Requested access */
0, /* Shared mode */
NULL, /* SecurityAttributes */
OPEN_EXISTING, /* CreationDisposition */
dwflags, /* Flags and attributes */
NULL); /* TemplateFile */
bfd->fh = p_CreateFileW(utf16.c_str(), dwaccess, /* Requested access */
0, /* Shared mode */
NULL, /* SecurityAttributes */
OPEN_EXISTING, /* CreationDisposition */
dwflags, /* Flags and attributes */
NULL); /* TemplateFile */
} else {
PoolMem ansi(PM_FNAME);
unix_name_to_win32(ansi.addr(), fname);
// ASCII open
Dmsg1(100, "Write only CreateFileA=%s\n", ansi.c_str());
bfd->fh = p_CreateFileA(ansi.c_str(),
dwaccess, /* Requested access */
0, /* Shared mode */
NULL, /* SecurityAttributes */
OPEN_EXISTING, /* CreationDisposition */
dwflags, /* Flags and attributes */
NULL); /* TemplateFile */
bfd->fh = p_CreateFileA(ansi.c_str(), dwaccess, /* Requested access */
0, /* Shared mode */
NULL, /* SecurityAttributes */
OPEN_EXISTING, /* CreationDisposition */
dwflags, /* Flags and attributes */
NULL); /* TemplateFile */
}

bfd->mode = BF_WRITE;
Expand All @@ -667,25 +662,23 @@ static inline int BopenNonencrypted(BareosFilePacket* bfd,
// Unicode open for open existing read
std::wstring utf16 = make_win32_path_UTF8_2_wchar(fname);
Dmsg1(100, "Read CreateFileW=%s\n", FromUtf16(utf16).c_str());
bfd->fh = p_CreateFileW(utf16.c_str(),
dwaccess, /* Requested access */
dwshare, /* Share modes */
NULL, /* SecurityAttributes */
OPEN_EXISTING, /* CreationDisposition */
dwflags, /* Flags and attributes */
NULL); /* TemplateFile */
bfd->fh = p_CreateFileW(utf16.c_str(), dwaccess, /* Requested access */
dwshare, /* Share modes */
NULL, /* SecurityAttributes */
OPEN_EXISTING, /* CreationDisposition */
dwflags, /* Flags and attributes */
NULL); /* TemplateFile */
} else {
PoolMem ansi(PM_FNAME);
unix_name_to_win32(ansi.addr(), fname);
// ASCII open
Dmsg1(100, "Read CreateFileA=%s\n", ansi.c_str());
bfd->fh = p_CreateFileA(ansi.c_str(),
dwaccess, /* Requested access */
dwshare, /* Share modes */
NULL, /* SecurityAttributes */
OPEN_EXISTING, /* CreationDisposition */
dwflags, /* Flags and attributes */
NULL); /* TemplateFile */
bfd->fh = p_CreateFileA(ansi.c_str(), dwaccess, /* Requested access */
dwshare, /* Share modes */
NULL, /* SecurityAttributes */
OPEN_EXISTING, /* CreationDisposition */
dwflags, /* Flags and attributes */
NULL); /* TemplateFile */
}

bfd->mode = BF_READ;
Expand Down
3 changes: 2 additions & 1 deletion core/src/include/baconfig.h
Expand Up @@ -538,7 +538,8 @@ int Getdomainname(char* name, int len);
# define DEFAULT_CONFIGDIR "C:\\Documents and Settings\\All Users\\Bareos"
# define PathSeparator '\\'

inline bool IsPathSeparator(int ch) {
inline bool IsPathSeparator(int ch)
{
// check that this works regardless of whether one uses
// wchar_t or char
static_assert(int{L'/'} == int{'/'});
Expand Down
16 changes: 6 additions & 10 deletions core/src/tests/CMakeLists.txt
Expand Up @@ -367,19 +367,15 @@ if(NOT HAVE_WIN32 AND NOT client-only)
bareos_add_test(watchdog_timer LINK_LIBRARIES bareos GTest::gtest_main)
endif() # NOT HAVE_WIN32 AND NOT client-only

if (HAVE_WIN32)
if(HAVE_WIN32)
bareos_add_test(
test_unicode_conversion
LINK_LIBRARIES
bareos
GTest::gtest_main)
test_unicode_conversion LINK_LIBRARIES bareos GTest::gtest_main
)
bareos_add_test(
test_path_conversion
ADDITIONAL_SOURCES
compat_old_conversion.cc
LINK_LIBRARIES
bareos
GTest::gtest_main)
ADDITIONAL_SOURCES compat_old_conversion.cc
LINK_LIBRARIES bareos GTest::gtest_main
)
endif()
if(ENABLE_BCONSOLE)
bareos_add_test(
Expand Down

0 comments on commit b6fbdf8

Please sign in to comment.