From: Kern Sibbald Date: Fri, 14 Oct 2005 11:00:51 +0000 (+0000) Subject: Update num_parts only when writing to DVD. X-Git-Tag: Release-1.38.0~72 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=801a71b1d75e5788329c42c3fc19ba7df6894b7d;p=bacula%2Fbacula Update num_parts only when writing to DVD. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2441 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/autoconf/config.h.in b/bacula/autoconf/config.h.in index 7fde428cf9..52663e863e 100644 --- a/bacula/autoconf/config.h.in +++ b/bacula/autoconf/config.h.in @@ -96,6 +96,9 @@ very expensive. */ #undef CACHE_IDS +/* Define if you have the header file */ +#undef HAVE_SYS_STATVFS_H + /* Define to use SVR4 statvfs to get filesystem type. */ #undef FSTYPE_STATVFS @@ -776,9 +779,9 @@ /* If using the C implementation of alloca, define if you know the direction of stack growth for your system; otherwise it will be automatically deduced at run-time. - STACK_DIRECTION > 0 => grows toward higher addresses - STACK_DIRECTION < 0 => grows toward lower addresses - STACK_DIRECTION = 0 => direction of growth unknown */ + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown */ #undef STACK_DIRECTION /* Define to 1 if the `S_IS*' macros in do not work properly. */ diff --git a/bacula/autoconf/configure.in b/bacula/autoconf/configure.in index 7a01825bb1..9b1e5152c3 100644 --- a/bacula/autoconf/configure.in +++ b/bacula/autoconf/configure.in @@ -1271,6 +1271,8 @@ AC_TRY_CPP([#include fi AC_MSG_RESULT($fstype) +AC_CHECK_HEADER(sys/statvfs.h, [ AC_DEFINE(HAVE_SYS_STATVFS_H,1,[Defines if your system have the sys/statvfs.h header file])] , ) + dnl# -------------------------------------------------------------------------- dnl# CHECKING FOR TYPEDEFS, STRUCTURES, AND COMPILER CHARACTERISTICS. dnl# -------------------------------------------------------------------------- diff --git a/bacula/configure b/bacula/configure index 32f932f7a9..692a7f9f55 100755 --- a/bacula/configure +++ b/bacula/configure @@ -20959,6 +20959,153 @@ fi echo "$as_me:$LINENO: result: $fstype" >&5 echo "${ECHO_T}$fstype" >&6 +if test "${ac_cv_header_sys_statvfs_h+set}" = set; then + echo "$as_me:$LINENO: checking for sys/statvfs.h" >&5 +echo $ECHO_N "checking for sys/statvfs.h... $ECHO_C" >&6 +if test "${ac_cv_header_sys_statvfs_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: $ac_cv_header_sys_statvfs_h" >&5 +echo "${ECHO_T}$ac_cv_header_sys_statvfs_h" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking sys/statvfs.h usability" >&5 +echo $ECHO_N "checking sys/statvfs.h usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_header_compiler=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking sys/statvfs.h presence" >&5 +echo $ECHO_N "checking sys/statvfs.h presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: sys/statvfs.h: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: sys/statvfs.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: sys/statvfs.h: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: sys/statvfs.h: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: sys/statvfs.h: present but cannot be compiled" >&5 +echo "$as_me: WARNING: sys/statvfs.h: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: sys/statvfs.h: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: sys/statvfs.h: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: sys/statvfs.h: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: sys/statvfs.h: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: sys/statvfs.h: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: sys/statvfs.h: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: sys/statvfs.h: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: sys/statvfs.h: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: sys/statvfs.h: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: sys/statvfs.h: in the future, the compiler will take precedence" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------------ ## +## Report this to the AC_PACKAGE_NAME lists. ## +## ------------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for sys/statvfs.h" >&5 +echo $ECHO_N "checking for sys/statvfs.h... $ECHO_C" >&6 +if test "${ac_cv_header_sys_statvfs_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_header_sys_statvfs_h=$ac_header_preproc +fi +echo "$as_me:$LINENO: result: $ac_cv_header_sys_statvfs_h" >&5 +echo "${ECHO_T}$ac_cv_header_sys_statvfs_h" >&6 + +fi +if test $ac_cv_header_sys_statvfs_h = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_SYS_STATVFS_H 1 +_ACEOF + +fi + + + echo "$as_me:$LINENO: checking return type of signal handlers" >&5 echo $ECHO_N "checking return type of signal handlers... $ECHO_C" >&6 if test "${ac_cv_type_signal+set}" = set; then diff --git a/bacula/kes-1.37 b/bacula/kes-1.37 index 871ce2afc8..13b57f8231 100644 --- a/bacula/kes-1.37 +++ b/bacula/kes-1.37 @@ -4,6 +4,9 @@ General: Changes to 1.37.41: +14Oct05 +- Add NetBSD fstype patch from Geert Hendrickx +- Update num_parts only when writing to DVD. 13Oct05 - Fix error conditions in bpipe.c DVD routine (terminate buffer). - Use a bigger buffer 32K as suggested by Arno in bpipe.c. diff --git a/bacula/src/findlib/fstype.c b/bacula/src/findlib/fstype.c index 416e7bc382..6182c6bc96 100644 --- a/bacula/src/findlib/fstype.c +++ b/bacula/src/findlib/fstype.c @@ -45,19 +45,19 @@ "HAVE_NETBSD_OS\n" \ "HAVE_OPENBSD_OS\n" \ "HAVE_SUN_OS\n" -#define bool int -#define false 0 -#define true 1 -#define bstrncpy strncpy -#define Dmsg0(n,s) fprintf(stderr, s) -#define Dmsg1(n,s,a1) fprintf(stderr, s, a1) +#define bool int +#define false 0 +#define true 1 +#define bstrncpy strncpy +#define Dmsg0(n,s) fprintf(stderr, s) +#define Dmsg1(n,s,a1) fprintf(stderr, s, a1) #define Dmsg2(n,s,a1,a2) fprintf(stderr, s, a1, a2) #endif /* * These functions should be implemented for each OS * - * bool fstype(const char *fname, char *fs, int fslen); + * bool fstype(const char *fname, char *fs, int fslen); */ #if defined(HAVE_DARWIN_OS) \ || defined(HAVE_FREEBSD_OS ) \ @@ -79,6 +79,11 @@ bool fstype(const char *fname, char *fs, int fslen) #elif defined(HAVE_NETBSD_OS) #include #include +#ifdef HAVE_SYS_STATVFS_H +#include +#else +#define statvfs statfs +#endif bool fstype(const char *fname, char *fs, int fslen) { @@ -126,7 +131,7 @@ bool fstype(const char *fname, char *fs, int fslen) /* Known good values */ case 0xef53: bstrncpy(fs, "ext2", fslen); return true; /* EXT2_SUPER_MAGIC */ - /* case 0xef53: ext2 and ext3 are the same */ /* EXT3_SUPER_MAGIC */ + /* case 0xef53: ext2 and ext3 are the same */ /* EXT3_SUPER_MAGIC */ case 0x3153464a: bstrncpy(fs, "jfs", fslen); return true; /* JFS_SUPER_MAGIC */ case 0x5346544e: bstrncpy(fs, "ntfs", fslen); return true; /* NTFS_SB_MAGIC */ case 0x9fa0: bstrncpy(fs, "proc", fslen); return true; /* PROC_SUPER_MAGIC */ @@ -137,7 +142,7 @@ bool fstype(const char *fname, char *fs, int fslen) case 0x517B: bstrncpy(fs, "smbfs", fslen); return true; /* SMB_SUPER_MAGIC */ case 0x9660: bstrncpy(fs, "iso9660", fslen); return true; /* ISOFS_SUPER_MAGIC */ -#if 0 /* These need confirmation */ +#if 0 /* These need confirmation */ case 0xadf5: bstrncpy(fs, "adfs", fslen); return true; /* ADFS_SUPER_MAGIC */ case 0xadff: bstrncpy(fs, "affs", fslen); return true; /* AFFS_SUPER_MAGIC */ case 0x6B414653: bstrncpy(fs, "afs", fslen); return true; /* AFS_FS_MAGIC */ @@ -199,8 +204,8 @@ bool fstype(const char *fname, char *fs, int fslen) default: Dmsg2(10, "Unknown file system type \"0x%x\" for \"%s\".\n", st.f_type, - fname); - return false; + fname); + return false; } } Dmsg1(50, "statfs() failed for \"%s\"\n", fname); @@ -247,14 +252,14 @@ bool fstype(const char *fname, char *fs, int fslen) } /* Tru64 */ -#else /* No recognised OS */ +#else /* No recognised OS */ bool fstype(const char *fname, char *fs, int fslen) { Dmsg0(10, "!!! fstype() not implemented for this OS. !!!\n"); #ifdef TEST_PROGRAM Dmsg1(10, "Please define one of the following when compiling:\n\n%s\n", - SUPPORTEDOSES); + SUPPORTEDOSES); exit(EXIT_FAILURE); #endif @@ -273,12 +278,12 @@ int main(int argc, char **argv) p = (argc < 1) ? "fstype" : argv[0]; printf("usage:\t%s path ...\n" "\t%s prints the file system type and pathname of the paths.\n", - p, p); + p, p); return EXIT_FAILURE; } while (*++argv) { if (!fstype(*argv, fs, sizeof(fs))) { - status = EXIT_FAILURE; + status = EXIT_FAILURE; } else { printf("%s\t%s\n", fs, *argv); } diff --git a/bacula/src/stored/block.c b/bacula/src/stored/block.c index 042240b66a..293a782f82 100644 --- a/bacula/src/stored/block.c +++ b/bacula/src/stored/block.c @@ -682,7 +682,7 @@ static bool terminate_writing_volume(DCR *dcr) dcr->block->write_failed = true; if (weof_dev(dev, 1) != 0) { /* end the tape */ dev->VolCatInfo.VolCatErrors++; - Jmsg(dcr->jcr, M_ERROR, 0, _("Error writing final EOF to tape. This tape may not be readable.\n" + Jmsg(dcr->jcr, M_ERROR, 0, _("Error writing final EOF to tape. This Volume may not be readable.\n" "%s"), dev->errmsg); ok = false; Dmsg0(100, "WEOF error.\n"); diff --git a/bacula/src/stored/dvd.c b/bacula/src/stored/dvd.c index ef4e69f344..9e62acfe91 100644 --- a/bacula/src/stored/dvd.c +++ b/bacula/src/stored/dvd.c @@ -305,6 +305,8 @@ bool dvd_write_part(DCR *dcr) { DEVICE *dev = dcr->dev; POOL_MEM ocmd(PM_FNAME); + POOL_MEM results(PM_MESSAGE); + POOL_MEM archive_name(PM_FNAME); char* icmd; int status; int timeout; @@ -326,30 +328,24 @@ 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()); - Dmsg1(000, "%s", dev->errmsg); - dev->dev_errno = EIO; - mark_volume_in_error(dcr); - return false; - } + status = run_program_full_output(ocmd.c_str(), timeout, results.c_str()); + if (status != 0) { + Mmsg1(dev->errmsg, _("Error while writing current part to the DVD: %s"), + results.c_str()); + Dmsg1(000, "%s", dev->errmsg); + dev->dev_errno = EIO; + mark_volume_in_error(dcr); sm_check(__FILE__, __LINE__, false); + return false; + } else { + dev->num_parts++; /* there is no one more part on DVD */ } - { - 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); - } + /* 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); /* growisofs umounted the device, so remount it (it will update the free space) */ dev->clear_mounted(); @@ -397,6 +393,7 @@ int dvd_open_next_part(DCR *dcr) */ if (dev->is_dvd() && (dev->part >= dev->num_parts) && dev->can_append()) { if (!dvd_write_part(dcr)) { + Dmsg0(29, "Error in dvd_write part.\n"); return -1; } } @@ -429,8 +426,7 @@ int dvd_open_next_part(DCR *dcr) } } - Dmsg2(100, "Set npart=%d to part=%d\n", dev->num_parts, dev->part); - dev->num_parts = dev->part; + Dmsg2(100, "num_parts=%d part=%d\n", dev->num_parts, dev->part); dev->VolCatInfo.VolCatParts = dev->part; make_spooled_dvd_filename(dev, archive_name); /* makes spool name */ @@ -447,6 +443,11 @@ int dvd_open_next_part(DCR *dcr) } } } + /* KES. It seems to me that this if should not be + * needed. If num_parts represents what is on the DVD + * we should only need to change it when writing a part + * to the DVD. + */ 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; diff --git a/bacula/src/version.h b/bacula/src/version.h index 71e431a389..9de28b7b26 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -4,8 +4,8 @@ #undef VERSION #define VERSION "1.37.41" -#define BDATE "13 October 2005" -#define LSMDATE "13Oct05" +#define BDATE "14 October 2005" +#define LSMDATE "14Oct05" /* Debug flags */ #undef DEBUG