From 8e1a4eeb2bdc80c9ab45a822a8da1cfa0ece1a6d Mon Sep 17 00:00:00 2001 From: Robert Nelson Date: Fri, 30 Jun 2006 04:06:34 +0000 Subject: [PATCH] Merge in all the low-risk changes from the Windows branch. Add all the new files from the Windows branch. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3094 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/baconfig.h | 9 +- bacula/src/bacula.h | 4 +- bacula/src/bc_types.h | 4 - bacula/src/cats/Makefile.in | 3 + bacula/src/cats/bdb.c | 12 +- bacula/src/cats/bdb_create.c | 6 +- bacula/src/cats/bdb_find.c | 3 +- bacula/src/cats/bdb_get.c | 5 +- bacula/src/cats/make_mysql_tables.in | 22 +- bacula/src/cats/protos.h | 2 +- bacula/src/cats/sql_create.c | 12 +- bacula/src/cats/sql_get.c | 2 + bacula/src/cats/sql_list.c | 2 +- bacula/src/cats/sql_update.c | 14 +- bacula/src/console/console.c | 14 +- bacula/src/console/console_conf.c | 5 +- bacula/src/dird/backup.c | 2 +- bacula/src/dird/bsr.c | 2 +- bacula/src/dird/catreq.c | 2 +- bacula/src/dird/dird.c | 10 +- bacula/src/dird/dird_conf.c | 6 + bacula/src/dird/dird_conf.h | 14 +- bacula/src/dird/expand.c | 2 +- bacula/src/dird/fd_cmds.c | 4 +- bacula/src/dird/inc_conf.c | 8 +- bacula/src/dird/job.c | 2 +- bacula/src/dird/run_conf.c | 6 + bacula/src/dird/scheduler.c | 6 +- bacula/src/dird/sql_cmds.c | 8 +- bacula/src/dird/ua_cmds.c | 2 +- bacula/src/dird/ua_output.c | 4 +- bacula/src/dird/ua_prune.c | 34 +- bacula/src/dird/ua_query.c | 2 +- bacula/src/dird/ua_restore.c | 22 +- bacula/src/dird/ua_run.c | 2 +- bacula/src/dird/ua_update.c | 2 +- bacula/src/filed/estimate.c | 1 + bacula/src/filed/filed.c | 2 +- bacula/src/filed/filed_conf.c | 5 +- bacula/src/filed/job.c | 10 +- bacula/src/filed/status.c | 8 +- bacula/src/findlib/attribs.c | 13 +- bacula/src/findlib/bfile.c | 2 +- bacula/src/findlib/bfile.h | 4 +- bacula/src/findlib/drivetype.c | 116 ++ bacula/src/findlib/enable_priv.c | 6 +- bacula/src/findlib/find.c | 7 +- bacula/src/findlib/makepath.c | 8 +- bacula/src/findlib/match.c | 8 +- bacula/src/lib/base64.c | 2 +- bacula/src/lib/berrno.c | 3 +- bacula/src/lib/bnet.c | 6 +- bacula/src/lib/bpipe.c | 4 +- bacula/src/lib/bshm.c | 4 +- bacula/src/lib/bsys.c | 6 +- bacula/src/lib/btime.c | 16 +- bacula/src/lib/daemon.c | 4 +- bacula/src/lib/enh_fnmatch.c | 285 ++++ bacula/src/lib/enh_fnmatch.h | 51 + bacula/src/lib/events.c | 4 +- bacula/src/lib/lex.c | 2 +- bacula/src/lib/md5.c | 2 +- bacula/src/lib/message.c | 36 +- bacula/src/lib/parse_conf.c | 5 +- bacula/src/lib/protos.h | 2 +- bacula/src/lib/res.c | 11 - bacula/src/lib/runscript.c | 2 - bacula/src/lib/sha1.c | 2 +- bacula/src/stored/bextract.c | 6 +- bacula/src/stored/bls.c | 4 +- bacula/src/stored/bscan.c | 2 +- bacula/src/stored/btape.c | 12 +- bacula/src/stored/dev.c | 4 +- bacula/src/stored/dev.h | 2 +- bacula/src/stored/dircmd.c | 2 +- bacula/src/stored/fd_cmds.c | 2 +- bacula/src/stored/spool.c | 2 +- bacula/src/stored/stored_conf.c | 6 + bacula/src/stored/stored_conf.h | 2 +- bacula/src/tools/bwild.c | 1 - bacula/src/tools/drivetype.c | 94 ++ bacula/src/tools/fstype.c | 2 +- bacula/src/tools/testfind.c | 2 +- bacula/src/tools/testls.c | 6 +- bacula/src/win32/ClientConfig.ini | 157 ++ bacula/src/win32/Makefile.inc.cross | 72 + bacula/src/win32/Makefile.inc.native | 75 + bacula/src/win32/Makefile.rules | 73 + bacula/src/win32/Makefile.template | 74 + bacula/src/win32/bacula.sln | 260 +++- bacula/src/win32/compat/Makefile | 61 + bacula/src/win32/compat/compat.cpp | 29 +- bacula/src/win32/compat/compat.h | 8 + bacula/src/win32/compat/compat.vcproj | 296 ++++ bacula/src/win32/compat/getopt.c | 4 +- bacula/src/win32/compat/sys/mtio.h | 277 ++++ bacula/src/win32/compat/winapi.c | 189 +++ bacula/src/win32/console/console.vcproj | 1328 ++++------------- bacula/src/win32/filed/Makefile | 86 ++ bacula/src/win32/filed/baculafd.vcproj | 602 ++++++++ bacula/src/win32/filed/vss.cpp | 215 +++ bacula/src/win32/filed/vss.h | 120 ++ bacula/src/win32/filed/vss_W2K3.cpp | 13 + bacula/src/win32/filed/vss_XP.cpp | 4 + bacula/src/win32/filed/vss_generic.cpp | 633 ++++++++ bacula/src/win32/filed/winmain.cpp | 332 +++++ bacula/src/win32/filed/winservice.cpp | 763 ++++++++++ bacula/src/win32/mingw-utils.patch | 90 +- bacula/src/win32/winapi.h | 165 ++ bacula/src/win32/wx-console/wx-console.vcproj | 845 +++++------ bacula/src/wx-console/console_conf.c | 5 +- bacula/src/wx-console/console_thread.cpp | 40 +- 112 files changed, 5963 insertions(+), 1898 deletions(-) create mode 100644 bacula/src/findlib/drivetype.c create mode 100644 bacula/src/lib/enh_fnmatch.c create mode 100644 bacula/src/lib/enh_fnmatch.h create mode 100644 bacula/src/tools/drivetype.c create mode 100644 bacula/src/win32/ClientConfig.ini create mode 100644 bacula/src/win32/Makefile.inc.cross create mode 100644 bacula/src/win32/Makefile.inc.native create mode 100644 bacula/src/win32/Makefile.rules create mode 100644 bacula/src/win32/Makefile.template create mode 100644 bacula/src/win32/compat/Makefile create mode 100644 bacula/src/win32/compat/compat.vcproj create mode 100644 bacula/src/win32/compat/sys/mtio.h create mode 100644 bacula/src/win32/compat/winapi.c create mode 100644 bacula/src/win32/filed/Makefile create mode 100644 bacula/src/win32/filed/baculafd.vcproj create mode 100644 bacula/src/win32/filed/vss.cpp create mode 100644 bacula/src/win32/filed/vss.h create mode 100644 bacula/src/win32/filed/vss_W2K3.cpp create mode 100644 bacula/src/win32/filed/vss_XP.cpp create mode 100644 bacula/src/win32/filed/vss_generic.cpp create mode 100644 bacula/src/win32/filed/winmain.cpp create mode 100644 bacula/src/win32/filed/winservice.cpp create mode 100644 bacula/src/win32/winapi.h diff --git a/bacula/src/baconfig.h b/bacula/src/baconfig.h index 16e9cfe424..f052b13cde 100644 --- a/bacula/src/baconfig.h +++ b/bacula/src/baconfig.h @@ -65,7 +65,7 @@ /* Allow printing of NULL pointers */ #define NPRT(x) (x)?(x):_("*None*") -#ifdef WIN32 +#if defined(HAVE_WIN32) #undef ENABLE_NLS #endif @@ -218,6 +218,7 @@ * or saved */ #define FT_DIRBEGIN 18 /* Directory at beginning (not saved) */ #define FT_INVALIDFS 19 /* File system not allowed for */ +#define FT_INVALIDDT 20 /* Drive type not allowed for */ /* Definitions for upper part of type word (see above). */ #define AR_DATA_STREAM (1<<16) /* Data stream id present */ @@ -562,13 +563,9 @@ extern "C" int getdomainname(char *name, int len); extern "C" int mknod ( const char *path, int mode, dev_t device ); #endif -#ifdef HAVE_CYGWIN -/* They don't really have it */ -#undef HAVE_GETDOMAINNAME -#endif /* Define Winsock functions if we aren't on Windows */ -#if (!defined HAVE_WIN32) || (defined HAVE_CYGWIN) +#if !defined HAVE_WIN32 #define WSA_Init() 0 /* 0 = success */ #define WSACleanup() 0 /* 0 = success */ #endif diff --git a/bacula/src/bacula.h b/bacula/src/bacula.h index daedd83bd3..f677f2458a 100644 --- a/bacula/src/bacula.h +++ b/bacula/src/bacula.h @@ -26,8 +26,8 @@ #define _LANGUAGE_C_PLUS_PLUS 1 #endif -#ifdef WIN32 -#ifdef HAVE_MINGW +#if defined(HAVE_WIN32) +#if defined(HAVE_MINGW) #include "mingwconfig.h" #include "winhost.h" #define _STAT_H /* don't pull in MinGW stat.h */ diff --git a/bacula/src/bc_types.h b/bacula/src/bc_types.h index 75950bd32d..81595edb9e 100644 --- a/bacula/src/bc_types.h +++ b/bacula/src/bc_types.h @@ -173,10 +173,6 @@ typedef float float32_t; /* Unix time (time_t) widened to 64 bits */ #define utime_t int64_t -#ifdef HAVE_CYGWIN -#define int_least16_t int32_t -#endif - #ifndef HAVE_SOCKLEN_T #define socklen_t int #endif diff --git a/bacula/src/cats/Makefile.in b/bacula/src/cats/Makefile.in index 44ec71b360..0a3495610e 100644 --- a/bacula/src/cats/Makefile.in +++ b/bacula/src/cats/Makefile.in @@ -81,6 +81,9 @@ realclean: clean $(RMF) create_sqlite_database update_sqlite_tables make_sqlite_tables $(RMF) grant_sqlite_privileges drop_sqlite_tables drop_sqlite_database + $(RMF) create_sqlite3_database update_sqlite3_tables make_sqlite3_tables + $(RMF) grant_sqlite3_privileges drop_sqlite3_tables drop_sqlite3_database + $(RMF) mysql sqlite postgresql $(RMF) make_catalog_backup delete_catalog_backup diff --git a/bacula/src/cats/bdb.c b/bacula/src/cats/bdb.c index a0836efc9f..43cc175e2b 100644 --- a/bacula/src/cats/bdb.c +++ b/bacula/src/cats/bdb.c @@ -296,7 +296,7 @@ int bdb_open_jobs_file(B_DB *mdb) if (!mdb->jobfd) { dbf = make_filename(mdb, DB_JOBS_FILENAME); - mdb->jobfd = fopen(dbf, "r+"); + mdb->jobfd = fopen(dbf, "r+b"); if (!mdb->jobfd) { Mmsg2(&mdb->errmsg, "Error opening DB Jobs file %s: ERR=%s\n", dbf, strerror(errno)); @@ -318,7 +318,7 @@ int bdb_open_jobmedia_file(B_DB *mdb) if (!mdb->jobmediafd) { dbf = make_filename(mdb, DB_JOBMEDIA_FILENAME); - mdb->jobmediafd = fopen(dbf, "r+"); + mdb->jobmediafd = fopen(dbf, "r+b"); if (!mdb->jobmediafd) { Mmsg2(&mdb->errmsg, "Error opening DB JobMedia file %s: ERR=%s\n", dbf, strerror(errno)); @@ -341,7 +341,7 @@ int bdb_open_pools_file(B_DB *mdb) if (!mdb->poolfd) { dbf = make_filename(mdb, DB_POOLS_FILENAME); - mdb->poolfd = fopen(dbf, "r+"); + mdb->poolfd = fopen(dbf, "r+b"); if (!mdb->poolfd) { Mmsg2(&mdb->errmsg, "Error opening DB Pools file %s: ERR=%s\n", dbf, strerror(errno)); @@ -364,7 +364,7 @@ int bdb_open_client_file(B_DB *mdb) if (!mdb->clientfd) { dbf = make_filename(mdb, DB_CLIENT_FILENAME); - mdb->clientfd = fopen(dbf, "r+"); + mdb->clientfd = fopen(dbf, "r+b"); if (!mdb->clientfd) { Mmsg2(&mdb->errmsg, "Error opening DB Clients file %s: ERR=%s\n", dbf, strerror(errno)); @@ -386,7 +386,7 @@ int bdb_open_fileset_file(B_DB *mdb) if (!mdb->filesetfd) { dbf = make_filename(mdb, DB_CLIENT_FILENAME); - mdb->filesetfd = fopen(dbf, "r+"); + mdb->filesetfd = fopen(dbf, "r+b"); if (!mdb->filesetfd) { Mmsg2(&mdb->errmsg, "Error opening DB FileSet file %s: ERR=%s\n", dbf, strerror(errno)); @@ -410,7 +410,7 @@ int bdb_open_media_file(B_DB *mdb) if (!mdb->mediafd) { dbf = make_filename(mdb, DB_MEDIA_FILENAME); - mdb->mediafd = fopen(dbf, "r+"); + mdb->mediafd = fopen(dbf, "r+b"); if (!mdb->mediafd) { Mmsg2(&mdb->errmsg, "Error opening DB Media file %s: ERR=%s\n", dbf, strerror(errno)); diff --git a/bacula/src/cats/bdb_create.c b/bacula/src/cats/bdb_create.c index 3228d42e08..07d7b9a711 100644 --- a/bacula/src/cats/bdb_create.c +++ b/bacula/src/cats/bdb_create.c @@ -23,8 +23,8 @@ 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 - the file LICENSE for additional details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + file LICENSE for additional details. */ @@ -71,7 +71,7 @@ int db_create_file_item(JCR *jcr, B_DB *mdb, ATTR_DBR *ar) * Returns: 0 on failure * 1 on success */ -int db_create_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr) +bool db_create_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr) { int len; diff --git a/bacula/src/cats/bdb_find.c b/bacula/src/cats/bdb_find.c index 6c5bd3b117..f63a5354dc 100644 --- a/bacula/src/cats/bdb_find.c +++ b/bacula/src/cats/bdb_find.c @@ -16,6 +16,7 @@ * * Version $Id$ */ + /* Copyright (C) 2001-2006 Kern Sibbald @@ -171,7 +172,7 @@ db_find_next_volume(JCR *jcr, B_DB *mdb, int item, bool InChanger, MEDIA_DBR *mr return stat; } -int +bool db_find_last_jobid(JCR *jcr, B_DB *mdb, const char *Name, JOB_DBR *jr) { return 0; } diff --git a/bacula/src/cats/bdb_get.c b/bacula/src/cats/bdb_get.c index 8fd20b0fa3..3a1e7d8174 100644 --- a/bacula/src/cats/bdb_get.c +++ b/bacula/src/cats/bdb_get.c @@ -15,6 +15,7 @@ * * Version $Id$ */ + /* Copyright (C) 2001-2006 Kern Sibbald @@ -26,7 +27,7 @@ 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 - the file LICENSE for additional details. + file LICENSE for additional details. */ @@ -59,7 +60,7 @@ * 1 on success */ -int db_get_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr) +bool db_get_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr) { JOB_DBR ojr; faddr_t rec_addr; diff --git a/bacula/src/cats/make_mysql_tables.in b/bacula/src/cats/make_mysql_tables.in index 541e2d8863..d0f7f3108d 100644 --- a/bacula/src/cats/make_mysql_tables.in +++ b/bacula/src/cats/make_mysql_tables.in @@ -92,21 +92,21 @@ CREATE TABLE Job ( Name TINYBLOB NOT NULL, Type BINARY(1) NOT NULL, Level BINARY(1) NOT NULL, - ClientId INTEGER NOT NULL REFERENCES Client, + ClientId INTEGER NOT NULL DEFAULT 0 REFERENCES Client, JobStatus BINARY(1) NOT NULL, SchedTime DATETIME NOT NULL, - StartTime DATETIME NOT NULL, - EndTime DATETIME NOT NULL, - RealEndTime DATETIME NOT NULL, + StartTime DATETIME NOT NULL DEFAULT 0, + EndTime DATETIME NOT NULL DEFAULT 0, + RealEndTime DATETIME NOT NULL DEFAULT 0, JobTDate BIGINT UNSIGNED NOT NULL, VolSessionId INTEGER UNSIGNED NOT NULL DEFAULT 0, VolSessionTime INTEGER UNSIGNED NOT NULL DEFAULT 0, JobFiles INTEGER UNSIGNED NOT NULL DEFAULT 0, - JobBytes BIGINT UNSIGNED NOT NULL, + JobBytes BIGINT UNSIGNED NOT NULL DEFAULT 0, JobErrors INTEGER UNSIGNED NOT NULL DEFAULT 0, JobMissingFiles INTEGER UNSIGNED NOT NULL DEFAULT 0, - PoolId INTEGER UNSIGNED NOT NULL REFERENCES Pool, - FileSetId INTEGER UNSIGNED NOT NULL REFERENCES FileSet, + PoolId INTEGER UNSIGNED NOT NULL DEFAULT 0 REFERENCES Pool, + FileSetId INTEGER UNSIGNED NOT NULL DEFAULT 0 REFERENCES FileSet, PriorJobId INTEGER UNSIGNED DEFAULT 0 REFERENCES Job, PurgedFiles TINYINT NOT NULL DEFAULT 0, HasBase TINYINT NOT NULL DEFAULT 0, @@ -157,9 +157,9 @@ CREATE TABLE Media ( MediaType TINYBLOB NOT NULL, MediaTypeId INTEGER UNSIGNED NOT NULL REFERENCES MediaType, LabelType TINYINT NOT NULL DEFAULT 0, - FirstWritten DATETIME NOT NULL, - LastWritten DATETIME NOT NULL, - LabelDate DATETIME NOT NULL, + FirstWritten DATETIME NOT NULL DEFAULT 0, + LastWritten DATETIME NOT NULL DEFAULT 0, + LabelDate DATETIME NOT NULL DEFAULT 0, VolJobs INTEGER UNSIGNED NOT NULL DEFAULT 0, VolFiles INTEGER UNSIGNED NOT NULL DEFAULT 0, VolBlocks INTEGER UNSIGNED NOT NULL DEFAULT 0, @@ -188,7 +188,7 @@ CREATE TABLE Media ( EndBlock INTEGER UNSIGNED NOT NULL DEFAULT 0, LocationId INTEGER UNSIGNED DEFAULT 0 REFERENCES Location, RecycleCount INTEGER UNSIGNED DEFAULT 0, - InitialWrite DATETIME NOT NULL, + InitialWrite DATETIME NOT NULL DEFAULT 0, ScratchPoolId INTEGER UNSIGNED DEFAULT 0 REFERENCES Pool, RecyclePoolId INTEGER UNSIGNED DEFAULT 0 REFERENCES Pool, PRIMARY KEY(MediaId), diff --git a/bacula/src/cats/protos.h b/bacula/src/cats/protos.h index fd3aa6d818..dcc84f7cb8 100644 --- a/bacula/src/cats/protos.h +++ b/bacula/src/cats/protos.h @@ -93,7 +93,7 @@ void db_list_job_totals(JCR *jcr, B_DB *db, JOB_DBR *jr, DB_LIST_HANDLER sendit, void db_list_files_for_job(JCR *jcr, B_DB *db, uint32_t jobid, DB_LIST_HANDLER sendit, void *ctx); void db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr, DB_LIST_HANDLER *sendit, void *ctx, e_list_type type); void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, JobId_t JobId, DB_LIST_HANDLER *sendit, void *ctx, e_list_type type); -int db_list_sql_query(JCR *jcr, B_DB *mdb, char *query, DB_LIST_HANDLER *sendit, void *ctx, int verbose, e_list_type type); +int db_list_sql_query(JCR *jcr, B_DB *mdb, const char *query, DB_LIST_HANDLER *sendit, void *ctx, int verbose, e_list_type type); void db_list_client_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx, e_list_type type); /* update.c */ diff --git a/bacula/src/cats/sql_create.c b/bacula/src/cats/sql_create.c index f42f2cd3d3..7b1cc909d7 100644 --- a/bacula/src/cats/sql_create.c +++ b/bacula/src/cats/sql_create.c @@ -71,8 +71,8 @@ db_create_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr) stime = jr->SchedTime; ASSERT(stime != 0); - localtime_r(&stime, &tm); - strftime(dt, sizeof(dt), "%Y-%m-%d %T", &tm); + (void)localtime_r(&stime, &tm); + strftime(dt, sizeof(dt), "%Y-%m-%d %H:%M:%S", &tm); JobTDate = (utime_t)stime; /* Must create it */ @@ -443,8 +443,8 @@ db_create_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) if (mr->LabelDate == 0) { mr->LabelDate = time(NULL); } - localtime_r(&mr->LabelDate, &tm); - strftime(dt, sizeof(dt), "%Y-%m-%d %T", &tm); + (void)localtime_r(&mr->LabelDate, &tm); + strftime(dt, sizeof(dt), "%Y-%m-%d %H:%M:%S", &tm); Mmsg(mdb->cmd, "UPDATE Media SET LabelDate='%s' " "WHERE MediaId=%d", dt, mr->MediaId); stat = UPDATE_DB(jcr, mdb, mdb->cmd); @@ -615,8 +615,8 @@ bool db_create_fileset_record(JCR *jcr, B_DB *mdb, FILESET_DBR *fsr) if (fsr->CreateTime == 0 && fsr->cCreateTime[0] == 0) { fsr->CreateTime = time(NULL); } - localtime_r(&fsr->CreateTime, &tm); - strftime(fsr->cCreateTime, sizeof(fsr->cCreateTime), "%Y-%m-%d %T", &tm); + (void)localtime_r(&fsr->CreateTime, &tm); + strftime(fsr->cCreateTime, sizeof(fsr->cCreateTime), "%Y-%m-%d %H:%M:%S", &tm); /* Must create it */ Mmsg(mdb->cmd, "INSERT INTO FileSet (FileSet,MD5,CreateTime) " diff --git a/bacula/src/cats/sql_get.c b/bacula/src/cats/sql_get.c index 4068dfbaec..0fcc2dabd5 100644 --- a/bacula/src/cats/sql_get.c +++ b/bacula/src/cats/sql_get.c @@ -407,6 +407,8 @@ int db_get_job_volume_parameters(JCR *jcr, B_DB *mdb, JobId_t JobId, VOL_PARAMS if (stat > 0) { *VolParams = Vols = (VOL_PARAMS *)malloc(stat * sizeof(VOL_PARAMS)); SId = (DBId_t *)malloc(stat * sizeof(DBId_t)); + } else { + SId = NULL; } for (i=0; i < stat; i++) { if ((row = sql_fetch_row(mdb)) == NULL) { diff --git a/bacula/src/cats/sql_list.c b/bacula/src/cats/sql_list.c index ff71728cc3..cbc9413738 100644 --- a/bacula/src/cats/sql_list.c +++ b/bacula/src/cats/sql_list.c @@ -45,7 +45,7 @@ extern int QueryDB(const char *file, int line, JCR *jcr, B_DB *db, char *select_ /* * Submit general SQL query */ -int db_list_sql_query(JCR *jcr, B_DB *mdb, char *query, DB_LIST_HANDLER *sendit, +int db_list_sql_query(JCR *jcr, B_DB *mdb, const char *query, DB_LIST_HANDLER *sendit, void *ctx, int verbose, e_list_type type) { db_lock(mdb); diff --git a/bacula/src/cats/sql_update.c b/bacula/src/cats/sql_update.c index 736d94fb31..b276c671bd 100644 --- a/bacula/src/cats/sql_update.c +++ b/bacula/src/cats/sql_update.c @@ -96,7 +96,7 @@ db_update_job_start_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr) char ed1[50], ed2[50], ed3[50], ed4[50]; stime = jr->StartTime; - localtime_r(&stime, &tm); + (void)localtime_r(&stime, &tm); strftime(dt, sizeof(dt), "%Y-%m-%d %H:%M:%S", &tm); JobTDate = (btime_t)stime; @@ -157,14 +157,14 @@ db_update_job_end_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr) } ttime = jr->EndTime; - localtime_r(&ttime, &tm); + (void)localtime_r(&ttime, &tm); strftime(dt, sizeof(dt), "%Y-%m-%d %H:%M:%S", &tm); if (jr->RealEndTime == 0) { jr->RealEndTime = jr->EndTime; } ttime = jr->RealEndTime; - localtime_r(&ttime, &tm); + (void)localtime_r(&ttime, &tm); strftime(rdt, sizeof(rdt), "%Y-%m-%d %H:%M:%S", &tm); JobTDate = ttime; @@ -178,7 +178,7 @@ db_update_job_end_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr) (char)(jr->JobStatus), dt, ClientId, edit_uint64(jr->JobBytes, ed1), jr->JobFiles, jr->JobErrors, jr->VolSessionId, jr->VolSessionTime, PoolId, FileSetId, edit_uint64(JobTDate, ed2), - rdt, + rdt, PriorJobId, edit_int64(jr->JobId, ed3)); @@ -312,7 +312,7 @@ db_update_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) if (mr->set_first_written) { Dmsg1(400, "Set FirstWritten Vol=%s\n", mr->VolumeName); ttime = mr->FirstWritten; - localtime_r(&ttime, &tm); + (void)localtime_r(&ttime, &tm); strftime(dt, sizeof(dt), "%Y-%m-%d %H:%M:%S", &tm); Mmsg(mdb->cmd, "UPDATE Media SET FirstWritten='%s'" " WHERE VolumeName='%s'", dt, mr->VolumeName); @@ -326,7 +326,7 @@ db_update_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) if (ttime == 0) { ttime = time(NULL); } - localtime_r(&ttime, &tm); + (void)localtime_r(&ttime, &tm); strftime(dt, sizeof(dt), "%Y-%m-%d %H:%M:%S", &tm); Mmsg(mdb->cmd, "UPDATE Media SET LabelDate='%s' " "WHERE VolumeName='%s'", dt, mr->VolumeName); @@ -335,7 +335,7 @@ db_update_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) if (mr->LastWritten != 0) { ttime = mr->LastWritten; - localtime_r(&ttime, &tm); + (void)localtime_r(&ttime, &tm); strftime(dt, sizeof(dt), "%Y-%m-%d %H:%M:%S", &tm); Mmsg(mdb->cmd, "UPDATE Media Set LastWritten='%s' " "WHERE VolumeName='%s'", dt, mr->VolumeName); diff --git a/bacula/src/console/console.c b/bacula/src/console/console.c index 38a12f89ca..b4392f2b06 100644 --- a/bacula/src/console/console.c +++ b/bacula/src/console/console.c @@ -44,11 +44,7 @@ /* Exported variables */ -#ifdef HAVE_CYGWIN -int rl_catch_signals; -#else extern int rl_catch_signals; -#endif #ifdef HAVE_MINGW /* Remove when we have real lib in src/lib */ int enable_vss; @@ -383,9 +379,9 @@ int main(int argc, char *argv[]) init_signals(terminate_console); } + #if !defined(HAVE_WIN32) /* Override Bacula default signals */ -// signal(SIGCHLD, SIG_IGN); signal(SIGQUIT, SIG_IGN); signal(SIGTSTP, got_sigstop); signal(SIGCONT, got_sigcontinue); @@ -533,7 +529,7 @@ try_again: FILE *fd; pm_strcpy(&UA_sock->msg, env); pm_strcat(&UA_sock->msg, "/.bconsolerc"); - fd = fopen(UA_sock->msg, "r"); + fd = fopen(UA_sock->msg, "rb"); if (fd) { read_and_process_input(fd, UA_sock); fclose(fd); @@ -780,7 +776,7 @@ static int inputcmd(FILE *input, BSOCK *UA_sock) sendit(_("First argument to input command must be a filename.\n")); return 1; } - fd = fopen(argk[1], "r"); + fd = fopen(argk[1], "rb"); if (!fd) { senditf(_("Cannot open file %s for input. ERR=%s\n"), argk[1], strerror(errno)); @@ -809,7 +805,7 @@ static int outputcmd(FILE *input, BSOCK *UA_sock) static int do_outputcmd(FILE *input, BSOCK *UA_sock) { FILE *fd; - const char *mode = "a+"; + const char *mode = "a+b"; if (argc > 3) { sendit(_("Too many arguments on output/tee command.\n")); @@ -855,7 +851,7 @@ static int timecmd(FILE *input, BSOCK *UA_sock) char sdt[50]; time_t ttime = time(NULL); struct tm tm; - localtime_r(&ttime, &tm); + (void)localtime_r(&ttime, &tm); strftime(sdt, sizeof(sdt), "%d-%b-%Y %H:%M:%S", &tm); sendit("\n"); return 1; diff --git a/bacula/src/console/console_conf.c b/bacula/src/console/console_conf.c index 8112adfac3..0336a957cb 100644 --- a/bacula/src/console/console_conf.c +++ b/bacula/src/console/console_conf.c @@ -54,15 +54,14 @@ RES **res_head = sres_head; * then move it to allocated memory when the resource * scan is complete. */ -#if defined(HAVE_WIN32) && !defined(HAVE_CYGWIN) && !defined(HAVE_MINGW) +#if defined(_MSC_VER) extern "C" { // work around visual compiler mangling variables URES res_all; - int res_all_size = sizeof(res_all); } #else URES res_all; -int res_all_size = sizeof(res_all); #endif +int res_all_size = sizeof(res_all); /* Definition of records permitted within each * resource with the routine to process the record diff --git a/bacula/src/dird/backup.c b/bacula/src/dird/backup.c index fe7cbc292c..ef845c7233 100644 --- a/bacula/src/dird/backup.c +++ b/bacula/src/dird/backup.c @@ -499,7 +499,7 @@ void update_bootstrap_file(JCR *jcr) fd = bpipe ? bpipe->wfd : NULL; } else { /* ***FIXME*** handle BASE */ - fd = fopen(fname, jcr->JobLevel==L_FULL?"w+":"a+"); + fd = fopen(fname, jcr->JobLevel==L_FULL?"w+b":"a+b"); } if (fd) { VolCount = db_get_job_volume_parameters(jcr, jcr->db, jcr->JobId, diff --git a/bacula/src/dird/bsr.c b/bacula/src/dird/bsr.c index 2b2e77526e..ae4317c452 100644 --- a/bacula/src/dird/bsr.c +++ b/bacula/src/dird/bsr.c @@ -227,7 +227,7 @@ uint32_t write_bsr_file(UAContext *ua, RESTORE_CTX &rx) JobId_t JobId; make_unique_restore_filename(ua, &fname); - fd = fopen(fname, "w+"); + fd = fopen(fname, "w+b"); if (!fd) { berrno be; bsendmsg(ua, _("Unable to create bootstrap file %s. ERR=%s\n"), diff --git a/bacula/src/dird/catreq.c b/bacula/src/dird/catreq.c index 02514e8d49..f40b39a41a 100644 --- a/bacula/src/dird/catreq.c +++ b/bacula/src/dird/catreq.c @@ -415,7 +415,7 @@ void catalog_update(JCR *jcr, BSOCK *bs) Jmsg(jcr, M_WARNING, 0, _("Got %s but not same File as attributes\n"), stream_to_ascii(Stream)); } else { /* Update digest in catalog */ - char digestbuf[CRYPTO_DIGEST_MAX_SIZE]; + char digestbuf[BASE64_SIZE(CRYPTO_DIGEST_MAX_SIZE)]; int len = 0; int type = CRYPTO_DIGEST_NONE; diff --git a/bacula/src/dird/dird.c b/bacula/src/dird/dird.c index a5f65266e8..26af749a6a 100644 --- a/bacula/src/dird/dird.c +++ b/bacula/src/dird/dird.c @@ -60,8 +60,14 @@ extern int r_first, r_last; /* first and last resources */ extern RES_TABLE resources[]; extern RES **res_head; extern RES_ITEM job_items[]; -extern URES res_all; +#if defined(_MSC_VER) +extern "C" { // work around visual compiler mangling variables + extern URES res_all; +} +#else +extern URES res_all; +#endif #define CONFIG_FILE "./bacula-dir.conf" /* default configuration file */ @@ -250,6 +256,8 @@ int main (int argc, char *argv[]) } terminate_dird(0); + + return 0; } /* Cleanup and then exit */ diff --git a/bacula/src/dird/dird_conf.c b/bacula/src/dird/dird_conf.c index 9eedba0e6f..e7ba378dd4 100644 --- a/bacula/src/dird/dird_conf.c +++ b/bacula/src/dird/dird_conf.c @@ -72,7 +72,13 @@ static void store_short_runscript(LEX *lc, RES_ITEM *item, int index, int pass); * then move it to allocated memory when the resource * scan is complete. */ +#if defined(_MSC_VER) +extern "C" { // work around visual compiler mangling variables + URES res_all; +} +#else URES res_all; +#endif int res_all_size = sizeof(res_all); diff --git a/bacula/src/dird/dird_conf.h b/bacula/src/dird/dird_conf.h index f6a80fea97..56efa2fb2d 100644 --- a/bacula/src/dird/dird_conf.h +++ b/bacula/src/dird/dird_conf.h @@ -77,13 +77,13 @@ struct s_jt { /* Definition of the contents of each Resource */ /* Needed for forward references */ -struct SCHED; -struct CLIENT; -struct FILESET; -struct POOL; -struct RUN; -struct DEVICE; -struct RUNSCRIPT; +class SCHED; +class CLIENT; +class FILESET; +class POOL; +class RUN; +class DEVICE; +class RUNSCRIPT; /* * Director Resource diff --git a/bacula/src/dird/expand.c b/bacula/src/dird/expand.c index f7d9167b7b..3a41434215 100644 --- a/bacula/src/dird/expand.c +++ b/bacula/src/dird/expand.c @@ -37,7 +37,7 @@ static int date_item(JCR *jcr, int code, { struct tm tm; time_t now = time(NULL); - localtime_r(&now, &tm); + (void)localtime_r(&now, &tm); int val = 0; char buf[10]; diff --git a/bacula/src/dird/fd_cmds.c b/bacula/src/dird/fd_cmds.c index febd1873d8..3d884f4663 100644 --- a/bacula/src/dird/fd_cmds.c +++ b/bacula/src/dird/fd_cmds.c @@ -341,7 +341,7 @@ static bool send_fileset(JCR *jcr) break; case '<': p++; /* skip over < */ - if ((ffd = fopen(p, "r")) == NULL) { + if ((ffd = fopen(p, "rb")) == NULL) { berrno be; Jmsg(jcr, M_FATAL, 0, _("Cannot open included file: %s. ERR=%s\n"), p, be.strerror()); @@ -435,7 +435,7 @@ bool send_bootstrap_file(JCR *jcr, BSOCK *sock) if (!jcr->RestoreBootstrap) { return true; } - bs = fopen(jcr->RestoreBootstrap, "r"); + bs = fopen(jcr->RestoreBootstrap, "rb"); if (!bs) { berrno be; Jmsg(jcr, M_FATAL, 0, _("Could not open bootstrap file %s: ERR=%s\n"), diff --git a/bacula/src/dird/inc_conf.c b/bacula/src/dird/inc_conf.c index dff8eae194..3b5e0d8d52 100644 --- a/bacula/src/dird/inc_conf.c +++ b/bacula/src/dird/inc_conf.c @@ -51,7 +51,13 @@ static void setup_current_opts(void); * then move it to allocated memory when the resource * scan is complete. */ +#if defined(_MSC_VER) +extern "C" { // work around visual compiler mangling variables + extern URES res_all; +} +#else extern URES res_all; +#endif extern int res_all_size; /* We build the current new Include and Exclude items here */ @@ -246,7 +252,7 @@ static void scan_include_options(LEX *lc, int keyword, char *opts, int optlen) */ } else { for (i=0; FS_options[i].name; i++) { - if (strcasecmp(lc->str, FS_options[i].name) == 0 && FS_options[i].keyword == keyword) { + if (FS_options[i].keyword == keyword && strcasecmp(lc->str, FS_options[i].name) == 0) { /* NOTE! maximum 2 letters here or increase option[3] */ option[0] = FS_options[i].option[0]; option[1] = FS_options[i].option[1]; diff --git a/bacula/src/dird/job.c b/bacula/src/dird/job.c index 09499daa3e..984f932041 100644 --- a/bacula/src/dird/job.c +++ b/bacula/src/dird/job.c @@ -771,7 +771,7 @@ void create_unique_job_name(JCR *jcr, const char *base_name) V(mutex); /* allow creation of jobs */ jcr->start_time = now; /* Form Unique JobName */ - localtime_r(&now, &tm); + (void)localtime_r(&now, &tm); /* Use only characters that are permitted in Windows filenames */ strftime(dt, sizeof(dt), "%Y-%m-%d_%H.%M.%S", &tm); bstrncpy(name, base_name, sizeof(name)); diff --git a/bacula/src/dird/run_conf.c b/bacula/src/dird/run_conf.c index 44337d50fb..b7eb4896d0 100644 --- a/bacula/src/dird/run_conf.c +++ b/bacula/src/dird/run_conf.c @@ -25,7 +25,13 @@ #include "bacula.h" #include "dird.h" +#if defined(_MSC_VER) +extern "C" { // work around visual compiler mangling variables + extern URES res_all; +} +#else extern URES res_all; +#endif extern struct s_jl joblevels[]; /* Forward referenced subroutines */ diff --git a/bacula/src/dird/scheduler.c b/bacula/src/dird/scheduler.c index 498bef71f7..ada34c437a 100644 --- a/bacula/src/dird/scheduler.c +++ b/bacula/src/dird/scheduler.c @@ -259,7 +259,7 @@ static void find_runs() /* compute values for time now */ now = time(NULL); - localtime_r(&now, &tm); + (void)localtime_r(&now, &tm); hour = tm.tm_hour; minute = tm.tm_min; mday = tm.tm_mday - 1; @@ -274,7 +274,7 @@ static void find_runs() * sleeping. */ next_hour = now + 3600; - localtime_r(&next_hour, &tm); + (void)localtime_r(&next_hour, &tm); nh_hour = tm.tm_hour; nh_mday = tm.tm_mday - 1; nh_wday = tm.tm_wday; @@ -336,7 +336,7 @@ static void find_runs() Dmsg3(dbglvl, "run@%p: run_now=%d run_nh=%d\n", run, run_now, run_nh); /* find time (time_t) job is to be run */ - localtime_r(&now, &tm); /* reset tm structure */ + (void)localtime_r(&now, &tm); /* reset tm structure */ tm.tm_min = run->minute; /* set run minute */ tm.tm_sec = 0; /* zero secs */ if (run_now) { diff --git a/bacula/src/dird/sql_cmds.c b/bacula/src/dird/sql_cmds.c index a5291a751c..de34bead73 100644 --- a/bacula/src/dird/sql_cmds.c +++ b/bacula/src/dird/sql_cmds.c @@ -69,14 +69,13 @@ const char *drop_deltabs[] = { /* List of SQL commands to create temp table and indicies */ const char *create_deltabs[] = { "CREATE TEMPORARY TABLE DelCandidates (" -#ifdef HAVE_MYSQL +#if defined(HAVE_MYSQL) "JobId INTEGER UNSIGNED NOT NULL, " "PurgedFiles TINYINT, " "FileSetId INTEGER UNSIGNED, " "JobFiles INTEGER UNSIGNED, " "JobStatus BINARY(1))", -#else -#ifdef HAVE_POSTGRESQL +#elif defined(HAVE_POSTGRESQL) "JobId INTEGER NOT NULL, " "PurgedFiles SMALLINT, " "FileSetId INTEGER, " @@ -88,7 +87,6 @@ const char *create_deltabs[] = { "FileSetId INTEGER UNSIGNED, " "JobFiles INTEGER UNSIGNED, " "JobStatus CHAR)", -#endif #endif "CREATE INDEX DelInx1 ON DelCandidates (JobId)", NULL}; @@ -194,7 +192,7 @@ const char *uar_file = "AND Job.JobId=File.JobId " "AND Path.PathId=File.PathId AND Filename.FilenameId=File.FilenameId " "AND Filename.Name='%s' ORDER BY StartTime DESC LIMIT 20"; - #endif +#endif /* diff --git a/bacula/src/dird/ua_cmds.c b/bacula/src/dird/ua_cmds.c index 9b19f765c7..7e71408bb4 100644 --- a/bacula/src/dird/ua_cmds.c +++ b/bacula/src/dird/ua_cmds.c @@ -1084,7 +1084,7 @@ static int time_cmd(UAContext *ua, const char *cmd) char sdt[50]; time_t ttime = time(NULL); struct tm tm; - localtime_r(&ttime, &tm); + (void)localtime_r(&ttime, &tm); strftime(sdt, sizeof(sdt), "%d-%b-%Y %H:%M:%S", &tm); bsendmsg(ua, "%s\n", sdt); return 1; diff --git a/bacula/src/dird/ua_output.c b/bacula/src/dird/ua_output.c index d53d41ad11..a738dfe326 100644 --- a/bacula/src/dird/ua_output.c +++ b/bacula/src/dird/ua_output.c @@ -537,7 +537,7 @@ RUN *find_next_run(RUN *run, JOB *job, time_t &runtime, int ndays) future = now + (day * 60 * 60 * 24); /* Break down the time into components */ - localtime_r(&future, &tm); + (void)localtime_r(&future, &tm); mday = tm.tm_mday - 1; wday = tm.tm_wday; month = tm.tm_mon; @@ -571,7 +571,7 @@ RUN *find_next_run(RUN *run, JOB *job, time_t &runtime, int ndays) Dmsg1(000, "%s", buf); #endif /* find time (time_t) job is to be run */ - localtime_r(&future, &runtm); + (void)localtime_r(&future, &runtm); for (i= 0; i < 24; i++) { if (bit_is_set(i, run->hour)) { runtm.tm_hour = i; diff --git a/bacula/src/dird/ua_prune.c b/bacula/src/dird/ua_prune.c index e6d65dd512..bfbaf8f748 100644 --- a/bacula/src/dird/ua_prune.c +++ b/bacula/src/dird/ua_prune.c @@ -33,23 +33,23 @@ #define MAX_DEL_LIST_LEN 2000000 /* Imported variables */ -extern char *select_job; -extern char *drop_deltabs[]; -extern char *create_deltabs[]; -extern char *insert_delcand; -extern char *select_backup_del; -extern char *select_verify_del; -extern char *select_restore_del; -extern char *select_admin_del; -extern char *cnt_File; -extern char *del_File; -extern char *upd_Purged; -extern char *cnt_DelCand; -extern char *del_Job; -extern char *del_MAC; -extern char *del_JobMedia; -extern char *cnt_JobMedia; -extern char *sel_JobMedia; +extern const char *select_job; +extern const char *drop_deltabs[]; +extern const char *create_deltabs[]; +extern const char *insert_delcand; +extern const char *select_backup_del; +extern const char *select_verify_del; +extern const char *select_restore_del; +extern const char *select_admin_del; +extern const char *cnt_File; +extern const char *del_File; +extern const char *upd_Purged; +extern const char *cnt_DelCand; +extern const char *del_Job; +extern const char *del_MAC; +extern const char *del_JobMedia; +extern const char *cnt_JobMedia; +extern const char *sel_JobMedia; /* In memory list of JobIds */ diff --git a/bacula/src/dird/ua_query.c b/bacula/src/dird/ua_query.c index ba8cd81534..6e1a3c2b84 100644 --- a/bacula/src/dird/ua_query.c +++ b/bacula/src/dird/ua_query.c @@ -55,7 +55,7 @@ int querycmd(UAContext *ua, const char *cmd) if (!open_db(ua)) { goto bail_out; } - if ((fd=fopen(query_file, "r")) == NULL) { + if ((fd=fopen(query_file, "rb")) == NULL) { bsendmsg(ua, _("Could not open %s: ERR=%s\n"), query_file, strerror(errno)); goto bail_out; diff --git a/bacula/src/dird/ua_restore.c b/bacula/src/dird/ua_restore.c index a625da14c9..78889be8ff 100644 --- a/bacula/src/dird/ua_restore.c +++ b/bacula/src/dird/ua_restore.c @@ -36,15 +36,15 @@ extern void print_bsr(UAContext *ua, RBSR *bsr); /* Imported variables */ -extern char *uar_list_jobs, *uar_file, *uar_sel_files; -extern char *uar_del_temp, *uar_del_temp1, *uar_create_temp; -extern char *uar_create_temp1, *uar_last_full, *uar_full; -extern char *uar_inc, *uar_list_temp, *uar_sel_jobid_temp; -extern char *uar_sel_all_temp1, *uar_sel_fileset, *uar_mediatype; -extern char *uar_jobid_fileindex, *uar_dif, *uar_sel_all_temp; -extern char *uar_count_files, *uar_jobids_fileindex; -extern char *uar_jobid_fileindex_from_dir; -extern char *uar_jobid_fileindex_from_table; +extern const char *uar_list_jobs, *uar_file, *uar_sel_files; +extern const char *uar_del_temp, *uar_del_temp1, *uar_create_temp; +extern const char *uar_create_temp1, *uar_last_full, *uar_full; +extern const char *uar_inc, *uar_list_temp, *uar_sel_jobid_temp; +extern const char *uar_sel_all_temp1, *uar_sel_fileset, *uar_mediatype; +extern const char *uar_jobid_fileindex, *uar_dif, *uar_sel_all_temp; +extern const char *uar_count_files, *uar_jobids_fileindex; +extern const char *uar_jobid_fileindex_from_dir; +extern const char *uar_jobid_fileindex_from_table; @@ -276,7 +276,7 @@ static int user_select_jobids_or_files(UAContext *ua, RESTORE_CTX *rx) char date[MAX_TIME_LENGTH]; bool have_date = false; JobId_t JobId; - JOB_DBR jr; + JOB_DBR jr = { (JobId_t)-1 }; bool done = false; int i, j; const char *list[] = { @@ -678,7 +678,7 @@ static void insert_one_file_or_dir(UAContext *ua, RESTORE_CTX *rx, char *date, b switch (*p) { case '<': p++; - if ((ffd = fopen(p, "r")) == NULL) { + if ((ffd = fopen(p, "rb")) == NULL) { berrno be; bsendmsg(ua, _("Cannot open file %s: ERR=%s\n"), p, be.strerror()); diff --git a/bacula/src/dird/ua_run.c b/bacula/src/dird/ua_run.c index 52315f6976..5aa292d101 100644 --- a/bacula/src/dird/ua_run.c +++ b/bacula/src/dird/ua_run.c @@ -866,7 +866,7 @@ try_again: } if (ua->cmd[0] != 0) { jcr->RestoreBootstrap = bstrdup(ua->cmd); - fd = fopen(jcr->RestoreBootstrap, "r"); + fd = fopen(jcr->RestoreBootstrap, "rb"); if (!fd) { bsendmsg(ua, _("Warning cannot open %s: ERR=%s\n"), jcr->RestoreBootstrap, strerror(errno)); diff --git a/bacula/src/dird/ua_update.c b/bacula/src/dird/ua_update.c index ccf7db8916..75a1a3489d 100644 --- a/bacula/src/dird/ua_update.c +++ b/bacula/src/dird/ua_update.c @@ -26,7 +26,7 @@ #include "dird.h" /* External variables */ -extern char *list_pool; /* in sql_cmds.c */ +extern const char *list_pool; /* in sql_cmds.c */ /* Imported functions */ void update_slots(UAContext *ua); diff --git a/bacula/src/filed/estimate.c b/bacula/src/filed/estimate.c index 1651f2d457..ccf2e660f3 100644 --- a/bacula/src/filed/estimate.c +++ b/bacula/src/filed/estimate.c @@ -67,6 +67,7 @@ static int tally_file(FF_PKT *ff_pkt, void *ijcr, bool top_level) case FT_NORECURSE: case FT_NOFSCHG: case FT_INVALIDFS: + case FT_INVALIDDT: case FT_DIREND: case FT_SPEC: case FT_RAW: diff --git a/bacula/src/filed/filed.c b/bacula/src/filed/filed.c index ae021bbf2c..5145735a1c 100644 --- a/bacula/src/filed/filed.c +++ b/bacula/src/filed/filed.c @@ -74,7 +74,7 @@ static void usage() * Main Bacula Unix Client Program * */ -#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32) +#if defined(HAVE_WIN32) #define main BaculaMain #endif diff --git a/bacula/src/filed/filed_conf.c b/bacula/src/filed/filed_conf.c index e20709827d..f06d921eff 100644 --- a/bacula/src/filed/filed_conf.c +++ b/bacula/src/filed/filed_conf.c @@ -57,15 +57,14 @@ RES **res_head = sres_head; * then move it to allocated memory when the resource * scan is complete. */ -#if defined(HAVE_WIN32) && !defined(HAVE_CYGWIN) +#if defined(_MSC_VER) extern "C" { // work around visual compiler mangling variables URES res_all; - int res_all_size = sizeof(res_all); } #else URES res_all; -int res_all_size = sizeof(res_all); #endif +int res_all_size = sizeof(res_all); /* Definition of records permitted within each * resource with the routine to process the record diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index 1e6835c780..96365bff36 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -338,9 +338,7 @@ static int cancel_cmd(JCR *jcr) if (cjcr->store_bsock) { cjcr->store_bsock->timed_out = 1; cjcr->store_bsock->terminated = 1; -#if !defined(HAVE_CYGWIN) pthread_kill(cjcr->my_thread_id, TIMEOUT_SIGNAL); -#endif } set_jcr_job_status(cjcr, JS_Canceled); free_jcr(cjcr); @@ -400,7 +398,7 @@ static int job_cmd(JCR *jcr) { BSOCK *dir = jcr->dir_bsock; POOLMEM *sd_auth_key; - + sd_auth_key = get_memory(dir->msglen); if (sscanf(dir->msg, jobcmd, &jcr->JobId, jcr->Job, &jcr->VolSessionId, &jcr->VolSessionTime, @@ -604,7 +602,7 @@ static void add_file_to_fileset(JCR *jcr, const char *fname, findFILESET *filese case '<': Dmsg0(100, "Doing < include on client.\n"); p++; /* skip over < */ - if ((ffd = fopen(p, "r")) == NULL) { + if ((ffd = fopen(p, "rb")) == NULL) { berrno be; Jmsg(jcr, M_FATAL, 0, _("Cannot open FileSet input file: %s. ERR=%s\n"), p, be.strerror()); @@ -1011,7 +1009,7 @@ static int bootstrap_cmd(JCR *jcr) jcr->Job); Dmsg1(400, "bootstrap=%s\n", fname); jcr->RestoreBootstrap = fname; - bs = fopen(fname, "a+"); /* create file */ + bs = fopen(fname, "a+b"); /* create file */ if (!bs) { berrno be; Jmsg(jcr, M_FATAL, 0, _("Could not create bootstrap file %s: ERR=%s\n"), @@ -1695,7 +1693,7 @@ static int send_bootstrap_file(JCR *jcr) if (!jcr->RestoreBootstrap) { return 1; } - bs = fopen(jcr->RestoreBootstrap, "r"); + bs = fopen(jcr->RestoreBootstrap, "rb"); if (!bs) { berrno be; Jmsg(jcr, M_FATAL, 0, _("Could not open bootstrap file %s: ERR=%s\n"), diff --git a/bacula/src/filed/status.c b/bacula/src/filed/status.c index e96060aead..2c90d7a0a9 100755 --- a/bacula/src/filed/status.c +++ b/bacula/src/filed/status.c @@ -40,7 +40,7 @@ static char qstatus[] = ".status %s\n"; static char OKqstatus[] = "2000 OK .status\n"; static char DotStatusJob[] = "JobId=%d JobStatus=%c JobErrors=%d\n"; -#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32) +#if defined(HAVE_WIN32) static int privs = 0; #endif #ifdef WIN32_VSS @@ -71,7 +71,7 @@ static void do_status(void sendit(const char *msg, int len, void *sarg), void *a len = Mmsg(msg, _("Daemon started %s, %d Job%s run since started.\n"), dt, num_jobs_run, num_jobs_run == 1 ? "" : "s"); sendit(msg, len, arg); -#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32) +#if defined(HAVE_WIN32) if (debug_level > 0) { if (!privs) { privs = enable_backup_privileges(NULL, 1); @@ -402,7 +402,7 @@ static const char *level_to_str(int level) } -#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32) +#if defined(HAVE_WIN32) #include int bacstat = 0; @@ -493,4 +493,4 @@ done: return buf; } -#endif /* HAVE_CYGWIN */ +#endif /* HAVE_WIN32 */ diff --git a/bacula/src/findlib/attribs.c b/bacula/src/findlib/attribs.c index 3988eae7aa..fdf0c67322 100755 --- a/bacula/src/findlib/attribs.c +++ b/bacula/src/findlib/attribs.c @@ -26,7 +26,7 @@ #include "bacula.h" #include "find.h" -#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32) +#if defined(HAVE_WIN32) #include "../lib/winapi.h" @@ -36,7 +36,7 @@ static bool set_win32_attributes(JCR *jcr, ATTR *attr, BFILE *ofd); void unix_name_to_win32(POOLMEM **win32_name, char *name); void win_error(JCR *jcr, char *prefix, POOLMEM *ofile); HANDLE bget_handle(BFILE *bfd); -#endif +#endif /* HAVE_WIN32 */ /* For old systems that don't have lchown() use chown() */ #ifndef HAVE_LCHOWN @@ -219,6 +219,7 @@ void encode_stat(char *buf, FF_PKT *ff_pkt, int data_stream) #endif #endif + /* Decode a stat packet from base64 characters */ int decode_stat(char *buf, struct stat *statp, int32_t *LinkFI) { @@ -362,7 +363,7 @@ bool set_attributes(JCR *jcr, ATTR *attr, BFILE *ofd) bool ok = true; off_t fsize; -#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32) +#if defined(HAVE_WIN32) if (attr->stream == STREAM_UNIX_ATTRIBUTES_EX && set_win32_attributes(jcr, attr, ofd)) { if (is_bopen(ofd)) { @@ -467,7 +468,7 @@ bool set_attributes(JCR *jcr, ATTR *attr, BFILE *ofd) /* */ /*=============================================================*/ -#if !defined(HAVE_CYGWIN) && !defined(HAVE_WIN32) +#if !defined(HAVE_WIN32) /* * It is possible to piggyback additional data e.g. ACLs on @@ -507,7 +508,7 @@ int encode_attribsEx(JCR *jcr, char *attribsEx, FF_PKT *ff_pkt) /* */ /*=============================================================*/ -#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32) +#if defined(HAVE_WIN32) int encode_attribsEx(JCR *jcr, char *attribsEx, FF_PKT *ff_pkt) { @@ -726,4 +727,4 @@ void unix_name_to_win32(POOLMEM **win32_name, char *name) conv_unix_to_win32_path(name, *win32_name, dwSize); } -#endif /* HAVE_CYGWIN */ +#endif /* HAVE_WIN32 */ diff --git a/bacula/src/findlib/bfile.c b/bacula/src/findlib/bfile.c index 21ea1705bd..8f930ed5d2 100644 --- a/bacula/src/findlib/bfile.c +++ b/bacula/src/findlib/bfile.c @@ -253,7 +253,7 @@ bool processWin32BackupAPIBlock (BFILE *bfd, void *pBuffer, ssize_t dwSize) * =============================================================== */ -#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32) +#if defined(HAVE_WIN32) void unix_name_to_win32(POOLMEM **win32_name, char *name); extern "C" HANDLE get_osfhandle(int fd); diff --git a/bacula/src/findlib/bfile.h b/bacula/src/findlib/bfile.h index 46b58cc1c7..69cce6fb68 100644 --- a/bacula/src/findlib/bfile.h +++ b/bacula/src/findlib/bfile.h @@ -64,7 +64,7 @@ typedef struct _PROCESS_WIN32_BACKUPAPIBLOCK_CONTEXT { * * ======================================================= */ -#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32) +#if defined(HAVE_WIN32) #include #include "../lib/winapi.h" @@ -79,7 +79,7 @@ enum { /* Basic Win32 low level I/O file packet */ struct BFILE { - int use_backup_api; /* set if using BackupRead/Write */ + bool use_backup_api; /* set if using BackupRead/Write */ int mode; /* set if file is open */ HANDLE fh; /* Win32 file handle */ int fid; /* fd if doing Unix style */ diff --git a/bacula/src/findlib/drivetype.c b/bacula/src/findlib/drivetype.c new file mode 100644 index 0000000000..a12fef363b --- /dev/null +++ b/bacula/src/findlib/drivetype.c @@ -0,0 +1,116 @@ +/* + * Implement routines to determine drive type (Windows specific). + * + * Written by Robert Nelson, June 2006 + * + * Version $Id$ + */ + +/* + Copyright (C) 2006 Kern Sibbald + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + version 2 as amended with additional clauses defined in the + file LICENSE in the main source directory. + + 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 + the file LICENSE for additional details. + + */ + +#ifndef TEST_PROGRAM + +#include "bacula.h" +#include "find.h" + +#else /* Set up for testing a stand alone program */ + +#include +#include +#include +#define SUPPORTEDOSES \ + "HAVE_WIN32\n" +#define false 0 +#define true 1 +#define bstrncpy strncpy +#define Dmsg0(n,s) fprintf(stderr, s) +#define Dmsg1(n,s,a1) fprintf(stderr, s, a1) +#define Dmsg2(n,s,a1,a2) fprintf(stderr, s, a1, a2) +#endif + +/* + * These functions should be implemented for each OS + * + * bool drivetype(const char *fname, char *dt, int dtlen); + */ + +#if defined (HAVE_WIN32) +/* Windows */ + +bool drivetype(const char *fname, char *dt, int dtlen) +{ + CHAR rootpath[4]; + UINT type; + + /* Copy Drive Letter, colon, and backslash to rootpath */ + bstrncpy(rootpath, fname, 3); + rootpath[3] = '\0'; + + type = GetDriveType(rootpath); + + switch (type) { + case DRIVE_REMOVABLE: bstrncpy(dt, "removable", dtlen); return true; + case DRIVE_FIXED: bstrncpy(dt, "fixed", dtlen); return true; + case DRIVE_REMOTE: bstrncpy(dt, "remote", dtlen); return true; + case DRIVE_CDROM: bstrncpy(dt, "cdrom", dtlen); return true; + case DRIVE_RAMDISK: bstrncpy(dt, "ramdisk", dtlen); return true; + case DRIVE_UNKNOWN: + case DRIVE_NO_ROOT_DIR: + default: + return false; + } +} +/* Windows */ + +#else /* No recognised OS */ + +bool drivetype(const char *fname, char *dt, int dtlen) +{ + Dmsg0(10, "!!! drivetype() not implemented for this OS. !!!\n"); +#ifdef TEST_PROGRAM + Dmsg1(10, "Please define one of the following when compiling:\n\n%s\n", + SUPPORTEDOSES); + exit(EXIT_FAILURE); +#endif + + return false; +} +#endif + +#ifdef TEST_PROGRAM +int main(int argc, char **argv) +{ + char *p; + char dt[1000]; + int status = 0; + + if (argc < 2) { + p = (argc < 1) ? "drivetype" : argv[0]; + printf("usage:\t%s path ...\n" + "\t%s prints the drive type and pathname of the paths.\n", + p, p); + return EXIT_FAILURE; + } + while (*++argv) { + if (!drivetype(*argv, dt, sizeof(dt))) { + status = EXIT_FAILURE; + } else { + printf("%s\t%s\n", dt, *argv); + } + } + return status; +} +#endif diff --git a/bacula/src/findlib/enable_priv.c b/bacula/src/findlib/enable_priv.c index 8fd78fbd9c..34539eb8eb 100755 --- a/bacula/src/findlib/enable_priv.c +++ b/bacula/src/findlib/enable_priv.c @@ -37,7 +37,7 @@ /* */ /*=============================================================*/ -#if !defined(HAVE_CYGWIN) && !defined(HAVE_WIN32) +#if !defined(HAVE_WIN32) int enable_backup_privileges(JCR *jcr, int ignore_errors) { return 0; } @@ -53,7 +53,7 @@ int enable_backup_privileges(JCR *jcr, int ignore_errors) /* */ /*=============================================================*/ -#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32) +#if defined(HAVE_WIN32) void win_error(JCR *jcr, char *prefix, DWORD lerror); @@ -155,4 +155,4 @@ int enable_backup_privileges(JCR *jcr, int ignore_errors) return stat; } -#endif /* HAVE_CYGWIN */ +#endif /* HAVE_WIN32 */ diff --git a/bacula/src/findlib/find.c b/bacula/src/findlib/find.c index 1565234489..8fde075a35 100644 --- a/bacula/src/findlib/find.c +++ b/bacula/src/findlib/find.c @@ -97,7 +97,7 @@ get_win32_driveletters(FF_PKT *ff, char* szDrives) { /* szDrives must be at least 27 bytes long */ -#ifndef WIN32 +#if !defined(HAVE_WIN32) return 0; #endif @@ -209,9 +209,9 @@ static bool accept_file(FF_PKT *ff) if (ff->flags & FO_EXCLUDE) { Dmsg2(100, "Exclude wilddir: %s file=%s\n", (char *)fo->wilddir.get(k), ff->fname); - return false; /* reject file */ + return false; /* reject dir */ } - return true; /* accept file */ + return true; /* accept dir */ } } } else { @@ -325,6 +325,7 @@ static int our_callback(FF_PKT *ff, void *hpkt, bool top_level) case FT_NORECURSE: case FT_NOFSCHG: case FT_INVALIDFS: + case FT_INVALIDDT: case FT_NOOPEN: // return ff->callback(ff, hpkt, top_level); diff --git a/bacula/src/findlib/makepath.c b/bacula/src/findlib/makepath.c index 11eb9f804e..70e7feaf4c 100644 --- a/bacula/src/findlib/makepath.c +++ b/bacula/src/findlib/makepath.c @@ -136,7 +136,7 @@ make_dir(JCR *jcr, const char *dir, const char *dirpath, mode_t mode, int *creat int isAbsolute(const char *path) { -#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32) +#if defined(HAVE_WIN32) return path[1] == ':' || *path == '/' || *path == '\\'; /* drivespec:/blah is absolute */ #else return *path == '/'; @@ -213,12 +213,6 @@ make_path( re_protect = 0; } -#if defined(HAVE_CYGWIN) - /* Because of silly Win32 security, we allow everything */ - tmp_mode = S_IRWXUGO; - re_protect = 0; - -#endif #if defined(HAVE_WIN32) // chdir can fail if permissions are sufficiently restricted since I don't think // backup/restore security rights affect ChangeWorkingDirectory diff --git a/bacula/src/findlib/match.c b/bacula/src/findlib/match.c index a5d9d8f713..4c239840a9 100644 --- a/bacula/src/findlib/match.c +++ b/bacula/src/findlib/match.c @@ -39,7 +39,7 @@ #endif /* Fold case in fnmatch() on Win32 */ -#ifdef WIN32 +#ifdef HAVE_WIN32 static const int fnmode = FNM_CASEFOLD; #else static const int fnmode = 0; @@ -213,7 +213,7 @@ void add_fname_to_include_list(FF_PKT *ff, int prefixed, const char *fname) break; } } -#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32) +#if defined(HAVE_WIN32) /* Convert any \'s into /'s */ for (p=inc->fname; *p; p++) { if (*p == '\\') { @@ -247,7 +247,7 @@ void add_fname_to_exclude_list(FF_PKT *ff, const char *fname) Dmsg1(20, "Add name to exclude: %s\n", fname); -#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32) +#if defined(HAVE_WIN32) if (strchr(fname, '/') || strchr(fname, '\\')) { #else if (strchr(fname, '/')) { @@ -263,7 +263,7 @@ void add_fname_to_exclude_list(FF_PKT *ff, const char *fname) exc->next = *list; exc->len = len; strcpy(exc->fname, fname); -#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32) +#if defined(HAVE_WIN32) /* Convert any \'s into /'s */ for (char *p=exc->fname; *p; p++) { if (*p == '\\') { diff --git a/bacula/src/lib/base64.c b/bacula/src/lib/base64.c index d81b00cd18..19e83ce49d 100644 --- a/bacula/src/lib/base64.c +++ b/bacula/src/lib/base64.c @@ -157,7 +157,7 @@ bin_to_base64(char *buf, char *bin, int len) } save = reg; reg >>= (rem - 6); - buf[j++] = base64_digits[reg & (uint32_t)0x3F]; + buf[j++] = base64_digits[reg & 0x3F]; reg = save; rem -= 6; } diff --git a/bacula/src/lib/berrno.c b/bacula/src/lib/berrno.c index 03b4eb381a..76641fd49b 100644 --- a/bacula/src/lib/berrno.c +++ b/bacula/src/lib/berrno.c @@ -36,12 +36,13 @@ extern int execvp_errors[]; const char *berrno::strerror() { - int stat = 0; #ifdef HAVE_WIN32 if (berrno_ & b_errno_win32) { return (const char *)buf_; } #else + int stat = 0; + if (berrno_ & b_errno_exit) { stat = (berrno_ & ~b_errno_exit); /* remove bit */ if (stat == 0) { diff --git a/bacula/src/lib/bnet.c b/bacula/src/lib/bnet.c index eb58d956b4..7ebaecd940 100644 --- a/bacula/src/lib/bnet.c +++ b/bacula/src/lib/bnet.c @@ -1003,7 +1003,7 @@ bool bnet_set_buffer_size(BSOCK * bs, uint32_t size, int rw) * Returns previous socket flag */ int bnet_set_nonblocking (BSOCK *bsock) { -#ifndef WIN32 +#ifndef HAVE_WIN32 int oflags; /* Get current flags */ @@ -1038,7 +1038,7 @@ int bnet_set_nonblocking (BSOCK *bsock) { */ int bnet_set_blocking (BSOCK *bsock) { -#ifndef WIN32 +#ifndef HAVE_WIN32 int oflags; /* Get current flags */ if ((oflags = fcntl(bsock->fd, F_GETFL, 0)) < 0) { @@ -1071,7 +1071,7 @@ int bnet_set_blocking (BSOCK *bsock) */ void bnet_restore_blocking (BSOCK *bsock, int flags) { -#ifndef WIN32 +#ifndef HAVE_WIN32 if ((fcntl(bsock->fd, F_SETFL, flags)) < 0) { berrno be; Jmsg1(bsock->jcr, M_ABORT, 0, _("fcntl F_SETFL error. ERR=%s\n"), be.strerror()); diff --git a/bacula/src/lib/bpipe.c b/bacula/src/lib/bpipe.c index a28f3650b3..12a5d8b925 100644 --- a/bacula/src/lib/bpipe.c +++ b/bacula/src/lib/bpipe.c @@ -32,7 +32,7 @@ int execvp_errors[] = { E2BIG, ENAMETOOLONG, ENOMEM, -#ifndef WIN32 +#ifndef HAVE_WIN32 ETXTBSY, #endif ENOENT @@ -232,7 +232,7 @@ int close_bpipe(BPIPE *bpipe) } Dmsg1(800, "child status=%d\n", stat & ~b_errno_exit); } else if (WIFSIGNALED(chldstatus)) { /* process died */ -#ifndef WIN32 +#ifndef HAVE_WIN32 stat = WTERMSIG(chldstatus); #else #warning "WTERMSIG undefined in Win32 !!!" diff --git a/bacula/src/lib/bshm.c b/bacula/src/lib/bshm.c index 41f62cf4d8..7849266e39 100644 --- a/bacula/src/lib/bshm.c +++ b/bacula/src/lib/bshm.c @@ -38,7 +38,7 @@ #include "bacula.h" -#if !defined(HAVE_CYGWIN) && !defined(HAVE_WIN32) +#if !defined(HAVE_WIN32) #ifdef NEED_SHARED_MEMORY #define SHM_KEY 0x0BACB01 /* key for shared memory */ @@ -145,6 +145,6 @@ void shm_destroy(BSHM *shm) #endif } -#endif /* ! HAVE_CYGWIN */ +#endif /* ! HAVE_WIN32 */ #endif diff --git a/bacula/src/lib/bsys.c b/bacula/src/lib/bsys.c index 7ccfa0f9b3..26a9b72cae 100644 --- a/bacula/src/lib/bsys.c +++ b/bacula/src/lib/bsys.c @@ -417,7 +417,7 @@ void b_memset(const char *file, int line, void *mem, int val, size_t num) } #endif -#if !defined(HAVE_CYGWIN) && !defined(HAVE_WIN32) +#if !defined(HAVE_WIN32) static int del_pid_file_ok = FALSE; #endif @@ -426,7 +426,7 @@ static int del_pid_file_ok = FALSE; */ void create_pid_file(char *dir, const char *progname, int port) { -#if !defined(HAVE_CYGWIN) && !defined(HAVE_WIN32) +#if !defined(HAVE_WIN32) int pidfd, len; int oldpid; char pidbuf[20]; @@ -469,7 +469,7 @@ void create_pid_file(char *dir, const char *progname, int port) */ int delete_pid_file(char *dir, const char *progname, int port) { -#if !defined(HAVE_CYGWIN) && !defined(HAVE_WIN32) +#if !defined(HAVE_WIN32) POOLMEM *fname = get_pool_memory(PM_FNAME); if (!del_pid_file_ok) { diff --git a/bacula/src/lib/btime.c b/bacula/src/lib/btime.c index 943a886088..79fc7578f9 100644 --- a/bacula/src/lib/btime.c +++ b/bacula/src/lib/btime.c @@ -48,7 +48,7 @@ char *bstrftime(char *dt, int maxlen, utime_t tim) struct tm tm; /* ***FIXME**** the format and localtime_r() should be user configurable */ - localtime_r(&ttime, &tm); + (void)localtime_r(&ttime, &tm); strftime(dt, maxlen, "%d-%b-%Y %H:%M", &tm); return dt; } @@ -60,7 +60,7 @@ char *bstrftimes(char *dt, int maxlen, utime_t tim) struct tm tm; /* ***FIXME**** the format and localtime_r() should be user configurable */ - localtime_r(&ttime, &tm); + (void)localtime_r(&ttime, &tm); strftime(dt, maxlen, "%d-%b-%Y %H:%M:%S", &tm); return dt; } @@ -73,7 +73,7 @@ char *bstrftime_ny(char *dt, int maxlen, utime_t tim) struct tm tm; /* ***FIXME**** the format and localtime_r() should be user configurable */ - localtime_r(&ttime, &tm); + (void)localtime_r(&ttime, &tm); strftime(dt, maxlen, "%d-%b %H:%M", &tm); return dt; } @@ -86,7 +86,7 @@ char *bstrftime_nc(char *dt, int maxlen, utime_t tim) struct tm tm; /* ***FIXME**** the format and localtime_r() should be user configurable */ - localtime_r(&ttime, &tm); + (void)localtime_r(&ttime, &tm); /* NOTE! since the compiler complains about %y, I use %y and cut the century */ strftime(dt, maxlen, "%d-%b-%Y %H:%M", &tm); strcpy(dt+7, dt+9); @@ -99,7 +99,7 @@ char *bstrutime(char *dt, int maxlen, utime_t tim) { time_t ttime = (time_t)tim; struct tm tm; - localtime_r(&ttime, &tm); + (void)localtime_r(&ttime, &tm); strftime(dt, maxlen, "%Y-%m-%d %H:%M:%S", &tm); return dt; } @@ -197,12 +197,12 @@ int tm_woy(time_t stime) time_t time4; struct tm tm; memset(&tm, 0, sizeof(struct tm)); - localtime_r(&stime, &tm); + (void)localtime_r(&stime, &tm); tm_yday = tm.tm_yday; tm.tm_mon = 0; tm.tm_mday = 4; time4 = mktime(&tm); - localtime_r(&time4, &tm); + (void)localtime_r(&time4, &tm); fty = 1 - tm.tm_wday; if (fty <= 0) { fty += 7; @@ -221,7 +221,7 @@ void get_current_time(struct date_time *dt) time_t now; now = time(NULL); - gmtime_r(&now, &tm); + (void)gmtime_r(&now, &tm); Dmsg6(200, "m=%d d=%d y=%d h=%d m=%d s=%d\n", tm.tm_mon+1, tm.tm_mday, tm.tm_year+1900, tm.tm_hour, tm.tm_min, tm.tm_sec); tm_encode(dt, &tm); diff --git a/bacula/src/lib/daemon.c b/bacula/src/lib/daemon.c index 871a25e169..540c5f711e 100644 --- a/bacula/src/lib/daemon.c +++ b/bacula/src/lib/daemon.c @@ -34,7 +34,7 @@ extern int debug_level; void daemon_start() { -#if !defined(HAVE_CYGWIN) && !defined(HAVE_WIN32) +#if !defined(HAVE_WIN32) int i; pid_t cpid; mode_t oldmask; @@ -101,6 +101,6 @@ daemon_start() } } -#endif /* HAVE_CYGWIN */ +#endif /* HAVE_WIN32 */ Dmsg0(900, "Exit daemon_start\n"); } diff --git a/bacula/src/lib/enh_fnmatch.c b/bacula/src/lib/enh_fnmatch.c new file mode 100644 index 0000000000..090f68efdb --- /dev/null +++ b/bacula/src/lib/enh_fnmatch.c @@ -0,0 +1,285 @@ +/* Copyright (C) 1991, 1992, 1993, 1996, 1997 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* Modified version of fnmatch.c - Robert Nelson */ + +#include "bacula.h" +#include "enh_fnmatch.h" + +# ifndef errno +extern int errno; +# endif + +int +enh_fnmatch_sub(const char *pattern, const char *string, int patternlen, int flags) +{ + register const char *p = pattern, *n = string; + register char c; + +/* Note that this evaluates C many times. */ +# define FOLD(c) ((flags & FNM_CASEFOLD) && B_ISUPPER (c) ? tolower (c) : (c)) + + while ((p - pattern) < patternlen) + { + c = *p++; + c = FOLD (c); + + switch (c) + { + case '?': + if (*n == '\0') + return 0; + else if ((flags & FNM_FILE_NAME) && *n == '/') + return 0; + else if ((flags & FNM_PERIOD) && *n == '.' && + (n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/'))) + return 0; + break; + + case '\\': + if (!(flags & FNM_NOESCAPE)) + { + if ((p - pattern) >= patternlen) + /* Trailing \ loses. */ + return 0; + + c = *p++; + c = FOLD(c); + } + if (FOLD (*n) != c) + return 0; + break; + + case '*': + if ((flags & FNM_PERIOD) && *n == '.' && + (n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/'))) + return FNM_NOMATCH; + + if ((p - pattern) >= patternlen) + return patternlen; + + for (c = *p++; ((p - pattern) <= patternlen) && (c == '?' || c == '*'); c = *p++) + { + if ((flags & FNM_FILE_NAME) && *n == '/') + /* A slash does not match a wildcard under FNM_FILE_NAME. */ + return 0; + else if (c == '?') + { + /* A ? needs to match one character. */ + if (*n == '\0') + /* There isn't another character; no match. */ + return 0; + else + /* One character of the string is consumed in matching + this ? wildcard, so *??? won't match if there are + less than three characters. */ + ++n; + } + } + + if ((p - pattern) >= patternlen) + return patternlen; + + { + char c1 = (!(flags & FNM_NOESCAPE) && c == '\\') ? *p : c; + c1 = FOLD (c1); + for (--p; *n != '\0'; ++n) + { + if (c == '[' || c == '{' || FOLD((unsigned char)*n) == c1) + { + int len; + + len = enh_fnmatch_sub(p, n, (int)(patternlen - (p - pattern)), flags & ~FNM_PERIOD); + + if (len > 0 && n[len] == '\0') + return (int)(n - string + len); + } + else + { + if ((flags & FNM_FILE_NAME) && *n == '/') + return 0; /* A slash does not match a wildcard under FNM_FILE_NAME. */ + } + + } + return 0; + } + + case '{': + { + const char *pstart = p; + + while ((p - pattern) < patternlen) + { + c = *p++; + + if (!(flags & FNM_NOESCAPE) && c == '\\') + { + if ((p - pattern) >= patternlen) + return 0; + + ++p; + continue; + } + + if (c == ',' || c == '}') + { + int matchlen; + + matchlen = enh_fnmatch_sub(pstart, n, (int)(p - pstart - 1), flags & ~FNM_PERIOD); + + if (matchlen > 0) + { + n += matchlen - 1; + while (c != '}') + { + if (!(flags & FNM_NOESCAPE) && c == '\\') + { + if ((p - pattern) >= patternlen) + return 0; + + ++p; + } + + if ((p - pattern) >= patternlen) + return 0; + + c = *p++; + } + break; + } + + if (c == '}') + return 0; + + pstart = p; + } + } + break; + } + + case '[': + { + /* Nonzero if the sense of the character class is inverted. */ + register int nnot; + + if (*n == '\0') + return 0; + + if ((flags & FNM_PERIOD) && *n == '.' && + (n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/'))) + return 0; + + nnot = (*p == '!' || *p == '^'); + if (nnot) + ++p; + + if ((p - pattern) >= patternlen) + /* [ (unterminated) loses. */ + return 0; + + c = *p++; + + for (;;) + { + register char cstart, cend; + + cstart = cend = FOLD (c); + + if ((p - pattern) >= patternlen) + /* [ (unterminated) loses. */ + return 0; + + c = *p++; + c = FOLD (c); + + if ((flags & FNM_FILE_NAME) && c == '/') + /* [/] can never match. */ + return 0; + + if (c == '-' && *p != ']') + { + if ((p - pattern) >= patternlen) + return 0; + + cend = *p++; + + cend = FOLD (cend); + + if ((p - pattern) >= patternlen) + return 0; + + c = *p++; + } + + if (FOLD (*n) >= cstart && FOLD (*n) <= cend) + goto matched; + + if (c == ']') + break; + } + if (!nnot) + return 0; + break; + + matched:; + /* Skip the rest of the [...] that already matched. */ + while (c != ']') + { + if ((p - pattern) >= patternlen) + return 0; + + c = *p++; + } + if (nnot) + return 0; + } + break; + + default: + if (c != FOLD (*n)) + return 0; + break; + } + + ++n; + } + + return (int)(n - string); + +# undef FOLD +} + +/* Match STRING against the filename pattern PATTERN, returning number of characters + in STRING that were matched if all of PATTERN matches, nonzero if not. */ +int +enh_fnmatch(const char *pattern, const char *string, int flags) +{ + int matchlen; + + matchlen = enh_fnmatch_sub(pattern, string, (int)strlen(pattern), flags); + + if (matchlen == 0) + return FNM_NOMATCH; + + if (string[matchlen] == '\0') + return 0; + + if ((flags & FNM_LEADING_DIR) && string[matchlen] == '/') + /* The FNM_LEADING_DIR flag says that "foo*" matches "foobar/frobozz". */ + return 0; + + return FNM_NOMATCH; +} diff --git a/bacula/src/lib/enh_fnmatch.h b/bacula/src/lib/enh_fnmatch.h new file mode 100644 index 0000000000..0a530163cc --- /dev/null +++ b/bacula/src/lib/enh_fnmatch.h @@ -0,0 +1,51 @@ +/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. + +NOTE: The canonical source of this file is maintained with the GNU C Library. +Bugs can be reported to bug-glibc@prep.ai.mit.edu. + +This program is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software Foundation, +Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* Modified version of fnmatch.h - Robert Nelson */ + +#ifndef _ENH_FNMATCH_H + +#define _ENH_FNMATCH_H 1 + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined (__cplusplus) || (defined (__STDC__) && __STDC__) +#undef __P +#define __P(protos) protos +#else /* Not C++ or ANSI C. */ +#undef __P +#define __P(protos) () +/* We can get away without defining `const' here only because in this file + it is used only inside the prototype for `fnmatch', which is elided in + non-ANSI C where `const' is problematical. */ +#endif /* C++ or ANSI C. */ + + +/* Match STRING against the filename pattern PATTERN, + returning zero if it matches, FNM_NOMATCH if not. */ +extern int enh_fnmatch __P ((const char *__pattern, const char *__string, + int __flags)); + +#ifdef __cplusplus +} +#endif + +#endif /* fnmatch.h */ diff --git a/bacula/src/lib/events.c b/bacula/src/lib/events.c index 861c8c8b78..782778e12a 100644 --- a/bacula/src/lib/events.c +++ b/bacula/src/lib/events.c @@ -138,7 +138,7 @@ bailout: #endif /* IMPLEMENTED */ -#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32) +#if defined(HAVE_WIN32) #include @@ -172,4 +172,4 @@ void FillEventsBox(HWND hwnd, int idlist) return; } -#endif /* HAVE_CYGWIN */ +#endif /* HAVE_WIN32 */ diff --git a/bacula/src/lib/lex.c b/bacula/src/lib/lex.c index 11b9af0156..13b2cb9ab2 100644 --- a/bacula/src/lib/lex.c +++ b/bacula/src/lib/lex.c @@ -155,7 +155,7 @@ LEX *lex_open_file(LEX *lf, const char *filename, LEX_ERROR_HANDLER *scan_error) char *fname = bstrdup(filename); - if ((fd = fopen(fname, "r")) == NULL) { + if ((fd = fopen(fname, "rb")) == NULL) { return NULL; } Dmsg1(400, "Open config file: %s\n", fname); diff --git a/bacula/src/lib/md5.c b/bacula/src/lib/md5.c index 0725dc5eaa..d5b5bf7e4e 100644 --- a/bacula/src/lib/md5.c +++ b/bacula/src/lib/md5.c @@ -298,7 +298,7 @@ int main(int argc, char *argv[]) exit(1); } - fd = fopen(argv[0], "r"); + fd = fopen(argv[0], "rb"); if (!fd) { printf("Could not open %s: ERR=%s\n", argv[0], strerror(errno)); exit(1); diff --git a/bacula/src/lib/message.c b/bacula/src/lib/message.c index a394f0dac5..1c4b685d9a 100755 --- a/bacula/src/lib/message.c +++ b/bacula/src/lib/message.c @@ -26,11 +26,9 @@ #include "bacula.h" #include "jcr.h" -#if !defined(HAVE_CONSOLE) -#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32) +#if !defined(HAVE_CONSOLE) && defined(HAVE_WIN32) #include #endif -#endif #define FULL_LOCATION 1 /* set for file:line in Debug messages */ @@ -52,19 +50,15 @@ FILE *con_fd = NULL; /* Console file descriptor */ brwlock_t con_lock; /* Console lock structure */ -#ifdef HAVE_POSTGRESQL +#if defined(HAVE_POSTGRESQL) char catalog_db[] = "PostgreSQL"; -#else -#ifdef HAVE_MYSQL +#elif defined(HAVE_MYSQL) char catalog_db[] = "MySQL"; -#else -#ifdef HAVE_SQLITE +#elif defined(HAVE_SQLITE) char catalog_db[] = "SQLite"; #else char catalog_db[] = "Internal"; #endif -#endif -#endif const char *host_os = HOST_OS; const char *distname = DISTNAME; @@ -117,7 +111,7 @@ void my_name_is(int argc, char *argv[], const char *name) l++; } else { l = argv[0]; -#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32) +#if defined(HAVE_WIN32) /* On Windows allow c: junk */ if (l[1] == ':') { l += 2; @@ -162,7 +156,9 @@ void init_msg(JCR *jcr, MSGS *msg) { DEST *d, *dnew, *temp_chain = NULL; +#ifndef HAVE_WIN32 int i; +#endif if (jcr == NULL && msg == NULL) { init_last_jobs_list(); @@ -193,7 +189,7 @@ init_msg(JCR *jcr, MSGS *msg) if (msg == NULL) { daemon_msgs = (MSGS *)malloc(sizeof(MSGS)); memset(daemon_msgs, 0, sizeof(MSGS)); -#ifndef WIN32 +#ifndef HAVE_WIN32 for (i=1; i<=M_MAX; i++) { add_msg_dest(daemon_msgs, MD_STDOUT, i, NULL, NULL); } @@ -258,7 +254,7 @@ void init_console_msg(const char *wd) console_msg_pending = 1; } close(fd); - con_fd = fopen(con_fname, "a+"); + con_fd = fopen(con_fname, "a+b"); if (!con_fd) { berrno be; Emsg2(M_ERROR, 0, _("Could not open console message file %s: ERR=%s\n"), @@ -606,7 +602,7 @@ void dispatch_message(JCR *jcr, int type, time_t mtime, char *msg) case MD_CONSOLE: Dmsg1(850, "CONSOLE for following msg: %s", msg); if (!con_fd) { - con_fd = fopen(con_fname, "a+"); + con_fd = fopen(con_fname, "a+b"); Dmsg0(850, "Console file not open.\n"); } if (con_fd) { @@ -630,7 +626,7 @@ void dispatch_message(JCR *jcr, int type, time_t mtime, char *msg) } break; case MD_SYSLOG: - Dmsg1(850, "SYSLOG for collowing msg: %s\n", msg); + Dmsg1(850, "SYSLOG for following msg: %s\n", msg); /* * We really should do an openlog() here. */ @@ -661,7 +657,7 @@ void dispatch_message(JCR *jcr, int type, time_t mtime, char *msg) if (!d->fd) { POOLMEM *name = get_pool_memory(PM_MESSAGE); make_unique_mail_filename(jcr, name, d); - d->fd = fopen(name, "w+"); + d->fd = fopen(name, "w+b"); if (!d->fd) { berrno be; d->fd = stdout; @@ -683,7 +679,7 @@ void dispatch_message(JCR *jcr, int type, time_t mtime, char *msg) case MD_FILE: Dmsg1(850, "FILE for following msg: %s", msg); if (!d->fd) { - d->fd = fopen(d->where, "w+"); + d->fd = fopen(d->where, "w+b"); if (!d->fd) { berrno be; d->fd = stdout; @@ -699,7 +695,7 @@ void dispatch_message(JCR *jcr, int type, time_t mtime, char *msg) case MD_APPEND: Dmsg1(850, "APPEND for following msg: %s", msg); if (!d->fd) { - d->fd = fopen(d->where, "a"); + d->fd = fopen(d->where, "ab"); if (!d->fd) { berrno be; d->fd = stdout; @@ -789,7 +785,7 @@ d_msg(const char *file, int line, int level, const char *fmt,...) if (!trace_fd) { char fn[200]; bsnprintf(fn, sizeof(fn), "%s/bacula.trace", working_directory ? working_directory : "."); - trace_fd = fopen(fn, "a+"); + trace_fd = fopen(fn, "a+b"); } if (trace_fd) { fputs(buf, trace_fd); @@ -885,7 +881,7 @@ t_msg(const char *file, int line, int level, const char *fmt,...) if (level <= debug_level) { if (!trace_fd) { bsnprintf(buf, sizeof(buf), "%s/bacula.trace", working_directory); - trace_fd = fopen(buf, "a+"); + trace_fd = fopen(buf, "a+b"); } #ifdef FULL_LOCATION diff --git a/bacula/src/lib/parse_conf.c b/bacula/src/lib/parse_conf.c index 8e53477325..f95b609485 100755 --- a/bacula/src/lib/parse_conf.c +++ b/bacula/src/lib/parse_conf.c @@ -61,15 +61,14 @@ extern int r_last; extern RES_TABLE resources[]; extern RES **res_head; -#ifdef HAVE_WIN32 +#if defined(_MSC_VER) // work around visual studio name manling preventing external linkage since res_all // is declared as a different type when instantiated. extern "C" CURES res_all; -extern "C" int res_all_size; #else extern CURES res_all; -extern int res_all_size; #endif +extern int res_all_size; extern brwlock_t res_lock; /* resource lock */ diff --git a/bacula/src/lib/protos.h b/bacula/src/lib/protos.h index 118989c0de..9198e74b97 100644 --- a/bacula/src/lib/protos.h +++ b/bacula/src/lib/protos.h @@ -76,7 +76,7 @@ BSOCK * bnet_connect (JCR *jcr, int retry_interval, void bnet_close (BSOCK *bsock); BSOCK * init_bsock (JCR *jcr, int sockfd, const char *who, const char *ip, int port, struct sockaddr *client_addr); -#ifdef WIN32 +#ifdef HAVE_WIN32 #ifndef socklen_t #define socklen_t int #endif diff --git a/bacula/src/lib/res.c b/bacula/src/lib/res.c index 9c6e360100..c35fb68ee5 100644 --- a/bacula/src/lib/res.c +++ b/bacula/src/lib/res.c @@ -34,17 +34,6 @@ extern int r_last; extern RES_TABLE resources[]; extern RES **res_head; -#ifdef HAVE_WIN32 -// work around visual studio name manling preventing external linkage since res_all -// is declared as a different type when instantiated. -extern "C" CURES res_all; -extern "C" int res_all_size; -#else -extern CURES res_all; -extern int res_all_size; -#endif - - brwlock_t res_lock; /* resource lock */ static int res_locked = 0; /* set when resource chains locked -- for debug */ diff --git a/bacula/src/lib/runscript.c b/bacula/src/lib/runscript.c index 8b9b92c6ae..c73cc1012c 100644 --- a/bacula/src/lib/runscript.c +++ b/bacula/src/lib/runscript.c @@ -25,8 +25,6 @@ #include "bacula.h" #include "jcr.h" -#define USE_RUNSCRIPT - #include "runscript.h" RUNSCRIPT *new_runscript() diff --git a/bacula/src/lib/sha1.c b/bacula/src/lib/sha1.c index 136d8a7f17..063fad0e94 100644 --- a/bacula/src/lib/sha1.c +++ b/bacula/src/lib/sha1.c @@ -490,7 +490,7 @@ int main(int argc, char *argv[]) printf("Must have filename\n"); exit(1); } - fd = fopen(argv[1], "r"); + fd = fopen(argv[1], "rb"); if (!fd) { printf("Could not open %s: ERR=%s\n", argv[1], strerror(errno)); exit(1); diff --git a/bacula/src/stored/bextract.c b/bacula/src/stored/bextract.c index 4d1cf2051d..1856539ac3 100644 --- a/bacula/src/stored/bextract.c +++ b/bacula/src/stored/bextract.c @@ -26,7 +26,7 @@ #include "stored.h" #include "findlib/find.h" -#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32) +#if defined(HAVE_WIN32) int win32_client = 1; #else int win32_client = 0; @@ -122,7 +122,7 @@ int main (int argc, char *argv[]) break; case 'e': /* exclude list */ - if ((fd = fopen(optarg, "r")) == NULL) { + if ((fd = fopen(optarg, "rb")) == NULL) { berrno be; Pmsg2(0, _("Could not open exclude file: %s, ERR=%s\n"), optarg, be.strerror()); @@ -137,7 +137,7 @@ int main (int argc, char *argv[]) break; case 'i': /* include list */ - if ((fd = fopen(optarg, "r")) == NULL) { + if ((fd = fopen(optarg, "rb")) == NULL) { berrno be; Pmsg2(0, _("Could not open include file: %s, ERR=%s\n"), optarg, be.strerror()); diff --git a/bacula/src/stored/bls.c b/bacula/src/stored/bls.c index 933af258c2..40d348ccae 100644 --- a/bacula/src/stored/bls.c +++ b/bacula/src/stored/bls.c @@ -124,7 +124,7 @@ int main (int argc, char *argv[]) break; case 'e': /* exclude list */ - if ((fd = fopen(optarg, "r")) == NULL) { + if ((fd = fopen(optarg, "rb")) == NULL) { Pmsg2(0, _("Could not open exclude file: %s, ERR=%s\n"), optarg, strerror(errno)); exit(1); @@ -138,7 +138,7 @@ int main (int argc, char *argv[]) break; case 'i': /* include list */ - if ((fd = fopen(optarg, "r")) == NULL) { + if ((fd = fopen(optarg, "rb")) == NULL) { Pmsg2(0, _("Could not open include file: %s, ERR=%s\n"), optarg, strerror(errno)); exit(1); diff --git a/bacula/src/stored/bscan.c b/bacula/src/stored/bscan.c index d88a10991a..6d979c96f5 100644 --- a/bacula/src/stored/bscan.c +++ b/bacula/src/stored/bscan.c @@ -52,7 +52,7 @@ static int update_digest_record(B_DB *db, char *digest, DEV_RECORD *rec, int typ /* Global variables */ -#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32) +#if defined(HAVE_WIN32) int win32_client = 1; #else int win32_client = 0; diff --git a/bacula/src/stored/btape.c b/bacula/src/stored/btape.c index fd9338b9ad..4575531848 100644 --- a/bacula/src/stored/btape.c +++ b/bacula/src/stored/btape.c @@ -1881,8 +1881,8 @@ static void fillcmd() */ jcr->dcr->VolFirstIndex = 0; time(&jcr->run_time); /* start counting time for rates */ - localtime_r(&jcr->run_time, &tm); - strftime(buf1, sizeof(buf1), "%T", &tm); + (void)localtime_r(&jcr->run_time, &tm); + strftime(buf1, sizeof(buf1), "%H:%M:%S", &tm); if (simple) { Pmsg1(-1, _("%s Begin writing Bacula records to tape ...\n"), buf1); } else { @@ -1935,8 +1935,8 @@ static void fillcmd() */ if ((block->BlockNumber % 32000) == 0) { now = time(NULL); - localtime_r(&now, &tm); - strftime(buf1, sizeof(buf1), "%T", &tm); + (void)localtime_r(&now, &tm); + strftime(buf1, sizeof(buf1), "%H:%M:%S", &tm); Pmsg1(-1, _("%s Flush block, write EOF\n"), buf1); flush_block(block, 0); dev->weof(1); @@ -2012,8 +2012,8 @@ static void fillcmd() } now = time(NULL); - localtime_r(&now, &tm); - strftime(buf1, sizeof(buf1), "%T", &tm); + (void)localtime_r(&now, &tm); + strftime(buf1, sizeof(buf1), "%H:%M:%S", &tm); if (simple) { Pmsg3(-1, _("\n\n%s Done filling tape at %d:%d. Now beginning re-read of tape ...\n"), buf1, jcr->dcr->dev->file, jcr->dcr->dev->block_num); diff --git a/bacula/src/stored/dev.c b/bacula/src/stored/dev.c index 99be022c91..6373a8e39f 100644 --- a/bacula/src/stored/dev.c +++ b/bacula/src/stored/dev.c @@ -12,7 +12,7 @@ * to carry out operations without worrying about who * set what lock (i.e. race conditions). * - * Note, this is the device dependent code, and my have + * Note, this is the device dependent code, and may have * to be modified for each system, but is meant to * be as "generic" as possible. * @@ -103,7 +103,7 @@ init_dev(JCR *jcr, DEVRES *device) DCR *dcr = NULL; DEVICE *dev; - + /* If no device type specified, try to guess */ if (!device->dev_type) { /* Check that device is available */ diff --git a/bacula/src/stored/dev.h b/bacula/src/stored/dev.h index 4ca8fb6da7..e52f19e0c0 100644 --- a/bacula/src/stored/dev.h +++ b/bacula/src/stored/dev.h @@ -181,7 +181,7 @@ typedef struct s_steal_lock { int dev_prev_blocked; /* previous blocked state */ } bsteal_lock_t; -struct DEVRES; /* Device resource defined in stored_conf.h */ +class DEVRES; /* Device resource defined in stored_conf.h */ class DCR; /* forward reference */ /* diff --git a/bacula/src/stored/dircmd.c b/bacula/src/stored/dircmd.c index b00f425233..c2a429378e 100644 --- a/bacula/src/stored/dircmd.c +++ b/bacula/src/stored/dircmd.c @@ -873,7 +873,7 @@ static bool changer_cmd(JCR *jcr) if (dcr) { dev = dcr->dev; P(dev->mutex); /* Use P to avoid indefinite block */ - if (!dev->device->changer_res) { + if (!dev->device->changer_res) { bnet_fsend(dir, _("3995 Device %s is not an autochanger.\n"), dev->print_name()); /* Under certain "safe" conditions, we can steal the lock */ diff --git a/bacula/src/stored/fd_cmds.c b/bacula/src/stored/fd_cmds.c index 41df7eae30..af51981731 100644 --- a/bacula/src/stored/fd_cmds.c +++ b/bacula/src/stored/fd_cmds.c @@ -324,7 +324,7 @@ bool get_bootstrap_file(JCR *jcr, BSOCK *sock) jcr->Job); Dmsg1(400, "bootstrap=%s\n", fname); jcr->RestoreBootstrap = fname; - bs = fopen(fname, "a+"); /* create file */ + bs = fopen(fname, "a+b"); /* create file */ if (!bs) { Jmsg(jcr, M_FATAL, 0, _("Could not create bootstrap file %s: ERR=%s\n"), jcr->RestoreBootstrap, strerror(errno)); diff --git a/bacula/src/stored/spool.c b/bacula/src/stored/spool.c index 9cf930447b..e57326ccc1 100644 --- a/bacula/src/stored/spool.c +++ b/bacula/src/stored/spool.c @@ -579,7 +579,7 @@ bool open_attr_spool_file(JCR *jcr, BSOCK *bs) POOLMEM *name = get_pool_memory(PM_MESSAGE); make_unique_spool_filename(jcr, &name, bs->fd); - bs->spool_fd = fopen(name, "w+"); + bs->spool_fd = fopen(name, "w+b"); if (!bs->spool_fd) { berrno be; Jmsg(jcr, M_FATAL, 0, _("fopen attr spool file %s failed: ERR=%s\n"), name, diff --git a/bacula/src/stored/stored_conf.c b/bacula/src/stored/stored_conf.c index 51b7dd76b7..cb9766cd6f 100644 --- a/bacula/src/stored/stored_conf.c +++ b/bacula/src/stored/stored_conf.c @@ -39,7 +39,13 @@ static void store_devtype(LEX *lc, RES_ITEM *item, int index, int pass); /* We build the current resource here statically, * then move it to dynamic memory */ +#if defined(_MSC_VER) +extern "C" { // work around visual compiler mangling variables + URES res_all; +} +#else URES res_all; +#endif int res_all_size = sizeof(res_all); /* Definition of records permitted within each diff --git a/bacula/src/stored/stored_conf.h b/bacula/src/stored/stored_conf.h index e1db10d0bc..77a759eb06 100644 --- a/bacula/src/stored/stored_conf.h +++ b/bacula/src/stored/stored_conf.h @@ -85,7 +85,7 @@ public: TLS_CONTEXT *tls_ctx; /* Shared TLS Context */ }; -typedef struct s_res_store STORES; +typedef class s_res_store STORES; class AUTOCHANGER { public: diff --git a/bacula/src/tools/bwild.c b/bacula/src/tools/bwild.c index 65b6a2d647..a7b0977046 100644 --- a/bacula/src/tools/bwild.c +++ b/bacula/src/tools/bwild.c @@ -19,7 +19,6 @@ #include "bacula.h" #include "lib/fnmatch.h" - static void usage() { fprintf(stderr, diff --git a/bacula/src/tools/drivetype.c b/bacula/src/tools/drivetype.c new file mode 100644 index 0000000000..b778ade3a4 --- /dev/null +++ b/bacula/src/tools/drivetype.c @@ -0,0 +1,94 @@ +/* + * Program for determining drive type + * + * Written by Robert Nelson, June 2006 + * + * Version $Id$ + * + */ +/* + Copyright (C) 2006 Kern Sibbald + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + version 2 as amended with additional clauses defined in the + file LICENSE in the main source directory. + + 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 + file LICENSE for additional details. + + */ + +#include "bacula.h" +#include "findlib/find.h" + +/* Dummy functions */ +int generate_daemon_event(JCR *jcr, const char *event) + { return 1; } + +static void usage() +{ + fprintf(stderr, _( +"\n" +"Usage: drivetype [-v] path ...\n" +"\n" +" Print the drive type a given file/directory is on.\n" +" The following options are supported:\n" +"\n" +" -v print both path and file system type.\n" +" -? print this message.\n" +"\n")); + + exit(1); +} + + +int +main (int argc, char *const *argv) +{ + char dt[100]; + int verbose = 0; + int status = 0; + int ch, i; + + setlocale(LC_ALL, ""); + bindtextdomain("bacula", LOCALEDIR); + textdomain("bacula"); + + while ((ch = getopt(argc, argv, "v?")) != -1) { + switch (ch) { + case 'v': + verbose = 1; + break; + case '?': + default: + usage(); + + } + } + argc -= optind; + argv += optind; + + if (argc < 1) { + usage(); + } + + OSDependentInit(); + + for (i = 0; i < argc; --argc, ++argv) { + if (drivetype(*argv, dt, sizeof(dt))) { + if (verbose) { + printf("%s: %s\n", *argv, dt); + } else { + puts(dt); + } + } else { + fprintf(stderr, _("%s: unknown\n"), *argv); + status = 1; + } + } + + exit(status); +} diff --git a/bacula/src/tools/fstype.c b/bacula/src/tools/fstype.c index e671257908..796588d9a6 100644 --- a/bacula/src/tools/fstype.c +++ b/bacula/src/tools/fstype.c @@ -32,7 +32,7 @@ static void usage() { fprintf(stderr, _( "\n" -"Usage: fstype [-d debug_level] path ...\n" +"Usage: fstype [-v] path ...\n" "\n" " Print the file system type a given file/directory is on.\n" " The following options are supported:\n" diff --git a/bacula/src/tools/testfind.c b/bacula/src/tools/testfind.c index 851c3a8794..fe4c21a2e6 100644 --- a/bacula/src/tools/testfind.c +++ b/bacula/src/tools/testfind.c @@ -20,7 +20,7 @@ #include "findlib/find.h" -#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32) +#if defined(HAVE_WIN32) int win32_client = 1; #else int win32_client = 0; diff --git a/bacula/src/tools/testls.c b/bacula/src/tools/testls.c index e48df2e6cc..78ff15d3ec 100755 --- a/bacula/src/tools/testls.c +++ b/bacula/src/tools/testls.c @@ -19,7 +19,7 @@ #include "bacula.h" #include "findlib/find.h" -#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32) +#if defined(HAVE_WIN32) int win32_client = 1; #else int win32_client = 0; @@ -125,7 +125,7 @@ main (int argc, char *const *argv) } } if (inc) { - fd = fopen(inc, "r"); + fd = fopen(inc, "rb"); if (!fd) { printf(_("Could not open include file: %s\n"), inc); exit(1); @@ -138,7 +138,7 @@ main (int argc, char *const *argv) } if (exc) { - fd = fopen(exc, "r"); + fd = fopen(exc, "rb"); if (!fd) { printf(_("Could not open exclude file: %s\n"), exc); exit(1); diff --git a/bacula/src/win32/ClientConfig.ini b/bacula/src/win32/ClientConfig.ini new file mode 100644 index 0000000000..c536d2e4fe --- /dev/null +++ b/bacula/src/win32/ClientConfig.ini @@ -0,0 +1,157 @@ +[Settings] +NumFields=20 + +[Field 1] +Type="GroupBox" +Text="Client" +Left=0 +Top=0 +Right=300 +Bottom=52 + +[Field 2] +Type="Label" +Text="Name" +Left=6 +Top=10 +Right=40 +Bottom=18 + +[Field 3] +Type="Text" +Left=40 +Top=8 +Right=128 +Bottom=20 + +[Field 4] +Type="Label" +Text="(eg. hostname-fd)" +Left=136 +Top=10 +Right=288 +Bottom=18 + +[Field 5] +Type="Label" +Text="Port" +Left=6 +Top=24 +Right=40 +Bottom=32 + +[Field 6] +Type="Text" +Flags=ONLY_NUMBERS +Left=40 +Top=22 +Right=68 +Bottom=34 + +[Field 7] +Type="Label" +Text="Max Jobs" +Left=6 +Top=38 +Right=40 +Bottom=46 + +[Field 8] +Type="Text" +Flags=ONLY_NUMBERS +Left=40 +Top=36 +Right=56 +Bottom=48 + +[Field 9] +Type="GroupBox" +Text="Director" +Left=0 +Top=54 +Right=300 +Bottom=92 + +[Field 10] +Type="Label" +Text="Name" +Left=6 +Top=64 +Right=40 +Bottom=72 + +[Field 11] +Type="Text" +Left=40 +Top=62 +Right=128 +Bottom=74 + +[Field 12] +Type="Label" +Text="(eg. servername-dir)" +Left=136 +Top=64 +Right=288 +Bottom=72 + +[Field 13] +Type="Label" +Text="Password" +Left=6 +Top=78 +Right=40 +Bottom=86 + +[Field 14] +Type="Text" +Left=40 +Top=76 +Right=288 +Bottom=88 + +[Field 15] +Type="GroupBox" +Text="Monitor" +Left=0 +Top=94 +Right=300 +Bottom=132 + +[Field 16] +Type="Label" +Text="Name" +Left=6 +Top=104 +Right=40 +Bottom=112 + +[Field 17] +Type="Text" +Left=40 +Top=102 +Right=128 +Bottom=114 + +[Field 18] +Type="Label" +Text="(eg. servername-mon)" +Left=136 +Top=104 +Right=288 +Bottom=112 + +[Field 19] +Type="Label" +Text="Password" +Left=6 +Top=118 +Right=36 +Bottom=126 + +[Field 20] +Type="Text" +Left=40 +Top=116 +Right=288 +Bottom=128 diff --git a/bacula/src/win32/Makefile.inc.cross b/bacula/src/win32/Makefile.inc.cross new file mode 100644 index 0000000000..0e9896f0ef --- /dev/null +++ b/bacula/src/win32/Makefile.inc.cross @@ -0,0 +1,72 @@ +# +# Makefile for win32 bacula executables +# Using MinGW cross-compiler on GNU/Linux +# +# Written by Robert Nelson, June 2006 +# + +# Global Configuration + +ECHO_CMD = @ + +TOPDIR = /home/robert/src/bacula-w32 +DEPKGS = $(TOPDIR)/depkgs-test + +MINGW_BIN = $(TOPDIR)/cross-tools/mingw32/bin +MINGW_INCLUDE = $(TOPDIR)/cross-tools/mingw32/mingw32/include + +CC = $(MINGW_BIN)/mingw32-g++ $(DEFINES) $(INCLUDES) +CXX = $(MINGW_BIN)/mingw32-g++ $(DEFINES) $(INCLUDES) +AR = $(MINGW_BIN)/mingw32-ar +RANLIB = $(MINGW_BIN)/mingw32-ranlib +WINDRES = $(MINGW_BIN)/mingw32-windres +OBJCPY = $(MINGW_BIN)/mingw32-objcopy + +CFLAGS = -Wall -mno-cygwin -m32 -mwin32 -mthreads -O3 -fno-strict-aliasing +LDFLAGS = -Wall -mno-cygwin -Wl,--disable-auto-import + +INCLUDE_DDK = -I$(MINGW_INCLUDE)/ddk +INCLUDE_BACULA = -I../.. -I../compat +INCLUDE_PTHREADS = -I$(DEPKGS)/include/pthreads +INCLUDE_ZLIB = -I$(DEPKGS)/include +INCLUDE_VSS = -I$(DEPKGS)/vss +INCLUDE_ICONS = -I../libwin32 +INCLUDE_OPENSSL = -I$(DEPKGS)/include +INCLUDE_WX = -I$(DEPKGS)/lib/wx_dll/msw -I$(DEPKGS)/include +INCLUDE_MYSQL = -I$(DEPKGS)/include/mysql + +LIBS_PTHREADS = \ + $(DEPKGS)/lib/libpthreadGCE.a + +LIBS_ZLIB = \ + $(DEPKGS)/lib/libz.a + +LIBS_SQL = \ + $(DEPKGS)/lib/libmysql.a + +LIBS_SSL = \ + $(DEPKGS)/lib/libssl.dll.a + +LIBS_CRYPTO = \ + $(DEPKGS)/lib/libcrypto.dll.a + +LIBS_WX = \ + $(DEPKGS)/lib/wx_dll/libwxmsw26_core.a \ + $(DEPKGS)/lib/wx_dll/libwxbase26.a + +LIBS_BACULA = \ + $(LIBDIR)/libbacula.a + +HAVES = \ + -DHAVE_WIN32 \ + -DHAVE_MINGW \ + -DHAVE_ZLIB_H \ + -DHAVE_LIBZ \ + -DHAVE_MYSQL \ + -DHAVE_CRYPTO \ + -DHAVE_OPENSSL \ + -DHAVE_TLS + +BINDIR = ../release +LIBDIR = ../release +OBJDIR = . diff --git a/bacula/src/win32/Makefile.inc.native b/bacula/src/win32/Makefile.inc.native new file mode 100644 index 0000000000..5ddc40ce93 --- /dev/null +++ b/bacula/src/win32/Makefile.inc.native @@ -0,0 +1,75 @@ +# +# Makefile for win32 bacula executables +# Using MinGW cross-compiler on GNU/Linux +# +# Written by Robert Nelson, June 2006 +# + +# Global Configuration + +ECHO_CMD = @ + +TOPDIR = /c/src/bacula-1.38.9 +DEPKGS = $(TOPDIR)/depkgs-mingw + +MINGW_BIN = /mingw/bin +MINGW_INCLUDE = /mingw/include + +CC = $(MINGW_BIN)/g++ $(DEFINES) $(INCLUDES) +CXX = $(MINGW_BIN)/g++ $(DEFINES) $(INCLUDES) +AR = $(MINGW_BIN)/ar +RANLIB = $(MINGW_BIN)/ranlib +WINDRES = $(MINGW_BIN)/windres +OBJCPY = $(MINGW_BIN)/objcopy + +#CFLAGS = -ffunction-sections -fdata-sections -O3 -fno-strict-aliasing +#LDFLAGS = -Wl,--gc-sections -Wl,--disable-auto-import + +CFLAGS = -Wall -mno-cygwin -m32 -mwin32 -mthreads -O3 -fno-strict-aliasing +LDFLAGS = -Wall -mno-cygwin -Wl,--disable-auto-import + +INCLUDE_DDK = -I$(MINGW_INCLUDE)/ddk +INCLUDE_BACULA = -I../.. -I../compat +INCLUDE_PTHREADS = -I$(DEPKGS)/pthreads +INCLUDE_ZLIB = -I$(DEPKGS)/zlib +INCLUDE_VSS = -I"$(subst C:,/c,$(subst \,/,$(VSSSDK_DIR)))" +INCLUDE_ICONS = -I../libwin32 +INCLUDE_OPENSSL = -I$(DEPKGS)/openssl/outinc +INCLUDE_WX = -I$(DEPKGS)/wx/lib/gcc_lib/msw -I$(DEPKGS)/wx/include +INCLUDE_MYSQL = -I$(DEPKGS)/mysql/include + +LIBS_PTHREADS = \ + $(DEPKGS)/pthreads/libpthreadGCE.a + +LIBS_ZLIB = \ + $(DEPKGS)/zlib/libz.a + +LIBS_SQL = \ + $(DEPKGS)/mysql/lib/opt/libmysql.lib + +LIBS_SSL = \ + $(DEPKGS)/openssl/out/libssl.a + +LIBS_CRYPTO = \ + $(DEPKGS)/openssl/out/libcrypto.a + +LIBS_WX = \ + $(DEPKGS)/wx/lib/gcc_lib/libwxmsw26_core.a \ + $(DEPKGS)/wx/lib/gcc_lib/libwxbase26.a + +LIBS_BACULA = \ + $(LIBDIR)/libbacula.a + +HAVES = \ + -DHAVE_WIN32 \ + -DHAVE_MINGW \ + -DHAVE_ZLIB_H \ + -DHAVE_LIBZ \ + -DHAVE_MYSQL \ + -DHAVE_CRYPTO \ + -DHAVE_OPENSSL \ + -DHAVE_TLS + +BINDIR = ../release +LIBDIR = ../release +OBJDIR = . diff --git a/bacula/src/win32/Makefile.rules b/bacula/src/win32/Makefile.rules new file mode 100644 index 0000000000..62ee60c462 --- /dev/null +++ b/bacula/src/win32/Makefile.rules @@ -0,0 +1,73 @@ +# +# Makefile for win32 bacula executables +# Using MinGW cross-compiler on GNU/Linux +# +# Written by Robert Nelson, June 2006 +# + +define clean_obj + $(ECHO_CMD)rm -f $(1) $(patsubst %.o,%.d,$(filter-out %.res,$(1))) +endef + +define clean_exe + $(ECHO_CMD)rm -f $(1) $(addsuffix .dbg,$(basename $(1))) +endef + +define checkdir + @if [ ! -e $(dir $(1)) ]; then mkdir $(dir $(1)); fi +endef + +define makedep + @echo "Generating dependencies for $<" + $(call checkdir,$@) + $(ECHO_CMD)$(CXX) -MM $(CPPFLAGS) $< > $@.$$$$; \ + sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ + rm -f $@.$$$$ +endef + +define link_conapp + @echo "Linking $@" + $(call checkdir,$@) + $(ECHO_CMD)$(CXX) $(CFLAGS) $(LDFLAGS) -mconsole $^ $(1) -o $@ + $(makedbg) +endef + +define link_winapp + @echo "Linking $@" + $(call checkdir,$@) + $(ECHO_CMD)$(CXX) $(CFLAGS) $(LDFLAGS) -mwindows $^ $(1) -o $@ + $(makedbg) +endef + +define makedbg + @echo "Stripping debug info from $@" + $(call checkdir,$@) + $(ECHO_CMD)$(OBJCPY) --only-keep-debug $@ $(addsuffix .dbg,$(basename $@)) ; \ + $(OBJCPY) --strip-debug $@ ; \ + $(OBJCPY) --add-gnu-debuglink=$(addsuffix .dbg,$(basename $@)) $@ +endef + +$(OBJDIR)/%.o: %.c + @echo "Compiling $<" + $(call checkdir, $@) + $(ECHO_CMD)$(CXX) $(CFLAGS) -c $< -o $@ + +$(OBJDIR)/%.o: %.cpp + @echo "Compiling $<" + $(call checkdir, $@) + $(ECHO_CMD)$(CXX) $(CFLAGS) -c $< -o $@ + +$(OBJDIR)/%.res: %.rc + @echo "Compiling $<" + $(call checkdir, $@) + $(ECHO_CMD)$(WINDRES) -O coff $< -o $@ + +$(OBJDIR)/%.d: %.c + $(makedep) + +$(OBJDIR)/%.d: %.cpp + $(makedep) + +ifneq ($(MAKECMDGOALS),clean) +include $(patsubst %.o,%.d,$(filter-out %.res,$(ALL_OBJS))) +endif diff --git a/bacula/src/win32/Makefile.template b/bacula/src/win32/Makefile.template new file mode 100644 index 0000000000..978221d4ee --- /dev/null +++ b/bacula/src/win32/Makefile.template @@ -0,0 +1,74 @@ +# +# Makefile for win32 bacula executables +# Using MinGW cross-compiler on GNU/Linux +# +# Written by Robert Nelson, June 2006 +# + +include ../Makefile.inc + +INCLUDES = \ + $(INCLUDE_DDK) \ + $(INCLUDE_PTHREADS) \ + $(INCLUDE_BACULA) \ + $(INCLUDE_ZLIB) \ + $(INCLUDE_VSS) \ + $(INCLUDE_ICONS) \ + $(INCLUDE_OPENSSL) + +DEFINES = \ + -DUSING_DLL \ + $(HAVES) + +# Replace MODULE with the directory in the main Bacula tree containing the source +VPATH = ../../MODULE + +########################################################################## + +MODULE1_OBJS = \ + $(OBJDIR)/object1.o \ + $(OBJDIR)/object2.o \ + $(OBJDIR)/objectN.o + +MODULE1_LIBS = \ + $(LIBS_PTHREADS) \ + -lwsock32 + +MODULE2_OBJS = \ + $(OBJDIR)/object3.o \ + $(OBJDIR)/object4.o \ + $(OBJDIR)/objectN.o + +MODULE2_LIBS = \ + $(LIBS_PTHREADS) \ + -lwsock32 + +ALL_OBJS = \ + OBJS_MODULE1 \ + OBJS_MODULE2 + +###################################################################### + +# Targets + +.PHONY: all clean + +all: $(BINDIR)/MODULE1.exe $(BINDIR)/MODULE2.exe + +clean: + @echo "Cleaning `pwd`" + $(call clean_obj,$(ALL_OBJS)) + $(call clean_exe,$(BINDIR)/MODULE1.exe) + $(call clean_exe,$(BINDIR)/MODULE2.exe) + +# +# Rules +# + +$(BINDIR)/MODULE1.exe: $(SDOBJS) $(MODULE1_OBJS) $(LIBS_BACULA) + $(call link_winapp,$(MODULE1_LIBS)) + +$(BINDIR)/MODULE2.exe: $(SDOBJS) $(MODULE2_OBJS) $(LIBS_BACULA) + $(call link_conapp,$(MODULE1_LIBS)) + +include ../Makefile.rules diff --git a/bacula/src/win32/bacula.sln b/bacula/src/win32/bacula.sln index 4300ccb513..fd9e8a33d2 100644 --- a/bacula/src/win32/bacula.sln +++ b/bacula/src/win32/bacula.sln @@ -1,11 +1,156 @@  Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual C++ Express 2005 +# Visual Studio 2005 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wx-console", "wx-console\wx-console.vcproj", "{9BA8E10D-0D82-4B25-8543-DE34641FBC10}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "baculafd", "baculafd\baculafd.vcproj", "{6A435DBB-4D3D-4DAE-8CB3-E0AF169A240B}" + ProjectSection(ProjectDependencies) = postProject + {374BF775-AF68-4A88-814A-48F692DFFE5A} = {374BF775-AF68-4A88-814A-48F692DFFE5A} + {05CF01A0-3C11-443B-B14B-D806C79212F1} = {05CF01A0-3C11-443B-B14B-D806C79212F1} + EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "console", "console\console.vcproj", "{A0F65E06-9F18-40AC-81F6-A080852F1104}" + ProjectSection(ProjectDependencies) = postProject + {374BF775-AF68-4A88-814A-48F692DFFE5A} = {374BF775-AF68-4A88-814A-48F692DFFE5A} + {05CF01A0-3C11-443B-B14B-D806C79212F1} = {05CF01A0-3C11-443B-B14B-D806C79212F1} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fstype", "tools\fstype\fstype.vcproj", "{AAF33ADD-A4F9-4BCA-B7F9-0C35C843CC7E}" + ProjectSection(ProjectDependencies) = postProject + {05567F02-5DD8-4EB6-9C8E-C236C1D9AB1F} = {05567F02-5DD8-4EB6-9C8E-C236C1D9AB1F} + {374BF775-AF68-4A88-814A-48F692DFFE5A} = {374BF775-AF68-4A88-814A-48F692DFFE5A} + {05CF01A0-3C11-443B-B14B-D806C79212F1} = {05CF01A0-3C11-443B-B14B-D806C79212F1} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libbac", "libbac\libbac.vcproj", "{374BF775-AF68-4A88-814A-48F692DFFE5A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libfind", "libfind\libfind.vcproj", "{05567F02-5DD8-4EB6-9C8E-C236C1D9AB1F}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "drivetype", "tools\drivetype\drivetype.vcproj", "{E5BC5B2E-976D-4DED-AA07-5DD52BF2163F}" + ProjectSection(ProjectDependencies) = postProject + {05567F02-5DD8-4EB6-9C8E-C236C1D9AB1F} = {05567F02-5DD8-4EB6-9C8E-C236C1D9AB1F} + {374BF775-AF68-4A88-814A-48F692DFFE5A} = {374BF775-AF68-4A88-814A-48F692DFFE5A} + {05CF01A0-3C11-443B-B14B-D806C79212F1} = {05CF01A0-3C11-443B-B14B-D806C79212F1} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "compat", "compat\compat.vcproj", "{05CF01A0-3C11-443B-B14B-D806C79212F1}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testfind", "tools\testfind\testfind.vcproj", "{558838F9-D792-4F56-AAB2-99C03687C5FF}" + ProjectSection(ProjectDependencies) = postProject + {05567F02-5DD8-4EB6-9C8E-C236C1D9AB1F} = {05567F02-5DD8-4EB6-9C8E-C236C1D9AB1F} + {374BF775-AF68-4A88-814A-48F692DFFE5A} = {374BF775-AF68-4A88-814A-48F692DFFE5A} + {05CF01A0-3C11-443B-B14B-D806C79212F1} = {05CF01A0-3C11-443B-B14B-D806C79212F1} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testls", "tools\testls\testls.vcproj", "{28FB58CE-AB8C-4C60-83DA-BC1BFCC59BFF}" + ProjectSection(ProjectDependencies) = postProject + {05567F02-5DD8-4EB6-9C8E-C236C1D9AB1F} = {05567F02-5DD8-4EB6-9C8E-C236C1D9AB1F} + {374BF775-AF68-4A88-814A-48F692DFFE5A} = {374BF775-AF68-4A88-814A-48F692DFFE5A} + {05CF01A0-3C11-443B-B14B-D806C79212F1} = {05CF01A0-3C11-443B-B14B-D806C79212F1} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "baculafd", "filed\baculafd.vcproj", "{6A435DBB-4D3D-4DAE-8CB3-E0AF169A240B}" + ProjectSection(ProjectDependencies) = postProject + {05567F02-5DD8-4EB6-9C8E-C236C1D9AB1F} = {05567F02-5DD8-4EB6-9C8E-C236C1D9AB1F} + {374BF775-AF68-4A88-814A-48F692DFFE5A} = {374BF775-AF68-4A88-814A-48F692DFFE5A} + {05CF01A0-3C11-443B-B14B-D806C79212F1} = {05CF01A0-3C11-443B-B14B-D806C79212F1} + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{825DFFD0-4747-43CA-8326-529655E31935}" + ProjectSection(SolutionItems) = preProject + ClientConfig.ini = ClientConfig.ini + ..\..\autoconf\bacula-macros\db.m4 = ..\..\autoconf\bacula-macros\db.m4 + ..\..\autoconf\bacula-macros\largefiles.m4 = ..\..\autoconf\bacula-macros\largefiles.m4 + ..\..\autoconf\bacula-macros\os.m4 = ..\..\autoconf\bacula-macros\os.m4 + winbacula.nsi.in = winbacula.nsi.in + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Header Files", "Header Files", "{C8301485-CFD1-43D4-827C-8EA050C8E256}" + ProjectSection(SolutionItems) = preProject + ..\baconfig.h = ..\baconfig.h + ..\bacula.h = ..\bacula.h + ..\bc_types.h = ..\bc_types.h + ..\jcr.h = ..\jcr.h + ..\version.h = ..\version.h + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "baculadird", "dird\dird.vcproj", "{D03415F7-654E-42F4-B0E9-CB8FBE3F22FA}" + ProjectSection(ProjectDependencies) = postProject + {05567F02-5DD8-4EB6-9C8E-C236C1D9AB1F} = {05567F02-5DD8-4EB6-9C8E-C236C1D9AB1F} + {BAB13141-20F9-4B2D-8C0A-021804ADD077} = {BAB13141-20F9-4B2D-8C0A-021804ADD077} + {374BF775-AF68-4A88-814A-48F692DFFE5A} = {374BF775-AF68-4A88-814A-48F692DFFE5A} + {05CF01A0-3C11-443B-B14B-D806C79212F1} = {05CF01A0-3C11-443B-B14B-D806C79212F1} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "baculasd", "stored\baculasd\baculasd.vcproj", "{F5F063F8-11A1-475A-82E2-19759BB40B25}" + ProjectSection(ProjectDependencies) = postProject + {CAD30B43-D93B-47D5-9161-6A3E9BADCC1D} = {CAD30B43-D93B-47D5-9161-6A3E9BADCC1D} + {374BF775-AF68-4A88-814A-48F692DFFE5A} = {374BF775-AF68-4A88-814A-48F692DFFE5A} + {05CF01A0-3C11-443B-B14B-D806C79212F1} = {05CF01A0-3C11-443B-B14B-D806C79212F1} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bcopy", "stored\bcopy\bcopy.vcproj", "{614CE916-0972-4126-9392-CD9FC0ADD7DE}" + ProjectSection(ProjectDependencies) = postProject + {CAD30B43-D93B-47D5-9161-6A3E9BADCC1D} = {CAD30B43-D93B-47D5-9161-6A3E9BADCC1D} + {374BF775-AF68-4A88-814A-48F692DFFE5A} = {374BF775-AF68-4A88-814A-48F692DFFE5A} + {05CF01A0-3C11-443B-B14B-D806C79212F1} = {05CF01A0-3C11-443B-B14B-D806C79212F1} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bextract", "stored\bextract\bextract.vcproj", "{6A7AA493-E46C-4994-B8D6-AA6C9C19C9BA}" + ProjectSection(ProjectDependencies) = postProject + {05567F02-5DD8-4EB6-9C8E-C236C1D9AB1F} = {05567F02-5DD8-4EB6-9C8E-C236C1D9AB1F} + {CAD30B43-D93B-47D5-9161-6A3E9BADCC1D} = {CAD30B43-D93B-47D5-9161-6A3E9BADCC1D} + {374BF775-AF68-4A88-814A-48F692DFFE5A} = {374BF775-AF68-4A88-814A-48F692DFFE5A} + {05CF01A0-3C11-443B-B14B-D806C79212F1} = {05CF01A0-3C11-443B-B14B-D806C79212F1} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bls", "stored\bls\bls.vcproj", "{F8AF7D74-2918-422B-A7B6-4D98566B7160}" + ProjectSection(ProjectDependencies) = postProject + {05567F02-5DD8-4EB6-9C8E-C236C1D9AB1F} = {05567F02-5DD8-4EB6-9C8E-C236C1D9AB1F} + {CAD30B43-D93B-47D5-9161-6A3E9BADCC1D} = {CAD30B43-D93B-47D5-9161-6A3E9BADCC1D} + {374BF775-AF68-4A88-814A-48F692DFFE5A} = {374BF775-AF68-4A88-814A-48F692DFFE5A} + {05CF01A0-3C11-443B-B14B-D806C79212F1} = {05CF01A0-3C11-443B-B14B-D806C79212F1} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bscan", "stored\bscan\bscan.vcproj", "{56EADEDB-FBED-4758-8B54-7B0B47ABDABF}" + ProjectSection(ProjectDependencies) = postProject + {05567F02-5DD8-4EB6-9C8E-C236C1D9AB1F} = {05567F02-5DD8-4EB6-9C8E-C236C1D9AB1F} + {BAB13141-20F9-4B2D-8C0A-021804ADD077} = {BAB13141-20F9-4B2D-8C0A-021804ADD077} + {CAD30B43-D93B-47D5-9161-6A3E9BADCC1D} = {CAD30B43-D93B-47D5-9161-6A3E9BADCC1D} + {374BF775-AF68-4A88-814A-48F692DFFE5A} = {374BF775-AF68-4A88-814A-48F692DFFE5A} + {05CF01A0-3C11-443B-B14B-D806C79212F1} = {05CF01A0-3C11-443B-B14B-D806C79212F1} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "btape", "stored\btape\btape.vcproj", "{496415E0-AF44-4AD8-8C99-91B837DDF469}" + ProjectSection(ProjectDependencies) = postProject + {CAD30B43-D93B-47D5-9161-6A3E9BADCC1D} = {CAD30B43-D93B-47D5-9161-6A3E9BADCC1D} + {374BF775-AF68-4A88-814A-48F692DFFE5A} = {374BF775-AF68-4A88-814A-48F692DFFE5A} + {05CF01A0-3C11-443B-B14B-D806C79212F1} = {05CF01A0-3C11-443B-B14B-D806C79212F1} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "storelib", "stored\storelib\storelib.vcproj", "{CAD30B43-D93B-47D5-9161-6A3E9BADCC1D}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcats", "cats\cats.vcproj", "{BAB13141-20F9-4B2D-8C0A-021804ADD077}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mt", "tapetools\mt\mt\mt.vcproj", "{8F29646A-559A-484C-9C73-B3FCE80EDD9C}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "postest", "stored\postest\postest.vcproj", "{208D3989-794B-47A2-9D04-D7AEE1524078}" + ProjectSection(ProjectDependencies) = postProject + {05567F02-5DD8-4EB6-9C8E-C236C1D9AB1F} = {05567F02-5DD8-4EB6-9C8E-C236C1D9AB1F} + {CAD30B43-D93B-47D5-9161-6A3E9BADCC1D} = {CAD30B43-D93B-47D5-9161-6A3E9BADCC1D} + {374BF775-AF68-4A88-814A-48F692DFFE5A} = {374BF775-AF68-4A88-814A-48F692DFFE5A} + {05CF01A0-3C11-443B-B14B-D806C79212F1} = {05CF01A0-3C11-443B-B14B-D806C79212F1} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sleep", "scripts\sleep.vcproj", "{0F56AEB0-14DA-4A80-8962-1F85A17339D0}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libraries", "Libraries", "{0377E151-3352-487B-A5CF-24BCDC9EC43F}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Test Tools", "Test Tools", "{D6767108-F420-41C0-A834-2E6F487E1AB3}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Daemons", "Daemons", "{B9099DDA-18C9-4DE0-AECB-5D8139EA619F}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Utilities", "Utilities", "{37F903FE-3474-4C93-AD5B-987CB6A92E62}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Consoles", "Consoles", "{C66C8B3B-C156-4498-91E9-CA9A24CF9051}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -17,16 +162,117 @@ Global {9BA8E10D-0D82-4B25-8543-DE34641FBC10}.Debug|Win32.Build.0 = Debug|Win32 {9BA8E10D-0D82-4B25-8543-DE34641FBC10}.Release|Win32.ActiveCfg = Release|Win32 {9BA8E10D-0D82-4B25-8543-DE34641FBC10}.Release|Win32.Build.0 = Release|Win32 - {6A435DBB-4D3D-4DAE-8CB3-E0AF169A240B}.Debug|Win32.ActiveCfg = Debug|Win32 - {6A435DBB-4D3D-4DAE-8CB3-E0AF169A240B}.Debug|Win32.Build.0 = Debug|Win32 - {6A435DBB-4D3D-4DAE-8CB3-E0AF169A240B}.Release|Win32.ActiveCfg = Release|Win32 - {6A435DBB-4D3D-4DAE-8CB3-E0AF169A240B}.Release|Win32.Build.0 = Release|Win32 {A0F65E06-9F18-40AC-81F6-A080852F1104}.Debug|Win32.ActiveCfg = Debug|Win32 {A0F65E06-9F18-40AC-81F6-A080852F1104}.Debug|Win32.Build.0 = Debug|Win32 {A0F65E06-9F18-40AC-81F6-A080852F1104}.Release|Win32.ActiveCfg = Release|Win32 {A0F65E06-9F18-40AC-81F6-A080852F1104}.Release|Win32.Build.0 = Release|Win32 + {AAF33ADD-A4F9-4BCA-B7F9-0C35C843CC7E}.Debug|Win32.ActiveCfg = Debug|Win32 + {AAF33ADD-A4F9-4BCA-B7F9-0C35C843CC7E}.Debug|Win32.Build.0 = Debug|Win32 + {AAF33ADD-A4F9-4BCA-B7F9-0C35C843CC7E}.Release|Win32.ActiveCfg = Release|Win32 + {AAF33ADD-A4F9-4BCA-B7F9-0C35C843CC7E}.Release|Win32.Build.0 = Release|Win32 + {374BF775-AF68-4A88-814A-48F692DFFE5A}.Debug|Win32.ActiveCfg = Debug|Win32 + {374BF775-AF68-4A88-814A-48F692DFFE5A}.Debug|Win32.Build.0 = Debug|Win32 + {374BF775-AF68-4A88-814A-48F692DFFE5A}.Release|Win32.ActiveCfg = Release|Win32 + {374BF775-AF68-4A88-814A-48F692DFFE5A}.Release|Win32.Build.0 = Release|Win32 + {05567F02-5DD8-4EB6-9C8E-C236C1D9AB1F}.Debug|Win32.ActiveCfg = Debug|Win32 + {05567F02-5DD8-4EB6-9C8E-C236C1D9AB1F}.Debug|Win32.Build.0 = Debug|Win32 + {05567F02-5DD8-4EB6-9C8E-C236C1D9AB1F}.Release|Win32.ActiveCfg = Release|Win32 + {05567F02-5DD8-4EB6-9C8E-C236C1D9AB1F}.Release|Win32.Build.0 = Release|Win32 + {E5BC5B2E-976D-4DED-AA07-5DD52BF2163F}.Debug|Win32.ActiveCfg = Debug|Win32 + {E5BC5B2E-976D-4DED-AA07-5DD52BF2163F}.Debug|Win32.Build.0 = Debug|Win32 + {E5BC5B2E-976D-4DED-AA07-5DD52BF2163F}.Release|Win32.ActiveCfg = Release|Win32 + {E5BC5B2E-976D-4DED-AA07-5DD52BF2163F}.Release|Win32.Build.0 = Release|Win32 + {05CF01A0-3C11-443B-B14B-D806C79212F1}.Debug|Win32.ActiveCfg = Debug|Win32 + {05CF01A0-3C11-443B-B14B-D806C79212F1}.Debug|Win32.Build.0 = Debug|Win32 + {05CF01A0-3C11-443B-B14B-D806C79212F1}.Release|Win32.ActiveCfg = Release|Win32 + {05CF01A0-3C11-443B-B14B-D806C79212F1}.Release|Win32.Build.0 = Release|Win32 + {558838F9-D792-4F56-AAB2-99C03687C5FF}.Debug|Win32.ActiveCfg = Debug|Win32 + {558838F9-D792-4F56-AAB2-99C03687C5FF}.Debug|Win32.Build.0 = Debug|Win32 + {558838F9-D792-4F56-AAB2-99C03687C5FF}.Release|Win32.ActiveCfg = Release|Win32 + {558838F9-D792-4F56-AAB2-99C03687C5FF}.Release|Win32.Build.0 = Release|Win32 + {28FB58CE-AB8C-4C60-83DA-BC1BFCC59BFF}.Debug|Win32.ActiveCfg = Debug|Win32 + {28FB58CE-AB8C-4C60-83DA-BC1BFCC59BFF}.Debug|Win32.Build.0 = Debug|Win32 + {28FB58CE-AB8C-4C60-83DA-BC1BFCC59BFF}.Release|Win32.ActiveCfg = Release|Win32 + {28FB58CE-AB8C-4C60-83DA-BC1BFCC59BFF}.Release|Win32.Build.0 = Release|Win32 + {6A435DBB-4D3D-4DAE-8CB3-E0AF169A240B}.Debug|Win32.ActiveCfg = Debug|Win32 + {6A435DBB-4D3D-4DAE-8CB3-E0AF169A240B}.Debug|Win32.Build.0 = Debug|Win32 + {6A435DBB-4D3D-4DAE-8CB3-E0AF169A240B}.Release|Win32.ActiveCfg = Release|Win32 + {6A435DBB-4D3D-4DAE-8CB3-E0AF169A240B}.Release|Win32.Build.0 = Release|Win32 + {D03415F7-654E-42F4-B0E9-CB8FBE3F22FA}.Debug|Win32.ActiveCfg = Debug|Win32 + {D03415F7-654E-42F4-B0E9-CB8FBE3F22FA}.Debug|Win32.Build.0 = Debug|Win32 + {D03415F7-654E-42F4-B0E9-CB8FBE3F22FA}.Release|Win32.ActiveCfg = Release|Win32 + {D03415F7-654E-42F4-B0E9-CB8FBE3F22FA}.Release|Win32.Build.0 = Release|Win32 + {F5F063F8-11A1-475A-82E2-19759BB40B25}.Debug|Win32.ActiveCfg = Debug|Win32 + {F5F063F8-11A1-475A-82E2-19759BB40B25}.Debug|Win32.Build.0 = Debug|Win32 + {F5F063F8-11A1-475A-82E2-19759BB40B25}.Release|Win32.ActiveCfg = Release|Win32 + {F5F063F8-11A1-475A-82E2-19759BB40B25}.Release|Win32.Build.0 = Release|Win32 + {614CE916-0972-4126-9392-CD9FC0ADD7DE}.Debug|Win32.ActiveCfg = Debug|Win32 + {614CE916-0972-4126-9392-CD9FC0ADD7DE}.Debug|Win32.Build.0 = Debug|Win32 + {614CE916-0972-4126-9392-CD9FC0ADD7DE}.Release|Win32.ActiveCfg = Release|Win32 + {614CE916-0972-4126-9392-CD9FC0ADD7DE}.Release|Win32.Build.0 = Release|Win32 + {6A7AA493-E46C-4994-B8D6-AA6C9C19C9BA}.Debug|Win32.ActiveCfg = Debug|Win32 + {6A7AA493-E46C-4994-B8D6-AA6C9C19C9BA}.Debug|Win32.Build.0 = Debug|Win32 + {6A7AA493-E46C-4994-B8D6-AA6C9C19C9BA}.Release|Win32.ActiveCfg = Release|Win32 + {6A7AA493-E46C-4994-B8D6-AA6C9C19C9BA}.Release|Win32.Build.0 = Release|Win32 + {F8AF7D74-2918-422B-A7B6-4D98566B7160}.Debug|Win32.ActiveCfg = Debug|Win32 + {F8AF7D74-2918-422B-A7B6-4D98566B7160}.Debug|Win32.Build.0 = Debug|Win32 + {F8AF7D74-2918-422B-A7B6-4D98566B7160}.Release|Win32.ActiveCfg = Release|Win32 + {F8AF7D74-2918-422B-A7B6-4D98566B7160}.Release|Win32.Build.0 = Release|Win32 + {56EADEDB-FBED-4758-8B54-7B0B47ABDABF}.Debug|Win32.ActiveCfg = Debug|Win32 + {56EADEDB-FBED-4758-8B54-7B0B47ABDABF}.Debug|Win32.Build.0 = Debug|Win32 + {56EADEDB-FBED-4758-8B54-7B0B47ABDABF}.Release|Win32.ActiveCfg = Release|Win32 + {56EADEDB-FBED-4758-8B54-7B0B47ABDABF}.Release|Win32.Build.0 = Release|Win32 + {496415E0-AF44-4AD8-8C99-91B837DDF469}.Debug|Win32.ActiveCfg = Debug|Win32 + {496415E0-AF44-4AD8-8C99-91B837DDF469}.Debug|Win32.Build.0 = Debug|Win32 + {496415E0-AF44-4AD8-8C99-91B837DDF469}.Release|Win32.ActiveCfg = Release|Win32 + {496415E0-AF44-4AD8-8C99-91B837DDF469}.Release|Win32.Build.0 = Release|Win32 + {CAD30B43-D93B-47D5-9161-6A3E9BADCC1D}.Debug|Win32.ActiveCfg = Debug|Win32 + {CAD30B43-D93B-47D5-9161-6A3E9BADCC1D}.Debug|Win32.Build.0 = Debug|Win32 + {CAD30B43-D93B-47D5-9161-6A3E9BADCC1D}.Release|Win32.ActiveCfg = Release|Win32 + {CAD30B43-D93B-47D5-9161-6A3E9BADCC1D}.Release|Win32.Build.0 = Release|Win32 + {BAB13141-20F9-4B2D-8C0A-021804ADD077}.Debug|Win32.ActiveCfg = Debug|Win32 + {BAB13141-20F9-4B2D-8C0A-021804ADD077}.Debug|Win32.Build.0 = Debug|Win32 + {BAB13141-20F9-4B2D-8C0A-021804ADD077}.Release|Win32.ActiveCfg = Release|Win32 + {BAB13141-20F9-4B2D-8C0A-021804ADD077}.Release|Win32.Build.0 = Release|Win32 + {8F29646A-559A-484C-9C73-B3FCE80EDD9C}.Debug|Win32.ActiveCfg = Debug|Win32 + {8F29646A-559A-484C-9C73-B3FCE80EDD9C}.Debug|Win32.Build.0 = Debug|Win32 + {8F29646A-559A-484C-9C73-B3FCE80EDD9C}.Release|Win32.ActiveCfg = Release|Win32 + {8F29646A-559A-484C-9C73-B3FCE80EDD9C}.Release|Win32.Build.0 = Release|Win32 + {208D3989-794B-47A2-9D04-D7AEE1524078}.Debug|Win32.ActiveCfg = Debug|Win32 + {208D3989-794B-47A2-9D04-D7AEE1524078}.Debug|Win32.Build.0 = Debug|Win32 + {208D3989-794B-47A2-9D04-D7AEE1524078}.Release|Win32.ActiveCfg = Release|Win32 + {208D3989-794B-47A2-9D04-D7AEE1524078}.Release|Win32.Build.0 = Release|Win32 + {0F56AEB0-14DA-4A80-8962-1F85A17339D0}.Debug|Win32.ActiveCfg = Debug|Win32 + {0F56AEB0-14DA-4A80-8962-1F85A17339D0}.Debug|Win32.Build.0 = Debug|Win32 + {0F56AEB0-14DA-4A80-8962-1F85A17339D0}.Release|Win32.ActiveCfg = Release|Win32 + {0F56AEB0-14DA-4A80-8962-1F85A17339D0}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {A0F65E06-9F18-40AC-81F6-A080852F1104} = {C66C8B3B-C156-4498-91E9-CA9A24CF9051} + {9BA8E10D-0D82-4B25-8543-DE34641FBC10} = {C66C8B3B-C156-4498-91E9-CA9A24CF9051} + {E5BC5B2E-976D-4DED-AA07-5DD52BF2163F} = {D6767108-F420-41C0-A834-2E6F487E1AB3} + {558838F9-D792-4F56-AAB2-99C03687C5FF} = {D6767108-F420-41C0-A834-2E6F487E1AB3} + {28FB58CE-AB8C-4C60-83DA-BC1BFCC59BFF} = {D6767108-F420-41C0-A834-2E6F487E1AB3} + {208D3989-794B-47A2-9D04-D7AEE1524078} = {D6767108-F420-41C0-A834-2E6F487E1AB3} + {AAF33ADD-A4F9-4BCA-B7F9-0C35C843CC7E} = {D6767108-F420-41C0-A834-2E6F487E1AB3} + {05567F02-5DD8-4EB6-9C8E-C236C1D9AB1F} = {0377E151-3352-487B-A5CF-24BCDC9EC43F} + {05CF01A0-3C11-443B-B14B-D806C79212F1} = {0377E151-3352-487B-A5CF-24BCDC9EC43F} + {CAD30B43-D93B-47D5-9161-6A3E9BADCC1D} = {0377E151-3352-487B-A5CF-24BCDC9EC43F} + {BAB13141-20F9-4B2D-8C0A-021804ADD077} = {0377E151-3352-487B-A5CF-24BCDC9EC43F} + {374BF775-AF68-4A88-814A-48F692DFFE5A} = {0377E151-3352-487B-A5CF-24BCDC9EC43F} + {D03415F7-654E-42F4-B0E9-CB8FBE3F22FA} = {B9099DDA-18C9-4DE0-AECB-5D8139EA619F} + {F5F063F8-11A1-475A-82E2-19759BB40B25} = {B9099DDA-18C9-4DE0-AECB-5D8139EA619F} + {6A435DBB-4D3D-4DAE-8CB3-E0AF169A240B} = {B9099DDA-18C9-4DE0-AECB-5D8139EA619F} + {C8301485-CFD1-43D4-827C-8EA050C8E256} = {825DFFD0-4747-43CA-8326-529655E31935} + {6A7AA493-E46C-4994-B8D6-AA6C9C19C9BA} = {37F903FE-3474-4C93-AD5B-987CB6A92E62} + {F8AF7D74-2918-422B-A7B6-4D98566B7160} = {37F903FE-3474-4C93-AD5B-987CB6A92E62} + {56EADEDB-FBED-4758-8B54-7B0B47ABDABF} = {37F903FE-3474-4C93-AD5B-987CB6A92E62} + {496415E0-AF44-4AD8-8C99-91B837DDF469} = {37F903FE-3474-4C93-AD5B-987CB6A92E62} + {8F29646A-559A-484C-9C73-B3FCE80EDD9C} = {37F903FE-3474-4C93-AD5B-987CB6A92E62} + {0F56AEB0-14DA-4A80-8962-1F85A17339D0} = {37F903FE-3474-4C93-AD5B-987CB6A92E62} + {614CE916-0972-4126-9392-CD9FC0ADD7DE} = {37F903FE-3474-4C93-AD5B-987CB6A92E62} + EndGlobalSection EndGlobal diff --git a/bacula/src/win32/compat/Makefile b/bacula/src/win32/compat/Makefile new file mode 100644 index 0000000000..9b5f5d3c00 --- /dev/null +++ b/bacula/src/win32/compat/Makefile @@ -0,0 +1,61 @@ +# +# Makefile for win32 bacula executables +# Using MinGW cross-compiler on GNU/Linux +# +# Written for Bacula by Howard Thomson, April 2006 +# + +include ../Makefile.inc + +INCLUDES = \ + $(INCLUDE_GCC) \ + $(INCLUDE_MINGW) \ + $(INCLUDE_PTHREADS) \ + $(INCLUDE_BACULA) \ + $(INCLUDE_ZLIB) \ + $(INCLUDE_VSS) \ + $(INCLUDE_ICONS) \ + $(INCLUDE_OPENSSL) + +DEFINES = \ + -DWIN32 \ + $(HAVES) + +###################################################################### + +# Files files in src/win32/compat + +LIB_OBJS = \ + $(OBJDIR)/compat.o \ + $(OBJDIR)/getopt.o \ + $(OBJDIR)/print.o \ + $(OBJDIR)/vss.o \ + $(OBJDIR)/vss_XP.o \ + $(OBJDIR)/vss_W2K3.o + +###################################################################### + +# Targets + +.PHONY: all clean + +all: $(LIBDIR)/libcompat.a + +clean: + @echo "Cleaning `pwd`" + $(ECHO_CMD)rm -f $(OBJDIR)/*.[od] $(LIBDIR)/libcompat.a + +# +# Rules +# + +$(LIBDIR)/libcompat.a: $(LIB_OBJS) + @echo "Updating archive $@" + $(call checkdir,$@) + $(ECHO_CMD)$(AR) rs $@ $^ + +include ../Makefile.rules + +ifneq ($(MAKECMDGOALS),clean) +include $(patsubst %.o,%.d,$(filter-out %.res,$(LIB_OBJS))) +endif diff --git a/bacula/src/win32/compat/compat.cpp b/bacula/src/win32/compat/compat.cpp index a9f46a1173..50451a37fe 100644 --- a/bacula/src/win32/compat/compat.cpp +++ b/bacula/src/win32/compat/compat.cpp @@ -21,21 +21,12 @@ // Created On : Sat Jan 31 15:55:00 2004 // $Id$ -#ifdef __APCUPSD__ - -#include "apc.h" -#include "compat.h" -#include "winapi.h" - -#else - #include "bacula.h" #include "compat.h" #include "jcr.h" #include "../../lib/winapi.h" #include "vss.h" -#endif #define b_errno_win32 (1<<29) @@ -459,16 +450,16 @@ srandom(unsigned int seed) void cvt_utime_to_ftime(const time_t &time, FILETIME &wintime) { - uint64_t mstime = time; - mstime *= WIN32_FILETIME_SCALE; - mstime += WIN32_FILETIME_ADJUST; + uint64_t mstime = time; + mstime *= WIN32_FILETIME_SCALE; + mstime += WIN32_FILETIME_ADJUST; - #ifdef HAVE_MINGW - wintime.dwLowDateTime = (DWORD)(mstime & 0xffffffffUL); - #else - wintime.dwLowDateTime = (DWORD)(mstime & 0xffffffffI64); - #endif - wintime.dwHighDateTime = (DWORD) ((mstime>>32)& 0xffffffffUL); +#if defined(_MSC_VER) + wintime.dwLowDateTime = (DWORD)(mstime & 0xffffffffI64); +#else + wintime.dwLowDateTime = (DWORD)(mstime & 0xffffffffUL); +#endif + wintime.dwHighDateTime = (DWORD) ((mstime>>32)& 0xffffffffUL); } time_t @@ -617,7 +608,7 @@ stat2(const char *file, struct stat *sb) attr = p_GetFileAttributesA(tmpbuf); } - if (attr == -1) { + if (attr == (DWORD)-1) { const char *err = errorString(); d_msg(__FILE__, __LINE__, 99, "GetFileAttributes(%s): %s\n", tmpbuf, err); diff --git a/bacula/src/win32/compat/compat.h b/bacula/src/win32/compat/compat.h index fe0c44f740..5ac44ad0e3 100644 --- a/bacula/src/win32/compat/compat.h +++ b/bacula/src/win32/compat/compat.h @@ -177,10 +177,18 @@ struct timezone { int strcasecmp(const char*, const char *); int gettimeofday(struct timeval *, struct timezone *); +#ifndef EETXTBUSY +#define EETXTBUSY 26 +#endif + #ifndef ETIMEDOUT #define ETIMEDOUT 55 #endif +#ifndef ENOMEDIUM +#define ENOMEDIUM 123 +#endif + #ifndef HAVE_WXCONSOLE struct stat { diff --git a/bacula/src/win32/compat/compat.vcproj b/bacula/src/win32/compat/compat.vcproj new file mode 100644 index 0000000000..c36ee0bd95 --- /dev/null +++ b/bacula/src/win32/compat/compat.vcproj @@ -0,0 +1,296 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bacula/src/win32/compat/getopt.c b/bacula/src/win32/compat/getopt.c index f5f676ad51..3ca810cc06 100644 --- a/bacula/src/win32/compat/getopt.c +++ b/bacula/src/win32/compat/getopt.c @@ -27,7 +27,7 @@ #endif #include //for strncmp -#if defined (WIN32) +#if defined (HAVE_WIN32) #include #endif @@ -41,7 +41,7 @@ #if defined (HAVE_ALLOCA_H) || (defined(sparc) && (defined(sun) || (!defined(USG) && !defined(SVR4) && !defined(__svr4__)))) #include #else -#if !defined (_AIX) && !defined (WIN32) +#if !defined (_AIX) && !defined (HAVE_WIN32) char *alloca (); #endif #endif /* alloca.h */ diff --git a/bacula/src/win32/compat/sys/mtio.h b/bacula/src/win32/compat/sys/mtio.h new file mode 100644 index 0000000000..51fa550cd4 --- /dev/null +++ b/bacula/src/win32/compat/sys/mtio.h @@ -0,0 +1,277 @@ +/* Structures and definitions for magnetic tape I/O control commands. + Copyright (C) 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* Written by H. Bergman . */ + +#ifndef _SYS_MTIO_H +#define _SYS_MTIO_H 1 + +/* Get necessary definitions from system and kernel headers. */ +#include +#include + + +/* Structure for MTIOCTOP - magnetic tape operation command. */ +struct mtop + { + short int mt_op; /* Operations defined below. */ + int mt_count; /* How many of them. */ + }; +#define _IOT_mtop /* Hurd ioctl type field. */ \ + _IOT (_IOTS (short), 1, _IOTS (int), 1, 0, 0) + +/* Magnetic Tape operations [Not all operations supported by all drivers]. */ +#define MTRESET 0 /* +reset drive in case of problems. */ +#define MTFSF 1 /* Forward space over FileMark, + * position at first record of next file. */ +#define MTBSF 2 /* Backward space FileMark (position before FM). */ +#define MTFSR 3 /* Forward space record. */ +#define MTBSR 4 /* Backward space record. */ +#define MTWEOF 5 /* Write an end-of-file record (mark). */ +#define MTREW 6 /* Rewind. */ +#define MTOFFL 7 /* Rewind and put the drive offline (eject?). */ +#define MTNOP 8 /* No op, set status only (read with MTIOCGET). */ +#define MTRETEN 9 /* Retension tape. */ +#define MTBSFM 10 /* +backward space FileMark, position at FM. */ +#define MTFSFM 11 /* +forward space FileMark, position at FM. */ +#define MTEOM 12 /* Goto end of recorded media (for appending files). + MTEOM positions after the last FM, ready for + appending another file. */ +#define MTERASE 13 /* Erase tape -- be careful! */ + +#define MTRAS1 14 /* Run self test 1 (nondestructive). */ +#define MTRAS2 15 /* Run self test 2 (destructive). */ +#define MTRAS3 16 /* Reserved for self test 3. */ + +#define MTSETBLK 20 /* Set block length (SCSI). */ +#define MTSETDENSITY 21 /* Set tape density (SCSI). */ +#define MTSEEK 22 /* Seek to block (Tandberg, etc.). */ +#define MTTELL 23 /* Tell block (Tandberg, etc.). */ +#define MTSETDRVBUFFER 24 /* Set the drive buffering according to SCSI-2. + Ordinary buffered operation with code 1. */ +#define MTFSS 25 /* Space forward over setmarks. */ +#define MTBSS 26 /* Space backward over setmarks. */ +#define MTWSM 27 /* Write setmarks. */ + +#define MTLOCK 28 /* Lock the drive door. */ +#define MTUNLOCK 29 /* Unlock the drive door. */ +#define MTLOAD 30 /* Execute the SCSI load command. */ +#define MTUNLOAD 31 /* Execute the SCSI unload command. */ +#define MTCOMPRESSION 32/* Control compression with SCSI mode page 15. */ +#define MTSETPART 33 /* Change the active tape partition. */ +#define MTMKPART 34 /* Format the tape with one or two partitions. */ + +/* structure for MTIOCGET - mag tape get status command */ + +struct mtget + { + long int mt_type; /* Type of magtape device. */ + long int mt_resid; /* Residual count: (not sure) + number of bytes ignored, or + number of files not skipped, or + number of records not skipped. */ + /* The following registers are device dependent. */ + long int mt_dsreg; /* Status register. */ + long int mt_gstat; /* Generic (device independent) status. */ + long int mt_erreg; /* Error register. */ + /* The next two fields are not always used. */ + __daddr_t mt_fileno; /* Number of current file on tape. */ + __daddr_t mt_blkno; /* Current block number. */ + }; +#define _IOT_mtget /* Hurd ioctl type field. */ \ + _IOT (_IOTS (long), 7, 0, 0, 0, 0) + + +/* Constants for mt_type. Not all of these are supported, and + these are not all of the ones that are supported. */ +#define MT_ISUNKNOWN 0x01 +#define MT_ISQIC02 0x02 /* Generic QIC-02 tape streamer. */ +#define MT_ISWT5150 0x03 /* Wangtek 5150EQ, QIC-150, QIC-02. */ +#define MT_ISARCHIVE_5945L2 0x04 /* Archive 5945L-2, QIC-24, QIC-02?. */ +#define MT_ISCMSJ500 0x05 /* CMS Jumbo 500 (QIC-02?). */ +#define MT_ISTDC3610 0x06 /* Tandberg 6310, QIC-24. */ +#define MT_ISARCHIVE_VP60I 0x07 /* Archive VP60i, QIC-02. */ +#define MT_ISARCHIVE_2150L 0x08 /* Archive Viper 2150L. */ +#define MT_ISARCHIVE_2060L 0x09 /* Archive Viper 2060L. */ +#define MT_ISARCHIVESC499 0x0A /* Archive SC-499 QIC-36 controller. */ +#define MT_ISQIC02_ALL_FEATURES 0x0F /* Generic QIC-02 with all features. */ +#define MT_ISWT5099EEN24 0x11 /* Wangtek 5099-een24, 60MB, QIC-24. */ +#define MT_ISTEAC_MT2ST 0x12 /* Teac MT-2ST 155mb drive, + Teac DC-1 card (Wangtek type). */ +#define MT_ISEVEREX_FT40A 0x32 /* Everex FT40A (QIC-40). */ +#define MT_ISDDS1 0x51 /* DDS device without partitions. */ +#define MT_ISDDS2 0x52 /* DDS device with partitions. */ +#define MT_ISSCSI1 0x71 /* Generic ANSI SCSI-1 tape unit. */ +#define MT_ISSCSI2 0x72 /* Generic ANSI SCSI-2 tape unit. */ + +/* QIC-40/80/3010/3020 ftape supported drives. + 20bit vendor ID + 0x800000 (see vendors.h in ftape distribution). */ +#define MT_ISFTAPE_UNKNOWN 0x800000 /* obsolete */ +#define MT_ISFTAPE_FLAG 0x800000 + +struct mt_tape_info + { + long int t_type; /* Device type id (mt_type). */ + char *t_name; /* Descriptive name. */ + }; + +#define MT_TAPE_INFO \ + { \ + {MT_ISUNKNOWN, "Unknown type of tape device"}, \ + {MT_ISQIC02, "Generic QIC-02 tape streamer"}, \ + {MT_ISWT5150, "Wangtek 5150, QIC-150"}, \ + {MT_ISARCHIVE_5945L2, "Archive 5945L-2"}, \ + {MT_ISCMSJ500, "CMS Jumbo 500"}, \ + {MT_ISTDC3610, "Tandberg TDC 3610, QIC-24"}, \ + {MT_ISARCHIVE_VP60I, "Archive VP60i, QIC-02"}, \ + {MT_ISARCHIVE_2150L, "Archive Viper 2150L"}, \ + {MT_ISARCHIVE_2060L, "Archive Viper 2060L"}, \ + {MT_ISARCHIVESC499, "Archive SC-499 QIC-36 controller"}, \ + {MT_ISQIC02_ALL_FEATURES, "Generic QIC-02 tape, all features"}, \ + {MT_ISWT5099EEN24, "Wangtek 5099-een24, 60MB"}, \ + {MT_ISTEAC_MT2ST, "Teac MT-2ST 155mb data cassette drive"}, \ + {MT_ISEVEREX_FT40A, "Everex FT40A, QIC-40"}, \ + {MT_ISSCSI1, "Generic SCSI-1 tape"}, \ + {MT_ISSCSI2, "Generic SCSI-2 tape"}, \ + {0, NULL} \ + } + + +/* Structure for MTIOCPOS - mag tape get position command. */ + +struct mtpos + { + long int mt_blkno; /* Current block number. */ + }; +#define _IOT_mtpos /* Hurd ioctl type field. */ \ + _IOT_SIMPLE (long) + + +/* Structure for MTIOCGETCONFIG/MTIOCSETCONFIG primarily intended + as an interim solution for QIC-02 until DDI is fully implemented. */ +struct mtconfiginfo + { + long int mt_type; /* Drive type. */ + long int ifc_type; /* Interface card type. */ + unsigned short int irqnr; /* IRQ number to use. */ + unsigned short int dmanr; /* DMA channel to use. */ + unsigned short int port; /* IO port base address. */ + + unsigned long int debug; /* Debugging flags. */ + + unsigned have_dens:1; + unsigned have_bsf:1; + unsigned have_fsr:1; + unsigned have_bsr:1; + unsigned have_eod:1; + unsigned have_seek:1; + unsigned have_tell:1; + unsigned have_ras1:1; + unsigned have_ras2:1; + unsigned have_ras3:1; + unsigned have_qfa:1; + + unsigned pad1:5; + char reserved[10]; + }; +#define _IOT_mtconfiginfo /* Hurd ioctl type field. */ \ + _IOT (_IOTS (long), 2, _IOTS (short), 3, _IOTS (long), 1) /* XXX wrong */ + + +/* Magnetic tape I/O control commands. */ +#define MTIOCTOP _IOW('m', 1, struct mtop) /* Do a mag tape op. */ +#define MTIOCGET _IOR('m', 2, struct mtget) /* Get tape status. */ +#define MTIOCPOS _IOR('m', 3, struct mtpos) /* Get tape position.*/ + +/* The next two are used by the QIC-02 driver for runtime reconfiguration. + See tpqic02.h for struct mtconfiginfo. */ +#define MTIOCGETCONFIG _IOR('m', 4, struct mtconfiginfo) /* Get tape config.*/ +#define MTIOCSETCONFIG _IOW('m', 5, struct mtconfiginfo) /* Set tape config.*/ + +/* Generic Mag Tape (device independent) status macros for examining + mt_gstat -- HP-UX compatible. + There is room for more generic status bits here, but I don't + know which of them are reserved. At least three or so should + be added to make this really useful. */ +#define GMT_EOF(x) ((x) & 0x80000000) +#define GMT_BOT(x) ((x) & 0x40000000) +#define GMT_EOT(x) ((x) & 0x20000000) +#define GMT_SM(x) ((x) & 0x10000000) /* DDS setmark */ +#define GMT_EOD(x) ((x) & 0x08000000) /* DDS EOD */ +#define GMT_WR_PROT(x) ((x) & 0x04000000) +/* #define GMT_ ? ((x) & 0x02000000) */ +#define GMT_ONLINE(x) ((x) & 0x01000000) +#define GMT_D_6250(x) ((x) & 0x00800000) +#define GMT_D_1600(x) ((x) & 0x00400000) +#define GMT_D_800(x) ((x) & 0x00200000) +/* #define GMT_ ? ((x) & 0x00100000) */ +/* #define GMT_ ? ((x) & 0x00080000) */ +#define GMT_DR_OPEN(x) ((x) & 0x00040000) /* Door open (no tape). */ +/* #define GMT_ ? ((x) & 0x00020000) */ +#define GMT_IM_REP_EN(x) ((x) & 0x00010000) /* Immediate report mode.*/ +/* 16 generic status bits unused. */ + + +/* SCSI-tape specific definitions. Bitfield shifts in the status */ +#define MT_ST_BLKSIZE_SHIFT 0 +#define MT_ST_BLKSIZE_MASK 0xffffff +#define MT_ST_DENSITY_SHIFT 24 +#define MT_ST_DENSITY_MASK 0xff000000 + +#define MT_ST_SOFTERR_SHIFT 0 +#define MT_ST_SOFTERR_MASK 0xffff + +/* Bitfields for the MTSETDRVBUFFER ioctl. */ +#define MT_ST_OPTIONS 0xf0000000 +#define MT_ST_BOOLEANS 0x10000000 +#define MT_ST_SETBOOLEANS 0x30000000 +#define MT_ST_CLEARBOOLEANS 0x40000000 +#define MT_ST_WRITE_THRESHOLD 0x20000000 +#define MT_ST_DEF_BLKSIZE 0x50000000 +#define MT_ST_DEF_OPTIONS 0x60000000 + +#define MT_ST_BUFFER_WRITES 0x1 +#define MT_ST_ASYNC_WRITES 0x2 +#define MT_ST_READ_AHEAD 0x4 +#define MT_ST_DEBUGGING 0x8 +#define MT_ST_TWO_FM 0x10 +#define MT_ST_FAST_MTEOM 0x20 +#define MT_ST_AUTO_LOCK 0x40 +#define MT_ST_DEF_WRITES 0x80 +#define MT_ST_CAN_BSR 0x100 +#define MT_ST_NO_BLKLIMS 0x200 +#define MT_ST_CAN_PARTITIONS 0x400 +#define MT_ST_SCSI2LOGICAL 0x800 + +/* The mode parameters to be controlled. Parameter chosen with bits 20-28. */ +#define MT_ST_CLEAR_DEFAULT 0xfffff +#define MT_ST_DEF_DENSITY (MT_ST_DEF_OPTIONS | 0x100000) +#define MT_ST_DEF_COMPRESSION (MT_ST_DEF_OPTIONS | 0x200000) +#define MT_ST_DEF_DRVBUFFER (MT_ST_DEF_OPTIONS | 0x300000) + +/* The offset for the arguments for the special HP changer load command. */ +#define MT_ST_HPLOADER_OFFSET 10000 + + +/* Specify default tape device. */ +#ifndef DEFTAPE +# define DEFTAPE "/dev/tape" +#endif + +#endif /* mtio.h */ diff --git a/bacula/src/win32/compat/winapi.c b/bacula/src/win32/compat/winapi.c new file mode 100644 index 0000000000..f08cf623dd --- /dev/null +++ b/bacula/src/win32/compat/winapi.c @@ -0,0 +1,189 @@ +/* + * Windows APIs that are different for each system. + * We use pointers to the entry points so that a + * single binary will run on all Windows systems. + * + * Kern Sibbald MMIII + */ +/* + Copyright (C) 2003-2006 Kern Sibbald + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + version 2 as amended with additional clauses defined in the + file LICENSE in the main source directory. + + 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 + the file LICENSE for additional details. + + */ + +#include "bacula.h" + +// init with win9x, but maybe set to NT in InitWinAPI +DWORD g_platform_id = VER_PLATFORM_WIN32_WINDOWS; +DWORD g_MinorVersion = 0; + +/* API Pointers */ + +t_OpenProcessToken p_OpenProcessToken = NULL; +t_AdjustTokenPrivileges p_AdjustTokenPrivileges = NULL; +t_LookupPrivilegeValue p_LookupPrivilegeValue = NULL; + +t_SetProcessShutdownParameters p_SetProcessShutdownParameters = NULL; + +t_CreateFileA p_CreateFileA = NULL; +t_CreateFileW p_CreateFileW = NULL; +t_CreateDirectoryA p_CreateDirectoryA; +t_CreateDirectoryW p_CreateDirectoryW; + +t_wunlink p_wunlink = NULL; +t_wmkdir p_wmkdir = NULL; + +t_GetFileAttributesA p_GetFileAttributesA = NULL; +t_GetFileAttributesW p_GetFileAttributesW = NULL; + +t_GetFileAttributesExA p_GetFileAttributesExA = NULL; +t_GetFileAttributesExW p_GetFileAttributesExW = NULL; + +t_SetFileAttributesA p_SetFileAttributesA = NULL; +t_SetFileAttributesW p_SetFileAttributesW = NULL; +t_BackupRead p_BackupRead = NULL; +t_BackupWrite p_BackupWrite = NULL; +t_WideCharToMultiByte p_WideCharToMultiByte = NULL; +t_MultiByteToWideChar p_MultiByteToWideChar = NULL; + +t_FindFirstFileA p_FindFirstFileA = NULL; +t_FindFirstFileW p_FindFirstFileW = NULL; + +t_FindNextFileA p_FindNextFileA = NULL; +t_FindNextFileW p_FindNextFileW = NULL; + +t_SetCurrentDirectoryA p_SetCurrentDirectoryA = NULL; +t_SetCurrentDirectoryW p_SetCurrentDirectoryW = NULL; + +t_GetCurrentDirectoryA p_GetCurrentDirectoryA = NULL; +t_GetCurrentDirectoryW p_GetCurrentDirectoryW = NULL; + +t_GetVolumePathNameW p_GetVolumePathNameW = NULL; +t_GetVolumeNameForVolumeMountPointW p_GetVolumeNameForVolumeMountPointW = NULL; + +void +InitWinAPIWrapper() +{ + OSVERSIONINFO osversioninfo = { sizeof(OSVERSIONINFO) }; + + // Get the current OS version + if (!GetVersionEx(&osversioninfo)) { + g_platform_id = 0; + g_MinorVersion = 0; + } else { + g_platform_id = osversioninfo.dwPlatformId; + g_MinorVersion = osversioninfo.dwMinorVersion; + } + + HMODULE hLib = LoadLibraryA("KERNEL32.DLL"); + if (hLib) { + /* create file calls */ + p_CreateFileA = (t_CreateFileA) + GetProcAddress(hLib, "CreateFileA"); + p_CreateDirectoryA = (t_CreateDirectoryA) + GetProcAddress(hLib, "CreateDirectoryA"); + + /* attribute calls */ + p_GetFileAttributesA = (t_GetFileAttributesA) + GetProcAddress(hLib, "GetFileAttributesA"); + p_GetFileAttributesExA = (t_GetFileAttributesExA) + GetProcAddress(hLib, "GetFileAttributesExA"); + p_SetFileAttributesA = (t_SetFileAttributesA) + GetProcAddress(hLib, "SetFileAttributesA"); + + /* process calls */ + p_SetProcessShutdownParameters = (t_SetProcessShutdownParameters) + GetProcAddress(hLib, "SetProcessShutdownParameters"); + + /* char conversion calls */ + p_WideCharToMultiByte = (t_WideCharToMultiByte) + GetProcAddress(hLib, "WideCharToMultiByte"); + p_MultiByteToWideChar = (t_MultiByteToWideChar) + GetProcAddress(hLib, "MultiByteToWideChar"); + + /* find files */ + p_FindFirstFileA = (t_FindFirstFileA) + GetProcAddress(hLib, "FindFirstFileA"); + p_FindNextFileA = (t_FindNextFileA) + GetProcAddress(hLib, "FindNextFileA"); + + /* get and set directory */ + p_GetCurrentDirectoryA = (t_GetCurrentDirectoryA) + GetProcAddress(hLib, "GetCurrentDirectoryA"); + p_SetCurrentDirectoryA = (t_SetCurrentDirectoryA) + GetProcAddress(hLib, "SetCurrentDirectoryA"); + + if (g_platform_id != VER_PLATFORM_WIN32_WINDOWS) { + p_CreateFileW = (t_CreateFileW) + GetProcAddress(hLib, "CreateFileW"); + p_CreateDirectoryW = (t_CreateDirectoryW) + GetProcAddress(hLib, "CreateDirectoryW"); + + /* backup calls */ + p_BackupRead = (t_BackupRead) + GetProcAddress(hLib, "BackupRead"); + p_BackupWrite = (t_BackupWrite) + GetProcAddress(hLib, "BackupWrite"); + + p_GetFileAttributesW = (t_GetFileAttributesW) + GetProcAddress(hLib, "GetFileAttributesW"); + p_GetFileAttributesExW = (t_GetFileAttributesExW) + GetProcAddress(hLib, "GetFileAttributesExW"); + p_SetFileAttributesW = (t_SetFileAttributesW) + GetProcAddress(hLib, "SetFileAttributesW"); + p_FindFirstFileW = (t_FindFirstFileW) + GetProcAddress(hLib, "FindFirstFileW"); + p_FindNextFileW = (t_FindNextFileW) + GetProcAddress(hLib, "FindNextFileW"); + p_GetCurrentDirectoryW = (t_GetCurrentDirectoryW) + GetProcAddress(hLib, "GetCurrentDirectoryW"); + p_SetCurrentDirectoryW = (t_SetCurrentDirectoryW) + GetProcAddress(hLib, "SetCurrentDirectoryW"); + + /* some special stuff we need for VSS + but statically linkage doesn't work on Win 9x */ + p_GetVolumePathNameW = (t_GetVolumePathNameW) + GetProcAddress(hLib, "GetVolumePathNameW"); + p_GetVolumeNameForVolumeMountPointW = (t_GetVolumeNameForVolumeMountPointW) + GetProcAddress(hLib, "GetVolumeNameForVolumeMountPointW"); + } + + FreeLibrary(hLib); + } + + if (g_platform_id != VER_PLATFORM_WIN32_WINDOWS) { + hLib = LoadLibraryA("MSVCRT.DLL"); + if (hLib) { + /* unlink */ + p_wunlink = (t_wunlink) + GetProcAddress(hLib, "_wunlink"); + /* wmkdir */ + p_wmkdir = (t_wmkdir) + GetProcAddress(hLib, "_wmkdir"); + + FreeLibrary(hLib); + } + + hLib = LoadLibraryA("ADVAPI32.DLL"); + if (hLib) { + p_OpenProcessToken = (t_OpenProcessToken) + GetProcAddress(hLib, "OpenProcessToken"); + p_AdjustTokenPrivileges = (t_AdjustTokenPrivileges) + GetProcAddress(hLib, "AdjustTokenPrivileges"); + p_LookupPrivilegeValue = (t_LookupPrivilegeValue) + GetProcAddress(hLib, "LookupPrivilegeValueA"); + FreeLibrary(hLib); + } + } + + atexit(Win32ConvCleanupCache); +} diff --git a/bacula/src/win32/console/console.vcproj b/bacula/src/win32/console/console.vcproj index dc5fe36f02..e9ffdcb486 100644 --- a/bacula/src/win32/console/console.vcproj +++ b/bacula/src/win32/console/console.vcproj @@ -1,1035 +1,293 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bacula/src/win32/filed/Makefile b/bacula/src/win32/filed/Makefile new file mode 100644 index 0000000000..5993565d53 --- /dev/null +++ b/bacula/src/win32/filed/Makefile @@ -0,0 +1,86 @@ +# +# Makefile for win32 bacula executables +# Using MinGW cross-compiler on GNU/Linux +# +# Written by Robert Nelson, June 2006 +# + +include ../Makefile.inc + +INCLUDES = \ + -I. \ + $(INCLUDE_PTHREADS) \ + $(INCLUDE_BACULA) \ + $(INCLUDE_ZLIB) \ + $(INCLUDE_VSS) \ + $(INCLUDE_OPENSSL) \ + $(INCLUDE_ICONS) + +DEFINES = \ + -DUSING_DLL \ + -DWIN32_VSS \ + $(HAVES) + +VPATH = ../../filed ../libwin32 + +########################################################################## + +FILED_OBJS = \ + $(OBJDIR)/authenticate.o \ + $(OBJDIR)/backup.o \ + $(OBJDIR)/estimate.o \ + $(OBJDIR)/filed.o \ + $(OBJDIR)/filed_conf.o \ + $(OBJDIR)/heartbeat.o \ + $(OBJDIR)/job.o \ + $(OBJDIR)/restore.o \ + $(OBJDIR)/status.o \ + $(OBJDIR)/verify.o \ + $(OBJDIR)/verify_vol.o \ + $(OBJDIR)/vss.o \ + $(OBJDIR)/vss_XP.o \ + $(OBJDIR)/vss_W2K3.o \ + $(OBJDIR)/winabout.o \ + $(OBJDIR)/winevents.o \ + $(OBJDIR)/winservice.o \ + $(OBJDIR)/winstat.o \ + $(OBJDIR)/wintray.o \ + $(OBJDIR)/winmain.o \ + $(OBJDIR)/winres.res + +ALL_OBJS = $(FILED_OBJS) + +FILED_LIBS = \ + $(LIBS_PTHREADS) \ + $(LIBS_ZLIB) \ + -lole32 \ + -loleaut32 \ + -lwsock32 \ + -luuid + +###################################################################### + +# Targets + +.PHONY: all clean + +all: $(BINDIR)/bacula-fd.exe + +clean: + @echo "Cleaning `pwd`" + $(call clean_obj,$(ALL_OBJS)) + $(call clean_exe,$(BINDIR)/bacula-fd.exe) + +# +# Rules +# + +$(BINDIR)/bacula-fd.exe: $(FILED_OBJS) $(LIBS_BACULA) + $(call link_winapp,$(FILED_LIBS)) + +$(OBJDIR)/winres.res: ../libwin32/winres.rc + @echo "Compiling $@" + $(call checkdir,$@) + $(ECHO_CMD)$(WINDRES) $(INCLUDE_ICONS) -O coff $< -o $@ + +include ../Makefile.rules diff --git a/bacula/src/win32/filed/baculafd.vcproj b/bacula/src/win32/filed/baculafd.vcproj new file mode 100644 index 0000000000..5c6c820962 --- /dev/null +++ b/bacula/src/win32/filed/baculafd.vcproj @@ -0,0 +1,602 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bacula/src/win32/filed/vss.cpp b/bacula/src/win32/filed/vss.cpp new file mode 100644 index 0000000000..b3d1fa7e36 --- /dev/null +++ b/bacula/src/win32/filed/vss.cpp @@ -0,0 +1,215 @@ + +// vss.cpp -- Interface to Volume Shadow Copies (VSS) +// +// Copyright transferred from MATRIX-Computer GmbH to +// Kern Sibbald by express permission. +// +// Copyright (C) 2005-2006 Kern Sibbald +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// version 2 as amended with additional clauses defined in the +// file LICENSE in the main source directory. +// +// 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 +// the file LICENSE for additional details. +// +// +// Author : Thorsten Engel +// Created On : Fri May 06 21:44:00 2005 + + +#ifdef WIN32_VSS +#include "bacula.h" +#include "compat.h" + +#include "ms_atl.h" +#include + +#include "vss.h" + +VSSClient *g_pVSSClient; + +void +VSSCleanup() +{ + if (g_pVSSClient) + delete (g_pVSSClient); +} + +void +VSSInit() +{ + /* decide which vss class to initialize */ + switch (g_MinorVersion) { + case 1: + g_pVSSClient = new VSSClientXP(); + atexit(VSSCleanup); + break; + case 2: + g_pVSSClient = new VSSClient2003(); + atexit(VSSCleanup); + break; + } +} + +BOOL +VSSPathConvert(const char *szFilePath, char *szShadowPath, int nBuflen) +{ + return g_pVSSClient->GetShadowPath(szFilePath, szShadowPath, nBuflen); +} + +BOOL +VSSPathConvertW(const wchar_t *szFilePath, wchar_t *szShadowPath, int nBuflen) +{ + return g_pVSSClient->GetShadowPathW(szFilePath, szShadowPath, nBuflen); +} + +// Constructor +VSSClient::VSSClient() +{ + m_bCoInitializeCalled = false; + m_bCoInitializeSecurityCalled = false; + m_dwContext = 0; // VSS_CTX_BACKUP; + m_bDuringRestore = false; + m_bBackupIsInitialized = false; + m_pVssObject = NULL; + m_pAlistWriterState = New (alist(10, not_owned_by_alist)); + m_pAlistWriterInfoText = New (alist(10, owned_by_alist)); + m_uidCurrentSnapshotSet = GUID_NULL; + memset(m_wszUniqueVolumeName, 0, sizeof(m_wszUniqueVolumeName)); + memset(m_szShadowCopyName, 0, sizeof(m_szShadowCopyName)); +} + +// Destructor +VSSClient::~VSSClient() +{ + // Release the IVssBackupComponents interface + // WARNING: this must be done BEFORE calling CoUninitialize() + if (m_pVssObject) { + m_pVssObject->Release(); + m_pVssObject = NULL; + } + + DestroyWriterInfo(); + delete (alist*) m_pAlistWriterState; + delete (alist*) m_pAlistWriterInfoText; + + // Call CoUninitialize if the CoInitialize was performed successfully + if (m_bCoInitializeCalled) + CoUninitialize(); +} + +BOOL VSSClient::InitializeForBackup() +{ + //return Initialize (VSS_CTX_BACKUP); + return Initialize(0); +} + + + + +BOOL VSSClient::GetShadowPath(const char *szFilePath, char *szShadowPath, int nBuflen) +{ + if (!m_bBackupIsInitialized) + return FALSE; + + /* check for valid pathname */ + BOOL bIsValidName; + + bIsValidName = strlen(szFilePath) > 3; + if (bIsValidName) + bIsValidName &= isalpha (szFilePath[0]) && + szFilePath[1]==':' && + szFilePath[2] == '\\'; + + if (bIsValidName) { + int nDriveIndex = toupper(szFilePath[0])-'A'; + if (m_szShadowCopyName[nDriveIndex][0] != 0) { + + if (WideCharToMultiByte(CP_UTF8,0,m_szShadowCopyName[nDriveIndex],-1,szShadowPath,nBuflen-1,NULL,NULL)) { + nBuflen -= (int)strlen(szShadowPath); + strncat(szShadowPath, szFilePath+2, nBuflen); + return TRUE; + } + } + } + + strncpy(szShadowPath, szFilePath, nBuflen); + errno = EINVAL; + return FALSE; +} + +BOOL VSSClient::GetShadowPathW(const wchar_t *szFilePath, wchar_t *szShadowPath, int nBuflen) +{ + if (!m_bBackupIsInitialized) + return FALSE; + + /* check for valid pathname */ + BOOL bIsValidName; + + bIsValidName = wcslen(szFilePath) > 3; + if (bIsValidName) + bIsValidName &= iswalpha (szFilePath[0]) && + szFilePath[1]==':' && + szFilePath[2] == '\\'; + + if (bIsValidName) { + int nDriveIndex = towupper(szFilePath[0])-'A'; + if (m_szShadowCopyName[nDriveIndex][0] != 0) { + wcsncpy(szShadowPath, m_szShadowCopyName[nDriveIndex], nBuflen); + nBuflen -= (int)wcslen(m_szShadowCopyName[nDriveIndex]); + wcsncat(szShadowPath, szFilePath+2, nBuflen); + return TRUE; + } + } + + wcsncpy(szShadowPath, szFilePath, nBuflen); + errno = EINVAL; + return FALSE; +} + + +const size_t VSSClient::GetWriterCount() +{ + alist* pV = (alist*) m_pAlistWriterInfoText; + return pV->size(); +} + +const char* VSSClient::GetWriterInfo(int nIndex) +{ + alist* pV = (alist*) m_pAlistWriterInfoText; + return (char*) pV->get(nIndex); +} + + +const int VSSClient::GetWriterState(int nIndex) +{ + alist* pV = (alist*) m_pAlistWriterState; + return (int) pV->get(nIndex); +} + +void VSSClient::AppendWriterInfo(int nState, const char* pszInfo) +{ + alist* pT = (alist*) m_pAlistWriterInfoText; + alist* pS = (alist*) m_pAlistWriterState; + + pT->push (bstrdup(pszInfo)); + pS->push ((void*) nState); +} + +void VSSClient::DestroyWriterInfo() +{ + alist* pT = (alist*) m_pAlistWriterInfoText; + alist* pS = (alist*) m_pAlistWriterState; + + while (!pT->empty()) + free (pT->pop()); + + while (!pS->empty()) + pS->pop(); +} + +#endif diff --git a/bacula/src/win32/filed/vss.h b/bacula/src/win32/filed/vss.h new file mode 100644 index 0000000000..d8a8a0beef --- /dev/null +++ b/bacula/src/win32/filed/vss.h @@ -0,0 +1,120 @@ +/* -*- Mode: C -*- + * vss.h -- + */ +// +// Copyright transferred from MATRIX-Computer GmbH to +// Kern Sibbald by express permission. +// +// Copyright (C) 2005-2006 Kern Sibbald +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// version 2 as amended with additional clauses defined in the +// file LICENSE in the main source directory. +// +// 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 +// the file LICENSE for additional details. +// + +/* + * + * Author : Thorsten Engel + * Created On : Fri May 06 21:44:00 2006 + */ + +#ifndef __VSS_H_ +#define __VSS_H_ + +#ifndef b_errno_win32 +#define b_errno_win32 (1<<29) +#endif + +#ifdef WIN32_VSS + +// some forward declarations +struct IVssAsync; + +class VSSClient +{ +public: + VSSClient(); + virtual ~VSSClient(); + + // Backup Process + BOOL InitializeForBackup(); + virtual BOOL CreateSnapshots(char* szDriveLetters) = 0; + virtual BOOL CloseBackup() = 0; + virtual const char* GetDriverName() = 0; + BOOL GetShadowPath (const char* szFilePath, char* szShadowPath, int nBuflen); + BOOL GetShadowPathW (const wchar_t* szFilePath, wchar_t* szShadowPath, int nBuflen); /* nBuflen in characters */ + + const size_t GetWriterCount(); + const char* GetWriterInfo(int nIndex); + const int GetWriterState(int nIndex); + void DestroyWriterInfo(); + void AppendWriterInfo(int nState, const char* pszInfo); + const BOOL IsInitialized() { return m_bBackupIsInitialized; }; + +private: + virtual BOOL Initialize(DWORD dwContext, BOOL bDuringRestore = FALSE) = 0; + virtual BOOL WaitAndCheckForAsyncOperation(IVssAsync* pAsync) = 0; + virtual void QuerySnapshotSet(GUID snapshotSetID) = 0; + +protected: + HMODULE m_hLib; + + BOOL m_bCoInitializeCalled; + BOOL m_bCoInitializeSecurityCalled; + DWORD m_dwContext; + + IUnknown* m_pVssObject; + GUID m_uidCurrentSnapshotSet; + // TRUE if we are during restore + BOOL m_bDuringRestore; + BOOL m_bBackupIsInitialized; + + // drive A will be stored on position 0,Z on pos. 25 + wchar_t m_wszUniqueVolumeName[26][MAX_PATH]; // approx. 7 KB + wchar_t m_szShadowCopyName[26][MAX_PATH]; // approx. 7 KB + + void* m_pAlistWriterState; + void* m_pAlistWriterInfoText; +}; + +class VSSClientXP:public VSSClient +{ +public: + VSSClientXP(); + virtual ~VSSClientXP(); + virtual BOOL CreateSnapshots(char* szDriveLetters); + virtual BOOL CloseBackup(); + virtual const char* GetDriverName() { return "VSS WinXP"; }; +private: + virtual BOOL Initialize(DWORD dwContext, BOOL bDuringRestore); + virtual BOOL WaitAndCheckForAsyncOperation(IVssAsync* pAsync); + virtual void QuerySnapshotSet(GUID snapshotSetID); + BOOL CheckWriterStatus(); +}; + +class VSSClient2003:public VSSClient +{ +public: + VSSClient2003(); + virtual ~VSSClient2003(); + virtual BOOL CreateSnapshots(char* szDriveLetters); + virtual BOOL CloseBackup(); + virtual const char* GetDriverName() { return "VSS Win 2003"; }; +private: + virtual BOOL Initialize(DWORD dwContext, BOOL bDuringRestore); + virtual BOOL WaitAndCheckForAsyncOperation(IVssAsync* pAsync); + virtual void QuerySnapshotSet(GUID snapshotSetID); + BOOL CheckWriterStatus(); +}; + +extern VSSClient *g_pVSSClient; + +#endif /* WIN32_VSS */ + +#endif /* __VSS_H_ */ diff --git a/bacula/src/win32/filed/vss_W2K3.cpp b/bacula/src/win32/filed/vss_W2K3.cpp new file mode 100644 index 0000000000..68914d0f9c --- /dev/null +++ b/bacula/src/win32/filed/vss_W2K3.cpp @@ -0,0 +1,13 @@ +/* +we need one class per OS as Microsofts API +differs only by calling convention and some +function we don't use. + +vss_generic will handle all versions and +switch between different headers to include. +*/ + +#ifdef WIN32_VSS +#define B_VSS_W2K3 +#include "vss_generic.cpp" +#endif diff --git a/bacula/src/win32/filed/vss_XP.cpp b/bacula/src/win32/filed/vss_XP.cpp new file mode 100644 index 0000000000..20871296d9 --- /dev/null +++ b/bacula/src/win32/filed/vss_XP.cpp @@ -0,0 +1,4 @@ +#ifdef WIN32_VSS +#define B_VSS_XP +#include "vss_generic.cpp" +#endif diff --git a/bacula/src/win32/filed/vss_generic.cpp b/bacula/src/win32/filed/vss_generic.cpp new file mode 100644 index 0000000000..a61830ab03 --- /dev/null +++ b/bacula/src/win32/filed/vss_generic.cpp @@ -0,0 +1,633 @@ +// -*- Mode: C++ -*- +// vss.cpp -- Interface to Volume Shadow Copies (VSS) +// +// Copyright transferred from MATRIX-Computer GmbH to +// Kern Sibbald by express permission. +// +// Copyright (C) 2005-2006 Kern Sibbald +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// version 2 as amended with additional clauses defined in the +// file LICENSE in the main source directory. +// +// 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 +// the file LICENSE for additional details. +// +// +// Author : Thorsten Engel +// Created On : Fri May 06 21:44:00 2005 + + +#ifdef WIN32_VSS + +#include + +#undef setlocale + +// STL includes +#include +#include +#include +#include +#include +using namespace std; + +#include "ms_atl.h" +#include + +#if !defined(ENABLE_NLS) +#define setlocale(p, d) +#endif + +#ifdef HAVE_STRSAFE_H +// Used for safe string manipulation +#include +#endif + +BOOL VSSPathConvert(const char *szFilePath, char *szShadowPath, int nBuflen); +BOOL VSSPathConvertW(const wchar_t *szFilePath, wchar_t *szShadowPath, int nBuflen); + +#ifdef HAVE_MINGW +class IXMLDOMDocument; +#endif + +#ifdef B_VSS_XP + #pragma message("compile VSS for Windows XP") + #define VSSClientGeneric VSSClientXP + + #include "inc/WinXP/vss.h" + #include "inc/WinXP/vswriter.h" + #include "inc/WinXP/vsbackup.h" + + /* In VSSAPI.DLL */ + typedef HRESULT (STDAPICALLTYPE* t_CreateVssBackupComponents)(OUT IVssBackupComponents **); + typedef void (APIENTRY* t_VssFreeSnapshotProperties)(IN VSS_SNAPSHOT_PROP*); + + static t_CreateVssBackupComponents p_CreateVssBackupComponents = NULL; + static t_VssFreeSnapshotProperties p_VssFreeSnapshotProperties = NULL; + + #define VSSVBACK_ENTRY "?CreateVssBackupComponents@@YGJPAPAVIVssBackupComponents@@@Z" +#endif + +#ifdef B_VSS_W2K3 + #pragma message("compile VSS for Windows 2003") + #define VSSClientGeneric VSSClient2003 + + #include "inc/Win2003/vss.h" + #include "inc/Win2003/vswriter.h" + #include "inc/Win2003/vsbackup.h" + + /* In VSSAPI.DLL */ + typedef HRESULT (STDAPICALLTYPE* t_CreateVssBackupComponents)(OUT IVssBackupComponents **); + typedef void (APIENTRY* t_VssFreeSnapshotProperties)(IN VSS_SNAPSHOT_PROP*); + + static t_CreateVssBackupComponents p_CreateVssBackupComponents = NULL; + static t_VssFreeSnapshotProperties p_VssFreeSnapshotProperties = NULL; + + #define VSSVBACK_ENTRY "?CreateVssBackupComponents@@YGJPAPAVIVssBackupComponents@@@Z" +#endif + +#include "vss.h" + +/* + * + * some helper functions + * + * + */ + +// Append a backslash to the current string +inline wstring AppendBackslash(wstring str) +{ + if (str.length() == 0) + return wstring(L"\\"); + if (str[str.length() - 1] == L'\\') + return str; + return str.append(L"\\"); +} + +// Get the unique volume name for the given path +inline wstring GetUniqueVolumeNameForPath(wstring path) +{ + if (path.length() <= 0) { + return L""; + } + + // Add the backslash termination, if needed + path = AppendBackslash(path); + + // Get the root path of the volume + wchar_t volumeRootPath[MAX_PATH]; + wchar_t volumeName[MAX_PATH]; + wchar_t volumeUniqueName[MAX_PATH]; + + if (!p_GetVolumePathNameW || !p_GetVolumePathNameW((LPCWSTR)path.c_str(), volumeRootPath, MAX_PATH)) + return L""; + + // Get the volume name alias (might be different from the unique volume name in rare cases) + if (!p_GetVolumeNameForVolumeMountPointW || !p_GetVolumeNameForVolumeMountPointW(volumeRootPath, volumeName, MAX_PATH)) + return L""; + + // Get the unique volume name + if (!p_GetVolumeNameForVolumeMountPointW(volumeName, volumeUniqueName, MAX_PATH)) + return L""; + + return volumeUniqueName; +} + + +// Helper macro for quick treatment of case statements for error codes +#define GEN_MERGE(A, B) A##B +#define GEN_MAKE_W(A) GEN_MERGE(L, A) + +#define CHECK_CASE_FOR_CONSTANT(value) \ + case value: return (GEN_MAKE_W(#value)); + + +// Convert a writer status into a string +inline const wchar_t* GetStringFromWriterStatus(VSS_WRITER_STATE eWriterStatus) +{ + switch (eWriterStatus) { + CHECK_CASE_FOR_CONSTANT(VSS_WS_STABLE); + CHECK_CASE_FOR_CONSTANT(VSS_WS_WAITING_FOR_FREEZE); + CHECK_CASE_FOR_CONSTANT(VSS_WS_WAITING_FOR_THAW); + CHECK_CASE_FOR_CONSTANT(VSS_WS_WAITING_FOR_POST_SNAPSHOT); + CHECK_CASE_FOR_CONSTANT(VSS_WS_WAITING_FOR_BACKUP_COMPLETE); + CHECK_CASE_FOR_CONSTANT(VSS_WS_FAILED_AT_IDENTIFY); + CHECK_CASE_FOR_CONSTANT(VSS_WS_FAILED_AT_PREPARE_BACKUP); + CHECK_CASE_FOR_CONSTANT(VSS_WS_FAILED_AT_PREPARE_SNAPSHOT); + CHECK_CASE_FOR_CONSTANT(VSS_WS_FAILED_AT_FREEZE); + CHECK_CASE_FOR_CONSTANT(VSS_WS_FAILED_AT_THAW); + CHECK_CASE_FOR_CONSTANT(VSS_WS_FAILED_AT_POST_SNAPSHOT); + CHECK_CASE_FOR_CONSTANT(VSS_WS_FAILED_AT_BACKUP_COMPLETE); + CHECK_CASE_FOR_CONSTANT(VSS_WS_FAILED_AT_PRE_RESTORE); + CHECK_CASE_FOR_CONSTANT(VSS_WS_FAILED_AT_POST_RESTORE); + + default: + return L"Error or Undefined"; + } +} + +// Constructor + +VSSClientGeneric::VSSClientGeneric() +{ + m_hLib = LoadLibraryA("VSSAPI.DLL"); + if (m_hLib) { + p_CreateVssBackupComponents = (t_CreateVssBackupComponents) + GetProcAddress(m_hLib, VSSVBACK_ENTRY); + + p_VssFreeSnapshotProperties = (t_VssFreeSnapshotProperties) + GetProcAddress(m_hLib, "VssFreeSnapshotProperties"); + } +} + + + +// Destructor +VSSClientGeneric::~VSSClientGeneric() +{ + if (m_hLib) + FreeLibrary(m_hLib); +} + +// Initialize the COM infrastructure and the internal pointers +BOOL VSSClientGeneric::Initialize(DWORD dwContext, BOOL bDuringRestore) +{ + if (!(p_CreateVssBackupComponents && p_VssFreeSnapshotProperties)) { + errno = ENOSYS; + return FALSE; + } + + HRESULT hr; + // Initialize COM + if (!m_bCoInitializeCalled) { + if (FAILED(CoInitialize(NULL))) { + errno = b_errno_win32; + return FALSE; + } + m_bCoInitializeCalled = true; + } + + // Initialize COM security + if (!m_bCoInitializeSecurityCalled) { + hr = + CoInitializeSecurity( + NULL, // Allow *all* VSS writers to communicate back! + -1, // Default COM authentication service + NULL, // Default COM authorization service + NULL, // reserved parameter + RPC_C_AUTHN_LEVEL_PKT_PRIVACY, // Strongest COM authentication level + RPC_C_IMP_LEVEL_IDENTIFY, // Minimal impersonation abilities + NULL, // Default COM authentication settings + EOAC_NONE, // No special options + NULL // Reserved parameter + ); + + if (FAILED(hr)) { + errno = b_errno_win32; + return FALSE; + } + m_bCoInitializeSecurityCalled = true; + } + + // Release the IVssBackupComponents interface + if (m_pVssObject) { + m_pVssObject->Release(); + m_pVssObject = NULL; + } + + // Create the internal backup components object + hr = p_CreateVssBackupComponents((IVssBackupComponents**) &m_pVssObject); + if (FAILED(hr)) { + errno = b_errno_win32; + return FALSE; + } + +#ifdef B_VSS_W2K3 + if (dwContext != VSS_CTX_BACKUP) { + hr = ((IVssBackupComponents*) m_pVssObject)->SetContext(dwContext); + if (FAILED(hr)) { + errno = b_errno_win32; + return FALSE; + } + } +#endif + + if (!bDuringRestore) { + // 1. InitializeForBackup + hr = ((IVssBackupComponents*) m_pVssObject)->InitializeForBackup(); + if (FAILED(hr)) { + errno = b_errno_win32; + return FALSE; + } + + // 2. SetBackupState + hr = ((IVssBackupComponents*) m_pVssObject)->SetBackupState(true, true, VSS_BT_FULL, false); + if (FAILED(hr)) { + errno = b_errno_win32; + return FALSE; + } + + CComPtr pAsync1; + // 3. GatherWriterMetaData + hr = ((IVssBackupComponents*) m_pVssObject)->GatherWriterMetadata(&pAsync1.p); + if (FAILED(hr)) { + errno = b_errno_win32; + return FALSE; + } + // Waits for the async operation to finish and checks the result + WaitAndCheckForAsyncOperation(pAsync1.p); + } + + + // We are during restore now? + m_bDuringRestore = bDuringRestore; + + // Keep the context + m_dwContext = dwContext; + + return TRUE; +} + + +BOOL VSSClientGeneric::WaitAndCheckForAsyncOperation(IVssAsync* pAsync) +{ + // Wait until the async operation finishes + // unfortunately we can't use a timeout here yet. + // the interface would allow it on W2k3, + // but it is not implemented yet.... + + HRESULT hr; + + // Check the result of the asynchronous operation + HRESULT hrReturned = S_OK; + + int timeout = 600; // 10 minutes.... + + int queryErrors = 0; + do { + if (hrReturned != S_OK) + Sleep(1000); + + hrReturned = S_OK; + hr = pAsync->QueryStatus(&hrReturned, NULL); + + if (FAILED(hr)) + queryErrors++; + } while ((timeout-- > 0) && (hrReturned == VSS_S_ASYNC_PENDING)); + + if (hrReturned == VSS_S_ASYNC_FINISHED) + return TRUE; + + +#ifdef DEBUG + // Check if the async operation succeeded... + if(hrReturned != VSS_S_ASYNC_FINISHED) { + wchar_t *pwszBuffer = NULL; + DWORD dwRet = ::FormatMessageW( + FORMAT_MESSAGE_ALLOCATE_BUFFER + | FORMAT_MESSAGE_FROM_SYSTEM + | FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, hrReturned, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPWSTR)&pwszBuffer, 0, NULL); + + if (dwRet != 0) { + LocalFree(pwszBuffer); + } + errno = b_errno_win32; + } +#endif + + return FALSE; +} + +BOOL VSSClientGeneric::CreateSnapshots(char* szDriveLetters) +{ + /* szDriveLetters contains all drive letters in uppercase */ + /* if a drive can not being added, it's converted to lowercase in szDriveLetters */ + /* http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vss/base/ivssbackupcomponents_startsnapshotset.asp */ + + if (!m_pVssObject || m_bBackupIsInitialized) { + errno = ENOSYS; + return FALSE; + } + + m_uidCurrentSnapshotSet = GUID_NULL; + + IVssBackupComponents *pVss = (IVssBackupComponents*)m_pVssObject; + + /* startSnapshotSet */ + + pVss->StartSnapshotSet(&m_uidCurrentSnapshotSet); + + /* AddToSnapshotSet */ + + wchar_t szDrive[3]; + szDrive[1] = ':'; + szDrive[2] = 0; + + wstring volume; + + CComPtr pAsync1; + CComPtr pAsync2; + VSS_ID pid; + + for (size_t i=0; i < strlen (szDriveLetters); i++) { + szDrive[0] = szDriveLetters[i]; + volume = GetUniqueVolumeNameForPath(szDrive); + // store uniquevolumname + if (SUCCEEDED(pVss->AddToSnapshotSet((LPWSTR)volume.c_str(), GUID_NULL, &pid))) + wcsncpy (m_wszUniqueVolumeName[szDriveLetters[i]-'A'], (LPWSTR) volume.c_str(), MAX_PATH); + else + { + szDriveLetters[i] = tolower (szDriveLetters[i]); + } + } + + /* PrepareForBackup */ + if (FAILED(pVss->PrepareForBackup(&pAsync1.p))) { + return FALSE; + } + + // Waits for the async operation to finish and checks the result + WaitAndCheckForAsyncOperation(pAsync1.p); + + /* get latest info about writer status */ + if (!CheckWriterStatus()) { + return FALSE; + } + + /* DoSnapShotSet */ + if (FAILED(pVss->DoSnapshotSet(&pAsync2.p))) { + return FALSE; + } + + // Waits for the async operation to finish and checks the result + WaitAndCheckForAsyncOperation(pAsync2.p); + + /* query snapshot info */ + QuerySnapshotSet(m_uidCurrentSnapshotSet); + + SetVSSPathConvert(VSSPathConvert, VSSPathConvertW); + + m_bBackupIsInitialized = true; + + return TRUE; +} + +BOOL VSSClientGeneric::CloseBackup() +{ + BOOL bRet = FALSE; + if (!m_pVssObject) + errno = ENOSYS; + else { + IVssBackupComponents* pVss = (IVssBackupComponents*) m_pVssObject; + CComPtr pAsync; + + SetVSSPathConvert(NULL, NULL); + + m_bBackupIsInitialized = false; + + if (SUCCEEDED(pVss->BackupComplete(&pAsync.p))) { + // Waits for the async operation to finish and checks the result + WaitAndCheckForAsyncOperation(pAsync.p); + bRet = TRUE; + } else { + errno = b_errno_win32; + pVss->AbortBackup(); + } + + /* get latest info about writer status */ + CheckWriterStatus(); + + if (m_uidCurrentSnapshotSet != GUID_NULL) { + VSS_ID idNonDeletedSnapshotID = GUID_NULL; + LONG lSnapshots; + + pVss->DeleteSnapshots( + m_uidCurrentSnapshotSet, + VSS_OBJECT_SNAPSHOT_SET, + FALSE, + &lSnapshots, + &idNonDeletedSnapshotID); + + m_uidCurrentSnapshotSet = GUID_NULL; + } + + pVss->Release(); + m_pVssObject = NULL; + } + + // Call CoUninitialize if the CoInitialize was performed sucesfully + if (m_bCoInitializeCalled) { + CoUninitialize(); + m_bCoInitializeCalled = false; + } + + return bRet; +} + +// Query all the shadow copies in the given set +void VSSClientGeneric::QuerySnapshotSet(GUID snapshotSetID) +{ + if (!(p_CreateVssBackupComponents && p_VssFreeSnapshotProperties)) { + errno = ENOSYS; + return; + } + + memset (m_szShadowCopyName,0,sizeof (m_szShadowCopyName)); + + if (snapshotSetID == GUID_NULL || m_pVssObject == NULL) { + errno = ENOSYS; + return; + } + + IVssBackupComponents* pVss = (IVssBackupComponents*) m_pVssObject; + + // Get list all shadow copies. + CComPtr pIEnumSnapshots; + HRESULT hr = pVss->Query( GUID_NULL, + VSS_OBJECT_NONE, + VSS_OBJECT_SNAPSHOT, + (IVssEnumObject**)(&pIEnumSnapshots) ); + + // If there are no shadow copies, just return + if (FAILED(hr)) { + errno = b_errno_win32; + return; + } + + // Enumerate all shadow copies. + VSS_OBJECT_PROP Prop; + VSS_SNAPSHOT_PROP& Snap = Prop.Obj.Snap; + + while (true) { + // Get the next element + ULONG ulFetched; + hr = (pIEnumSnapshots.p)->Next( 1, &Prop, &ulFetched ); + + // We reached the end of list + if (ulFetched == 0) + break; + + // Print the shadow copy (if not filtered out) + if (Snap.m_SnapshotSetId == snapshotSetID) { + for (char ch='A'-'A';ch<='Z'-'A';ch++) { + if (wcscmp(Snap.m_pwszOriginalVolumeName, m_wszUniqueVolumeName[ch]) == 0) { + wcsncpy (m_szShadowCopyName[ch],Snap.m_pwszSnapshotDeviceObject, MAX_PATH-1); + break; + } + } + } + p_VssFreeSnapshotProperties(&Snap); + } + errno = 0; +} + +// Check the status for all selected writers +BOOL VSSClientGeneric::CheckWriterStatus() +{ + /* + http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vss/base/ivssbackupcomponents_startsnapshotset.asp + */ + IVssBackupComponents* pVss = (IVssBackupComponents*) m_pVssObject; + DestroyWriterInfo(); + + // Gather writer status to detect potential errors + CComPtr pAsync; + + HRESULT hr = pVss->GatherWriterStatus(&pAsync.p); + if (FAILED(hr)) { + errno = b_errno_win32; + return FALSE; + } + + // Waits for the async operation to finish and checks the result + WaitAndCheckForAsyncOperation(pAsync.p); + + unsigned cWriters = 0; + + hr = pVss->GetWriterStatusCount(&cWriters); + if (FAILED(hr)) { + errno = b_errno_win32; + return FALSE; + } + + int nState; + + // Enumerate each writer + for (unsigned iWriter = 0; iWriter < cWriters; iWriter++) { + VSS_ID idInstance = GUID_NULL; + VSS_ID idWriter= GUID_NULL; + VSS_WRITER_STATE eWriterStatus = VSS_WS_UNKNOWN; + CComBSTR bstrWriterName; + HRESULT hrWriterFailure = S_OK; + + // Get writer status + hr = pVss->GetWriterStatus(iWriter, + &idInstance, + &idWriter, + &bstrWriterName, + &eWriterStatus, + &hrWriterFailure); + if (FAILED(hr)) { + /* unknown */ + nState = 0; + } + else { + switch(eWriterStatus) { + case VSS_WS_FAILED_AT_IDENTIFY: + case VSS_WS_FAILED_AT_PREPARE_BACKUP: + case VSS_WS_FAILED_AT_PREPARE_SNAPSHOT: + case VSS_WS_FAILED_AT_FREEZE: + case VSS_WS_FAILED_AT_THAW: + case VSS_WS_FAILED_AT_POST_SNAPSHOT: + case VSS_WS_FAILED_AT_BACKUP_COMPLETE: + case VSS_WS_FAILED_AT_PRE_RESTORE: + case VSS_WS_FAILED_AT_POST_RESTORE: + #ifdef B_VSS_W2K3 + case VSS_WS_FAILED_AT_BACKUPSHUTDOWN: + #endif + /* failed */ + nState = -1; + break; + + default: + /* ok */ + nState = 1; + } + } + /* store text info */ + char str[1000]; + char szBuf[200]; + strcpy(str, "\""); + wchar_2_UTF8(szBuf, bstrWriterName.p, sizeof(szBuf)); + strcat(str, szBuf); + strcat(str, "\", State: 0x"); + itoa(eWriterStatus, szBuf, sizeof(szBuf)); + strcat(str, szBuf); + strcat(str, " ("); + wchar_2_UTF8(szBuf, GetStringFromWriterStatus(eWriterStatus), sizeof(szBuf)); + strcat(str, szBuf); + strcat(str, ")"); + + AppendWriterInfo(nState, (const char *)str); + } + + hr = pVss->FreeWriterStatus(); + + if (FAILED(hr)) { + errno = b_errno_win32; + return FALSE; + } + + errno = 0; + return TRUE; +} + +#endif /* WIN32_VSS */ diff --git a/bacula/src/win32/filed/winmain.cpp b/bacula/src/win32/filed/winmain.cpp new file mode 100644 index 0000000000..36bc4b7ba8 --- /dev/null +++ b/bacula/src/win32/filed/winmain.cpp @@ -0,0 +1,332 @@ +/* + Copyright (C) 2000-2006 Kern Sibbald + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + version 2 as amended with additional clauses defined in the + file LICENSE in the main source directory. + + 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 + the file LICENSE for additional details. + + This file is patterned after the VNC Win32 code by ATT + +*/ + +#include +#include + +#include "bacula.h" +#include "winbacula.h" +#include "wintray.h" +#include "winservice.h" +#include +#include + +extern int BaculaMain(int argc, char *argv[]); +extern void terminate_filed(int sig); +extern DWORD g_error; +extern BOOL ReportStatus(DWORD state, DWORD exitcode, DWORD waithint); +extern void d_msg(const char *, int, int, const char *, ...); +extern void VSSInit(); + +/* Globals */ +HINSTANCE hAppInstance; +const char *szAppName = "Bacula"; +DWORD mainthreadId; +bool silent = false; + +/* Imported variables */ +extern DWORD g_servicethread; +extern DWORD g_platform_id; + +#define MAX_COMMAND_ARGS 100 +static char *command_args[MAX_COMMAND_ARGS] = {"bacula-fd", NULL}; +static int num_command_args = 1; +static pid_t main_pid; +static pthread_t main_tid; + +/* + * WinMain parses the command line and either calls the main App + * routine or, under NT, the main service routine. + */ +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, + PSTR CmdLine, int iCmdShow) +{ + char *szCmdLine = CmdLine; + char *wordPtr, *tempPtr; + int i, quote; + + /* Save the application instance and main thread id */ + hAppInstance = hInstance; + mainthreadId = GetCurrentThreadId(); + + main_pid = getpid(); + main_tid = pthread_self(); + + /* + * Funny things happen with the command line if the + * execution comes from c:/Program Files/bacula/bacula.exe + * We get a command line like: Files/bacula/bacula.exe" options + * I.e. someone stops scanning command line on a space, not + * realizing that the filename is quoted!!!!!!!!!! + * So if first character is not a double quote and + * the last character before first space is a double + * quote, we throw away the junk. + */ + + wordPtr = szCmdLine; + while (*wordPtr && *wordPtr != ' ') + wordPtr++; + if (wordPtr > szCmdLine) /* backup to char before space */ + wordPtr--; + /* if first character is not a quote and last is, junk it */ + if (*szCmdLine != '"' && *wordPtr == '"') { + szCmdLine = wordPtr + 1; + } +// MessageBox(NULL, szCmdLine, "Cmdline", MB_OK); + + /* Build Unix style argc *argv[] */ + + /* Don't NULL command_args[0] !!! */ + for (i=1;i