From f29c2d619d081529297b745a46dfc29902735ffd Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Thu, 10 Oct 2002 16:59:40 +0000 Subject: [PATCH] Win32 fixes -- see kes10Oct02 git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@169 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/autoconf/acconfig.h | 3 + bacula/autoconf/config.h.in | 4 +- bacula/autoconf/configure.in | 1 + bacula/configure | 200 +++++++++++++++++++---------- bacula/src/baconfig.h | 7 + bacula/src/cats/sql_get.c | 15 ++- bacula/src/dird/bacula-dir.conf.in | 2 +- bacula/src/dird/job.c | 7 +- bacula/src/dird/ua_restore.c | 34 ++++- bacula/src/dird/ua_run.c | 19 ++- bacula/src/filed/restore.c | 44 ++++--- bacula/src/lib/bnet_server.c | 4 + bacula/src/lib/message.c | 4 +- bacula/src/lib/tree.c | 20 ++- bacula/src/lib/tree.h | 3 +- bacula/src/version.h | 4 +- 16 files changed, 249 insertions(+), 122 deletions(-) diff --git a/bacula/autoconf/acconfig.h b/bacula/autoconf/acconfig.h index 8da8849a36..250f8b7a8f 100644 --- a/bacula/autoconf/acconfig.h +++ b/bacula/autoconf/acconfig.h @@ -195,3 +195,6 @@ #undef HAVE_READDIR_R #undef HAVE_STRERROR_R #undef HAVE_GETHOSTBYNAME_R + +#undef HAVE_INET_PTON + diff --git a/bacula/autoconf/config.h.in b/bacula/autoconf/config.h.in index 93eedae385..ac49e75470 100644 --- a/bacula/autoconf/config.h.in +++ b/bacula/autoconf/config.h.in @@ -319,6 +319,9 @@ /* Define if you have the getpid function. */ #undef HAVE_GETPID +/* Define if you have the inet_pton function. */ +#undef HAVE_INET_PTON + /* Define if you have the lchown function. */ #undef HAVE_LCHOWN @@ -480,4 +483,3 @@ /* Define for large files, on AIX-style hosts. */ #undef _LARGE_FILES - diff --git a/bacula/autoconf/configure.in b/bacula/autoconf/configure.in index 07661c5466..2a86c70286 100644 --- a/bacula/autoconf/configure.in +++ b/bacula/autoconf/configure.in @@ -972,6 +972,7 @@ AC_CHECK_FUNC(socket, AC_CHECK_LIB(socket,socket) AC_CHECK_LIB(inet,socket)) +AC_CHECK_FUNCS(inet_pton, [AC_DEFINE(HAVE_INET_PTON)]) AC_FUNC_STRFTIME AC_FUNC_VPRINTF diff --git a/bacula/configure b/bacula/configure index 151cafb71c..f909a8e4fc 100755 --- a/bacula/configure +++ b/bacula/configure @@ -8049,14 +8049,72 @@ fi fi +for ac_func in inet_pton +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:8056: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:8084: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <> confdefs.h <<\EOF +#define HAVE_INET_PTON 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi +done + echo $ac_n "checking for strftime""... $ac_c" 1>&6 -echo "configure:8055: checking for strftime" >&5 +echo "configure:8113: checking for strftime" >&5 if eval "test \"`echo '$''{'ac_cv_func_strftime'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8141: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_strftime=yes" else @@ -8101,7 +8159,7 @@ else echo "$ac_t""no" 1>&6 # strftime is in -lintl on SCO UNIX. echo $ac_n "checking for strftime in -lintl""... $ac_c" 1>&6 -echo "configure:8105: checking for strftime in -lintl" >&5 +echo "configure:8163: checking for strftime in -lintl" >&5 ac_lib_var=`echo intl'_'strftime | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -8109,7 +8167,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lintl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8182: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -8147,12 +8205,12 @@ fi fi echo $ac_n "checking for vprintf""... $ac_c" 1>&6 -echo "configure:8151: checking for vprintf" >&5 +echo "configure:8209: checking for vprintf" >&5 if eval "test \"`echo '$''{'ac_cv_func_vprintf'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8237: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_vprintf=yes" else @@ -8199,12 +8257,12 @@ fi if test "$ac_cv_func_vprintf" != yes; then echo $ac_n "checking for _doprnt""... $ac_c" 1>&6 -echo "configure:8203: checking for _doprnt" >&5 +echo "configure:8261: checking for _doprnt" >&5 if eval "test \"`echo '$''{'ac_cv_func__doprnt'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8289: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func__doprnt=yes" else @@ -8254,19 +8312,19 @@ fi # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works # for constant arguments. Useless! echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6 -echo "configure:8258: checking for working alloca.h" >&5 +echo "configure:8316: checking for working alloca.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { char *p = alloca(2 * sizeof(int)); ; return 0; } EOF -if { (eval echo configure:8270: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8328: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_header_alloca_h=yes else @@ -8287,12 +8345,12 @@ EOF fi echo $ac_n "checking for alloca""... $ac_c" 1>&6 -echo "configure:8291: checking for alloca" >&5 +echo "configure:8349: checking for alloca" >&5 if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8382: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_func_alloca_works=yes else @@ -8352,12 +8410,12 @@ EOF echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6 -echo "configure:8356: checking whether alloca needs Cray hooks" >&5 +echo "configure:8414: checking whether alloca needs Cray hooks" >&5 if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&6 if test $ac_cv_os_cray = yes; then for ac_func in _getb67 GETB67 getb67; do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:8386: checking for $ac_func" >&5 +echo "configure:8444: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8472: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -8437,7 +8495,7 @@ done fi echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6 -echo "configure:8441: checking stack direction for C alloca" >&5 +echo "configure:8499: checking stack direction for C alloca" >&5 if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -8445,7 +8503,7 @@ else ac_cv_c_stack_direction=0 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:8526: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_c_stack_direction=1 else @@ -8487,7 +8545,7 @@ fi # getmntent is in -lsun on Irix 4, -lseq on Dynix/PTX, -lgen on Unixware. echo $ac_n "checking for getmntent in -lsun""... $ac_c" 1>&6 -echo "configure:8491: checking for getmntent in -lsun" >&5 +echo "configure:8549: checking for getmntent in -lsun" >&5 ac_lib_var=`echo sun'_'getmntent | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -8495,7 +8553,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lsun $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8568: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -8525,7 +8583,7 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then else echo "$ac_t""no" 1>&6 echo $ac_n "checking for getmntent in -lseq""... $ac_c" 1>&6 -echo "configure:8529: checking for getmntent in -lseq" >&5 +echo "configure:8587: checking for getmntent in -lseq" >&5 ac_lib_var=`echo seq'_'getmntent | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -8533,7 +8591,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lseq $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8606: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -8563,7 +8621,7 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then else echo "$ac_t""no" 1>&6 echo $ac_n "checking for getmntent in -lgen""... $ac_c" 1>&6 -echo "configure:8567: checking for getmntent in -lgen" >&5 +echo "configure:8625: checking for getmntent in -lgen" >&5 ac_lib_var=`echo gen'_'getmntent | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -8571,7 +8629,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lgen $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8644: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -8607,12 +8665,12 @@ fi fi echo $ac_n "checking for getmntent""... $ac_c" 1>&6 -echo "configure:8611: checking for getmntent" >&5 +echo "configure:8669: checking for getmntent" >&5 if eval "test \"`echo '$''{'ac_cv_func_getmntent'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8697: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_getmntent=yes" else @@ -8658,7 +8716,7 @@ else fi echo $ac_n "checking whether closedir returns void""... $ac_c" 1>&6 -echo "configure:8662: checking whether closedir returns void" >&5 +echo "configure:8720: checking whether closedir returns void" >&5 if eval "test \"`echo '$''{'ac_cv_func_closedir_void'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -8666,13 +8724,13 @@ else ac_cv_func_closedir_void=yes else cat > conftest.$ac_ext < #include <$ac_header_dirent> int closedir(); main() { exit(closedir(opendir(".")) != 0); } EOF -if { (eval echo configure:8676: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:8734: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_func_closedir_void=no else @@ -8695,7 +8753,7 @@ EOF fi echo $ac_n "checking whether setpgrp takes no argument""... $ac_c" 1>&6 -echo "configure:8699: checking whether setpgrp takes no argument" >&5 +echo "configure:8757: checking whether setpgrp takes no argument" >&5 if eval "test \"`echo '$''{'ac_cv_func_setpgrp_void'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -8703,7 +8761,7 @@ else { echo "configure: error: cannot check setpgrp if cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:8785: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_func_setpgrp_void=no else @@ -8746,7 +8804,7 @@ EOF fi echo $ac_n "checking for working fnmatch""... $ac_c" 1>&6 -echo "configure:8750: checking for working fnmatch" >&5 +echo "configure:8808: checking for working fnmatch" >&5 if eval "test \"`echo '$''{'ac_cv_func_fnmatch_works'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -8757,11 +8815,11 @@ if test "$cross_compiling" = yes; then ac_cv_func_fnmatch_works=no else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:8823: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_func_fnmatch_works=yes else @@ -8786,7 +8844,7 @@ fi echo $ac_n "checking for setlocale in -lxpg4""... $ac_c" 1>&6 -echo "configure:8790: checking for setlocale in -lxpg4" >&5 +echo "configure:8848: checking for setlocale in -lxpg4" >&5 ac_lib_var=`echo xpg4'_'setlocale | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -8794,7 +8852,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lxpg4 $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8867: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -8828,7 +8886,7 @@ fi echo $ac_n "checking for getpwnam in -lsun""... $ac_c" 1>&6 -echo "configure:8832: checking for getpwnam in -lsun" >&5 +echo "configure:8890: checking for getpwnam in -lsun" >&5 ac_lib_var=`echo sun'_'getpwnam | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -8836,7 +8894,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lsun $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8909: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -8879,17 +8937,17 @@ for ac_hdr in zlib.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:8883: checking for $ac_hdr" >&5 +echo "configure:8941: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:8893: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:8951: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -8916,7 +8974,7 @@ fi done echo $ac_n "checking for deflate in -lz""... $ac_c" 1>&6 -echo "configure:8920: checking for deflate in -lz" >&5 +echo "configure:8978: checking for deflate in -lz" >&5 ac_lib_var=`echo z'_'deflate | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -8924,7 +8982,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lz $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8997: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -8966,7 +9024,7 @@ fi PTHREAD_LIB="" echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6 -echo "configure:8970: checking for pthread_create in -lpthread" >&5 +echo "configure:9028: checking for pthread_create in -lpthread" >&5 ac_lib_var=`echo pthread'_'pthread_create | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -8974,7 +9032,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lpthread $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:9047: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -9004,7 +9062,7 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then else echo "$ac_t""no" 1>&6 echo $ac_n "checking for pthread_create in -lpthreads""... $ac_c" 1>&6 -echo "configure:9008: checking for pthread_create in -lpthreads" >&5 +echo "configure:9066: checking for pthread_create in -lpthreads" >&5 ac_lib_var=`echo pthreads'_'pthread_create | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -9012,7 +9070,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lpthreads $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:9085: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -9042,7 +9100,7 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then else echo "$ac_t""no" 1>&6 echo $ac_n "checking for pthread_create in -lc_r""... $ac_c" 1>&6 -echo "configure:9046: checking for pthread_create in -lc_r" >&5 +echo "configure:9104: checking for pthread_create in -lc_r" >&5 ac_lib_var=`echo c_r'_'pthread_create | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -9050,7 +9108,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lc_r $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:9123: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -9080,12 +9138,12 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then else echo "$ac_t""no" 1>&6 echo $ac_n "checking for pthread_create""... $ac_c" 1>&6 -echo "configure:9084: checking for pthread_create" >&5 +echo "configure:9142: checking for pthread_create" >&5 if eval "test \"`echo '$''{'ac_cv_func_pthread_create'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:9170: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_pthread_create=yes" else diff --git a/bacula/src/baconfig.h b/bacula/src/baconfig.h index a76333b92f..e03d0c1ee8 100644 --- a/bacula/src/baconfig.h +++ b/bacula/src/baconfig.h @@ -333,4 +333,11 @@ extern int thr_setconcurrency(int); #define ALIGN_SIZE (sizeof(double)) #define BALIGN(x) (((x) + ALIGN_SIZE - 1) & ~(ALIGN_SIZE -1)) + +/* Added by KES to deal with Win32 systems */ +#ifndef S_ISWIN32 +#define S_ISWIN32 020000 +#endif + + #endif /* _BACONFIG_H */ diff --git a/bacula/src/cats/sql_get.c b/bacula/src/cats/sql_get.c index eb021b4000..3363877487 100644 --- a/bacula/src/cats/sql_get.c +++ b/bacula/src/cats/sql_get.c @@ -128,16 +128,16 @@ int db_get_file_attributes_record(B_DB *mdb, char *fname, FILE_DBR *fdbr) pnl = 1; } - Dmsg1(100, "spath=%s\n", spath); - Dmsg1(100, "file=%s\n", file); + Dmsg1(400, "spath=%s\n", spath); + Dmsg1(400, "file=%s\n", file); db_escape_string(buf, file, fnl); fdbr->FilenameId = db_get_filename_record(mdb, buf); - Dmsg2(100, "db_get_filename_record FilenameId=%u file=%s\n", fdbr->FilenameId, buf); + Dmsg2(400, "db_get_filename_record FilenameId=%u file=%s\n", fdbr->FilenameId, buf); db_escape_string(buf, spath, pnl); fdbr->PathId = db_get_path_record(mdb, buf); - Dmsg2(100, "db_get_path_record PathId=%u path=%s\n", fdbr->PathId, buf); + Dmsg2(400, "db_get_path_record PathId=%u path=%s\n", fdbr->PathId, buf); stat = db_get_file_record(mdb, fdbr); @@ -192,6 +192,9 @@ File.FilenameId=%u", fdbr->JobId, fdbr->PathId, fdbr->FilenameId); fdbr->MD5[sizeof(fdbr->MD5)] = 0; stat = 1; } + } else { + Mmsg2(&mdb->errmsg, _("File record not found for PathId=%u FilenameId=%u\n"), + fdbr->PathId, fdbr->FilenameId); } sql_free_result(mdb); } @@ -236,6 +239,8 @@ static int db_get_filename_record(B_DB *mdb, char *fname) FilenameId = 0; } } + } else { + Mmsg1(&mdb->errmsg, _("Filename record: %s not found.\n"), fname); } sql_free_result(mdb); } @@ -294,6 +299,8 @@ static int db_get_path_record(B_DB *mdb, char *path) } } } + } else { + Mmsg1(&mdb->errmsg, _("Path record: %s not found.\n"), path); } sql_free_result(mdb); } diff --git a/bacula/src/dird/bacula-dir.conf.in b/bacula/src/dird/bacula-dir.conf.in index 5bebcb0411..fbed802461 100644 --- a/bacula/src/dird/bacula-dir.conf.in +++ b/bacula/src/dird/bacula-dir.conf.in @@ -45,7 +45,7 @@ Job { Storage = DLTDrive Messages = Standard Pool = Default - Where = /tmp + Where = /tmp/bacula-restores } diff --git a/bacula/src/dird/job.c b/bacula/src/dird/job.c index ebf9bac1b4..c5556aaf1a 100644 --- a/bacula/src/dird/job.c +++ b/bacula/src/dird/job.c @@ -274,17 +274,18 @@ void create_unique_job_name(JCR *jcr, char *base_name) * thus unique Job Name */ P(mutex); /* lock creation of jobs */ - time(&now); + now = time(NULL); while (now == last_start_time) { sleep(1); - time(&now); + now = time(NULL); } last_start_time = now; V(mutex); /* allow creation of jobs */ jcr->start_time = now; /* Form Unique JobName */ localtime_r(&now, &tm); - strftime(dt, sizeof(dt), "%Y-%m-%d.%H:%M:%S", &tm); + /* Use only characters that are permitted in Windows filenames */ + strftime(dt, sizeof(dt), "%Y-%m-%d_%H.%M.%S", &tm); strncpy(name, base_name, sizeof(name)); name[sizeof(name)-22] = 0; /* truncate if too long */ sprintf(jcr->Job, "%s.%s", name, dt); /* add date & time */ diff --git a/bacula/src/dird/ua_restore.c b/bacula/src/dird/ua_restore.c index 6fc2cb3b85..807efa13db 100644 --- a/bacula/src/dird/ua_restore.c +++ b/bacula/src/dird/ua_restore.c @@ -132,6 +132,7 @@ int restorecmd(UAContext *ua, char *cmd) JOB *restore_job = NULL; int restore_jobs = 0; NAME_LIST name_list; + uint32_t selected_files = 0; if (!open_db(ua)) { return 0; @@ -219,6 +220,7 @@ int restorecmd(UAContext *ua, char *cmd) if (node->extract) { Dmsg2(400, "type=%d FI=%d\n", node->type, node->FileIndex); add_findex(bsr, node->JobId, node->FileIndex); + selected_files++; } } @@ -232,6 +234,7 @@ int restorecmd(UAContext *ua, char *cmd) } // print_bsr(ua, bsr); write_bsr_file(ua, bsr); + bsendmsg(ua, _("\n%u files selected to restore.\n\n"), selected_files); } else { bsendmsg(ua, _("No files selected to restore.\n")); } @@ -832,7 +835,11 @@ static int insert_tree_handler(void *ctx, int num_fields, char **row) strip_trailing_junk(row[1]); if (*row[1] == 0) { - type = TN_DIR; + if (*row[0] != '/') { /* Must be Win32 directory */ + type = TN_DIR_NLS; + } else { + type = TN_DIR; + } } else { type = TN_FILE; } @@ -843,7 +850,7 @@ static int insert_tree_handler(void *ctx, int num_fields, char **row) node = new_tree_node(tree->root, type); tree->avail_node = node; } - Dmsg2(400, "FI=%d fname=%s\n", node->FileIndex, fname); + Dmsg3(200, "FI=%d type=%d fname=%s\n", node->FileIndex, type, fname); new_node = insert_tree_node(fname, node, tree->root, NULL); /* Note, if node already exists, save new one for next time */ if (new_node != node) { @@ -958,6 +965,8 @@ static void ls_output(char *buf, char *fname, struct stat *statp) char ec1[30]; int n; +// Dmsg2(000, "%s mode=0%o\n", fname, statp->st_mode); + p = encode_mode(statp->st_mode, buf); n = sprintf(p, " %2d ", (uint32_t)statp->st_nlink); p += n; @@ -997,6 +1006,10 @@ static int dircmd(UAContext *ua, TREE_CTX *tree) decode_stat(fdbr.LStat, &statp); /* decode stat pkt */ ls_output(buf, cwd, &statp); bsendmsg(ua, "%s\n", buf); + } else { + /* Something went wrong getting attributes -- print name */ + bsendmsg(ua, "%s%s%s\n", node->extract?"*":"", node->fname, + (node->type==TN_DIR||node->type==TN_NEWDIR)?"/":""); } } } @@ -1017,6 +1030,11 @@ static int helpcmd(UAContext *ua, TREE_CTX *tree) return 1; } +/* + * Change directories. Note, if the user specifies x: and it fails, + * we assume it is a Win32 absolute cd rather than relative and + * try a second time with /x: ... Win32 kludge. + */ static int cdcmd(UAContext *ua, TREE_CTX *tree) { TREE_NODE *node; @@ -1027,7 +1045,17 @@ static int cdcmd(UAContext *ua, TREE_CTX *tree) } node = tree_cwd(ua->argk[1], tree->root, tree->node); if (!node) { - bsendmsg(ua, _("Invalid path given.\n")); + /* Try once more if Win32 drive -- make absolute */ + if (ua->argk[1][1] == ':') { /* win32 drive */ + strcpy(cwd, "/"); + strcat(cwd, ua->argk[1]); + node = tree_cwd(cwd, tree->root, tree->node); + } + if (!node) { + bsendmsg(ua, _("Invalid path given.\n")); + } else { + tree->node = node; + } } else { tree->node = node; } diff --git a/bacula/src/dird/ua_run.c b/bacula/src/dird/ua_run.c index 63afffc465..8703957cb7 100644 --- a/bacula/src/dird/ua_run.c +++ b/bacula/src/dird/ua_run.c @@ -481,18 +481,17 @@ JobId: %s\n"), goto try_again; case 6: /* Where */ - if (!get_cmd(ua, _("Please enter path prefix (where) for restore: "))) { + if (!get_cmd(ua, _("Please enter path prefix for restore (/ for none): "))) { break; } - /* ***FIXME*** allow drive:/ for Windows */ - if (ua->cmd[0] != 0 && ua->cmd[0] != '/') { - bsendmsg(ua, _("Prefix must be null or begin with a /\n")); - } else { - if (jcr->RestoreWhere) { - free(jcr->RestoreWhere); - } - jcr->RestoreWhere = bstrdup(ua->cmd); - } + if (jcr->RestoreWhere) { + free(jcr->RestoreWhere); + jcr->RestoreWhere = NULL; + } + if (ua->cmd[0] == '/' && ua->cmd[1] == 0) { + ua->cmd[0] = 0; + } + jcr->RestoreWhere = bstrdup(ua->cmd); goto try_again; case 7: /* JobId */ diff --git a/bacula/src/filed/restore.c b/bacula/src/filed/restore.c index 9ee8f9fd9e..14f9c77501 100644 --- a/bacula/src/filed/restore.c +++ b/bacula/src/filed/restore.c @@ -179,42 +179,48 @@ void do_restore(JCR *jcr) } decode_stat(ap, &statp); + /* + * ***FIXME*** add REAL Win32 code to backup.c + * Temp kludge so that low level routines (set_statp) know + * we are dealing with a Win32 system. + */ +#ifdef HAVE_CYGWIN + statp.st_mode |= S_ISWIN32; +#endif /* * Prepend the where directory so that the * files are put where the user wants. * * We do a little jig here to handle Win32 files with - * a drive letter. - * If where is null and we are running on a win32 client, - * change nothing. - * Otherwise, if the second character of the filename is a - * colon (:), change it into a slash (/) -- this creates - * a reasonable pathname on most systems. + * a drive letter -- we simply strip the drive: from + * every filename if a prefix is supplied. + * */ - if (jcr->where[0] == 0 && win32_client) { + if (jcr->where[0] == 0) { strcpy(ofile, fname); strcpy(lname, lp); } else { - strcpy(ofile, jcr->where); - if (fname[1] == ':') { - fname[1] = '/'; - strcat(ofile, fname); - fname[1] = ':'; + char *fn; + strcpy(ofile, jcr->where); /* copy prefix */ + if (win32_client && fname[1] == ':') { + fn = fname+2; /* skip over drive: */ } else { - strcat(ofile, fname); + fn = fname; /* take whole name */ + } + /* Ensure where is terminated with a slash */ + if (jcr->where[wherelen-1] != '/' && fn[0] != '/') { + strcat(ofile, "/"); } + strcat(ofile, fn); /* copy rest of name */ /* Fixup link name */ if (type == FT_LNK || type == FT_LNKSAVED) { if (lp[0] == '/') { /* if absolute path */ strcpy(lname, jcr->where); } - /* ***FIXME**** we shouldn't have links on Windoz */ - if (lp[1] == ':') { - lp[1] = '/'; - strcat(lname, lp); - lp[1] = ':'; + if (win32_client && lp[1] == ':') { + strcat(lname, lp+2); /* copy rest of name */ } else { - strcat(lname, lp); + strcat(lname, lp); /* On Unix systems we take everything */ } } } diff --git a/bacula/src/lib/bnet_server.c b/bacula/src/lib/bnet_server.c index 1841e0f69d..d61521b162 100644 --- a/bacula/src/lib/bnet_server.c +++ b/bacula/src/lib/bnet_server.c @@ -78,7 +78,11 @@ bnet_thread_server(char *bind_addr, int port, int max_clients, workq_t *client_w */ bind_ip.s_addr = htonl(INADDR_ANY); if (bind_addr && bind_addr[0]) { +#ifdef HAVE_INET_PTON if (inet_pton(AF_INET, bind_addr, &bind_ip) <= 0) { +#else + if (inet_aton(bind_addr, &bind_ip) <= 0) { +#endif Emsg1(M_WARNING, 0, _("Invalid bind address: %s, using INADDR_ANY\n"), bind_addr); bind_ip.s_addr = htonl(INADDR_ANY); diff --git a/bacula/src/lib/message.c b/bacula/src/lib/message.c index 1f746a32d7..aa0083a5c8 100755 --- a/bacula/src/lib/message.c +++ b/bacula/src/lib/message.c @@ -357,9 +357,9 @@ static char *edit_job_codes(JCR *jcr, char *omsg, char *imsg, char *to) add[1] = 0; str = add; } - Dmsg1(200, "add_str %s\n", str); + Dmsg1(1200, "add_str %s\n", str); pm_strcat(&omsg, str); - Dmsg1(200, "omsg=%s\n", omsg); + Dmsg1(1200, "omsg=%s\n", omsg); } return omsg; } diff --git a/bacula/src/lib/tree.c b/bacula/src/lib/tree.c index f89214cdb9..959529e155 100755 --- a/bacula/src/lib/tree.c +++ b/bacula/src/lib/tree.c @@ -171,6 +171,7 @@ TREE_NODE *insert_tree_node(char *path, TREE_NODE *node, TREE_ROOT *root, TREE_N fname = path; if (!parent) { parent = (TREE_NODE *)root; + node->type = TN_DIR_NLS; } Dmsg1(100, "No / found: %s\n", path); } @@ -203,6 +204,7 @@ TREE_NODE *make_tree_path(char *path, TREE_ROOT *root) { TREE_NODE *parent, *sibling, *node; char *fname, *p; + int type = TN_NEWDIR; Dmsg1(100, "make_tree_path: %s\n", path); if (*path == 0) { @@ -218,6 +220,7 @@ TREE_NODE *make_tree_path(char *path, TREE_ROOT *root) } else { fname = path; parent = (TREE_NODE *)root; + type = TN_DIR_NLS; } /* Is it already a sibling? */ for (sibling=parent->child; sibling; sibling=sibling->sibling) { @@ -228,7 +231,7 @@ TREE_NODE *make_tree_path(char *path, TREE_ROOT *root) } } /* Must add */ - node = new_tree_node(root, TN_NEWDIR); + node = new_tree_node(root, type); append_tree_node(fname, node, root, parent); Dmsg1(100, "make_tree_path: add parent=%s\n", node->fname); return node; @@ -286,6 +289,7 @@ void print_tree(char *path, TREE_NODE *tree) return; } switch (tree->type) { + case TN_DIR_NLS: case TN_DIR: case TN_NEWDIR: termchr = "/"; @@ -300,17 +304,15 @@ void print_tree(char *path, TREE_NODE *tree) switch (tree->type) { case TN_FILE: break; + case TN_NEWDIR: case TN_DIR: + case TN_DIR_NLS: sprintf(buf, "%s/%s", path, tree->fname); print_tree(buf, tree->child); break; case TN_ROOT: print_tree(path, tree->child); break; - case TN_NEWDIR: - sprintf(buf, "%s/%s", path, tree->fname); - print_tree(buf, tree->child); - break; default: Pmsg1(000, "Unknown node type %d\n", tree->type); } @@ -325,6 +327,14 @@ int tree_getpath(TREE_NODE *node, char *buf, int buf_size) return 1; } tree_getpath(node->parent, buf, buf_size); + /* + * Fixup for Win32. If we have a Win32 directory and + * there is only a / in the buffer, remove it since + * win32 names don't generally start with / + */ + if (node->type == TN_DIR_NLS && buf[0] == '/' && buf[1] == 0) { + buf[0] = 0; + } strcat(buf, node->fname); if (node->type != TN_FILE) { strcat(buf, "/"); diff --git a/bacula/src/lib/tree.h b/bacula/src/lib/tree.h index 7ad9668b45..8e9bfdaa0b 100644 --- a/bacula/src/lib/tree.h +++ b/bacula/src/lib/tree.h @@ -66,7 +66,8 @@ typedef struct s_tree_root TREE_ROOT; #define TN_ROOT 1 /* root node */ #define TN_NEWDIR 2 /* created directory to fill path */ #define TN_DIR 3 /* directory entry */ -#define TN_FILE 4 /* file entry */ +#define TN_DIR_NLS 4 /* directory -- no leading slash -- win32 */ +#define TN_FILE 5 /* file entry */ TREE_ROOT *new_tree(int count); TREE_NODE *new_tree_node(TREE_ROOT *root, int type); diff --git a/bacula/src/version.h b/bacula/src/version.h index ef79285da5..d68602ab23 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -1,8 +1,8 @@ /* */ #define VERSION "1.26" #define VSTRING "1" -#define DATE "8 October 2002" -#define LSMDATE "08Oct02" +#define DATE "10 October 2002" +#define LSMDATE "10Oct02" /* Debug flags */ #define DEBUG 1 -- 2.39.5