extern int save_file(JCR *jcr, FF_PKT *ff_pkt, bool top_level);
/* Function pointers to be set here */
-extern DLL_IMP_EXP int (*plugin_bopen)(JCR *jcr, const char *fname, int flags, mode_t mode);
-extern DLL_IMP_EXP int (*plugin_bclose)(JCR *jcr);
-extern DLL_IMP_EXP ssize_t (*plugin_bread)(JCR *jcr, void *buf, size_t count);
-extern DLL_IMP_EXP ssize_t (*plugin_bwrite)(JCR *jcr, void *buf, size_t count);
-extern DLL_IMP_EXP boffset_t (*plugin_blseek)(JCR *jcr, boffset_t offset, int whence);
+extern DLL_IMP_EXP int (*plugin_bopen)(BFILE *bfd, const char *fname, int flags, mode_t mode);
+extern DLL_IMP_EXP int (*plugin_bclose)(BFILE *bfd);
+extern DLL_IMP_EXP ssize_t (*plugin_bread)(BFILE *bfd, void *buf, size_t count);
+extern DLL_IMP_EXP ssize_t (*plugin_bwrite)(BFILE *bfd, void *buf, size_t count);
+extern DLL_IMP_EXP boffset_t (*plugin_blseek)(BFILE *bfd, boffset_t offset, int whence);
/* Forward referenced functions */
static bRC baculaDebugMsg(bpContext *ctx, const char *file, int line,
int level, const char *fmt, ...);
-static int my_plugin_bopen(JCR *jcr, const char *fname, int flags, mode_t mode);
-static int my_plugin_bclose(JCR *jcr);
-static ssize_t my_plugin_bread(JCR *jcr, void *buf, size_t count);
-static ssize_t my_plugin_bwrite(JCR *jcr, void *buf, size_t count);
-static boffset_t my_plugin_blseek(JCR *jcr, boffset_t offset, int whence);
+static int my_plugin_bopen(BFILE *bfd, const char *fname, int flags, mode_t mode);
+static int my_plugin_bclose(BFILE *bfd);
+static ssize_t my_plugin_bread(BFILE *bfd, void *buf, size_t count);
+static ssize_t my_plugin_bwrite(BFILE *bfd, void *buf, size_t count);
+static boffset_t my_plugin_blseek(BFILE *bfd, boffset_t offset, int whence);
/* Bacula info */
jcr->plugin_ctx_list = NULL;
}
-static int my_plugin_bopen(JCR *jcr, const char *fname, int flags, mode_t mode)
+static int my_plugin_bopen(BFILE *bfd, const char *fname, int flags, mode_t mode)
{
+ JCR *jcr = bfd->jcr;
Plugin *plugin = (Plugin *)jcr->plugin;
bpContext *plugin_ctx = (bpContext *)jcr->plugin_ctx;
struct io_pkt io;
io.func = IO_OPEN;
io.count = 0;
io.buf = NULL;
- io.mode = mode;
+ io.fname = fname;
io.flags = flags;
+ io.mode = mode;
+ io.win32 = false;
+ io.lerror = 0;
plug_func(plugin)->pluginIO(plugin_ctx, &io);
+ bfd->berrno = io.io_errno;
+ if (io.win32) {
+ errno = b_errno_win32;
+ } else {
+ errno = io.io_errno;
+ bfd->lerror = io.lerror;
+ }
return io.status;
}
-static int my_plugin_bclose(JCR *jcr)
+static int my_plugin_bclose(BFILE *bfd)
{
+ JCR *jcr = bfd->jcr;
Plugin *plugin = (Plugin *)jcr->plugin;
bpContext *plugin_ctx = (bpContext *)jcr->plugin_ctx;
struct io_pkt io;
io.func = IO_CLOSE;
io.count = 0;
io.buf = NULL;
+ io.win32 = false;
+ io.lerror = 0;
plug_func(plugin)->pluginIO(plugin_ctx, &io);
+ bfd->berrno = io.io_errno;
+ if (io.win32) {
+ errno = b_errno_win32;
+ } else {
+ errno = io.io_errno;
+ bfd->lerror = io.lerror;
+ }
return io.status;
}
-static ssize_t my_plugin_bread(JCR *jcr, void *buf, size_t count)
+static ssize_t my_plugin_bread(BFILE *bfd, void *buf, size_t count)
{
+ JCR *jcr = bfd->jcr;
Plugin *plugin = (Plugin *)jcr->plugin;
bpContext *plugin_ctx = (bpContext *)jcr->plugin_ctx;
struct io_pkt io;
io.func = IO_READ;
io.count = count;
io.buf = (char *)buf;
+ io.win32 = false;
+ io.lerror = 0;
plug_func(plugin)->pluginIO(plugin_ctx, &io);
+ bfd->berrno = io.io_errno;
+ if (io.win32) {
+ errno = b_errno_win32;
+ } else {
+ errno = io.io_errno;
+ bfd->lerror = io.lerror;
+ }
return (ssize_t)io.status;
}
-static ssize_t my_plugin_bwrite(JCR *jcr, void *buf, size_t count)
+static ssize_t my_plugin_bwrite(BFILE *bfd, void *buf, size_t count)
{
+ JCR *jcr = bfd->jcr;
Plugin *plugin = (Plugin *)jcr->plugin;
bpContext *plugin_ctx = (bpContext *)jcr->plugin_ctx;
struct io_pkt io;
io.func = IO_WRITE;
io.count = count;
io.buf = (char *)buf;
+ io.win32 = false;
+ io.lerror = 0;
plug_func(plugin)->pluginIO(plugin_ctx, &io);
+ bfd->berrno = io.io_errno;
+ if (io.win32) {
+ errno = b_errno_win32;
+ } else {
+ errno = io.io_errno;
+ bfd->lerror = io.lerror;
+ }
return (ssize_t)io.status;
}
-static boffset_t my_plugin_blseek(JCR *jcr, boffset_t offset, int whence)
+static boffset_t my_plugin_blseek(BFILE *bfd, boffset_t offset, int whence)
{
+ JCR *jcr = bfd->jcr;
Plugin *plugin = (Plugin *)jcr->plugin;
bpContext *plugin_ctx = (bpContext *)jcr->plugin_ctx;
struct io_pkt io;
io.func = IO_SEEK;
io.offset = offset;
io.whence = whence;
+ io.win32 = false;
+ io.lerror = 0;
plug_func(plugin)->pluginIO(plugin_ctx, &io);
+ bfd->berrno = io.io_errno;
+ if (io.win32) {
+ errno = b_errno_win32;
+ } else {
+ errno = io.io_errno;
+ bfd->lerror = io.lerror;
+ }
return (boffset_t)io.offset;
}
struct io_pkt {
int32_t func; /* Function code */
int32_t count; /* read/write count */
+ int32_t flags; /* Open flags */
mode_t mode; /* permissions for created files */
- int32_t flags; /* open flags (e.g. O_WRONLY ...) */
char *buf; /* read/write buffer */
+ const char *fname; /* open filename */
int32_t status; /* return status */
int32_t io_errno; /* errno code */
- int32_t whence;
- boffset_t offset;
+ int32_t lerror; /* Win32 error code */
+ int32_t whence; /* lseek argument */
+ boffset_t offset; /* lseek argument */
+ bool win32; /* Win32 GetLastError returned */
};
/****************************************************************************
const int dbglvl = 200;
-int (*plugin_bopen)(JCR *jcr, const char *fname, int flags, mode_t mode) = NULL;
-int (*plugin_bclose)(JCR *jcr) = NULL;
-ssize_t (*plugin_bread)(JCR *jcr, void *buf, size_t count) = NULL;
-ssize_t (*plugin_bwrite)(JCR *jcr, void *buf, size_t count) = NULL;
-boffset_t (*plugin_blseek)(JCR *jcr, boffset_t offset, int whence) = NULL;
+int (*plugin_bopen)(BFILE *bfd, const char *fname, int flags, mode_t mode) = NULL;
+int (*plugin_bclose)(BFILE *bfd) = NULL;
+ssize_t (*plugin_bread)(BFILE *bfd, void *buf, size_t count) = NULL;
+ssize_t (*plugin_bwrite)(BFILE *bfd, void *buf, size_t count) = NULL;
+boffset_t (*plugin_blseek)(BFILE *bfd, boffset_t offset, int whence) = NULL;
#ifdef HAVE_DARWIN_OS
if (bfd->cmd_plugin && plugin_bopen) {
int rtnstat;
Dmsg1(000, "call plugin_bopen fname=%s\n", fname);
- rtnstat = plugin_bopen(bfd->jcr, fname, flags, mode);
+ rtnstat = plugin_bopen(bfd, fname, flags, mode);
free_pool_memory(win32_fname_wchar);
free_pool_memory(win32_fname);
return rtnstat;
}
if (bfd->cmd_plugin && plugin_bclose) {
- stat = plugin_bclose(bfd->jcr);
+ stat = plugin_bclose(bfd);
goto all_done;
}
bfd->rw_bytes = 0;
if (bfd->cmd_plugin && plugin_bread) {
- return plugin_bread(bfd->jcr, buf, count);
+ return plugin_bread(bfd, buf, count);
}
if (bfd->use_backup_api) {
bfd->rw_bytes = 0;
if (bfd->cmd_plugin && plugin_bwrite) {
- return plugin_bwrite(bfd->jcr, buf, count);
+ return plugin_bwrite(bfd, buf, count);
}
if (bfd->use_backup_api) {
DWORD dwResult;
if (bfd->cmd_plugin && plugin_bwrite) {
- return plugin_blseek(bfd->jcr, offset, whence);
+ return plugin_blseek(bfd, offset, whence);
}
dwResult = SetFilePointer(bfd->fh, offset_low, &offset_high, whence);
{
if (bfd->cmd_plugin && plugin_bopen) {
Dmsg1(000, "call plugin_bopen fname=%s\n", fname);
- return plugin_bopen(bfd->jcr, fname, flags, mode);
+ return plugin_bopen(bfd, fname, flags, mode);
}
/* Normal file open */
Dmsg1(400, "Close file %d\n", bfd->fid);
if (bfd->cmd_plugin && plugin_bclose) {
- stat = plugin_bclose(bfd->jcr);
+ stat = plugin_bclose(bfd);
bfd->fid = -1;
bfd->cmd_plugin = false;
}
ssize_t stat;
if (bfd->cmd_plugin && plugin_bread) {
- return plugin_bread(bfd->jcr, buf, count);
+ return plugin_bread(bfd, buf, count);
}
stat = read(bfd->fid, buf, count);
ssize_t stat;
if (bfd->cmd_plugin && plugin_bwrite) {
- return plugin_bwrite(bfd->jcr, buf, count);
+ return plugin_bwrite(bfd, buf, count);
}
stat = write(bfd->fid, buf, count);
bfd->berrno = errno;
boffset_t pos;
if (bfd->cmd_plugin && plugin_bwrite) {
- return plugin_blseek(bfd->jcr, offset, whence);
+ return plugin_blseek(bfd, offset, whence);
}
pos = (boffset_t)lseek(bfd->fid, offset, whence);
bfd->berrno = errno;
struct BFILE {
int fid; /* file id on Unix */
int m_flags; /* open flags */
- int berrno;
+ int berrno; /* errno */
+ int32_t lerror; /* not used - simplies Win32 builds */
JCR *jcr; /* jcr for editing job codes */
PROCESS_WIN32_BACKUPAPIBLOCK_CONTEXT win32DecompContext; /* context for decomposition of win32 backup streams */
int use_backup_decomp; /* set if using BackupRead Stream Decomposition */
#
# Simple Makefile for building test FD plugins for Bacula
#
-# Version $Id: $
+# Version $Id: Makefile.in 7638 2008-09-25 14:04:17Z kerns $
#
#
# This file is pulled in by all the Unix Bacula Makefiles
# so it has all the "common" definitions
#
-DATE="24 September 2008"
-LSMDATE=24Sep08
-VERSION=2.5.3
+DATE="25 September 2008"
+LSMDATE=25Sep08
+VERSION=2.5.4
VERNAME=bacula-$(VERSION)#
MAINT=Kern Sibbald#
MAINTEMAIL=<kern@sibbald.com>#
*/
#undef VERSION
-#define VERSION "2.5.4"
-#define BDATE "25 September 2008"
-#define LSMDATE "25Sep08"
+#define VERSION "2.5.5"
+#define BDATE "26 September 2008"
+#define LSMDATE "26Sep08"
#define PROG_COPYRIGHT "Copyright (C) %d-2008 Free Software Foundation Europe e.V.\n"
#define BYEAR "2008" /* year for copyright messages in progs */
remove reader/writer in FOPTS????
General:
+26Sep08
+kes Rework the pluginIO Bacula internal code to enable
+ proper handling of Win32 error codes from GetLastError.
+kes Apply Joao's patch to regress startover_libdbi.
25Sep08
ebl Add -B option to dbcheck to get catalog information
kes Fix Win32 build to include new library function.