From 54670a74263540c34bdd370775e3d10547483064 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Fri, 5 May 2006 14:10:27 +0000 Subject: [PATCH] - Correct EOF with no \n lex.c problem. - Tweak compat.h compat.cpp and merge with apcupsd - Add additional INFO messages if autochanger cannot be used. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3002 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/kernstodo | 124 +++++++++++++++++++++++++++++ bacula/kes-1.39 | 4 + bacula/src/filed/win32/winres.rc | 4 +- bacula/src/lib/lex.c | 73 ++++++++--------- bacula/src/lib/lex.h | 17 ++-- bacula/src/stored/autochanger.c | 15 +++- bacula/src/tools/testfind.c | 2 +- bacula/src/version.h | 4 +- bacula/src/win32/compat/compat.cpp | 7 +- bacula/src/win32/compat/compat.h | 4 +- bacula/src/win32/compat/syslog.h | 32 ++++++++ 11 files changed, 225 insertions(+), 61 deletions(-) diff --git a/bacula/kernstodo b/bacula/kernstodo index 6d9dc679f2..0c3e7b5ded 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -12,6 +12,13 @@ Document: - Pruning with Admin job. - Does WildFile match against full name? Doc. - %d and %v only valid on Director, not for ClientRunBefore/After. +- During tests with the 260 char fix code, I found one problem: + if the system "sees" a long path once, it seems to forget it's + working drive (e.g. c:\), which will lead to a problem during + the next job (create bootstrap file will fail). Here is the + workaround: specify absolute working and pid directory in + bacula-fd.conf (e.g. c:\bacula\working instead of + \bacula\working). Priority: @@ -88,6 +95,123 @@ minutes). [ possibly a Python event -- kes ] === +- Mount on an Autochanger with no tape in the drive causes: + Automatically selected Storage: LTO-changer + Enter autochanger drive[0]: 0 + 3301 Issuing autochanger "loaded drive 0" command. + 3302 Autochanger "loaded drive 0", result: nothing loaded. + 3301 Issuing autochanger "loaded drive 0" command. + 3302 Autochanger "loaded drive 0", result: nothing loaded. + 3902 Cannot mount Volume on Storage Device "LTO-Drive1" (/dev/nst0) because: + Couldn't rewind device "LTO-Drive1" (/dev/nst0): ERR=dev.c:678 Rewind error on "LTO-Drive1" (/dev/nst0). ERR=No medium found. + 3905 Device "LTO-Drive1" (/dev/nst0) open but no Bacula volume is mounted. + If this is not a blank tape, try unmounting and remounting the Volume. +- If Drive 0 is blocked, and drive 1 is set "Autoselect=no", drive 1 will + be used. +- Autochanger did not change volumes. + select * from Storage; + +-----------+-------------+-------------+ + | StorageId | Name | AutoChanger | + +-----------+-------------+-------------+ + | 1 | LTO-changer | 0 | + +-----------+-------------+-------------+ + 05-May 03:50 roxie-sd: 3302 Autochanger "loaded drive 0", result is Slot 11. + 05-May 03:50 roxie-sd: Tibs.2006-05-05_03.05.02 Warning: Director wanted Volume "LT + Current Volume "LT0-002" not acceptable because: + 1997 Volume "LT0-002" not in catalog. + 05-May 03:50 roxie-sd: Tibs.2006-05-05_03.05.02 Error: Autochanger Volume "LT0-002" + Setting InChanger to zero in catalog. + 05-May 03:50 roxie-dir: Tibs.2006-05-05_03.05.02 Error: Unable to get Media record + + 05-May 03:50 roxie-sd: Tibs.2006-05-05_03.05.02 Fatal error: Error getting Volume i + 05-May 03:50 roxie-sd: Tibs.2006-05-05_03.05.02 Fatal error: Job 530 canceled. + 05-May 03:50 roxie-sd: Tibs.2006-05-05_03.05.02 Fatal error: spool.c:249 Fatal appe + 05-May 03:49 Tibs: Tibs.2006-05-05_03.05.02 Fatal error: c:\cygwin\home\kern\bacula + , got + (missing) + llist volume=LTO-002 + MediaId: 6 + VolumeName: LTO-002 + Slot: 0 + PoolId: 1 + MediaType: LTO-2 + FirstWritten: 2006-05-05 03:11:54 + LastWritten: 2006-05-05 03:50:23 + LabelDate: 2005-12-26 16:52:40 + VolJobs: 1 + VolFiles: 0 + VolBlocks: 1 + VolMounts: 0 + VolBytes: 206 + VolErrors: 0 + VolWrites: 0 + VolCapacityBytes: 0 + VolStatus: + Recycle: 1 + VolRetention: 31,536,000 + VolUseDuration: 0 + MaxVolJobs: 0 + MaxVolFiles: 0 + MaxVolBytes: 0 + InChanger: 0 + EndFile: 0 + EndBlock: 0 + VolParts: 0 + LabelType: 0 + StorageId: 1 + + Note VolStatus is blank!!!!! + llist volume=LTO-003 + MediaId: 7 + VolumeName: LTO-003 + Slot: 12 + PoolId: 1 + MediaType: LTO-2 + FirstWritten: 0000-00-00 00:00:00 + LastWritten: 0000-00-00 00:00:00 + LabelDate: 2005-12-26 16:52:40 + VolJobs: 0 + VolFiles: 0 + VolBlocks: 0 + VolMounts: 0 + VolBytes: 1 + VolErrors: 0 + VolWrites: 0 + VolCapacityBytes: 0 + VolStatus: Append + Recycle: 1 + VolRetention: 31,536,000 + VolUseDuration: 0 + MaxVolJobs: 0 + MaxVolFiles: 0 + MaxVolBytes: 0 + InChanger: 0 + EndFile: 0 + EndBlock: 0 + VolParts: 0 + LabelType: 0 + StorageId: 1 +=== + mount + Automatically selected Storage: LTO-changer + Enter autochanger drive[0]: 0 + 3301 Issuing autochanger "loaded drive 0" command. + 3302 Autochanger "loaded drive 0", result: nothing loaded. + 3301 Issuing autochanger "loaded drive 0" command. + 3302 Autochanger "loaded drive 0", result: nothing loaded. + 3902 Cannot mount Volume on Storage Device "LTO-Drive1" (/dev/nst0) because: + Couldn't rewind device "LTO-Drive1" (/dev/nst0): ERR=dev.c:678 Rewind error on "LTO-Drive1" (/dev/nst0). ERR=No medium found. + + 3905 Device "LTO-Drive1" (/dev/nst0) open but no Bacula volume is mounted. + If this is not a blank tape, try unmounting and remounting the Volume. + +- The btape fill command does not seem to use the Autochanger +- Make Windows installer default to system disk drive. +- Look at using ioctl(FIOBMAP, ...) on Linux, and + DeviceIoControl(..., FSCTL_QUERY_ALLOCATED_RANGES, ...) on + Win32 for sparse files. + http://www.flexhex.com/docs/articles/sparse-files.phtml + http://www.informatik.uni-frankfurt.de/~loizides/reiserfs/fibmap.html - Directive: at "command" - Command: pycmd "command" generates "command" event. How to attach to a specific job? diff --git a/bacula/kes-1.39 b/bacula/kes-1.39 index c5fda47246..8c877d0ad6 100644 --- a/bacula/kes-1.39 +++ b/bacula/kes-1.39 @@ -2,6 +2,10 @@ Kern Sibbald General: +05May06 +- Correct EOF with no \n lex.c problem. +- Tweak compat.h compat.cpp and merge with apcupsd +- Add additional INFO messages if autochanger cannot be used. 02May06 - Simplify Win32 Makefile - Correct count of buffers/bytes used by smartall.c diff --git a/bacula/src/filed/win32/winres.rc b/bacula/src/filed/win32/winres.rc index 51adfd7491..8e6dbb7826 100644 --- a/bacula/src/filed/win32/winres.rc +++ b/bacula/src/filed/win32/winres.rc @@ -68,7 +68,7 @@ BEGIN VALUE "FileDescription", "Bacula File daemon for Win32\0" VALUE "FileVersion", VERSION "\0" VALUE "InternalName", "Bacula\0" - VALUE "LegalCopyright", "Copyright Kern Sibbald, 1999-2005\0" + VALUE "LegalCopyright", "Copyright Kern Sibbald, 1999-2006\0" VALUE "LegalTrademarks", "Licensed under GNU GPL 2.0\0" VALUE "OriginalFilename", "filed.exe\0" VALUE "PrivateBuild", "\0" @@ -141,7 +141,7 @@ BEGIN LTEXT " www.bacula.org",IDC_WWW,115,70,100,10 // LTEXT " ",-1,69,81,100,10 // LTEXT " ",-1,90,70,100,10 - LTEXT "Copyright (C) 1999-2005, Kern Sibbald",IDC_COPYRIGHT,7,120,175,10 + LTEXT "Copyright (C) 1999-2006, Kern Sibbald",IDC_COPYRIGHT,7,120,175,10 LTEXT N_("Licensed under GNU GPL 2.0."),IDC_TRADEMARK,7,130,175,10 RTEXT N_("Build Date:"),-1,108,24,42,8 RTEXT N_("Bacula Version:"),-1,100,9,50,8 diff --git a/bacula/src/lib/lex.c b/bacula/src/lib/lex.c index 0df090f09b..11b9af0156 100644 --- a/bacula/src/lib/lex.c +++ b/bacula/src/lib/lex.c @@ -6,32 +6,30 @@ * Version $Id$ * */ - /* - Copyright (C) 2000-2005 Kern Sibbald + 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 as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. + 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 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. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + the file LICENSE for additional details. */ + #include "bacula.h" #include "lex.h" extern int debug_level; +/* Debug level for this source file */ +static const int dbglvl = 5000; + /* * Scan to "logical" end of line. I.e. end of line, * or semicolon, but stop on T_EOB (same as end of @@ -40,7 +38,7 @@ extern int debug_level; void scan_to_eol(LEX *lc) { int token; - Dmsg0(2000, "start scan to eof\n"); + Dmsg0(dbglvl, "start scan to eof\n"); while ((token = lex_get_token(lc, T_ALL)) != T_EOL) { if (token == T_EOB) { lex_unget_char(lc); @@ -74,7 +72,7 @@ static void s_err(const char *file, int line, LEX *lc, const char *msg, ...) bvsnprintf(buf, sizeof(buf), msg, arg_ptr); va_end(arg_ptr); - if (lc->err_type == 0) { /* M_ERROR_TERM by default */ + if (lc->err_type == 0) { /* M_ERROR_TERM by default */ lc->err_type = M_ERROR_TERM; } @@ -120,16 +118,16 @@ LEX *lex_close_file(LEX *lf) if (lf == NULL) { Emsg0(M_ABORT, 0, _("Close of NULL file\n")); } - Dmsg1(2000, "Close lex file: %s\n", lf->fname); + Dmsg1(dbglvl, "Close lex file: %s\n", lf->fname); of = lf->next; fclose(lf->fd); - Dmsg1(2000, "Close cfg file %s\n", lf->fname); + Dmsg1(dbglvl, "Close cfg file %s\n", lf->fname); free(lf->fname); if (of) { of->options = lf->options; /* preserve options */ memcpy(lf, of, sizeof(LEX)); - Dmsg1(2000, "Restart scan of cfg file %s\n", of->fname); + Dmsg1(dbglvl, "Restart scan of cfg file %s\n", of->fname); } else { of = lf; lf = NULL; @@ -181,7 +179,7 @@ LEX *lex_open_file(LEX *lf, const char *filename, LEX_ERROR_HANDLER *scan_error) lf->fname = fname; lf->state = lex_none; lf->ch = L_EOL; - Dmsg1(2000, "Return lex=%x\n", lf); + Dmsg1(dbglvl, "Return lex=%x\n", lf); return lf; } @@ -214,15 +212,18 @@ int lex_get_char(LEX *lf) } else { lf->col_no++; } - Dmsg2(2000, "lex_get_char: %c %d\n", lf->ch, lf->ch); + Dmsg2(dbglvl, "lex_get_char: %c %d\n", lf->ch, lf->ch); return lf->ch; } void lex_unget_char(LEX *lf) { - lf->col_no--; - if (lf->ch == L_EOL) - lf->ch = 0; + if (lf->ch == L_EOL) { + lf->ch = 0; /* End of line, force read of next one */ + } else { + lf->col_no--; /* Backup to re-read char */ + } + } @@ -324,12 +325,12 @@ lex_get_token(LEX *lf, int expect) int token = T_NONE; bool esc_next = false; - Dmsg0(2000, "enter lex_get_token\n"); + Dmsg0(dbglvl, "enter lex_get_token\n"); while (token == T_NONE) { ch = lex_get_char(lf); switch (lf->state) { case lex_none: - Dmsg2(2000, "Lex state lex_none ch=%d,%x\n", ch, ch); + Dmsg2(dbglvl, "Lex state lex_none ch=%d,%x\n", ch, ch); if (B_ISSPACE(ch)) break; if (B_ISALPHA(ch)) { @@ -350,11 +351,11 @@ lex_get_token(LEX *lf, int expect) begin_str(lf, ch); break; } - Dmsg0(2000, "Enter lex_none switch\n"); + Dmsg0(dbglvl, "Enter lex_none switch\n"); switch (ch) { case L_EOF: token = T_EOF; - Dmsg0(2000, "got L_EOF set token=T_EOF\n"); + Dmsg0(dbglvl, "got L_EOF set token=T_EOF\n"); break; case '#': lf->state = lex_comment; @@ -385,7 +386,7 @@ lex_get_token(LEX *lf, int expect) } break; case L_EOL: - Dmsg0(2000, "got L_EOL set token=T_EOL\n"); + Dmsg0(dbglvl, "got L_EOL set token=T_EOL\n"); if (expect != T_SKIP_EOL) { token = T_EOL; } @@ -401,7 +402,7 @@ lex_get_token(LEX *lf, int expect) } break; case lex_comment: - Dmsg1(2000, "Lex state lex_comment ch=%x\n", ch); + Dmsg1(dbglvl, "Lex state lex_comment ch=%x\n", ch); if (ch == L_EOL) { lf->state = lex_none; if (expect != T_SKIP_EOL) { @@ -412,7 +413,7 @@ lex_get_token(LEX *lf, int expect) } break; case lex_number: - Dmsg2(2000, "Lex state lex_number ch=%x %c\n", ch, ch); + Dmsg2(dbglvl, "Lex state lex_number ch=%x %c\n", ch, ch); if (ch == L_EOF) { token = T_ERROR; break; @@ -437,10 +438,10 @@ lex_get_token(LEX *lf, int expect) token = T_ERROR; break; } - Dmsg1(2000, "Lex state lex_ip_addr ch=%x\n", ch); + Dmsg1(dbglvl, "Lex state lex_ip_addr ch=%x\n", ch); break; case lex_string: - Dmsg1(2000, "Lex state lex_string ch=%x\n", ch); + Dmsg1(dbglvl, "Lex state lex_string ch=%x\n", ch); if (ch == L_EOF) { token = T_ERROR; break; @@ -455,7 +456,7 @@ lex_get_token(LEX *lf, int expect) add_str(lf, ch); break; case lex_identifier: - Dmsg2(2000, "Lex state lex_identifier ch=%x %c\n", ch, ch); + Dmsg2(dbglvl, "Lex state lex_identifier ch=%x %c\n", ch, ch); if (B_ISALPHA(ch)) { add_str(lf, ch); break; @@ -478,7 +479,7 @@ lex_get_token(LEX *lf, int expect) add_str(lf, ch); break; case lex_quoted_string: - Dmsg2(2000, "Lex state lex_quoted_string ch=%x %c\n", ch, ch); + Dmsg2(dbglvl, "Lex state lex_quoted_string ch=%x %c\n", ch, ch); if (ch == L_EOF) { token = T_ERROR; break; @@ -526,10 +527,10 @@ lex_get_token(LEX *lf, int expect) add_str(lf, ch); break; } - Dmsg4(2000, "ch=%d state=%s token=%s %c\n", ch, lex_state_to_str(lf->state), + Dmsg4(dbglvl, "ch=%d state=%s token=%s %c\n", ch, lex_state_to_str(lf->state), lex_tok_to_str(token), ch); } - Dmsg2(2000, "lex returning: line %d token: %s\n", lf->line_no, lex_tok_to_str(token)); + Dmsg2(dbglvl, "lex returning: line %d token: %s\n", lf->line_no, lex_tok_to_str(token)); lf->token = token; /* @@ -583,7 +584,7 @@ lex_get_token(LEX *lf, int expect) break; case T_INT64: - Dmsg2(2000, "int64=:%s: %f\n", lf->str, strtod(lf->str, NULL)); + Dmsg2(dbglvl, "int64=:%s: %f\n", lf->str, strtod(lf->str, NULL)); if (token != T_NUMBER || !is_a_number(lf->str)) { scan_err2(lf, _("expected an integer number, got %s: %s"), lex_tok_to_str(token), lf->str); diff --git a/bacula/src/lib/lex.h b/bacula/src/lib/lex.h index c4ab324346..1a05225d0e 100644 --- a/bacula/src/lib/lex.h +++ b/bacula/src/lib/lex.h @@ -9,22 +9,17 @@ * */ /* - Copyright (C) 2000-2005 Kern Sibbald + 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 as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. + 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 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. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + the file LICENSE for additional details. */ diff --git a/bacula/src/stored/autochanger.c b/bacula/src/stored/autochanger.c index 9e2f01025a..af53989446 100644 --- a/bacula/src/stored/autochanger.c +++ b/bacula/src/stored/autochanger.c @@ -126,7 +126,18 @@ int autoload_device(DCR *dcr, int writing, BSOCK *dir) Dmsg1(400, "Want changer slot=%d\n", slot); changer = get_pool_memory(PM_FNAME); - if (slot > 0 && dcr->device->changer_name && dcr->device->changer_command) { + if (slot <= 0) { + Jmsg(jcr, M_INFO, 0, _("Invalid slot=%d defined, cannot autoload Volume.\n"), slot); + rtn_stat = 0; + } else if (!dcr->device->changer_name) { + Jmsg(jcr, M_INFO, 0, _("No \"Changer Device\" given cannot autoload Volume.\n")); + rtn_stat = 0; + } else if (!dcr->device->changer_command) { + Jmsg(jcr, M_INFO, 0, _("No \"Changer Command\" given cannot autoload Volume.\n")); + rtn_stat = 0; + } else { + /* Attempt to load the Volume */ + uint32_t timeout = dcr->device->max_changer_wait; int loaded, status; @@ -182,8 +193,6 @@ int autoload_device(DCR *dcr, int writing, BSOCK *dir) if (status == 0) { /* did we succeed? */ rtn_stat = 1; /* tape loaded by changer */ } - } else { - rtn_stat = 0; /* no changer found */ } free_pool_memory(changer); return rtn_stat; diff --git a/bacula/src/tools/testfind.c b/bacula/src/tools/testfind.c index 6313918d9f..851c3a8794 100644 --- a/bacula/src/tools/testfind.c +++ b/bacula/src/tools/testfind.c @@ -2,7 +2,7 @@ * Test program for find files */ /* - Copyright (C) 2000-2005 Kern Sibbald + 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 diff --git a/bacula/src/version.h b/bacula/src/version.h index d519c11b02..a2e8c6ab9e 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -4,8 +4,8 @@ #undef VERSION #define VERSION "1.39.10" -#define BDATE "02 May 2006" -#define LSMDATE "02May06" +#define BDATE "05 May 2006" +#define LSMDATE "05May06" /* Debug flags */ #undef DEBUG diff --git a/bacula/src/win32/compat/compat.cpp b/bacula/src/win32/compat/compat.cpp index 6a35103caf..03d8835b2d 100644 --- a/bacula/src/win32/compat/compat.cpp +++ b/bacula/src/win32/compat/compat.cpp @@ -824,14 +824,15 @@ gettimeofday(struct timeval *tv, struct timezone *) } -int -syslog(int type, const char *fmt, const char *msg) +/* For apcupsd this is in src/lib/wincompat.c */ +#ifndef __APCUPSD__ +extern "C" void syslog(int type, const char *fmt, ...) { /*#ifndef HAVE_CONSOLE MessageBox(NULL, msg, "Bacula", MB_OK); #endif*/ - return 0; } +#endif struct passwd * getpwuid(uid_t) diff --git a/bacula/src/win32/compat/compat.h b/bacula/src/win32/compat/compat.h index 5dd554e6cd..610e2d0298 100644 --- a/bacula/src/win32/compat/compat.h +++ b/bacula/src/win32/compat/compat.h @@ -306,8 +306,6 @@ int __sprintf(char *str, const char *fmt, ...); struct timespec; int readdir(unsigned int fd, struct dirent *dirp, unsigned int count); int nanosleep(const struct timespec*, struct timespec *); -//struct tm *localtime_r(const time_t *, struct tm *); -//struct tm *gmtime_r(const time_t *, struct tm *); long int random(void); void srandom(unsigned int seed); int lstat(const char *, struct stat *); @@ -343,7 +341,7 @@ struct sigaction { #define mkdir(p, m) win32_mkdir(p) #define unlink win32_unlink #define chdir win32_chdir -int syslog(int, const char *, const char *); +extern "C" void syslog(int type, const char *fmt, ...); #ifndef LOG_DAEMON #define LOG_DAEMON 0 #endif diff --git a/bacula/src/win32/compat/syslog.h b/bacula/src/win32/compat/syslog.h index e69de29bb2..6e4cb32e4e 100644 --- a/bacula/src/win32/compat/syslog.h +++ b/bacula/src/win32/compat/syslog.h @@ -0,0 +1,32 @@ +#ifndef _SYSLOG_H +#define _SYSLOG_H + +#define LOG_DAEMON 0 +#define LOG_ERR 1 +#define LOG_CRIT 2 +#define LOG_ALERT 3 +#define LOG_WARNING 4 +#define LOG_NOTICE 5 +#define LOG_INFO 6 +#define LOG_LOCAL0 10 +#define LOG_LOCAL1 11 +#define LOG_LOCAL2 12 +#define LOG_LOCAL3 13 +#define LOG_LOCAL4 14 +#define LOG_LOCAL5 15 +#define LOG_LOCAL6 16 +#define LOG_LOCAL7 17 +#define LOG_LPR 20 +#define LOG_MAIL 21 +#define LOG_NEWS 22 +#define LOG_UUCP 23 +#define LOG_USER 24 +#define LOG_CONS 0 +#define LOG_PID 0 + + +extern "C" void syslog(int type, const char *fmt, ...); +void openlog(const char *app, int, int); +void closelog(void); + +#endif /* _SYSLOG_H */ -- 2.39.5