Skip to content

Commit

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

    - some functions were left outside of directordaemon namespace; their names
      have to be in the global namespace because they are statically overloaded
      at library compile time with functions from storage or filedaemon
  • Loading branch information
franku committed Sep 20, 2018
1 parent 27f2790 commit d136bd8
Show file tree
Hide file tree
Showing 134 changed files with 1,690 additions and 1,159 deletions.
6 changes: 3 additions & 3 deletions core/src/dird/CMakeLists.txt
Expand Up @@ -20,7 +20,7 @@


set(DIRDSRCS admin.cc archive.cc authenticate.cc autoprune.cc backup.cc bsr.cc catreq.cc
consolidate.cc dir_plugins.cc dird_conf.cc dird.cc expand.cc fd_cmds.cc
consolidate.cc dird_globals.cc dir_plugins.cc dird_conf.cc dird.cc expand.cc fd_cmds.cc
getmsg.cc inc_conf.cc job.cc jobq.cc migrate.cc mountreq.cc msgchan.cc
ndmp_dma_storage.cc
ndmp_dma_backup_common.cc ndmp_dma_backup_NDMP_BAREOS.cc ndmp_dma_backup_NDMP_NATIVE.cc
Expand Down Expand Up @@ -49,12 +49,12 @@ ELSE()
ENDIF()


set(DBCHKSRCS dbcheck.cc dird_conf.cc ua_acl.cc ua_audit.cc run_conf.cc inc_conf.cc)
set(DBCHKSRCS dbcheck.cc dird_conf.cc dird_globals.cc ua_acl.cc ua_audit.cc run_conf.cc inc_conf.cc)
IF(HAVE_WIN32)
LIST(APPEND DBCHKSRCS ../win32/dird/dbcheckres.rc)
ENDIF()

set(TSTFNDSRCS testfind.cc dird_conf.cc ua_acl.cc ua_audit.cc run_conf.cc inc_conf.cc)
set(TSTFNDSRCS testfind.cc dird_conf.cc dird_globals.cc ua_acl.cc ua_audit.cc run_conf.cc inc_conf.cc)

set(DIRD_RESTYPES catalog client console counter director fileset job jobdefs messages pool profile schedule storage)

Expand Down
4 changes: 4 additions & 0 deletions core/src/dird/admin.cc
Expand Up @@ -35,6 +35,8 @@
#include "dird/job.h"
#include "dird/storage.h"

namespace directordaemon {

static const int debuglevel = 100;

bool DoAdminInit(JobControlRecord *jcr)
Expand Down Expand Up @@ -127,3 +129,5 @@ void AdminCleanup(JobControlRecord *jcr, int TermCode)

Dmsg0(debuglevel, "Leave AdminCleanup()\n");
}

} /* namespace directordaemon */
7 changes: 6 additions & 1 deletion core/src/dird/admin.h
Expand Up @@ -22,9 +22,14 @@
#ifndef BAREOS_DIRD_ADMIN_H_
#define BAREOS_DIRD_ADMIN_H_

#include "include/jcr.h"
class JobControlRecord;

namespace directordaemon {

bool DoAdminInit(JobControlRecord *jcr);
bool do_admin(JobControlRecord *jcr);
void AdminCleanup(JobControlRecord *jcr, int TermCode);

} /* namespace directordaemon */

#endif // BAREOS_DIRD_ADMIN_H_
3 changes: 3 additions & 0 deletions core/src/dird/archive.cc
Expand Up @@ -34,6 +34,8 @@
#include "dird/job.h"
#include "dird/storage.h"

namespace directordaemon {

static const int debuglevel = 100;

bool DoArchiveInit(JobControlRecord *jcr)
Expand Down Expand Up @@ -126,3 +128,4 @@ void ArchiveCleanup(JobControlRecord *jcr, int TermCode)

Dmsg0(debuglevel, "Leave ArchiveCleanup()\n");
}
} /* namespace directordaemon */
5 changes: 5 additions & 0 deletions core/src/dird/archive.h
Expand Up @@ -21,8 +21,13 @@

#ifndef BAREOS_DIRD_ARCHIVE_H_
#define BAREOS_DIRD_ARCHIVE_H_

namespace directordaemon {

bool DoArchiveInit(JobControlRecord *jcr);
bool DoArchive(JobControlRecord *jcr);
void ArchiveCleanup(JobControlRecord *jcr, int TermCode);

} /* namespace directordaemon */

#endif // BAREOS_DIRD_ARCHIVE_H_
4 changes: 4 additions & 0 deletions core/src/dird/authenticate.cc
Expand Up @@ -33,8 +33,11 @@
#include "include/bareos.h"
#include "dird.h"
#include "dird/fd_cmds.h"
#include "dird/dird_globals.h"
#include "lib/bnet.h"

namespace directordaemon {

static const int debuglevel = 50;

/*
Expand Down Expand Up @@ -294,3 +297,4 @@ bool AuthenticateUserAgent(UaContext *uac)

return true;
}
} /* namespace directordaemon */
4 changes: 4 additions & 0 deletions core/src/dird/authenticate.h
Expand Up @@ -22,9 +22,13 @@
#ifndef BAREOS_DIRD_AUTHENTICATE_H_
#define BAREOS_DIRD_AUTHENTICATE_H_

namespace directordaemon {

bool AuthenticateWithStorageDaemon(JobControlRecord *jcr, StorageResource *store);
bool AuthenticateWithFileDaemon(JobControlRecord *jcr);
bool AuthenticateFileDaemon(BareosSocket *fd, char *client_name);
bool AuthenticateUserAgent(UaContext *ua);

} /* namespace directordaemon */

#endif // BAREOS_DIRD_AUTHENTICATE_H_
3 changes: 2 additions & 1 deletion core/src/dird/autoprune.cc
Expand Up @@ -36,7 +36,7 @@
#include "dird/ua_purge.h"
#include "lib/edit.h"

/* Forward referenced functions */
namespace directordaemon {

/**
* Auto Prune Jobs and Files. This is called at the end of every
Expand Down Expand Up @@ -237,3 +237,4 @@ void PruneVolumes(JobControlRecord *jcr, bool InChanger,
}
return;
}
} /* namespace directordaemon */
3 changes: 3 additions & 0 deletions core/src/dird/autoprune.h
Expand Up @@ -22,8 +22,11 @@
#ifndef BAREOS_DIRD_AUTOPRUNE_H_
#define BAREOS_DIRD_AUTOPRUNE_H_

namespace directordaemon {

void DoAutoprune(JobControlRecord *jcr);
void PruneVolumes(JobControlRecord *jcr, bool InChanger, MediaDbRecord *mr,
StorageResource *store);

} /* namespace directordaemon */
#endif // BAREOS_DIRD_AUTOPRUNE_H_
3 changes: 3 additions & 0 deletions core/src/dird/autorecycle.h
Expand Up @@ -22,10 +22,13 @@
#ifndef BAREOS_DIRD_AUTORECYCLE_H_
#define BAREOS_DIRD_AUTORECYCLE_H_

namespace directordaemon {

bool FindRecycledVolume(JobControlRecord *jcr, bool InChanger, MediaDbRecord *mr,
StorageResource *store, const char *unwanted_volumes);
bool RecycleOldestPurgedVolume(JobControlRecord *jcr, bool InChanger, MediaDbRecord *mr,
StorageResource *store, const char *unwanted_volumes);
bool RecycleVolume(JobControlRecord *jcr, MediaDbRecord *mr);

} /* namespace directordaemon */
#endif // BAREOS_DIRD_AUTORECYCLE_H_
4 changes: 4 additions & 0 deletions core/src/dird/backup.cc
Expand Up @@ -36,6 +36,7 @@

#include "include/bareos.h"
#include "dird.h"
#include "dird/dird_globals.h"
#include "dird/backup.h"
#include "dird/fd_cmds.h"
#include "dird/getmsg.h"
Expand All @@ -50,6 +51,8 @@
#include "lib/bnet.h"
#include "lib/edit.h"

namespace directordaemon {

/* Commands sent to File daemon */
static char backupcmd[] =
"backup FileIndex=%ld\n";
Expand Down Expand Up @@ -1230,3 +1233,4 @@ void GenerateBackupSummary(JobControlRecord *jcr, ClientDbRecord *cr, int msg_ty
secure_erase_status.c_str(),
TermMsg);
}
} /* namespace directordaemon */
3 changes: 3 additions & 0 deletions core/src/dird/backup.h
Expand Up @@ -22,6 +22,8 @@
#ifndef BAREOS_DIRD_BACKUP_H_
#define BAREOS_DIRD_BACKUP_H_

namespace directordaemon {

int WaitForJobTermination(JobControlRecord *jcr, int timeout = 0);
bool DoNativeBackupInit(JobControlRecord *jcr);
bool DoNativeBackup(JobControlRecord *jcr);
Expand All @@ -35,4 +37,5 @@ char* StorageAddressToContact(ClientResource *client, StorageResource *store);
char* ClientAddressToContact(ClientResource *client, StorageResource *store);
char* StorageAddressToContact(StorageResource *rstore, StorageResource *wstore);

} /* namespace directordaemon */
#endif // BAREOS_DIRD_BACKUP_H_
3 changes: 3 additions & 0 deletions core/src/dird/bsr.cc
Expand Up @@ -36,6 +36,8 @@
#include "dird/ua_select.h"
#include "lib/edit.h"

namespace directordaemon {

#define UA_CMD_SIZE 1000

/* Forward referenced functions */
Expand Down Expand Up @@ -892,3 +894,4 @@ void CloseBootstrapFile(bootstrap_info &info)
FreeUaContext(info.ua);
}
}
} /* namespace directordaemon */
7 changes: 5 additions & 2 deletions core/src/dird/bsr.h
Expand Up @@ -33,6 +33,10 @@
#ifndef BAREOS_DIRD_BSR_H_
#define BAREOS_DIRD_BSR_H_

#include "dird/ua.h"

namespace directordaemon {

/**
* FileIndex entry in restore bootstrap record
*/
Expand Down Expand Up @@ -73,8 +77,6 @@ struct bootstrap_info
char storage[MAX_NAME_LENGTH + 1];
};

#include "dird/ua.h"

RestoreBootstrapRecord *new_bsr();
namespace directordaemon {
DLL_IMP_EXP void FreeBsr(RestoreBootstrapRecord *bsr);
Expand All @@ -92,4 +94,5 @@ bool OpenBootstrapFile(JobControlRecord *jcr, bootstrap_info &info);
bool SendBootstrapFile(JobControlRecord *jcr, BareosSocket *sock, bootstrap_info &info);
void CloseBootstrapFile(bootstrap_info &info);

} /* namespace directordaemon */
#endif // BAREOS_DIRD_BSR_H_
3 changes: 3 additions & 0 deletions core/src/dird/catreq.cc
Expand Up @@ -41,6 +41,8 @@
#include "findlib/find.h"
#include "lib/edit.h"

namespace directordaemon {

/*
* Handle catalog request
* For now, we simply return next Volume to be used
Expand Down Expand Up @@ -756,3 +758,4 @@ bool DespoolAttributesFromFile(JobControlRecord *jcr, const char *file)
Dmsg1(100, "End DespoolAttributesFromFile retval=%i\n", retval);
return retval;
}
} /* namespace directordaemon */
4 changes: 4 additions & 0 deletions core/src/dird/catreq.h
Expand Up @@ -22,8 +22,12 @@
#ifndef BAREOS_DIRD_CATREQ_H_
#define BAREOS_DIRD_CATREQ_H_

namespace directordaemon {

void CatalogRequest(JobControlRecord *jcr, BareosSocket *bs);
void CatalogUpdate(JobControlRecord *jcr, BareosSocket *bs);
bool DespoolAttributesFromFile(JobControlRecord *jcr, const char *file);

} /* namespace directordaemon */

#endif // BAREOS_DIRD_CATREQ_H_
3 changes: 3 additions & 0 deletions core/src/dird/consolidate.cc
Expand Up @@ -40,6 +40,8 @@
#include "dird/ua_run.h"
#include "lib/edit.h"

namespace directordaemon {

static const int debuglevel = 100;

bool DoConsolidateInit(JobControlRecord *jcr)
Expand Down Expand Up @@ -358,3 +360,4 @@ void ConsolidateCleanup(JobControlRecord *jcr, int TermCode)

Dmsg0(debuglevel, "Leave ConsolidateCleanup()\n");
}
} /* namespace directordaemon */
4 changes: 4 additions & 0 deletions core/src/dird/consolidate.h
Expand Up @@ -22,8 +22,12 @@
#ifndef BAREOS_DIRD_CONSOLIDATE_H_
#define BAREOS_DIRD_CONSOLIDATE_H_

namespace directordaemon {

bool DoConsolidateInit(JobControlRecord *jcr);
bool DoConsolidate(JobControlRecord *jcr);
void ConsolidateCleanup(JobControlRecord *jcr, int TermCode);

} /* namespace directordaemon */

#endif // BAREOS_DIRD_CONSOLIDATE_H_
6 changes: 3 additions & 3 deletions core/src/dird/dbcheck.cc
Expand Up @@ -32,8 +32,11 @@
#include "cats/cats_backends.h"
#include "lib/runscript.h"
#include "dird/dird_conf.h"
#include "dird/dird_globals.h"
#include "lib/edit.h"

using namespace directordaemon;

extern bool ParseDirConfig(const char *configfile, int exit_code);

typedef struct s_id_ctx {
Expand Down Expand Up @@ -67,9 +70,6 @@ static const char *idx_tmp_name;
static const char *backend_directory = _PATH_BAREOS_BACKENDDIR;
#endif

DirectorResource *me = NULL; /* Our Global resource */
ConfigurationParser *my_config = nullptr; /* Our Global config */

#define MAX_ID_LIST_LEN 10000000

/*
Expand Down
5 changes: 5 additions & 0 deletions core/src/dird/dir_plugins.cc
Expand Up @@ -28,9 +28,12 @@
*/
#include "include/bareos.h"
#include "dird.h"
#include "dird/dird_globals.h"
#include "dir_plugins.h"
#include "lib/edit.h"

namespace directordaemon {

const int debuglevel = 150;
#ifdef HAVE_WIN32
const char *plugin_type = "-dir.dll";
Expand Down Expand Up @@ -935,3 +938,5 @@ int main(int argc, char *argv[])
}

#endif /* TEST_PROGRAM */

} /* namespace directordaemon */
3 changes: 3 additions & 0 deletions core/src/dird/dir_plugins.h
Expand Up @@ -49,6 +49,8 @@
#include "bc_types.h"
#include "lib/plugins.h"

namespace directordaemon {

/*
* Bareos definitions
*/
Expand Down Expand Up @@ -187,4 +189,5 @@ typedef struct s_dirpluginFuncs {
}
#endif

} /* namespace directordaemon */
#endif /* BAREOS_FILED_FD_PLUGINS_H_ */

0 comments on commit d136bd8

Please sign in to comment.