From: Kern Sibbald Date: Tue, 29 Oct 2002 11:26:22 +0000 (+0000) Subject: Fix btape for files + more doc X-Git-Tag: Release-1.27~42 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=fab7c5a2055970877635299ad116b22c2ee89ef7;p=bacula%2Fbacula Fix btape for files + more doc git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@176 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/kernstodo b/bacula/kernstodo index bc16bde150..ad94b20945 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -1,5 +1,5 @@ Kern's ToDo List - 25 October 2002 + 29 October 2002 To do: - Document that two Verifys at same time on same client do not work. @@ -26,6 +26,7 @@ For 1.27 release: ANYTHING to and from a Bacula Volume, including horrible stuff like Windows ACLs). +- Write bcopy program. - Preprocessing command per file. - Postprocessing command per file (when restoring). - File system type from File daemon @@ -38,16 +39,13 @@ For 1.27 release: - Send Volumes needed during restore to Console (just after create_volume_list) -- also in restore command? - Document buffer size considerations with Sparse files -- -- Document all daemon tools MUST have a config file. - Move block size code from block.c to init_dev(). - Add code to fast seek to proper place on tape/file when doing Restore. If it doesn't work, try linear search as before. - Add code to reject whole blocks if not wanted on restore. -- Why does btape error when pointed to a file? - Possibly add email to Watchdog if drive is unmounted too long and a job is waiting on the drive. -- Disallow compile if long long not 64 bits. - What to do with btime and JobTDate? - Add FileSet MD5 to bscan. - Finish implementation of restore "replace" options, and document. @@ -560,3 +558,6 @@ Done: (see kernsdone for more) - Label (asks for slot, return and it stops). - Make SD reject writing on tape where Catalog and tape # files don't agree (possibly OK if tape > catalog). +- Document all daemon tools MUST have a config file. +- Why does btape error when pointed to a file? +- Disallow compile if long long not 64 bits. diff --git a/bacula/src/stored/btape.c b/bacula/src/stored/btape.c index c079ae7ae0..3238f3852e 100644 --- a/bacula/src/stored/btape.c +++ b/bacula/src/stored/btape.c @@ -391,10 +391,10 @@ static void weofcmd() static void eomcmd() { if (!eod_dev(dev)) { - Pmsg1(0, "Bad status from eod. ERR=%s\n", strerror_dev(dev)); + Pmsg1(0, _("Bad status from eod. ERR=%s\n"), strerror_dev(dev)); return; } else { - Pmsg0(0, "Moved to end of media\n"); + Pmsg0(0, _("Moved to end of media\n")); } } @@ -415,9 +415,9 @@ static void bsfcmd() int stat; if ((stat=bsf_dev(dev, 1)) < 0) { - Pmsg1(0, "Bad status from bsf. ERR=%s\n", strerror(errno)); + Pmsg1(0, _("Bad status from bsf. ERR=%s\n"), strerror(errno)); } else { - Pmsg0(0, "Back spaced one file.\n"); + Pmsg0(0, _("Back spaced one file.\n")); } } @@ -429,9 +429,9 @@ static void bsrcmd() int stat; if ((stat=bsr_dev(dev, 1)) < 0) { - Pmsg1(0, "Bad status from bsr. ERR=%s\n", strerror(errno)); + Pmsg1(0, _("Bad status from bsr. ERR=%s\n"), strerror(errno)); } else { - Pmsg0(0, "Back spaced one record.\n"); + Pmsg0(0, _("Back spaced one record.\n")); } } @@ -441,7 +441,7 @@ static void bsrcmd() */ static void capcmd() { - Pmsg0(0, "Device capabilities: "); + printf(_("Device capabilities:\n")); printf("%sEOF ", dev->capabilities & CAP_EOF ? "" : "!"); printf("%sBSR ", dev->capabilities & CAP_BSR ? "" : "!"); printf("%sBSF ", dev->capabilities & CAP_BSF ? "" : "!"); @@ -455,6 +455,21 @@ static void capcmd() printf("%sANONVOLS ", dev->capabilities & CAP_ANONVOLS ? "" : "!"); printf("%sALWAYSOPEN ", dev->capabilities & CAP_ALWAYSOPEN ? "" : "!"); printf("\n"); + + printf(_("Device status:\n")); + printf("%sOPENED ", dev->state & ST_OPENED ? "" : "!"); + printf("%sTAPE ", dev->state & ST_TAPE ? "" : "!"); + printf("%sLABEL ", dev->state & ST_LABEL ? "" : "!"); + printf("%sMALLOC ", dev->state & ST_MALLOC ? "" : "!"); + printf("%sAPPEND ", dev->state & ST_APPEND ? "" : "!"); + printf("%sREAD ", dev->state & ST_READ ? "" : "!"); + printf("%sEOT ", dev->state & ST_EOT ? "" : "!"); + printf("%sWEOT ", dev->state & ST_WEOT ? "" : "!"); + printf("%sEOF ", dev->state & ST_EOF ? "" : "!"); + printf("%sNEXTVOL ", dev->state & ST_NEXTVOL ? "" : "!"); + printf("%sSHORT ", dev->state & ST_SHORT ? "" : "!"); + printf("\n"); + } /* @@ -1113,7 +1128,7 @@ do_tape_cmds() break; } if (!found) - Pmsg1(0, "%s is an illegal command\n", cmd); + Pmsg1(0, _("%s is an illegal command\n"), cmd); if (quit) break; } @@ -1123,7 +1138,7 @@ static void helpcmd() { unsigned int i; usage(); - printf(" Command Description\n ======= ===========\n"); + printf(_(" Command Description\n ======= ===========\n")); for (i=0; i set configuration file to file\n" @@ -1139,7 +1154,7 @@ static void usage() " -s turn off signals\n" " -t open the default tape device\n" " -? print this message.\n" -"\n"); +"\n")); } diff --git a/bacula/src/stored/butil.c b/bacula/src/stored/butil.c index 68b2b9365f..4b372fca6e 100644 --- a/bacula/src/stored/butil.c +++ b/bacula/src/stored/butil.c @@ -112,8 +112,22 @@ DEVICE *setup_to_access_device(JCR *jcr, int read_access) if (read_access) { if (!acquire_device_for_read(jcr, dev, block)) { Emsg0(M_ERROR, 0, dev->errmsg); + free_block(block); return NULL; } + } else { + lock_device(dev); + if (!(dev->state & ST_OPENED)) { + Dmsg0(129, "Opening device.\n"); + if (open_dev(dev, jcr->VolumeName, READ_WRITE) < 0) { + Emsg1(M_FATAL, 0, _("dev open failed: %s\n"), dev->errmsg); + unlock_device(dev); + free_block(block); + return NULL; + } + } + Dmsg1(129, "open_dev %s OK\n", dev_name(dev)); + unlock_device(dev); } free_block(block); return dev; @@ -181,6 +195,9 @@ static void my_free_jcr(JCR *jcr) free_pool_memory(jcr->dev_name); jcr->dev_name = NULL; } + if (jcr->VolList) { + free_vol_list(jcr); + } return; } diff --git a/bacula/src/stored/parse_bsr.c b/bacula/src/stored/parse_bsr.c index f0dc3a62e2..27fc007c8c 100755 --- a/bacula/src/stored/parse_bsr.c +++ b/bacula/src/stored/parse_bsr.c @@ -711,6 +711,7 @@ void free_vol_list(JCR *jcr) free(next); next = tmp; } + jcr->VolList = NULL; } void create_vol_list(JCR *jcr)