Skip to content

Commit

Permalink
filed: implemented namespace "filedaemon"
Browse files Browse the repository at this point in the history
       - implemented "namespace filedaemon {}" in all files below subir "filed"
       - using namespace filedaemon; in all file daemon main program modules
       - implemented namespace qualifiers "filedaemon::" in all surrounding code that
         uses director namespace

       - some functions were left outside of filedaemon namespace; their names
         have to be in the global namespace because they are statically overloaded
         at library compile time with functions from storage or directordaemon
  • Loading branch information
franku committed Sep 17, 2018
1 parent 36f6b05 commit 41d2933
Show file tree
Hide file tree
Showing 51 changed files with 579 additions and 181 deletions.
4 changes: 2 additions & 2 deletions core/src/filed/CMakeLists.txt
Expand Up @@ -28,8 +28,8 @@ ELSE()
ENDIF()

set(FDSRCS accurate.cc authenticate.cc crypto.cc fd_plugins.cc fileset.cc sd_cmds.cc verify.cc
accurate_htable.cc backup.cc dir_cmd.cc filed.cc heartbeat.cc socket_server.cc verify_vol.cc
accurate_lmdb.cc compression.cc estimate.cc filed_conf.cc restore.cc status.cc)
accurate_htable.cc backup.cc dir_cmd.cc filed.cc filed_globals.cc heartbeat.cc socket_server.cc
verify_vol.cc accurate_lmdb.cc compression.cc estimate.cc filed_conf.cc restore.cc status.cc)

IF(HAVE_WIN32)
LIST(APPEND FDSRCS
Expand Down
5 changes: 5 additions & 0 deletions core/src/filed/accurate.cc
Expand Up @@ -24,10 +24,13 @@
#include "include/bareos.h"
#include "filed/filed.h"
#include "filed/accurate.h"
#include "filed/filed_globals.h"
#include "filed/verify.h"
#include "lib/attribs.h"
#include "lib/edit.h"

namespace filedaemon {

static int debuglevel = 100;

bool AccurateMarkFileAsSeen(JobControlRecord *jcr, char *fname)
Expand Down Expand Up @@ -414,3 +417,5 @@ bool AccurateCmd(JobControlRecord *jcr)

return true;
}

} /* namespace filedaemon */
3 changes: 3 additions & 0 deletions core/src/filed/accurate.h
Expand Up @@ -47,6 +47,8 @@
#pragma pack(push,4)
#endif

namespace filedaemon {

struct accurate_payload {
int64_t filenr;
int32_t delta_seq;
Expand Down Expand Up @@ -202,4 +204,5 @@ bool accurate_unMarkAllFilesAsSeen(JobControlRecord *jcr);
void AccurateFree(JobControlRecord *jcr);


} /* namespace filedaemon */
#endif /* BAREOS_FILED_ACCURATE_H_ */
4 changes: 4 additions & 0 deletions core/src/filed/accurate_htable.cc
Expand Up @@ -33,6 +33,8 @@
#include "accurate.h"
#include "lib/attribs.h"

namespace filedaemon {

static int debuglevel = 100;

BareosAccurateFilelistHtable::BareosAccurateFilelistHtable(JobControlRecord *jcr, uint32_t number_of_files)
Expand Down Expand Up @@ -194,3 +196,5 @@ void BareosAccurateFilelistHtable::destroy()

filenr_ = 0;
}

} /* namespace filedaemon */
7 changes: 6 additions & 1 deletion core/src/filed/accurate_lmdb.cc
Expand Up @@ -28,11 +28,15 @@

#include "include/bareos.h"
#include "filed/filed.h"
#include "filed/filed_globals.h"

#ifdef HAVE_LMDB

#include "accurate.h"
#endif

namespace filedaemon {

#ifdef HAVE_LMDB
static int debuglevel = 100;

#define AVG_NR_BYTES_PER_ENTRY 256
Expand Down Expand Up @@ -572,3 +576,4 @@ void BareosAccurateFilelistLmdb::destroy()
filenr_ = 0;
}
#endif /* HAVE_LMDB */
} /* namespace filedaemon */
5 changes: 5 additions & 0 deletions core/src/filed/authenticate.cc
Expand Up @@ -30,7 +30,11 @@

#include "include/bareos.h"
#include "filed/filed.h"
#include "filed/filed_globals.h"
#include "lib/bnet.h"
#include "restore.h"

namespace filedaemon {

const int debuglevel = 50;

Expand Down Expand Up @@ -195,3 +199,4 @@ bool AuthenticateWithStoragedaemon(JobControlRecord *jcr)

return result;
}
} /* namespace filedaemon */
31 changes: 31 additions & 0 deletions core/src/filed/authenticate.h
@@ -1,5 +1,36 @@
/*
BAREOS® - Backup Archiving REcovery Open Sourced
Copyright (C) 2000-2010 Free Software Foundation Europe e.V.
Copyright (C) 2011-2012 Planets Communications B.V.
Copyright (C) 2013-2018 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
License as published by the Free Software Foundation and included
in the file LICENSE.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/

#ifndef BAREOS_FILED_AUTHENTICATE_H_
#define BAREOS_FILED_AUTHENTICATE_H_ 1

namespace filedaemon {

bool AuthenticateDirector(JobControlRecord *jcr);
bool AuthenticateWithDirector(JobControlRecord *jcr, DirectorResource *director);
bool AuthenticateStoragedaemon(JobControlRecord *jcr);
bool AuthenticateWithStoragedaemon(JobControlRecord *jcr);

} /* namespace filedaemon */

#endif /* BAREOS_FILED_AUTHENTICATE_H_ */
4 changes: 4 additions & 0 deletions core/src/filed/backup.cc
Expand Up @@ -30,6 +30,7 @@

#include "include/bareos.h"
#include "filed/filed.h"
#include "filed/filed_globals.h"
#include "filed/accurate.h"
#include "filed/compression.h"
#include "filed/crypto.h"
Expand All @@ -41,6 +42,8 @@
#include "findlib/find_one.h"
#include "lib/btimers.h"

namespace filedaemon {

#ifdef HAVE_DARWIN_OS
const bool have_darwin_os = true;
#else
Expand Down Expand Up @@ -1623,3 +1626,4 @@ static void CloseVssBackupSession(JobControlRecord *jcr)
}
#endif
}
} /* namespace filedaemon */
3 changes: 3 additions & 0 deletions core/src/filed/backup.h
Expand Up @@ -24,6 +24,8 @@
#ifndef BAREOS_FILED_BACKUP_H_
#define BAREOS_FILED_BACKUP_H_

namespace filedaemon {

struct b_save_ctx {
JobControlRecord *jcr; /* Current Job Control Record */
FindFilesPacket *ff_pkt; /* File being processed */
Expand Down Expand Up @@ -66,4 +68,5 @@ bool EncodeAndSendAttributes(JobControlRecord *jcr, FindFilesPacket *ff_pkt, int
void StripPath(FindFilesPacket *ff_pkt);
void UnstripPath(FindFilesPacket *ff_pkt);

} /* namespace filedaemon */
#endif
9 changes: 8 additions & 1 deletion core/src/filed/compression.cc
Expand Up @@ -31,16 +31,21 @@

#include "include/bareos.h"
#include "filed/filed.h"
#include "filed/filed_globals.h"

#if defined(HAVE_LZO) || defined(HAVE_LIBZ) || defined(HAVE_FASTLZ)

#if defined(HAVE_LIBZ)
#include <zlib.h>
#endif

#if defined(HAVE_FASTLZ)
#include <fastlzlib.h>
#endif
#endif /* defined(HAVE_LZO) || defined(HAVE_LIBZ) || defined(HAVE_FASTLZ) */


namespace filedaemon {
#if defined(HAVE_LZO) || defined(HAVE_LIBZ) || defined(HAVE_FASTLZ)

/**
* For compression we enable all used compressors in the fileset.
Expand Down Expand Up @@ -226,4 +231,6 @@ bool SetupCompressionContext(b_ctx &bctx)
{
return true;
}

#endif /* defined(HAVE_LZO) || defined(HAVE_LIBZ) || defined(HAVE_FASTLZ) */
} /* namespace filedaemon */
8 changes: 8 additions & 0 deletions core/src/filed/compression.h
Expand Up @@ -19,7 +19,15 @@
02110-1301, USA.
*/

#ifndef BAREOS_FILED_COMPRESSION_H
#define BAREOS_FILED_COMPRESSION_H 1

namespace filedaemon {

bool AdjustCompressionBuffers(JobControlRecord *jcr);
bool AdjustDecompressionBuffers(JobControlRecord *jcr);
bool SetupCompressionContext(b_ctx &bctx);

} /* namespace filedaemon */

#endif /* BAREOS_FILED_COMPRESSION_H */
4 changes: 4 additions & 0 deletions core/src/filed/crypto.cc
Expand Up @@ -31,9 +31,12 @@

#include "include/bareos.h"
#include "filed/filed.h"
#include "filed/restore.h"
#include "findlib/find_one.h"
#include "lib/edit.h"

namespace filedaemon {

#ifdef HAVE_SHA2
const bool have_sha2 = true;
#else
Expand Down Expand Up @@ -606,3 +609,4 @@ bool DecryptData(JobControlRecord *jcr, char **data, uint32_t *length, RestoreCi
bail_out:
return false;
}
} /* namespace filedaemon */
11 changes: 11 additions & 0 deletions core/src/filed/crypto.h
Expand Up @@ -19,6 +19,14 @@
02110-1301, USA.
*/

#ifndef BAREOS_FILED_CRYPTO_H_
#define BAREOS_FILED_CRYPTO_H_

namespace filedaemon {

struct r_ctx;
class RestoreCipherContext;

bool CryptoSessionStart(JobControlRecord *jcr, crypto_cipher_t cipher);
void CryptoSessionEnd(JobControlRecord *jcr);
bool CryptoSessionSend(JobControlRecord *jcr, BareosSocket *sd);
Expand All @@ -32,3 +40,6 @@ bool SetupDecryptionContext(r_ctx &rctx, RestoreCipherContext &rcctx);
bool EncryptData(b_ctx *bctx, bool *need_more_data);
bool DecryptData(JobControlRecord *jcr, char **data, uint32_t *length, RestoreCipherContext *cipher_ctx);

} /* namespace filedaemon */

#endif /* BAREOS_FILED_CRYPTO_H_ */
5 changes: 5 additions & 0 deletions core/src/filed/dir_cmd.cc
Expand Up @@ -30,13 +30,15 @@

#include "include/bareos.h"
#include "filed/filed.h"
#include "filed/filed_globals.h"
#include "ch.h"
#include "filed/authenticate.h"
#include "filed/dir_cmd.h"
#include "filed/estimate.h"
#include "filed/heartbeat.h"
#include "filed/fileset.h"
#include "filed/socket_server.h"
#include "filed/restore.h"
#include "filed/verify.h"
#include "findlib/enable_priv.h"
#include "findlib/shadowing.h"
Expand All @@ -50,6 +52,8 @@
#include "vss.h"
#endif

namespace filedaemon {

extern bool backup_only_mode;
extern bool restore_only_mode;

Expand Down Expand Up @@ -2658,3 +2662,4 @@ bool response(JobControlRecord *jcr, BareosSocket *sd, char *resp, const char *c
}
return false;
}
} /* namespace filedaemon */
8 changes: 8 additions & 0 deletions core/src/filed/dir_cmd.h
Expand Up @@ -19,9 +19,17 @@
02110-1301, USA.
*/

#ifndef BAREOS_FILED_DIR_CMD_H_
#define BAREOS_FILED_DIR_CMD_H_ 1

namespace filedaemon {

JobControlRecord *create_new_director_session(BareosSocket *dir);
void *process_director_commands(JobControlRecord *jcr, BareosSocket *dir);
void *handle_director_connection(BareosSocket *dir);
bool StartConnectToDirectorThreads();
bool StopConnectToDirectorThreads(bool wait=false);

} /* namespace filedaemon */

#endif /* BAREOS_FILED_DIR_CMD_H_ */
3 changes: 3 additions & 0 deletions core/src/filed/estimate.cc
Expand Up @@ -32,6 +32,8 @@
#include "filed/filed.h"
#include "filed/accurate.h"

namespace filedaemon {

static int TallyFile(JobControlRecord *jcr, FindFilesPacket *ff_pkt, bool);

/**
Expand Down Expand Up @@ -117,3 +119,4 @@ static int TallyFile(JobControlRecord *jcr, FindFilesPacket *ff_pkt, bool top_le
}
return 1;
}
} /* namespace filedaemon */
8 changes: 8 additions & 0 deletions core/src/filed/estimate.h
Expand Up @@ -19,5 +19,13 @@
02110-1301, USA.
*/

#ifndef BAREOS_FILED_ESTIMATE_H_
#define BAREOS_FILED_ESTIMATE_H_ 1

namespace filedaemon {

int MakeEstimate(JobControlRecord *jcr);

} /* namespace filedaemon */

#endif /* BAREOS_FILED_ESTIMATE_H_ */
23 changes: 13 additions & 10 deletions core/src/filed/fd_plugins.cc
Expand Up @@ -29,6 +29,7 @@
*/
#include "include/bareos.h"
#include "filed/filed.h"
#include "filed/filed_globals.h"
#include "filed/accurate.h"
#include "filed/heartbeat.h"
#include "filed/fileset.h"
Expand All @@ -38,11 +39,21 @@
#include "findlib/find_one.h"
#include "findlib/hardlink.h"

extern ClientResource *me;
/**
* Function pointers to be set here (findlib)
*/
extern DLL_IMP_EXP int (*plugin_bopen)(BareosWinFilePacket *bfd, const char *fname, int flags, mode_t mode);
extern DLL_IMP_EXP int (*plugin_bclose)(BareosWinFilePacket *bfd);
extern DLL_IMP_EXP ssize_t (*plugin_bread)(BareosWinFilePacket *bfd, void *buf, size_t count);
extern DLL_IMP_EXP ssize_t (*plugin_bwrite)(BareosWinFilePacket *bfd, void *buf, size_t count);
extern DLL_IMP_EXP boffset_t (*plugin_blseek)(BareosWinFilePacket *bfd, boffset_t offset, int whence);

extern DLL_IMP_EXP char *exepath;
extern DLL_IMP_EXP char *version;
extern DLL_IMP_EXP char *dist_name;

namespace filedaemon {

const int debuglevel = 150;
#ifdef HAVE_WIN32
const char *plugin_type = "-fd.dll";
Expand All @@ -54,15 +65,6 @@ static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;

extern int SaveFile(JobControlRecord *jcr, FindFilesPacket *ff_pkt, bool top_level);

/**
* Function pointers to be set here
*/
extern DLL_IMP_EXP int (*plugin_bopen)(BareosWinFilePacket *bfd, const char *fname, int flags, mode_t mode);
extern DLL_IMP_EXP int (*plugin_bclose)(BareosWinFilePacket *bfd);
extern DLL_IMP_EXP ssize_t (*plugin_bread)(BareosWinFilePacket *bfd, void *buf, size_t count);
extern DLL_IMP_EXP ssize_t (*plugin_bwrite)(BareosWinFilePacket *bfd, void *buf, size_t count);
extern DLL_IMP_EXP boffset_t (*plugin_blseek)(BareosWinFilePacket *bfd, boffset_t offset, int whence);

/**
* Forward referenced functions
*/
Expand Down Expand Up @@ -2712,3 +2714,4 @@ int main(int argc, char *argv[])
}

#endif /* TEST_PROGRAM */
} /* namespace filedaemon */

0 comments on commit 41d2933

Please sign in to comment.