From 5246a53bc2e4f37e1f7970539e0c1226932f24d3 Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Tue, 6 May 2008 20:57:30 +0000 Subject: [PATCH] ebl First cup of faketape dummy tape driver for regression testing. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@6902 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/baconfig.h | 27 +++++++++++++++++++-------- bacula/src/stored/btape.c | 4 ++++ bacula/src/stored/dev.c | 2 +- bacula/src/version.h | 8 ++++++++ 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/bacula/src/baconfig.h b/bacula/src/baconfig.h index 00f0a4c928..180f6824fa 100644 --- a/bacula/src/baconfig.h +++ b/bacula/src/baconfig.h @@ -87,7 +87,7 @@ void InitWinAPIWrapper(); #define tape_read win32_tape_read #define tape_write win32_tape_write #define tape_close win32_tape_close - +#define IS_TAPE(x) (0) #define sbrk(x) 0 @@ -106,19 +106,30 @@ void InitWinAPIWrapper(); # define CATS_IMP_EXP #endif -#else +#else /* HAVE_WIN32 */ #define DLL_IMP_EXP #define CATS_IMP_EXP #define OSDependentInit() -#define tape_open ::open -#define tape_ioctl ::ioctl -#define tape_read ::read -#define tape_write ::write -#define tape_close ::close -#endif +#if defined(USE_FAKETAPE) +# define tape_open faketape_open +# define tape_ioctl faketape_ioctl +# define tape_read faketape_read +# define tape_write faketape_write +# define tape_close faketape_close +# define IS_TAPE(x) (S_ISCHR(x) || S_ISREG(x)) +#else /* UNIX && !FAKETAPE */ +# define tape_open ::open +# define tape_ioctl ::ioctl +# define tape_read ::read +# define tape_write ::write +# define tape_close ::close +# define IS_TAPE(x) S_ISCHR(x) +#endif + +#endif /* HAVE_WIN32 */ #ifdef ENABLE_NLS diff --git a/bacula/src/stored/btape.c b/bacula/src/stored/btape.c index f469691fd1..a92d01e215 100644 --- a/bacula/src/stored/btape.c +++ b/bacula/src/stored/btape.c @@ -44,6 +44,10 @@ #include "bacula.h" #include "stored.h" +#ifdef USE_FAKETAPE +#include "faketape.h" +#endif + /* Dummy functions */ int generate_daemon_event(JCR *jcr, const char *event) { return 1; } diff --git a/bacula/src/stored/dev.c b/bacula/src/stored/dev.c index 558fd72984..5afe0e10f8 100644 --- a/bacula/src/stored/dev.c +++ b/bacula/src/stored/dev.c @@ -123,7 +123,7 @@ init_dev(JCR *jcr, DEVRES *device) } if (S_ISDIR(statp.st_mode)) { device->dev_type = B_FILE_DEV; - } else if (S_ISCHR(statp.st_mode)) { + } else if (IS_TAPE(statp.st_mode)) { /* char device or fake tape */ device->dev_type = B_TAPE_DEV; } else if (S_ISFIFO(statp.st_mode)) { device->dev_type = B_FIFO_DEV; diff --git a/bacula/src/version.h b/bacula/src/version.h index 0fae6a841d..99fe973ac7 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -57,6 +57,14 @@ #define SMCHECK #endif +/* + * USE_FAKETAPE is a dummy tape driver. This is useful to + * run regress test. + */ +#ifdef DEVELOPER +//#define USE_FAKETAPE +#endif + /* * for fastest speed but you must have a UPS to avoid unwanted shutdowns */ -- 2.39.5