Skip to content

Commit

Permalink
adaptions for win32
Browse files Browse the repository at this point in the history
  • Loading branch information
pstorz authored and arogge committed Nov 2, 2022
1 parent d3da545 commit 5c2ed45
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 33 deletions.
2 changes: 1 addition & 1 deletion core/src/findlib/bfile.h
Expand Up @@ -85,7 +85,7 @@ struct BareosWinFilePacket {
int BErrNo = 0; /**< errno */
boffset_t offset = 0; /**< Delta offset */
JobControlRecord* jcr = nullptr; /**< jcr for editing job codes */
PROCESS_WIN32_BACKUPAPIBLOCK_CONTEXT win32Decomplugin_private_context{0}; /**< context for decomposition
PROCESS_WIN32_BACKUPAPIBLOCK_CONTEXT win32Decomplugin_private_context{}; /**< context for decomposition
of win32 backup streams */
int use_backup_decomp = 0; /**< set if using BackupRead Stream Decomposition */
bool reparse_point = false; /**< set if reparse point */
Expand Down
5 changes: 5 additions & 0 deletions core/src/lib/CMakeLists.txt
Expand Up @@ -113,6 +113,11 @@ if(HAVE_WIN32)
set_source_files_properties(
../win32/compat/glob.cc PROPERTIES COMPILE_DEFINITIONS register=
)
set_source_files_properties(
../win32/compat/winapi.cc ../win32/compat/service.cc
../win32/generic/service.cc osinfo_win32.cc
PROPERTIES COMPILE_FLAGS -Wno-cast-function-type
)

else()
list(APPEND BAREOS_SRCS scsi_tapealert.cc)
Expand Down
6 changes: 4 additions & 2 deletions core/src/lib/bpoll.cc
Expand Up @@ -2,7 +2,7 @@
BAREOS® - Backup Archiving REcovery Open Sourced
Copyright (C) 2011-2012 Planets Communications B.V.
Copyright (C) 2013-2018 Bareos GmbH & Co. KG
Copyright (C) 2013-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
Expand Down Expand Up @@ -151,7 +151,9 @@ int WaitForReadableFd(int fd, int msec, bool ignore_interupts)
* 0 if timeout
* -1 if error
*/
int WaitForWritableFd(int fd, int msec, bool ignore_interupts)
int WaitForWritableFd([[maybe_unused]] int fd,
[[maybe_unused]] int msec,
[[maybe_unused]] bool ignore_interupts)
{
# if defined(HAVE_WIN32)
return 1;
Expand Down
6 changes: 3 additions & 3 deletions core/src/lib/daemon.cc
Expand Up @@ -38,9 +38,9 @@

#if defined(HAVE_WIN32)

void daemon_start(const char* progname,
int pidfile_fd,
std::string pidfile_path)
void daemon_start([[maybe_unused]] const char* progname,
[[maybe_unused]] int pidfile_fd,
[[maybe_unused]] std::string pidfile_path)
{
return;
}
Expand Down
6 changes: 4 additions & 2 deletions core/src/lib/guid_to_name.cc
Expand Up @@ -94,7 +94,8 @@ static int GidCompare(guitem* item1, guitem* item2)
}


static void GetUidname(uid_t uid, guitem* item)
static void GetUidname([[maybe_unused]] uid_t uid,
[[maybe_unused]] guitem* item)
{
#ifndef HAVE_WIN32
struct passwd* pwbuf;
Expand All @@ -107,7 +108,8 @@ static void GetUidname(uid_t uid, guitem* item)
#endif
}

static void GetGidname(gid_t gid, guitem* item)
static void GetGidname([[maybe_unused]] gid_t gid,
[[maybe_unused]] guitem* item)
{
#ifndef HAVE_WIN32
struct group* grbuf;
Expand Down
11 changes: 6 additions & 5 deletions core/src/lib/mntent_cache.cc
Expand Up @@ -223,11 +223,12 @@ static inline bool SkipFstype(const char* fstype)
* This function should be called with a write lock on the mntent_cache.
*/
static void refresh_mount_cache(
mntent_cache_entry_t* handle_entry(uint32_t dev,
const char* special,
const char* mountpoint,
const char* fstype,
const char* mntopts))
[[maybe_unused]] mntent_cache_entry_t* handle_entry(
[[maybe_unused]] uint32_t dev,
[[maybe_unused]] const char* special,
[[maybe_unused]] const char* mountpoint,
[[maybe_unused]] const char* fstype,
[[maybe_unused]] const char* mntopts))
{
#if defined(HAVE_GETMNTENT)
FILE* fp;
Expand Down
6 changes: 4 additions & 2 deletions core/src/lib/priv.cc
Expand Up @@ -2,7 +2,7 @@
BAREOS® - Backup Archiving REcovery Open Sourced
Copyright (C) 2000-2011 Free Software Foundation Europe e.V.
Copyright (C) 2013-2021 Bareos GmbH & Co. KG
Copyright (C) 2013-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
Expand Down Expand Up @@ -44,7 +44,9 @@ extern "C" int initgroups(const char*, int);
* Lower privileges by switching to new UID and GID if non-NULL.
* If requested, keep readall capabilities after switch.
*/
void drop(char* uname, char* gname, bool keep_readall_caps)
void drop([[maybe_unused]] char* uname,
[[maybe_unused]] char* gname,
[[maybe_unused]] bool keep_readall_caps)
{
#if defined(HAVE_PWD_H) && defined(HAVE_GRP_H)
struct passwd* passw = NULL;
Expand Down
4 changes: 2 additions & 2 deletions core/src/stored/ndmp_tape.cc
Expand Up @@ -1305,8 +1305,8 @@ void StopNdmpThreadServer()
}
}
#else
void EndOfNdmpBackup(JobControlRecord* jcr) {}
void EndOfNdmpBackup([[maybe_unused]] JobControlRecord* jcr) {}

void EndOfNdmpRestore(JobControlRecord* jcr) {}
void EndOfNdmpRestore([[maybe_unused]] JobControlRecord* jcr) {}
#endif /* HAVE_NDMP */
} /* namespace storagedaemon */
37 changes: 28 additions & 9 deletions core/src/win32/compat/compat.cc
Expand Up @@ -832,11 +832,21 @@ char* dlerror(void)
return buf;
}

int fcntl(int fd, int cmd) { return 0; }
int fcntl([[maybe_unused]] int fd, [[maybe_unused]] int cmd) { return 0; }

int chown(const char* k, uid_t, gid_t) { return 0; }
int chown([[maybe_unused]] const char* k,
[[maybe_unused]] uid_t,
[[maybe_unused]] gid_t)
{
return 0;
}

int lchown(const char* k, uid_t, gid_t) { return 0; }
int lchown([[maybe_unused]] const char* k,
[[maybe_unused]] uid_t,
[[maybe_unused]] gid_t)
{
return 0;
}

long int random(void) { return rand(); }

Expand Down Expand Up @@ -1794,7 +1804,7 @@ int win32_ftruncate(int fd, int64_t length)
return 0;
}

int fcntl(int fd, int cmd, long arg)
int fcntl([[maybe_unused]] int fd, int cmd, [[maybe_unused]] long arg)
{
int rval = 0;

Expand Down Expand Up @@ -1939,7 +1949,8 @@ int win32_symlink(const char* name1, const char* name2, _dev_t st_rdev)
}

// Create a hardlink
int link(const char* existing, const char* newfile)
int link([[maybe_unused]] const char* existing,
[[maybe_unused]] const char* newfile)
{
errno = ENOSYS;
return -1;
Expand All @@ -1951,7 +1962,7 @@ int gettimeofday(struct timeval* tv, struct timezone* tz)
}

// Write in Windows System log
extern "C" void syslog(int type, const char* fmt, ...)
extern "C" void syslog([[maybe_unused]] int type, const char* fmt, ...)
{
va_list arg_ptr;
int len, maxlen;
Expand Down Expand Up @@ -2158,7 +2169,7 @@ int inet_aton(const char* a, struct in_addr* inp)
return 1;
}

void InitSignals(void Terminate(int sig)) {}
void InitSignals([[maybe_unused]] void Terminate(int sig)) {}

void InitStackDump(void) {}

Expand All @@ -2167,6 +2178,7 @@ long pathconf(const char* path, int name)
switch (name) {
case _PC_PATH_MAX:
if (strncmp(path, "\\\\?\\", 4) == 0) return 32767;
[[fallthrough]];
case _PC_NAME_MAX:
return 255;
}
Expand Down Expand Up @@ -3004,7 +3016,10 @@ static void CloseHandleIfValid(HANDLE handle)
if (handle != INVALID_HANDLE_VALUE) { CloseHandle(handle); }
}

Bpipe* OpenBpipe(char* prog, int wait, const char* mode, bool dup_stderr)
Bpipe* OpenBpipe(char* prog,
int wait,
const char* mode,
[[maybe_unused]] bool dup_stderr)
{
int mode_read, mode_write;
SECURITY_ATTRIBUTES saAttr;
Expand Down Expand Up @@ -3199,7 +3214,11 @@ int CloseWpipe(Bpipe* bpipe)
}

// Syslog function, added by Nicolas Boichat
extern "C" void openlog(const char* ident, int option, int facility) {}
extern "C" void openlog([[maybe_unused]] const char* ident,
[[maybe_unused]] int option,
[[maybe_unused]] int facility)
{
}

// Log an error message
void LogErrorMsg(const char* message)
Expand Down
4 changes: 2 additions & 2 deletions core/src/win32/compat/winapi.cc
Expand Up @@ -3,7 +3,7 @@
Copyright (C) 2003-2008 Free Software Foundation Europe e.V.
Copyright (C) 2011-2012 Planets Communications B.V.
Copyright (C) 2013-2017 Bareos GmbH & Co. KG
Copyright (C) 2013-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
Expand Down Expand Up @@ -108,7 +108,7 @@ t_GetLogicalDriveStringsW p_GetLogicalDriveStringsW = NULL;

void InitWinAPIWrapper()
{
OSVERSIONINFO osversioninfo = {sizeof(OSVERSIONINFO)};
OSVERSIONINFO osversioninfo = {sizeof(OSVERSIONINFO), 0, 0, 0, 0, 0};

// Get the current OS version
if (!GetVersionEx(&osversioninfo)) {
Expand Down
4 changes: 2 additions & 2 deletions core/src/win32/generic/main.cc
Expand Up @@ -2,7 +2,7 @@
BAREOS® - Backup Archiving REcovery Open Sourced
Copyright (C) 2007-2011 Free Software Foundation Europe e.V.
Copyright (C) 2016-2020 Bareos GmbH & Co. KG
Copyright (C) 2016-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
Expand Down Expand Up @@ -234,7 +234,7 @@ LRESULT CALLBACK bacWinProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
* Called as a thread from BareosAppMain()
* Here we handle the Windows messages
*/
void* Main_Msg_Loop(LPVOID lpwThreadParam)
void* Main_Msg_Loop([[maybe_unused]] LPVOID lpwThreadParam)
{
MSG msg;

Expand Down
7 changes: 4 additions & 3 deletions core/src/win32/generic/service.cc
Expand Up @@ -2,7 +2,7 @@
BAREOS® - Backup Archiving REcovery Open Sourced
Copyright (C) 2007-2010 Free Software Foundation Europe e.V.
Copyright (C) 2013-2017 Bareos GmbH & Co. KG
Copyright (C) 2013-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
Expand Down Expand Up @@ -76,7 +76,8 @@ int stopRunningBareos()
* the OS returns control here immediately after starting
* the service.
*/
void WINAPI serviceStartCallback(DWORD argc, char** argv)
void WINAPI serviceStartCallback([[maybe_unused]] DWORD argc,
[[maybe_unused]] char** argv)
{
DWORD dwThreadID;

Expand Down Expand Up @@ -176,7 +177,7 @@ int bareosServiceMain()
}

// New style service bareos worker thread
DWORD WINAPI bareosWorkerThread(LPVOID lpwThreadParam)
DWORD WINAPI bareosWorkerThread([[maybe_unused]] LPVOID lpwThreadParam)
{
service_thread_id = GetCurrentThreadId();

Expand Down

0 comments on commit 5c2ed45

Please sign in to comment.