From 050937a695d3571a1f26a7c5336700e75ace2408 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sat, 4 Oct 2008 10:50:50 +0000 Subject: [PATCH] Add more plugin restore debug code. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@7700 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/filed/fd_plugins.c | 22 ++++++++++++++++------ bacula/src/findlib/bfile.c | 5 ++++- bacula/src/findlib/create_file.c | 15 ++++++++------- bacula/src/version.h | 4 ++-- bacula/technotes-2.5 | 2 ++ 5 files changed, 32 insertions(+), 16 deletions(-) diff --git a/bacula/src/filed/fd_plugins.c b/bacula/src/filed/fd_plugins.c index cec7f7ec94..0d52728ddd 100644 --- a/bacula/src/filed/fd_plugins.c +++ b/bacula/src/filed/fd_plugins.c @@ -341,7 +341,8 @@ int plugin_create_file(JCR *jcr, ATTR *attr, BFILE *bfd, int replace) bpContext *plugin_ctx = (bpContext *)jcr->plugin_ctx; Plugin *plugin = (Plugin *)jcr->plugin; struct restore_pkt rp; - mode_t mode; + int flags; + int rc; if (!set_cmd_plugin(bfd, jcr)) { return CF_ERROR; @@ -363,15 +364,24 @@ int plugin_create_file(JCR *jcr, ATTR *attr, BFILE *bfd, int replace) rp.replace = jcr->replace; rp.create_status = CF_ERROR; Dmsg1(dbglvl, "call plugin createFile=%s\n", rp.ofname); - if (plug_func(plugin)->createFile(plugin_ctx, &rp) != bRC_OK) { + rc = plug_func(plugin)->createFile(plugin_ctx, &rp); + if (rc != bRC_OK) { + Qmsg2(jcr, M_ERROR, 0, _("Plugin createFile call failed. Stat=%d file=%s\n"), + rc, attr->ofname); return CF_ERROR; } - if (rp.create_status == CF_ERROR || rp.create_status == CF_CREATED) { - return rp.create_status; + if (rp.create_status == CF_ERROR) { + Qmsg1(jcr, M_ERROR, 0, _("Plugin createFile call failed. Returned CF_ERROR file=%s\n"), + attr->ofname); + return CF_ERROR; + } + /* Created link or directory? */ + if (rp.create_status == CF_CREATED) { + return rp.create_status; /* yes, no need to bopen */ } - mode = O_WRONLY | O_CREAT | O_TRUNC | O_BINARY; + flags = O_WRONLY | O_CREAT | O_TRUNC | O_BINARY; Dmsg0(dbglvl, "call bopen\n"); - if ((bopen(bfd, attr->ofname, mode, S_IRUSR | S_IWUSR)) < 0) { + if ((bopen(bfd, attr->ofname, flags, S_IRUSR | S_IWUSR)) < 0) { berrno be; be.set_errno(bfd->berrno); Qmsg2(jcr, M_ERROR, 0, _("Could not create %s: ERR=%s\n"), diff --git a/bacula/src/findlib/bfile.c b/bacula/src/findlib/bfile.c index 17bdcec500..778f49149e 100644 --- a/bacula/src/findlib/bfile.c +++ b/bacula/src/findlib/bfile.c @@ -420,16 +420,19 @@ int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode) if (bfd->cmd_plugin && plugin_bopen) { int rtnstat; - Dmsg1(000, "call plugin_bopen fname=%s\n", fname); + Dmsg1(50, "call plugin_bopen fname=%s\n", fname); rtnstat = plugin_bopen(bfd, fname, flags, mode); if (rtnstat >= 0) { if (flags & O_CREAT || flags & O_WRONLY) { /* Open existing for write */ + Dmsg1(50, "plugin_open for write OK file=%s.\n", fname); bfd->mode = BF_WRITE; } else { + Dmsg1(50, "plugin_open for read OK file=%s.\n", fname); bfd->mode = BF_READ; } } else { bfd->mode = BF_CLOSED; + Dmsg1(000, "plugin_bopen returned bad status=%d\n", rtnstat); } free_pool_memory(win32_fname_wchar); free_pool_memory(win32_fname); diff --git a/bacula/src/findlib/create_file.c b/bacula/src/findlib/create_file.c index 4a512c4e99..9e6f080ee4 100644 --- a/bacula/src/findlib/create_file.c +++ b/bacula/src/findlib/create_file.c @@ -71,7 +71,8 @@ static int path_already_seen(JCR *jcr, char *path, int pnl); */ int create_file(JCR *jcr, ATTR *attr, BFILE *bfd, int replace) { - mode_t new_mode, parent_mode, mode; + mode_t new_mode, parent_mode; + int flags; uid_t uid; gid_t gid; int pnl; @@ -205,9 +206,9 @@ int create_file(JCR *jcr, ATTR *attr, BFILE *bfd, int replace) case FT_REGE: case FT_REG: Dmsg1(100, "Create=%s\n", attr->ofname); - mode = O_WRONLY | O_CREAT | O_TRUNC | O_BINARY; /* O_NOFOLLOW; */ + flags = O_WRONLY | O_CREAT | O_TRUNC | O_BINARY; /* O_NOFOLLOW; */ if (IS_CTG(attr->statp.st_mode)) { - mode |= O_CTG; /* set contiguous bit if needed */ + flags |= O_CTG; /* set contiguous bit if needed */ } if (is_bopen(bfd)) { Qmsg1(jcr, M_ERROR, 0, _("bpkt already open fid=%d\n"), bfd->fid); @@ -215,7 +216,7 @@ int create_file(JCR *jcr, ATTR *attr, BFILE *bfd, int replace) } - if ((bopen(bfd, attr->ofname, mode, S_IRUSR | S_IWUSR)) < 0) { + if ((bopen(bfd, attr->ofname, flags, S_IRUSR | S_IWUSR)) < 0) { berrno be; be.set_errno(bfd->berrno); Qmsg2(jcr, M_ERROR, 0, _("Could not create %s: ERR=%s\n"), @@ -265,7 +266,7 @@ int create_file(JCR *jcr, ATTR *attr, BFILE *bfd, int replace) if (attr->type == FT_RAW || attr->type == FT_FIFO) { btimer_t *tid; Dmsg1(400, "FT_RAW|FT_FIFO %s\n", attr->ofname); - mode = O_WRONLY | O_BINARY; + flags = O_WRONLY | O_BINARY; /* Timeout open() in 60 seconds */ if (attr->type == FT_FIFO) { Dmsg0(400, "Set FIFO timer\n"); @@ -276,8 +277,8 @@ int create_file(JCR *jcr, ATTR *attr, BFILE *bfd, int replace) if (is_bopen(bfd)) { Qmsg1(jcr, M_ERROR, 0, _("bpkt already open fid=%d\n"), bfd->fid); } - Dmsg2(400, "open %s mode=0x%x\n", attr->ofname, mode); - if ((bopen(bfd, attr->ofname, mode, 0)) < 0) { + Dmsg2(400, "open %s flags=0x%x\n", attr->ofname, flags); + if ((bopen(bfd, attr->ofname, flags, 0)) < 0) { berrno be; be.set_errno(bfd->berrno); Qmsg2(jcr, M_ERROR, 0, _("Could not open %s: ERR=%s\n"), diff --git a/bacula/src/version.h b/bacula/src/version.h index 48cb5fde0f..bc4628c36e 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -4,8 +4,8 @@ #undef VERSION #define VERSION "2.5.10" -#define BDATE "03 October 2008" -#define LSMDATE "03Oct08" +#define BDATE "04 October 2008" +#define LSMDATE "04Oct08" #define PROG_COPYRIGHT "Copyright (C) %d-2008 Free Software Foundation Europe e.V.\n" #define BYEAR "2008" /* year for copyright messages in progs */ diff --git a/bacula/technotes-2.5 b/bacula/technotes-2.5 index 3aa54b784a..e1b16bdc72 100644 --- a/bacula/technotes-2.5 +++ b/bacula/technotes-2.5 @@ -17,6 +17,8 @@ dbdriver remove reader/writer in FOPTS???? General: +04Oct08 +kes Add more plugin restore debug code. 03Oct08 kes Fix plugin_bwrite - plugin-blseek mixup pointed out by James. kes Rewrite plugin restore interface a bit to correspond to how Bacula -- 2.39.5