]> git.sur5r.net Git - bacula/bacula/commitdiff
- Add check for df path for dvd_freespace
authorKern Sibbald <kern@sibbald.com>
Fri, 22 Jul 2005 09:12:43 +0000 (09:12 +0000)
committerKern Sibbald <kern@sibbald.com>
Fri, 22 Jul 2005 09:12:43 +0000 (09:12 +0000)
- Use df to get space used on DVD.
- Change sense of flag indicating erase DVD or not before writing.
- Fix bpipe so that it never modifies the result pointer.
- Replace more dev_name by print_name().
- Rewrite edit_device_codes_dev() so it does not overwrite the
  supplied buffer.
- Update printing of labels (for bls) so that critical information
  is printed (Job name and timestamp).
- Cleanup old spool files when starting the SD.
- Modify vss.cpp to allow C: as a path name.  Otherwise VSS
  doesn't work when only a drive name is given.
- Modify vss.c to eliminate double / in filenames.
- Update doc -- particularly the restore chapter.

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2233 91ce42f0-d328-0410-95d8-f526ca767f89

13 files changed:
bacula/autoconf/configure.in
bacula/configure
bacula/kernstodo
bacula/kes-1.37
bacula/scripts/dvd-freespace.in
bacula/scripts/dvd-writepart.in
bacula/src/lib/bpipe.c
bacula/src/stored/bacula-sd.conf.in
bacula/src/stored/dev.c
bacula/src/stored/dvd.c
bacula/src/stored/label.c
bacula/src/stored/stored.c
bacula/src/version.h

index 9c90075a205b9fc38a24adea19f637d599a55697..3ddacdbac5305fbf039f645dbfc6f90e78ba3c90 100644 (file)
@@ -64,6 +64,7 @@ AC_PATH_PROG(AR, ar, ar)
 dnl AC_PATH_PROG(RANLIB, ranlib, ranlib)
 AC_PATH_PROG(OPENSSL, openssl, none)
 AC_PATH_PROG(MTX, mtx, mtx)
+AC_PATH_PROG(DF, df, df)
 AC_PATH_PROG(MKISOFS, mkisofs, mkisofs)
 AC_PATH_PROG(PYTHON, python, python)
 AC_PATH_PROG(GROWISOFS, growisofs, growisofs)
index 6dddd39e7ffe527e2d7f042677b2592857e9a0b8..1a3f602504dc3c14d5810fec8f115944bef8f1b3 100755 (executable)
@@ -309,7 +309,7 @@ ac_includes_default="\
 # include <unistd.h>
 #endif"
 
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS BUILD_DIR TRUEPRG FALSEPRG VERSION DATE LSMDATE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CXX CXXFLAGS ac_ct_CXX CPP EGREP INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA RANLIB ac_ct_RANLIB MV RM CP SED ECHO CMP TBL AR OPENSSL MTX MKISOFS PYTHON GROWISOFS DVDRWMEDIAINFO PKGCONFIG WXCONFIG WXFLAGS CDRECORD PIDOF AWK ARFLAGS MAKE_SHELL LOCAL_LIBS LOCAL_CFLAGS LOCAL_LDFLAGS LOCAL_DEFS build build_cpu build_vendor build_os host host_cpu host_vendor host_os HAVE_SUN_OS_TRUE HAVE_SUN_OS_FALSE HAVE_OSF1_OS_TRUE HAVE_OSF1_OS_FALSE HAVE_AIX_OS_TRUE HAVE_AIX_OS_FALSE HAVE_HPUX_OS_TRUE HAVE_HPUX_OS_FALSE HAVE_LINUX_OS_TRUE HAVE_LINUX_OS_FALSE HAVE_FREEBSD_OS_TRUE HAVE_FREEBSD_OS_FALSE HAVE_NETBSD_OS_TRUE HAVE_NETBSD_OS_FALSE HAVE_OPENBSD_OS_TRUE HAVE_OPENBSD_OS_FALSE HAVE_BSDI_OS_TRUE HAVE_BSDI_OS_FALSE HAVE_SGI_OS_TRUE HAVE_SGI_OS_FALSE HAVE_IRIX_OS_TRUE HAVE_IRIX_OS_FALSE HAVE_DARWIN_OS_TRUE HAVE_DARWIN_OS_FALSE INSIDE_GNOME_COMMON_TRUE INSIDE_GNOME_COMMON_FALSE MSGFMT GNOME_INCLUDEDIR GNOMEUI_LIBS GNOME_LIBDIR GNOME_LIBS GNOME_DIR WXCONS_CPPFLAGS WXCONS_LDFLAGS WX_DIR TRAY_MONITOR_CPPFLAGS TRAY_MONITOR_LDFLAGS TRAY_MONITOR_DIR TTOOL_LDFLAGS STATIC_FD STATIC_SD STATIC_DIR STATIC_CONS STATIC_GNOME_CONS STATIC_WX_CONS ALL_DIRS CONS_INC CONS_OBJ CONS_SRC CONS_LIBS CONS_LDFLAGS READLINE_SRC PYTHON_LIBS PYTHON_INCDIR OPENSSL_LIBS OPENSSL_INC working_dir scriptdir dump_email job_email smtp_host piddir subsysdir baseport dir_port fd_port sd_port dir_password fd_password sd_password mon_dir_password mon_fd_password mon_sd_password dir_user dir_group sd_user sd_group fd_user fd_group SBINPERM SQL_LFLAGS SQL_INCLUDE SQL_BINDIR cats DB_NAME GETCONF ac_ct_GETCONF X_CFLAGS X_PRE_LIBS X_LIBS X_EXTRA_LIBS LIBOBJS ALLOCA FDLIBS DEBUG DINCLUDE DLIB DB_LIBS WCFLAGS WLDFLAGS OBJLIST hostname TAPEDRIVE PSCMD WIN32 MACOSX DISTNAME DISTVER LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS BUILD_DIR TRUEPRG FALSEPRG VERSION DATE LSMDATE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CXX CXXFLAGS ac_ct_CXX CPP EGREP INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA RANLIB ac_ct_RANLIB MV RM CP SED ECHO CMP TBL AR OPENSSL MTX DF MKISOFS PYTHON GROWISOFS DVDRWMEDIAINFO PKGCONFIG WXCONFIG WXFLAGS CDRECORD PIDOF AWK ARFLAGS MAKE_SHELL LOCAL_LIBS LOCAL_CFLAGS LOCAL_LDFLAGS LOCAL_DEFS build build_cpu build_vendor build_os host host_cpu host_vendor host_os HAVE_SUN_OS_TRUE HAVE_SUN_OS_FALSE HAVE_OSF1_OS_TRUE HAVE_OSF1_OS_FALSE HAVE_AIX_OS_TRUE HAVE_AIX_OS_FALSE HAVE_HPUX_OS_TRUE HAVE_HPUX_OS_FALSE HAVE_LINUX_OS_TRUE HAVE_LINUX_OS_FALSE HAVE_FREEBSD_OS_TRUE HAVE_FREEBSD_OS_FALSE HAVE_NETBSD_OS_TRUE HAVE_NETBSD_OS_FALSE HAVE_OPENBSD_OS_TRUE HAVE_OPENBSD_OS_FALSE HAVE_BSDI_OS_TRUE HAVE_BSDI_OS_FALSE HAVE_SGI_OS_TRUE HAVE_SGI_OS_FALSE HAVE_IRIX_OS_TRUE HAVE_IRIX_OS_FALSE HAVE_DARWIN_OS_TRUE HAVE_DARWIN_OS_FALSE INSIDE_GNOME_COMMON_TRUE INSIDE_GNOME_COMMON_FALSE MSGFMT GNOME_INCLUDEDIR GNOMEUI_LIBS GNOME_LIBDIR GNOME_LIBS GNOME_DIR WXCONS_CPPFLAGS WXCONS_LDFLAGS WX_DIR TRAY_MONITOR_CPPFLAGS TRAY_MONITOR_LDFLAGS TRAY_MONITOR_DIR TTOOL_LDFLAGS STATIC_FD STATIC_SD STATIC_DIR STATIC_CONS STATIC_GNOME_CONS STATIC_WX_CONS ALL_DIRS CONS_INC CONS_OBJ CONS_SRC CONS_LIBS CONS_LDFLAGS READLINE_SRC PYTHON_LIBS PYTHON_INCDIR OPENSSL_LIBS OPENSSL_INC working_dir scriptdir dump_email job_email smtp_host piddir subsysdir baseport dir_port fd_port sd_port dir_password fd_password sd_password mon_dir_password mon_fd_password mon_sd_password dir_user dir_group sd_user sd_group fd_user fd_group SBINPERM SQL_LFLAGS SQL_INCLUDE SQL_BINDIR cats DB_NAME GETCONF ac_ct_GETCONF X_CFLAGS X_PRE_LIBS X_LIBS X_EXTRA_LIBS LIBOBJS ALLOCA FDLIBS DEBUG DINCLUDE DLIB DB_LIBS WCFLAGS WLDFLAGS OBJLIST hostname TAPEDRIVE PSCMD WIN32 MACOSX DISTNAME DISTVER LTLIBOBJS'
 ac_subst_files='MCOMMON'
 
 # Initialize some variables set by options.
@@ -3806,6 +3806,46 @@ else
 echo "${ECHO_T}no" >&6
 fi
 
+# Extract the first word of "df", so it can be a program name with args.
+set dummy df; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_path_DF+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  case $DF in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_DF="$DF" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_DF="$as_dir/$ac_word$ac_exec_ext"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+  test -z "$ac_cv_path_DF" && ac_cv_path_DF="df"
+  ;;
+esac
+fi
+DF=$ac_cv_path_DF
+
+if test -n "$DF"; then
+  echo "$as_me:$LINENO: result: $DF" >&5
+echo "${ECHO_T}$DF" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
 # Extract the first word of "mkisofs", so it can be a program name with args.
 set dummy mkisofs; ac_word=$2
 echo "$as_me:$LINENO: checking for $ac_word" >&5
@@ -8007,7 +8047,6 @@ fi;
 
 if test "x$dir_password" = "x" ; then
    if test "x$OPENSSL" = "xnone" ; then
-#     key=`date | uuencode /dev/stdout | tr "\"@\\\`\\ \\=\\,\\(\\)\\#\\.\\!\\-$'" abcdefghijklmnopqrst | awk '{getline} {print} {exit}'`
       key=`autoconf/randpass 33`
    else
       key=`openssl rand -base64 33`
@@ -8030,7 +8069,6 @@ fi;
 
 if test "x$fd_password" = "x" ; then
    if test "x$OPENSSL" = "xnone" ; then
-#     key=`date | uuencode /dev/stdout | tr "\"@\\\`\\ \\=\\,\\(\\)\\#\\.\\!\\-$'" tsrqponmlkjihgfedcba | awk '{getline} {print} {exit}'`
       key=`autoconf/randpass 37`
    else
       key=`openssl rand -base64 33`
@@ -8053,7 +8091,6 @@ fi;
 
 if test "x$sd_password" = "x" ; then
    if test "x$OPENSSL" = "xnone" ; then
-#     key=`date | uuencode /dev/stdout | tr "\"@\\\`\\ \\=\\,\\(\\)\\#\\.\\!\\-$'" 123456789uvwxyzabcdef | awk '{getline} {print} {exit}'`
       key=`autoconf/randpass 41`
    else
       key=`openssl rand -base64 33`
@@ -8076,7 +8113,6 @@ fi;
 
 if test "x$mon_dir_password" = "x" ; then
    if test "x$OPENSSL" = "xnone" ; then
-#     key=`date | uuencode /dev/stdout | tr "\"@\\\`\\ \\=\\,\\(\\)\\#\\.\\!\\-$'" abcdefghijklmnopqrst | awk '{getline} {print} {exit}'`
       key=`autoconf/randpass 33`
    else
       key=`openssl rand -base64 33`
@@ -8099,7 +8135,6 @@ fi;
 
 if test "x$mon_fd_password" = "x" ; then
    if test "x$OPENSSL" = "xnone" ; then
-#     key=`date | uuencode /dev/stdout | tr "\"@\\\`\\ \\=\\,\\(\\)\\#\\.\\!\\-$'" tsrqponmlkjihgfedcba | awk '{getline} {print} {exit}'`
       key=`autoconf/randpass 37`
    else
       key=`openssl rand -base64 33`
@@ -8122,7 +8157,6 @@ fi;
 
 if test "x$mon_sd_password" = "x" ; then
    if test "x$OPENSSL" = "xnone" ; then
-#     key=`date | uuencode /dev/stdout | tr "\"@\\\`\\ \\=\\,\\(\\)\\#\\.\\!\\-$'" 123456789uvwxyzabcdef | awk '{getline} {print} {exit}'`
       key=`autoconf/randpass 41`
    else
       key=`openssl rand -base64 33`
@@ -21907,6 +21941,7 @@ s,@TBL@,$TBL,;t t
 s,@AR@,$AR,;t t
 s,@OPENSSL@,$OPENSSL,;t t
 s,@MTX@,$MTX,;t t
+s,@DF@,$DF,;t t
 s,@MKISOFS@,$MKISOFS,;t t
 s,@PYTHON@,$PYTHON,;t t
 s,@GROWISOFS@,$GROWISOFS,;t t
index 600115e41572ca61626bf9b30ac2748b6bb8b23f..41f313d5a221df7ce7463959d46ac227e5b664b7 100644 (file)
@@ -1,5 +1,5 @@
                     Kern's ToDo List
-                     18 July 2005
+                     20 July 2005
 
 Major development:      
 Project                     Developer
@@ -18,44 +18,21 @@ Final items for 1.37 before release:
 -  Test TLS.
 
 Document:
-- Document cleaning up the spool files.
+- Document cleaning up the spool files:
+  db, pid, state, bsr, mail, conmsg, spool
 - Add better documentation on how restores can be done
-- Document details of ANSI/IBM labels
-- Document that Bootstrap files can be written with cataloging
-  turned off.
-- Pruning with Admin job.
-- OS linux 2.4
-  1) ADIC, DLT, FastStor 4000, 7*20GB
-  2) Sun, DDS, (Suns name unknown - Archive Python DDS drive), 1.2GB
-  3) Wangtek, QIC, 6525ES, 525MB (fixed block size 1k, block size etc. 
-  driver dependent - aic7xxx works, ncr53c8xx with problems)
-  4) HP, DDS-2, C1553A, 6*4GB
-- Doc the following
-  to activate, check or disable the hardware compression feature on my 
-  exb-8900 i use the exabyte "MammothTool" you can get it here:
-  http://www.exabyte.com/support/online/downloads/index.cfm
-  There is a solaris version of this tool. With option -C 0 or 1 you can 
-  disable or activate compression. Start this tool without any options for 
-  a small reference.
-- Linux Sony LIB-D81, AIT-3 library works.
-- Document PostgreSQL performance problems bug 131.
-- Document testing
-- Document that ChangerDevice is used for Alert command.
-- Document new CDROM directory.
-- Document Heartbeat Interval in the dealing with firewalls section.
 - Document the multiple-drive-changer.txt script.
-- On Win32 working directory must have drive letter ????
-- On Win32 working directory must be writable by SYSTEM to
-  do restores.
-- Clean up working extensions: db, pid, state, bsr, mail, conmsg, spool
+- Pruning with Admin job.
 
 
 For 1.39:
+- Fix bpipe.c so that it does not modify results pointer.
+  ***FIXME*** calling sequence should be changed.
 1.xx Major Projects:
 #3   Migration (Move, Copy, Archive Jobs)
 #7   Single Job Writing to Multiple Storage Devices
 - Reserve blocks other restore jobs when first cannot connect
-  to SD -- no way to cancel in SD if Dir job canceled.
+  to SD.
 - Add true/false to conf same as yes/no
 - For Windows disaster recovery see http://unattended.sf.net/
 - regardless of the retention period, Bacula will not prune the
@@ -175,6 +152,22 @@ For 1.39:
 
      Make sure this information is stored on the tape too so
      that it can be restored directly from the tape.
+
+  Comments from Martin Simmons (I think they are all covered):
+  Ok, that should cover the basics.  There are few issues though:
+
+  - Restore will depend on the catalog.  I think it is better to include the
+  extra data in the backup as well, so it can be seen by bscan and bextract.
+
+  - I'm not sure if it will preserve multiple hard links to the same inode.  Or
+  maybe adding or removing links will cause the data to be dumped again?
+
+  - I'm not sure if it will handle renamed directories.  Possibly it will work
+  by dumping the whole tree under a renamed directory?
+
+  - It remains to be seen how the backup performance of the DIR's will be
+  affected when comparing the catalog for a large filesystem.
+
 =====
 
 Regression tests:
@@ -1368,3 +1361,22 @@ Block Position: 0
 -  bsr-opt-test fails. bsr deleted. Fix.
 -  Move Python daemon variables from Job to Bacula object.
    WorkingDir, ConfigFile
+- Document that Bootstrap files can be written with cataloging
+  turned off.
+- Document details of ANSI/IBM labels
+- OS linux 2.4
+  1) ADIC, DLT, FastStor 4000, 7*20GB
+- Linux Sony LIB-D81, AIT-3 library works.
+- Doc the following
+  to activate, check or disable the hardware compression feature on my 
+  exb-8900 i use the exabyte "MammothTool" you can get it here:
+  http://www.exabyte.com/support/online/downloads/index.cfm
+  There is a solaris version of this tool. With option -C 0 or 1 you can 
+  disable or activate compression. Start this tool without any options for 
+  a small reference.
+- Document Heartbeat Interval in the dealing with firewalls section.
+- Document new CDROM directory.
+- On Win32 working directory must have drive letter ????
+- On Win32 working directory must be writable by SYSTEM to
+  do restores.
+- Document that ChangerDevice is used for Alert command.
index afb4a8dc6c9e1a9d69737d56c4e244cd20f62815..5eb9806873a95a27fc3d1872e0b3681ead5259d3 100644 (file)
@@ -4,6 +4,21 @@
 General:
 
 Changes to 1.37.31:
+22Jul05
+- Add check for df path for dvd_freespace
+- Use df to get space used on DVD.
+- Change sense of flag indicating erase DVD or not before writing.
+- Fix bpipe so that it never modifies the result pointer.
+- Replace more dev_name by print_name().
+- Rewrite edit_device_codes_dev() so it does not overwrite the
+  supplied buffer.
+- Update printing of labels (for bls) so that critical information
+  is printed (Job name and timestamp).
+- Cleanup old spool files when starting the SD.
+- Modify vss.cpp to allow C: as a path name.  Otherwise VSS
+  doesn't work when only a drive name is given.
+- Modify vss.c to eliminate double / in filenames.
+- Update doc -- particularly the restore chapter.
 18Jul05
 - Make all files in working directory have .xxx at end.
 - Work on DVD writing.
index 7503260ee7edce2988d2b7b573f271479d50b1e6..d8cc05b0ff09b7e079a97a055edbbf6c24fc6f25 100755 (executable)
@@ -4,7 +4,7 @@
 # Should always exit with 0 status, otherwise it indicates a serious error.
 # (wrong number of arguments, Python exception...)
 #
-#  called:  dvd-freespace <dvd-device-name> <part-number>
+#  called:  dvd-freespace <dvd-device-name>
 #
 #
 # returns:
 # $Id$
 
 # Configurable values:
-mkisofs="@MKISOFS@"
-growisofs="@GROWISOFS@"
+df="@DF@"
 dvdrwmediainfo="@DVDRWMEDIAINFO@"
 
 margin=10485760 # 10 mb security margin
 
-growisofsparams=""
-
-# Uncomment the following line if you have a Linux kernel >=2.6.8, and
-# if you want to allow a session to start behind the 4gb boundary.
-#growisofsparams = growisofsparams + " -use-the-force-luke=4gms"
 
 # end of configurable values
 
@@ -34,14 +28,11 @@ import os
 import errno
 import sys
 
-if len(sys.argv) != 3:
-   print "Wrong number of argument."
+if len(sys.argv) < 2:
+   print "Wrong number of arguments."
    sys.exit(1)
 
 device=sys.argv[1]
-part_num=int(sys.argv[2])
-
-os.environ["MKISOFS"] = mkisofs
 
 def gettotalsize():
    cmd=dvdrwmediainfo + " " + device
@@ -83,17 +74,12 @@ def gettotalsize():
         print "Cannot get media lead-out index from " + dvdrwmediainfo
         sys.exit(0)
 
-if part_num == 0:
-   flag = "-Z"
-else:
-   flag = "-M"
-# the growisofs at the end is a dummy
-cmd=growisofs + " " + growisofsparams + " -use-the-force-luke=tty -dry-run -quiet " + flag + " " + device + " -R " + growisofs
+cmd=df + " " + device
 process = popen2.Popen4(cmd)
 status = process.wait()
 if not os.WIFEXITED(status):
    print -errno.EPIPE
-   print growisofs + " process did not not exit correctly."
+   print df + " process did not not exit correctly."
    sys.exit(0)
 
 exitstat = os.WEXITSTATUS(status) & ~0x80
@@ -105,23 +91,33 @@ if exitstat != 0:
    print -exitstat
    print os.strerror(exitstat)
    sys.exit(0)
+size = 0
 while 1:
    result = process.fromchild.readline()
    if not result:
       print -errno.EPIPE
-      print "Cannot find the seek argument in the output from " + growisofs
+      print "Cannot get output from " + df
       sys.exit(0)
-   index = result.find("seek=")
-   if index > -1:
-      res = result[index+5:-2]
+   index = result.find(device)
+   if index > -1: 
+      while result[index] != ' ':
+        index += 1
+      while result[index] == ' ':
+        index += 1
+      eindex = index;
+      while result[eindex] != ' ':
+        eindex += 1
+      res = result[index:eindex] 
       if not res.isdigit():
-        print -errno.EPIPE
-        print "Wrong seek argument in the output from " + growisofs
+        print -errno.EPIPE;
+        print "Could not find size in df output"
         sys.exit(0)
-      size = long(res)*32*1024
-      size = gettotalsize()-(size+margin)
-      if size < 0:
-        size = 0
-      print size
-      print "No error occurred"
-      sys.exit(0)
+      size = long(res)*1024
+      break
+
+size = gettotalsize()-(size+margin)
+if size < 0:
+   size = 0
+print size
+print "No error occurred"
+sys.exit(0)
index 669d9a7a60f93b9bd0f6ea931b8c610a3111e40d..49d2fdec5c22a4713922ed502891b999af909af0 100644 (file)
@@ -9,8 +9,8 @@
 #  Write Part Command = "path-to-this-script/dvd-writepart %n %a %v"
 #    you will have the following input to this script:
 #
-#  dvd-writepart "part_number"   "device"  "part_filename"
-#                    $1             $2           $3
+#  dvd-writepart "erase"  "device"  "part_filename"
+#                  $1       $2           $3
 #
 #  for example:
 #
@@ -39,11 +39,11 @@ if test $# -ne 3 ; then
 fi
 
 # Setup arguments
-partnum=$1
+erase=$1
 dev=$2
 filename=$3
 
-if test $partnum = 1 ; then
+if test $erase = 1 ; then
   arg="-Z"
 else
   arg="-M"  
index 4962f5c7bbf7d5a5e7ce43d22263586c563c3801..45fffe4447cae1c02bed921778e8a6eae87c9001 100644 (file)
@@ -5,27 +5,22 @@
  *
  *   Version $Id$
  */
-
 /*
-   Copyright (C) 2002-2004 Kern Sibbald and John Walker
+   Copyright (C) 2002-2005 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 "jcr.h"
 
@@ -255,16 +250,16 @@ int run_program(char *prog, int wait, POOLMEM *results)
    int stat1, stat2;
    char *mode;
 
-   if (results) {
-      results[0] = 0;
-   }
    mode = (char *)(results != NULL ? "r" : "");
    bpipe = open_bpipe(prog, wait, mode);
    if (!bpipe) {
       return ENOENT;
    }
    if (results) {
-      fgets(results, sizeof_pool_memory(results), bpipe->rfd);
+      results[0] = 0;
+      int len = sizeof_pool_memory(results) - 1;
+      fgets(results, len, bpipe->rfd);
+      results[len] = 0;
       if (feof(bpipe->rfd)) {
          stat1 = 0;
       } else {
@@ -307,26 +302,25 @@ int run_program_full_output(char *prog, int wait, POOLMEM *results)
       return run_program(prog, wait, NULL);
    }
    
+   sm_check(__FILE__, __LINE__, false);
+
    tmp = get_pool_memory(PM_MESSAGE);
    
    mode = (char *)"r";
    bpipe = open_bpipe(prog, wait, mode);
    if (!bpipe) {
+      if (results) {
+         results[0] = 0;
+      }
       return ENOENT;
    }
    
-   results[0] = 0;
-
+   sm_check(__FILE__, __LINE__, false);
+   tmp[0] = 0;
    while (1) {
-      tmp[0] = 0;
-      fgets(tmp, sizeof_pool_memory(tmp), bpipe->rfd);
-      Dmsg1(800, "Run program fgets=%s", tmp);
-      /* ***FIXME****
-       *   we need to pass POOL_MEM &results as arg to ensure
-       *   that change in address of results is passed back
-       */
-     //   pm_strcat(results, tmp);
-      bstrncat(results, tmp, sizeof_pool_memory(results));
+      char buf[1000];
+      fgets(buf, sizeof(buf), bpipe->rfd);
+      pm_strcat(tmp, buf);
       if (feof(bpipe->rfd)) {
          stat1 = 0;
          Dmsg1(900, "Run program fgets stat=%d\n", stat1);
@@ -342,7 +336,9 @@ int run_program_full_output(char *prog, int wait, POOLMEM *results)
          Dmsg1(900, "Run program fgets stat=%d\n", stat1);
       }
    }
-   
+   int len = sizeof_pool_memory(results) - 1;
+   bstrncpy(results, tmp, len);
+   Dmsg3(1900, "resadr=0x%x reslen=%d res=%s\n", results, strlen(results), results);
    stat2 = close_bpipe(bpipe);
    stat1 = stat2 != 0 ? stat2 : stat1;
    
index 19cfe98b26f1e4287f48099be232d5a3a3f33261..6b4cec289a37e199ce1e688dcbaa4da883a2f909 100644 (file)
@@ -161,8 +161,8 @@ Device {
 #  MountCommand = "/bin/mount -t iso9660 -o ro %a %m";
 #  UnmountCommand = "/bin/umount %m";
 #  SpoolDirectory = /tmp/backup;
-#  WritePartCommand = "/etc/bacula/dvd-writepart %n %a %v"
-#  FreeSpaceCommand = "/etc/bacula/dvd-freespace %a %n"
+#  WritePartCommand = "/etc/bacula/dvd-writepart %e %a %v"
+#  FreeSpaceCommand = "/etc/bacula/dvd-freespace %a %e"
 #}
 
 #
index b34e814b4d778f3e0d2741dc4ab1d3fcffe638d2..ab671bdcfd972f6e909ae64089abfdf98aa187fe 100644 (file)
 #define O_NONBLOCK 0
 #endif
 
-/* Functions in dvd.c */ 
-void update_free_space_dev(DEVICE* dev);
-
-
 /* Forward referenced functions */
 void set_os_device_parameters(DEVICE *dev);
 static bool dev_get_os_pos(DEVICE *dev, struct mtget *mt_stat);
@@ -276,7 +272,7 @@ DEVICE::open(DCR *dcr, int omode)
   }
 
    Dmsg4(29, "open dev: tape=%d dev_name=%s vol=%s mode=%s\n", is_tape(),
-         dev_name, VolCatInfo.VolCatName, mode_to_str(omode));
+         print_name(), VolCatInfo.VolCatName, mode_to_str(omode));
    state &= ~(ST_LABEL|ST_APPEND|ST_READ|ST_EOT|ST_WEOT|ST_EOF);
    label_type = B_BACULA_LABEL;
    if (is_tape() || is_fifo()) {
@@ -555,12 +551,6 @@ void DEVICE::open_dvd_device(DCR *dcr, int omode)
          }
       }
    }
-   Dmsg4(29, "open dev: DVD fd=%d opened, part=%d nump=%d, part_size=%u\n", 
-      fd, part, num_parts, part_size);
-   if (is_open() && (omode != OPEN_READ_ONLY) && 
-       (free_space_errno == 0 || num_parts == part)) {
-      update_free_space_dev(this);
-   }
 }
 
 
index 8425f2c913f322f48fe885f61448e874d983225c..b6af336243fbe13ba13d81a057329745b88817db 100644 (file)
@@ -26,7 +26,7 @@
 #include "stored.h"
 
 /* Forward referenced functions */
-static char *edit_device_codes_dev(DEVICE *dev, char *omsg, const char *imsg);
+static void edit_device_codes_dev(DEVICE *dev, POOL_MEM &omsg, const char *imsg);
 static bool do_mount_dev(DEVICE* dev, int mount, int dotimeout);
 static void add_file_and_part_name(DEVICE *dev, POOL_MEM &archive_name);
 
@@ -105,19 +105,22 @@ static bool do_mount_dev(DEVICE* dev, int mount, int dotimeout)
    char *icmd;
    int status, timeout;
    
+   sm_check(__FILE__, __LINE__, false);
    if (mount) {
       if (dev->is_mounted()) {
+         Dmsg0(200, "======= DVD mount=1\n");
          return true;
       }
       icmd = dev->device->mount_command;
    } else {
       if (!dev->is_mounted()) {
+         Dmsg0(200, "======= DVD mount=0\n");
          return true;
       }
       icmd = dev->device->unmount_command;
    }
    
-   edit_device_codes_dev(dev, ocmd.c_str(), icmd);
+   edit_device_codes_dev(dev, ocmd, icmd);
    
    Dmsg2(200, "do_mount_dev: cmd=%s mounted=%d\n", ocmd.c_str(), !!dev->is_mounted());
 
@@ -165,7 +168,8 @@ static bool do_mount_dev(DEVICE* dev, int mount, int dotimeout)
       if (!(dp = opendir(dev->device->mount_point))) {
          berrno be;
          dev->dev_errno = errno;
-         Dmsg3(29, "open_mounted_dev: failed to open dir %s (dev=%s), ERR=%s\n", dev->device->mount_point, dev->dev_name, be.strerror());
+         Dmsg3(29, "open_mounted_dev: failed to open dir %s (dev=%s), ERR=%s\n", 
+               dev->device->mount_point, dev->print_name(), be.strerror());
          goto get_out;
       }
       
@@ -173,7 +177,8 @@ static bool do_mount_dev(DEVICE* dev, int mount, int dotimeout)
       while (1) {
          if ((readdir_r(dp, entry, &result) != 0) || (result == NULL)) {
             dev->dev_errno = ENOENT;
-            Dmsg2(29, "open_mounted_dev: failed to find suitable file in dir %s (dev=%s)\n", dev->device->mount_point, dev->dev_name);
+            Dmsg2(29, "open_mounted_dev: failed to find suitable file in dir %s (dev=%s)\n", 
+                  dev->device->mount_point, dev->print_name());
             break;
          }
          count++;
@@ -185,12 +190,17 @@ static bool do_mount_dev(DEVICE* dev, int mount, int dotimeout)
          break;                          /*   there must be something mounted */
       }
 get_out:
+      dev->set_mounted(false);
+      sm_check(__FILE__, __LINE__, false);
       free_pool_memory(results);
+      Dmsg0(200, "============ DVD mount=0\n");
       return false;
    }
    
    dev->set_mounted(mount);              /* set/clear mounted flag */
    free_pool_memory(results);
+   update_free_space_dev(dev);
+   Dmsg1(200, "============ DVD mount=%d\n", mount);
    return true;
 }
 
@@ -204,6 +214,7 @@ void update_free_space_dev(DEVICE* dev)
    long long int free;
    char ed1[50];
    
+   sm_check(__FILE__, __LINE__, false);
    icmd = dev->device->free_space_command;
    
    if (!icmd) {
@@ -214,12 +225,11 @@ void update_free_space_dev(DEVICE* dev)
       return;
    }
    
-   edit_device_codes_dev(dev, ocmd.c_str(), icmd);
+   edit_device_codes_dev(dev, ocmd, icmd);
    
    Dmsg1(29, "update_free_space_dev: cmd=%s\n", ocmd.c_str());
 
    results = get_pool_memory(PM_MESSAGE);
-   results[0] = 0;
    
    /* Try at most 3 times to get the free space on the device. This should perhaps be configurable. */
    timeout = 3;
@@ -242,7 +252,7 @@ void update_free_space_dev(DEVICE* dev)
       
       if (--timeout > 0) {
          Dmsg4(40, "Cannot get free space on device %s. free_space=%s, "
-            "free_space_errno=%d ERR=%s\n", dev->dev_name
+            "free_space_errno=%d ERR=%s\n", dev->print_name()
                edit_uint64(dev->free_space, ed1), dev->free_space_errno, 
                dev->errmsg);
          bmicrosleep(1, 0);
@@ -252,7 +262,7 @@ void update_free_space_dev(DEVICE* dev)
       dev->dev_errno = -dev->free_space_errno;
       Dmsg4(40, "Cannot get free space on device %s. free_space=%s, "
          "free_space_errno=%d ERR=%s\n",
-            dev->dev_name, edit_uint64(dev->free_space, ed1),
+            dev->print_name(), edit_uint64(dev->free_space, ed1),
             dev->free_space_errno, dev->errmsg);
       break;
    }
@@ -260,6 +270,7 @@ void update_free_space_dev(DEVICE* dev)
    free_pool_memory(results);
    Dmsg3(29, "update_free_space_dev: free_space=%s, free_space_errno=%d have_media=%d\n", 
       edit_uint64(dev->free_space, ed1), dev->free_space_errno, dev->have_media());
+   sm_check(__FILE__, __LINE__, false);
    return;
 }
 
@@ -269,35 +280,17 @@ void update_free_space_dev(DEVICE* dev)
 static bool dvd_write_part(DCR *dcr) 
 {
    DEVICE *dev = dcr->dev;
-   Dmsg1(29, "dvd_write_part: device is %s\n", dev->print_name());
-   
-   if (!unmount_dev(dev, 1)) {
-      Dmsg0(29, "dvd_write_part: unable to unmount the device\n");
-   }
-   
    POOL_MEM ocmd(PM_FNAME);
-   POOL_MEM results(PM_MESSAGE);
    char* icmd;
    int status;
    int timeout;
-   int part;
    char ed1[50];
    
-   results.c_str()[0] = 0;
+   sm_check(__FILE__, __LINE__, false);
+   Dmsg1(29, "dvd_write_part: device is %s\n", dev->print_name());
    icmd = dev->device->write_part_command;
    
-   /* 
-    * Note! part is used to control whether or not we create a
-    *   new filesystem. If the device could be mounted, it is because
-    *   it already has a filesystem, so we artificially set part=1
-    *   to avoid zapping an existing filesystem.
-    */
-   part = dev->part;
-   if (dev->is_mounted() && dev->part < 2) {
-      dev->part = 2;      /* do not wipe out existing filesystem */
-   }
-   edit_device_codes_dev(dev, ocmd.c_str(), icmd);
-   dev->part = part;
+   edit_device_codes_dev(dev, ocmd, icmd);
       
    /*
     * Wait at most the time a maximum size part is written in DVD 0.5x speed
@@ -307,7 +300,11 @@ static bool dvd_write_part(DCR *dcr)
    
    Dmsg2(29, "dvd_write_part: cmd=%s timeout=%d\n", ocmd.c_str(), timeout);
       
+{
+   POOL_MEM results(PM_MESSAGE);
+   sm_check(__FILE__, __LINE__, false);
    status = run_program_full_output(ocmd.c_str(), timeout, results.c_str());
+   sm_check(__FILE__, __LINE__, false);
    if (status != 0) {
       Mmsg1(dev->errmsg, "Error while writing current part to the DVD: %s", 
             results.c_str());
@@ -315,15 +312,21 @@ static bool dvd_write_part(DCR *dcr)
       dev->dev_errno = EIO;
       return false;
    }
+   sm_check(__FILE__, __LINE__, false);
+}
 
+{
    POOL_MEM archive_name(PM_FNAME);
    /* Delete spool file */
    make_spooled_dvd_filename(dev, archive_name);
    unlink(archive_name.c_str());
    Dmsg1(29, "unlink(%s)\n", archive_name.c_str());
+   sm_check(__FILE__, __LINE__, false);
+}
    update_free_space_dev(dev);
    Jmsg(dcr->jcr, M_INFO, 0, _("Remaining free space %s on %s\n"), 
       edit_uint64_with_commas(dev->free_space, ed1), dev->print_name());
+   sm_check(__FILE__, __LINE__, false);
    return true;
 }
 
@@ -392,6 +395,7 @@ int open_next_part(DCR *dcr)
          return -1;
       }
 
+      Dmsg2(100, "Set npart=%d to part=%d\n", dev->num_parts, dev->part);
       dev->num_parts = dev->part;
       dev->VolCatInfo.VolCatParts = dev->part;
       make_spooled_dvd_filename(dev, archive_name);   /* makes spool name */
@@ -410,6 +414,7 @@ int open_next_part(DCR *dcr)
       }
    }
    if (dev->num_parts < dev->part) {
+      Dmsg2(100, "Set npart=%d to part=%d\n", dev->num_parts, dev->part);
       dev->num_parts = dev->part;
       dev->VolCatInfo.VolCatParts = dev->part;
    }
@@ -434,7 +439,7 @@ int open_first_part(DCR *dcr, int mode)
 {
    DEVICE *dev = dcr->dev;
 
-   Dmsg3(29, "Enter: ==== open_first_part dev=%s Vol=%s mode=%d\n", dev->dev_name
+   Dmsg3(29, "Enter: ==== open_first_part dev=%s Vol=%s mode=%d\n", dev->print_name()
          dev->VolCatInfo.VolCatName, dev->openmode);
 
    if (dev->fd >= 0) {
@@ -613,6 +618,7 @@ bool dvd_close_job(DCR *dcr)
  * Edit codes into (Un)MountCommand, Write(First)PartCommand
  *  %% = %
  *  %a = archive device name
+ *  %e = erase (set if cannot mount and first part)  
  *  %m = mount point
  *  %v = last part name
  *
@@ -620,7 +626,7 @@ bool dvd_close_job(DCR *dcr)
  *  imsg = input string containing edit codes (%x)
  *
  */
-static char *edit_device_codes_dev(DEVICE* dev, char *omsg, const char *imsg)
+static void edit_device_codes_dev(DEVICE* dev, POOL_MEM &omsg, const char *imsg)
 {
    const char *p;
    const char *str;
@@ -628,7 +634,7 @@ static char *edit_device_codes_dev(DEVICE* dev, char *omsg, const char *imsg)
    
    POOL_MEM archive_name(PM_FNAME);
 
-   *omsg = 0;
+   omsg.c_str()[0] = 0;
    Dmsg1(800, "edit_device_codes: %s\n", imsg);
    for (p=imsg; *p; p++) {
       if (*p == '%') {
@@ -636,13 +642,20 @@ static char *edit_device_codes_dev(DEVICE* dev, char *omsg, const char *imsg)
          case '%':
             str = "%";
             break;
+         case 'a':
+            str = dev->dev_name;
+            break;
+         case 'e':
+            if (dev->part == 1 && !dev->is_mounted()) {
+               str = "1";
+            } else {
+               str = "0";
+            }
+            break;
          case 'n':
             bsnprintf(add, sizeof(add), "%d", dev->part);
             str = add;
             break;
-         case 'a':
-            str = dev->dev_name;
-            break;
          case 'm':
             str = dev->device->mount_point;
             break;
@@ -663,8 +676,7 @@ static char *edit_device_codes_dev(DEVICE* dev, char *omsg, const char *imsg)
          str = add;
       }
       Dmsg1(1900, "add_str %s\n", str);
-      pm_strcat(&omsg, (char *)str);
-      Dmsg1(1800, "omsg=%s\n", omsg);
+      pm_strcat(omsg, (char *)str);
+      Dmsg1(1800, "omsg=%s\n", omsg.c_str());
    }
-   return omsg;
 }
index 50357885a27714d0f818cd6a3b612a7ba33f7ea8..c6bd1391d8638c74a2bdcfe9e8914240790b2621 100644 (file)
@@ -983,20 +983,24 @@ void dump_label_record(DEVICE *dev, DEV_RECORD *rec, int verbose)
       }
    } else {
       SESSION_LABEL label;
+      char dt[50];
       switch (rec->FileIndex) {
       case SOS_LABEL:
          unser_session_label(&label, rec);
-         Pmsg8(-1, "%s Record: File:blk=%u:%u SessId=%d SessTime=%d JobId=%d Level=%c Type=%c\n",
-            type, dev->file, dev->block_num, rec->VolSessionId, rec->VolSessionTime, rec->Stream,
-            label.JobLevel, label.JobType);
+         bstrftimes(dt, sizeof(dt), btime_to_unix(label.write_btime));
+         Pmsg6(-1, "%s Record: File:blk=%u:%u SessId=%d SessTime=%d JobId=%d\n",
+            type, dev->file, dev->block_num, rec->VolSessionId, rec->VolSessionTime, label.JobId);
+         Pmsg4(-1, "   Job=%s Date=%s Level=%c Type=%c\n",
+            label.Job, dt, label.JobLevel, label.JobType);
          break;
       case EOS_LABEL:
          char ed1[30], ed2[30];
          unser_session_label(&label, rec);
-         Pmsg8(-1, "%s Record: File:blk=%u:%u SessId=%d SessTime=%d JobId=%d Level=%c Type=%c\n",
-            type, dev->file, dev->block_num, rec->VolSessionId, rec->VolSessionTime, rec->Stream,
-            label.JobLevel, label.JobType);
-         Pmsg4(-1, "   Files=%s Bytes=%s Errors=%d Status=%c\n",
+         bstrftimes(dt, sizeof(dt), btime_to_unix(label.write_btime));
+         Pmsg6(-1, "%s Record: File:blk=%u:%u SessId=%d SessTime=%d JobId=%d\n",
+            type, dev->file, dev->block_num, rec->VolSessionId, rec->VolSessionTime, label.JobId);
+         Pmsg7(-1, "   Date=%s Level=%c Type=%c Files=%s Bytes=%s Errors=%d Status=%c\n",
+            dt, label.JobLevel, label.JobType,
             edit_uint64_with_commas(label.JobFiles, ed1),
             edit_uint64_with_commas(label.JobBytes, ed2),
             label.JobErrors, (char)label.JobStatus);
index b91718ed486885119280e360242e83625754ac9d..508b0abe454f018c486f6e1f4f2072cd16eca81a 100644 (file)
@@ -33,6 +33,7 @@
 /* Forward referenced functions */
 void terminate_stored(int sig);
 static int check_resources();
+static void cleanup_old_files();
 
 extern "C" void *device_initialization(void *arg);
 
@@ -205,6 +206,9 @@ int main (int argc, char *argv[])
 
    drop(uid, gid);
 
+   cleanup_old_files();
+
+
    /* Ensure that Volume Session Time and Id are both
     * set and are both non-zero.
     */
@@ -442,6 +446,22 @@ static int check_resources()
    return OK;
 }
 
+static void cleanup_old_files()
+{
+   POOLMEM *cleanup = get_pool_memory(PM_MESSAGE);
+   int len = strlen(me->working_directory);
+   pm_strcpy(cleanup, "/bin/rm -f ");
+   pm_strcat(cleanup, me->working_directory);
+   if (len > 0 && me->working_directory[len-1] != '/') {
+      pm_strcat(cleanup, "/");
+   }
+   pm_strcat(cleanup, my_name);
+   pm_strcat(cleanup, "*.spool");
+   run_program(cleanup, 0, NULL);
+   free_pool_memory(cleanup);
+}      
+
+
 /*
  * Here we attempt to init and open each device. This is done
  *  once at startup in a separate thread.
index 2180d613fa0611ec1057e47c3f0794716b380b49..33196a4bd57e125956774eedaaf4cb4863c29e25 100644 (file)
@@ -1,8 +1,8 @@
 /* */
 #undef  VERSION
 #define VERSION "1.37.31"
-#define BDATE   "18 July 2005"
-#define LSMDATE "18Jul05"
+#define BDATE   "22 July 2005"
+#define LSMDATE "22Jul05"
 
 /* Debug flags */
 #undef  DEBUG