From: Kern Sibbald Date: Sat, 25 Sep 2004 19:45:04 +0000 (+0000) Subject: - Make run_grub print manual procedure for installing grub X-Git-Tag: Release-1.35.6~13 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=86995e8102d3e7d73054b5b9b7359e4558ef2feb;p=bacula%2Fbacula - Make run_grub print manual procedure for installing grub - Add extra setsockopt keepalive. - Add code to set as many options as possible in the system tape driver for different OSes. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1617 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/autoconf/config.h.in b/bacula/autoconf/config.h.in index 0287af2c9c..f195ac7296 100644 --- a/bacula/autoconf/config.h.in +++ b/bacula/autoconf/config.h.in @@ -247,6 +247,9 @@ /* Set if Bacula conio support enabled */ #undef HAVE_CONIO +/* Define to 1 if you have the header file. */ +#undef HAVE_CURSES_H + /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_DIRENT_H diff --git a/bacula/autoconf/configure.in b/bacula/autoconf/configure.in index 3255254dbe..71fac94f32 100644 --- a/bacula/autoconf/configure.in +++ b/bacula/autoconf/configure.in @@ -40,7 +40,7 @@ AC_PROG_CXX AC_PROG_CC_C_O dnl Determine if C compiler support -c -o. AC_PROG_GCC_TRADITIONAL dnl Determine if ioctl() need -traditional. -if test x$CC = xgcc +if test "x$CC" = xgcc then AC_DEFINE(HAVE_GCC) fi @@ -396,18 +396,25 @@ if test x$support_conio = xyes; then AC_DEFINE(HAVE_CONIO, 1, [Set if Bacula conio support enabled]) ]) ]) + ], + [ + AC_CHECK_HEADERS(curses.h) + AC_CHECK_HEADER(term.h, + [ AC_CHECK_LIB(curses, tgetent, + [ CONS_LIBS="-lcurses" + CONS_OBJ="conio.o" + CONS_SRC="conio.c" + got_conio="yes" + support_readline=no + AC_DEFINE(HAVE_CONIO, 1, [Set if Bacula conio support enabled]) + ]) + ], + [ echo " "; echo "Required libraries not found. CONIO turned off ..."; echo " "], +[#if HAVE_CURSES_H +#include +#endif +]) ]) - - AC_CHECK_HEADER(term.h, - [ AC_CHECK_LIB(curses, tgetent, - [ CONS_LIBS="-lcurses" - CONS_OBJ="conio.o" - CONS_SRC="conio.c" - got_conio="yes" - support_readline=no - AC_DEFINE(HAVE_CONIO, 1, [Set if Bacula conio support enabled]) - ]) - ]) fi diff --git a/bacula/configure b/bacula/configure index e6a5069ae9..c57de6bd55 100755 --- a/bacula/configure +++ b/bacula/configure @@ -3050,7 +3050,7 @@ echo "${ECHO_T}$ac_cv_prog_gcc_traditional" >&6 fi fi -if test x$CC = xgcc +if test "x$CC" = xgcc then cat >>confdefs.h <<\_ACEOF #define HAVE_GCC 1 @@ -5450,22 +5450,24 @@ fi fi -fi - +else - if test "${ac_cv_header_term_h+set}" = set; then - echo "$as_me:$LINENO: checking for term.h" >&5 -echo $ECHO_N "checking for term.h... $ECHO_C" >&6 -if test "${ac_cv_header_term_h+set}" = set; then +for ac_header in curses.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi -echo "$as_me:$LINENO: result: $ac_cv_header_term_h" >&5 -echo "${ECHO_T}$ac_cv_header_term_h" >&6 +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 else # Is the header compilable? -echo "$as_me:$LINENO: checking term.h usability" >&5 -echo $ECHO_N "checking term.h usability... $ECHO_C" >&6 +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ @@ -5474,7 +5476,7 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default -#include +#include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 @@ -5500,8 +5502,8 @@ 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 term.h presence" >&5 -echo $ECHO_N "checking term.h presence... $ECHO_C" >&6 +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ @@ -5509,7 +5511,7 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include +#include <$ac_header> _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 @@ -5542,10 +5544,10 @@ echo "${ECHO_T}$ac_header_preproc" >&6 # So? What about this header? case $ac_header_compiler:$ac_header_preproc in yes:no ) - { echo "$as_me:$LINENO: WARNING: term.h: accepted by the compiler, rejected by the preprocessor!" >&5 -echo "$as_me: WARNING: term.h: accepted by the compiler, rejected by the preprocessor!" >&2;} - { echo "$as_me:$LINENO: WARNING: term.h: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: term.h: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} ( cat <<\_ASBOX ## ------------------------------------ ## @@ -5556,12 +5558,12 @@ _ASBOX sed "s/^/$as_me: WARNING: /" >&2 ;; no:yes ) - { echo "$as_me:$LINENO: WARNING: term.h: present but cannot be compiled" >&5 -echo "$as_me: WARNING: term.h: present but cannot be compiled" >&2;} - { echo "$as_me:$LINENO: WARNING: term.h: check for missing prerequisite headers?" >&5 -echo "$as_me: WARNING: term.h: check for missing prerequisite headers?" >&2;} - { echo "$as_me:$LINENO: WARNING: term.h: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: term.h: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} ( cat <<\_ASBOX ## ------------------------------------ ## @@ -5572,17 +5574,68 @@ _ASBOX sed "s/^/$as_me: WARNING: /" >&2 ;; esac -echo "$as_me:$LINENO: checking for term.h" >&5 +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + echo "$as_me:$LINENO: checking for term.h" >&5 echo $ECHO_N "checking for term.h... $ECHO_C" >&6 if test "${ac_cv_header_term_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_cv_header_term_h=$ac_header_preproc + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#if HAVE_CURSES_H +#include +#endif + + +#include +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 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_cv_header_term_h=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_header_term_h=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_header_term_h" >&5 echo "${ECHO_T}$ac_cv_header_term_h" >&6 - -fi if test $ac_cv_header_term_h = yes; then echo "$as_me:$LINENO: checking for tgetent in -lcurses" >&5 echo $ECHO_N "checking for tgetent in -lcurses... $ECHO_C" >&6 @@ -5640,10 +5693,10 @@ echo "$as_me:$LINENO: result: $ac_cv_lib_curses_tgetent" >&5 echo "${ECHO_T}$ac_cv_lib_curses_tgetent" >&6 if test $ac_cv_lib_curses_tgetent = yes; then CONS_LIBS="-lcurses" - CONS_OBJ="conio.o" - CONS_SRC="conio.c" - got_conio="yes" - support_readline=no + CONS_OBJ="conio.o" + CONS_SRC="conio.c" + got_conio="yes" + support_readline=no cat >>confdefs.h <<\_ACEOF #define HAVE_CONIO 1 @@ -5653,6 +5706,12 @@ _ACEOF fi +else + echo " "; echo "Required libraries not found. CONIO turned off ..."; echo " " +fi + + + fi diff --git a/bacula/src/console/conio.c b/bacula/src/console/conio.c index 9b866c317a..7a65d2ab99 100755 --- a/bacula/src/console/conio.c +++ b/bacula/src/console/conio.c @@ -70,14 +70,17 @@ extern char *BC; extern char *UP; /* Forward referenced functions */ +extern "C" { static void sigintcatcher(int); +} + static void add_smap(char *str, int func); /* Global variables */ -static char *t_up = "\n"; /* scroll up character */ -static char *t_honk = "\007"; /* sound beep */ +static const char *t_up = "\n"; /* scroll up character */ +static const char *t_honk = "\007"; /* sound beep */ static char *t_il; /* insert line */ static char *t_dl; /* delete line */ static char *t_cs; /* clear screen */ @@ -221,7 +224,7 @@ static void t_insert_line(void); static void t_delete_line(void); static void t_clrline(int pos, int width); void t_sendl(const char *msg, int len); -void t_send(char *msg); +void t_send(const char *msg); void t_char(char c); static void asclrs(); static void ascurs(int y, int x); @@ -234,7 +237,9 @@ static void asinsl(); static void asdell(); int input_line(char *string, int length); +extern "C" { void con_term(); +} void trapctlc(); int usrbrk(); void clrbrk(); @@ -897,7 +902,7 @@ t_clrline(int pos, int width) /* Helper function to add string preceded by * ESC to smap table */ -static void add_esc_smap(char *str, int func) +static void add_esc_smap(const char *str, int func) { char buf[1000]; buf[0] = 0x1B; /* esc */ @@ -1054,7 +1059,7 @@ t_sendl(const char *msg, int len) } void -t_send(char *msg) +t_send(const char *msg) { if (msg == NULL) { return; diff --git a/bacula/src/console/conio.h b/bacula/src/console/conio.h index 0d162712b4..cf37d1507d 100644 --- a/bacula/src/console/conio.h +++ b/bacula/src/console/conio.h @@ -21,7 +21,11 @@ #define __CONIO_H extern int input_line(char *line, int len); extern void con_init(FILE *input); + +extern "C" { extern void con_term(); +} + extern void con_set_zed_keys(); extern void t_sendl(char *buf, int len); extern void t_send(char *buf); diff --git a/bacula/src/lib/bnet.c b/bacula/src/lib/bnet.c index b1dc54e9ac..181574b543 100644 --- a/bacula/src/lib/bnet.c +++ b/bacula/src/lib/bnet.c @@ -701,10 +701,9 @@ static BSOCK *bnet_open(JCR * jcr, const char *name, char *host, char *service, continue; } /* - * Receive notification when connection dies. + * Keep socket from timing out from inactivity */ - if (setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, (sockopt_val_t) & turnon, - sizeof(turnon)) < 0) { + if (setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, (sockopt_val_t)&turnon, sizeof(turnon)) < 0) { berrno be; Qmsg1(jcr, M_WARNING, 0, _("Cannot set SO_KEEPALIVE on socket: %s\n"), be.strerror()); @@ -725,6 +724,15 @@ static BSOCK *bnet_open(JCR * jcr, const char *name, char *host, char *service, errno = save_errno; return NULL; } + /* + * Keep socket from timing out from inactivity + * Do this a second time out of paranoia + */ + if (setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, (sockopt_val_t)&turnon, sizeof(turnon)) < 0) { + berrno be; + Qmsg1(jcr, M_WARNING, 0, _("Cannot set SO_KEEPALIVE on socket: %s\n"), + be.strerror()); + } BSOCK* ret = init_bsock(jcr, sockfd, name, host, port, ipaddr->get_sockaddr()); free_addresses(addr_list); return ret; diff --git a/bacula/src/lib/bnet_server.c b/bacula/src/lib/bnet_server.c index cf0ee907df..b97ba237e3 100644 --- a/bacula/src/lib/bnet_server.c +++ b/bacula/src/lib/bnet_server.c @@ -107,7 +107,7 @@ bnet_thread_server(dlist *addrs, int max_clients, workq_t *client_wq, /* * Reuse old sockets */ - if (setsockopt(fd_ptr->fd, SOL_SOCKET, SO_REUSEADDR, (sockopt_val_t) & turnon, + if (setsockopt(fd_ptr->fd, SOL_SOCKET, SO_REUSEADDR, (sockopt_val_t)&turnon, sizeof(turnon)) < 0) { berrno be; Emsg1(M_WARNING, 0, _("Cannot set SO_REUSEADDR on socket: %s\n"), @@ -203,7 +203,7 @@ bnet_thread_server(dlist *addrs, int max_clients, workq_t *client_wq, /* * Receive notification when connection dies. */ - if (setsockopt(newsockfd, SOL_SOCKET, SO_KEEPALIVE, (sockopt_val_t) & turnon, + if (setsockopt(newsockfd, SOL_SOCKET, SO_KEEPALIVE, (sockopt_val_t)&turnon, sizeof(turnon)) < 0) { berrno be; Emsg1(M_WARNING, 0, _("Cannot set SO_KEEPALIVE on socket: %s\n"), @@ -275,9 +275,7 @@ BSOCK *bnet_bind(int port) /* * Reuse old sockets */ - if (setsockopt - (sockfd, SOL_SOCKET, SO_REUSEADDR, (sockopt_val_t) & turnon, - sizeof(turnon)) < 0) { + if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (sockopt_val_t)&turnon, sizeof(turnon)) < 0) { Emsg1(M_WARNING, 0, _("Cannot set SO_REUSEADDR on socket: %s\n"), strerror(errno)); } @@ -370,9 +368,7 @@ BSOCK *bnet_accept(BSOCK * bsock, char *who) /* * Receive notification when connection dies. */ - if (setsockopt - (newsockfd, SOL_SOCKET, SO_KEEPALIVE, (sockopt_val_t) & turnon, - sizeof(turnon)) < 0) { + if (setsockopt(newsockfd, SOL_SOCKET, SO_KEEPALIVE, (sockopt_val_t)&turnon, sizeof(turnon)) < 0) { Emsg1(M_WARNING, 0, _("Cannot set SO_KEEPALIVE on socket: %s\n"), strerror(errno)); } diff --git a/bacula/src/stored/dev.c b/bacula/src/stored/dev.c index d446b8c437..cc234bb7c2 100644 --- a/bacula/src/stored/dev.c +++ b/bacula/src/stored/dev.c @@ -81,6 +81,7 @@ #include "stored.h" /* Forward referenced functions */ +void set_os_device_parameters(DEVICE *dev); /* * Allocate and initialize the DEVICE structure @@ -314,9 +315,9 @@ open_dev(DEVICE *dev, char *VolName, int mode) return -1; } archive_name = get_pool_memory(PM_FNAME); - pm_strcpy(&archive_name, dev->dev_name); + pm_strcpy(archive_name, dev->dev_name); if (archive_name[strlen(archive_name)] != '/') { - pm_strcat(&archive_name, "/"); + pm_strcat(archive_name, "/"); } pm_strcat(&archive_name, VolName); Dmsg1(29, "open_dev: device is disk %s\n", archive_name); @@ -339,6 +340,7 @@ open_dev(DEVICE *dev, char *VolName, int mode) dev->state |= ST_OPENED; dev->use_count = 1; update_pos_dev(dev); /* update position */ + set_os_device_parameters(dev); /* do system dependent stuff */ } Dmsg1(29, "open_dev: disk fd=%d opened\n", dev->fd); free_pool_memory(archive_name); @@ -1261,6 +1263,18 @@ clrerror_dev(DEVICE *dev, int func) ioctl(dev->fd, MTIOCERRSTAT, (char *)&mt_errstat); } #endif + +/* Clear Subsystem Exception OSF1 */ +#ifdef MTCSE +{ + struct mtop mt_com; + mt_com.mt_op = MTCSE; + mt_com.mt_count = 1; + /* Clear any error condition on the tape */ + ioctl(dev->fd, MTIOCTOP, (char *)&mt_com); + Dmsg0(200, "Did MTCSE\n"); +} +#endif } /* @@ -1463,4 +1477,81 @@ bool double_dev_wait_time(DEVICE *dev) return false; } return true; +} + +void set_os_device_parameters(DEVICE *dev) +{ +#ifdef HAVE_LINUX_OS + struct mtop mt_com; + if (dev->min_block_size == dev->max_block_size && + dev->min_block_size == 0) { /* variable block mode */ + mt_com.mt_op = MTSETBLK; + mt_com.mt_count = 0; + if (ioctl(dev->fd, MTIOCTOP, (char *)&mt_com) < 0) { + clrerror_dev(dev, MTSETBLK); + } + mt_com.mt_op = MTSETDRVBUFFER; + mt_com.mt_count = MT_ST_CLEARBOOLEANS; + if (!dev_cap(dev, CAP_TWOEOF)) { + mt_com.mt_count |= MT_ST_TWO_FM; + } + if (dev_cap(dev, CAP_EOM)) { + mt_com.mt_count |= MT_ST_FAST_MTEOM; + } + if (ioctl(dev->fd, MTIOCTOP, (char *)&mt_com) < 0) { + clrerror_dev(dev, MTSETBLK); + } + } + return; +#endif + +#ifdef HAVE_NETBSD_OS + struct mtop mt_com; + if (dev->min_block_size == dev->max_block_size && + dev->min_block_size == 0) { /* variable block mode */ + mt_com.mt_op = MTSETBSIZ; + mt_com.mt_count = 0; + if (ioctl(dev->fd, MTIOCTOP, (char *)&mt_com) < 0) { + clrerror_dev(dev, MTSETBSIZ); + } + /* Get notified at logical end of tape */ + mt_com.mt_op = MTEWARN; + mt_com.mt_count = 1; + if (ioctl(dev->fd, MTIOCTOP, (char *)&mt_com) < 0) { + clrerror_dev(dev, MTEWARN); + } + } + return; +#endif + +#if HAVE_FREEBSD_OS || HAVE_OPENBSD_OS + struct mtop mt_com; + if (dev->min_block_size == dev->max_block_size && + dev->min_block_size == 0) { /* variable block mode */ + mt_com.mt_op = MTSETBSIZ; + mt_com.mt_count = 0; + if (ioctl(dev->fd, MTIOCTOP, (char *)&mt_com) < 0) { + clrerror_dev(dev, MTSETBSIZ); + } + } + return; +#endif + +#ifdef HAVE_SUN_OS + struct mtop mt_com; + if (dev->min_block_size == dev->max_block_size && + dev->min_block_size == 0) { /* variable block mode */ + mt_com.mt_op = MTSRSZ; + mt_com.mt_count = 0; + if (ioctl(dev->fd, MTIOCTOP, (char *)&mt_com) < 0) { + clrerror_dev(dev, MTSRSZ); + } + } + return; +#endif + + + + + } diff --git a/bacula/src/version.h b/bacula/src/version.h index 5f188820c0..c277453820 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -1,8 +1,8 @@ /* */ #undef VERSION #define VERSION "1.35.5" -#define BDATE "24 September 2004" -#define LSMDATE "24Sep04" +#define BDATE "25 September 2004" +#define LSMDATE "25Sep04" /* Debug flags */ #undef DEBUG