]> git.sur5r.net Git - bacula/bacula/commitdiff
- Tweak install chapter of French manual to add new paragraph
authorKern Sibbald <kern@sibbald.com>
Mon, 20 Sep 2004 09:07:03 +0000 (09:07 +0000)
committerKern Sibbald <kern@sibbald.com>
Mon, 20 Sep 2004 09:07:03 +0000 (09:07 +0000)
  from English.
- Tweak restore tree message to be a bit clearer.
- Modify watchdog to wakeup after 60 seconds, or wakeup if
  there is work to do.
- Modify watchdog stop routine to ping watchdog so that it
  stops immediately rather than after sleep time.
- Fix btape to use new dcr blocks rather than its own.
- Fix butil.c to correctly handle Volume names for the
  utility routines (broke when updating to dcrs).

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

bacula/src/dird/ua_tree.c
bacula/src/lib/bsys.c
bacula/src/lib/protos.h
bacula/src/lib/watchdog.c
bacula/src/stored/btape.c
bacula/src/stored/butil.c
bacula/src/version.h

index c59d1888fae2d69ffcf13c2497e7c2f019a9c2a0..9b12f1110883d483211eeb3272769755a325b896 100644 (file)
@@ -91,8 +91,8 @@ bool user_select_files_from_tree(TREE_CTX *tree)
    ua->UA_sock = tree->ua->UA_sock;   /* patch in UA socket */
 
    bsendmsg(tree->ua, _( 
-      "\nYou are now entering file selection mode where you add and\n"
-      "remove files to be restored. No files are initially added, unless\n"
+      "\nYou are now entering file selection mode where you add (mark) and\n"
+      "remove (unmark) files to be restored. No files are initially added, unless\n"
       "you used the \"all\" keyword on the command line.\n"
       "Enter \"done\" to leave this mode.\n\n"));
    /*
index 1aa87d9f6020db5c1a6e5c55f3b6dbf012091cd7..f81e91923e172db69a0322119e3f3b9ba18d3444 100644 (file)
@@ -531,8 +531,9 @@ int bmicrosleep(time_t sec, long usec)
    P(timer_mutex);
    stat = pthread_cond_timedwait(&timer, &timer_mutex, &timeout);
    if (stat != 0) {
+      berrno be;
       Dmsg2(200, "pthread_cond_timedwait stat=%d ERR=%s\n", stat,
-        strerror(stat));
+        be.strerror(stat));
    }
    V(timer_mutex);
    return stat;
index b5957e19c1606f11589bc298bd7818a1dabc2907..40f102437dbc1145caa3971db9d8aa3b0817f2f9 100644 (file)
 struct JCR;
 
 /* attr.c */
-ATTR    *new_attr();
-void     free_attr(ATTR *attr);
-int      unpack_attributes_record(JCR *jcr, int32_t stream, char *rec, ATTR *attr);
-void     build_attr_output_fnames(JCR *jcr, ATTR *attr);
-void     print_ls_output(JCR *jcr, ATTR *attr);
+ATTR     *new_attr();
+void      free_attr(ATTR *attr);
+int       unpack_attributes_record(JCR *jcr, int32_t stream, char *rec, ATTR *attr);
+void      build_attr_output_fnames(JCR *jcr, ATTR *attr);
+void      print_ls_output(JCR *jcr, ATTR *attr);
 
 /* base64.c */
-void     base64_init            (void);
-int      to_base64              (intmax_t value, char *where);
-int      from_base64            (intmax_t *value, char *where);
-int      bin_to_base64          (char *buf, char *bin, int len);
+void      base64_init            (void);
+int       to_base64              (intmax_t value, char *where);
+int       from_base64            (intmax_t *value, char *where);
+int       bin_to_base64          (char *buf, char *bin, int len);
 
 /* bsys.c */
-char    *bstrncpy               (char *dest, const char *src, int maxlen);
-char    *bstrncpy               (char *dest, POOL_MEM &src, int maxlen);
-char    *bstrncat               (char *dest, const char *src, int maxlen);
-char    *bstrncat               (char *dest, POOL_MEM &src, int maxlen);
-void    *b_malloc               (const char *file, int line, size_t size);
+char     *bstrncpy               (char *dest, const char *src, int maxlen);
+char     *bstrncpy               (char *dest, POOL_MEM &src, int maxlen);
+char     *bstrncat               (char *dest, const char *src, int maxlen);
+char     *bstrncat               (char *dest, POOL_MEM &src, int maxlen);
+void     *b_malloc               (const char *file, int line, size_t size);
 #ifndef DEBUG
-void    *bmalloc                (size_t size);
+void     *bmalloc                (size_t size);
 #endif
-void    *brealloc               (void *buf, size_t size);
-void    *bcalloc                (size_t size1, size_t size2);
-int      bsnprintf              (char *str, int32_t size, const char *format, ...);
-int      bvsnprintf             (char *str, int32_t size, const char *format, va_list ap);
-int      pool_sprintf           (char *pool_buf, const char *fmt, ...);
-void     create_pid_file        (char *dir, const char *progname, int port);
-int      delete_pid_file        (char *dir, const char *progname, int port);
-void     drop                   (char *uid, char *gid);
-int      bmicrosleep            (time_t sec, long usec);
-char    *bfgets                 (char *s, int size, FILE *fd);
-void     make_unique_filename   (POOLMEM **name, int Id, char *what);
+void     *brealloc               (void *buf, size_t size);
+void     *bcalloc                (size_t size1, size_t size2);
+int       bsnprintf              (char *str, int32_t size, const char *format, ...);
+int       bvsnprintf             (char *str, int32_t size, const char *format, va_list ap);
+int       pool_sprintf           (char *pool_buf, const char *fmt, ...);
+void      create_pid_file        (char *dir, const char *progname, int port);
+int       delete_pid_file        (char *dir, const char *progname, int port);
+void      drop                   (char *uid, char *gid);
+int       bmicrosleep            (time_t sec, long usec);
+char     *bfgets                 (char *s, int size, FILE *fd);
+void      make_unique_filename   (POOLMEM **name, int Id, char *what);
 #ifndef HAVE_STRTOLL
-long long int strtoll           (const char *ptr, char **endptr, int base);
+long long int strtoll            (const char *ptr, char **endptr, int base);
 #endif
-void     read_state_file(char *dir, const char *progname, int port);
-int      bstrerror(int errnum, char *buf, size_t bufsiz);
+void      read_state_file(char *dir, const char *progname, int port);
+int       bstrerror(int errnum, char *buf, size_t bufsiz);
 
 /* bnet.c */
-int32_t    bnet_recv            (BSOCK *bsock);
-bool      bnet_send             (BSOCK *bsock);
-bool      bnet_fsend            (BSOCK *bs, const char *fmt, ...);
-bool      bnet_set_buffer_size  (BSOCK *bs, uint32_t size, int rw);
-bool      bnet_sig              (BSOCK *bs, int sig);
-int       bnet_ssl_server       (BSOCK *bsock, char *password, int ssl_need, int ssl_has);
-int       bnet_ssl_client       (BSOCK *bsock, char *password, int ssl_need);
-BSOCK *    bnet_connect           (JCR *jcr, int retry_interval,
-              int max_retry_time, const char *name, char *host, char *service, 
-              int port, int verbose);
-void      bnet_close            (BSOCK *bsock);
-BSOCK *    init_bsock           (JCR *jcr, int sockfd, const char *who, const char *ip, 
-                                 int port, struct sockaddr *client_addr);
-BSOCK *    dup_bsock            (BSOCK *bsock);
-void      term_bsock            (BSOCK *bsock);
-char *    bnet_strerror         (BSOCK *bsock);
-const char *bnet_sig_to_ascii    (BSOCK *bsock);
-int       bnet_wait_data        (BSOCK *bsock, int sec);
-int       bnet_wait_data_intr   (BSOCK *bsock, int sec);
-int       bnet_despool_to_bsock (BSOCK *bsock, void update(ssize_t size), ssize_t size);
-bool      is_bnet_stop          (BSOCK *bsock);
-int       is_bnet_error         (BSOCK *bsock);
-void      bnet_suppress_error_messages(BSOCK *bsock, bool flag);
+int32_t    bnet_recv             (BSOCK *bsock);
+bool       bnet_send             (BSOCK *bsock);
+bool       bnet_fsend            (BSOCK *bs, const char *fmt, ...);
+bool       bnet_set_buffer_size  (BSOCK *bs, uint32_t size, int rw);
+bool       bnet_sig              (BSOCK *bs, int sig);
+int        bnet_ssl_server       (BSOCK *bsock, char *password, int ssl_need, int ssl_has);
+int        bnet_ssl_client       (BSOCK *bsock, char *password, int ssl_need);
+BSOCK *    bnet_connect            (JCR *jcr, int retry_interval,
+               int max_retry_time, const char *name, char *host, char *service, 
+               int port, int verbose);
+void       bnet_close            (BSOCK *bsock);
+BSOCK *    init_bsock            (JCR *jcr, int sockfd, const char *who, const char *ip, 
+                                  int port, struct sockaddr *client_addr);
+BSOCK *    dup_bsock             (BSOCK *bsock);
+void       term_bsock            (BSOCK *bsock);
+char *     bnet_strerror         (BSOCK *bsock);
+const char *bnet_sig_to_ascii     (BSOCK *bsock);
+int        bnet_wait_data        (BSOCK *bsock, int sec);
+int        bnet_wait_data_intr   (BSOCK *bsock, int sec);
+int        bnet_despool_to_bsock (BSOCK *bsock, void update(ssize_t size), ssize_t size);
+bool       is_bnet_stop          (BSOCK *bsock);
+int        is_bnet_error         (BSOCK *bsock);
+void       bnet_suppress_error_messages(BSOCK *bsock, bool flag);
 dlist *bnet_host2ipaddrs(const char *host, int family, const char **errstr);
 
 /* bget_msg.c */
-int     bget_msg(BSOCK *sock);
+int      bget_msg(BSOCK *sock);
 
 /* bpipe.c */
-BPIPE *         open_bpipe(char *prog, int wait, const char *mode);
-int             close_wpipe(BPIPE *bpipe);
-int             close_bpipe(BPIPE *bpipe);
+BPIPE *          open_bpipe(char *prog, int wait, const char *mode);
+int              close_wpipe(BPIPE *bpipe);
+int              close_bpipe(BPIPE *bpipe);
 
 /* cram-md5.c */
 int cram_md5_get_auth(BSOCK *bs, char *password, int ssl_need);
 int cram_md5_auth(BSOCK *bs, char *password, int ssl_need);
 void hmac_md5(uint8_t* text, int text_len, uint8_t*  key,
-             int key_len, uint8_t *hmac);
+              int key_len, uint8_t *hmac);
 
 /* crc32.c */
 
 uint32_t bcrc32(uint8_t *buf, int len);
 
 /* daemon.c */
-void    daemon_start            ();
+void     daemon_start            ();
 
 /* edit.c */
-uint64_t        str_to_uint64(char *str);
-int64_t         str_to_int64(char *str);
-char *          edit_uint64_with_commas   (uint64_t val, char *buf);
-char *          add_commas              (char *val, char *buf);
-char *          edit_uint64             (uint64_t val, char *buf);
-int             duration_to_utime       (char *str, utime_t *value);
-int             size_to_uint64(char *str, int str_len, uint64_t *rtn_value);
-char            *edit_utime             (utime_t val, char *buf, int buf_len);
-bool            is_a_number             (const char *num);
-bool            is_an_integer           (const char *n);
-bool            is_name_valid           (char *name, POOLMEM **msg);
+uint64_t         str_to_uint64(char *str);
+int64_t          str_to_int64(char *str);
+char *           edit_uint64_with_commas   (uint64_t val, char *buf);
+char *           add_commas              (char *val, char *buf);
+char *           edit_uint64             (uint64_t val, char *buf);
+int              duration_to_utime       (char *str, utime_t *value);
+int              size_to_uint64(char *str, int str_len, uint64_t *rtn_value);
+char             *edit_utime             (utime_t val, char *buf, int buf_len);
+bool             is_a_number             (const char *num);
+bool             is_an_integer           (const char *n);
+bool             is_name_valid           (char *name, POOLMEM **msg);
 
 /* jcr.c (most definitions are in src/jcr.h) */
 void init_last_jobs_list();
@@ -136,36 +136,36 @@ void job_end_push(JCR *jcr, void job_end_cb(JCR *jcr,void *), void *ctx);
 
 
 /* lex.c */
-LEX *    lex_close_file         (LEX *lf);
-LEX *    lex_open_file          (LEX *lf, const char *fname, LEX_ERROR_HANDLER *scan_error);
-int      lex_get_char           (LEX *lf);
-void     lex_unget_char         (LEX *lf);
-const char *  lex_tok_to_str    (int token);
-int      lex_get_token          (LEX *lf, int expect);
+LEX *     lex_close_file         (LEX *lf);
+LEX *     lex_open_file          (LEX *lf, const char *fname, LEX_ERROR_HANDLER *scan_error);
+int       lex_get_char           (LEX *lf);
+void      lex_unget_char         (LEX *lf);
+const char *  lex_tok_to_str     (int token);
+int       lex_get_token          (LEX *lf, int expect);
 
 /* message.c */
-void      my_name_is            (int argc, char *argv[], const char *name);
-void      init_msg              (JCR *jcr, MSGS *msg);
-void      term_msg              (void);
-void      close_msg             (JCR *jcr);
-void      add_msg_dest          (MSGS *msg, int dest, int type, char *where, char *dest_code);
-void      rem_msg_dest          (MSGS *msg, int dest, int type, char *where);
-void      Jmsg                  (JCR *jcr, int type, int level, const char *fmt, ...);
-void      dispatch_message      (JCR *jcr, int type, int level, char *buf);
-void      init_console_msg      (const char *wd);
-void      free_msgs_res         (MSGS *msgs);
-void      dequeue_messages      (JCR *jcr);
-void      set_trace             (int trace_flag);
-void      set_exit_on_error     (int value);
+void       my_name_is            (int argc, char *argv[], const char *name);
+void       init_msg              (JCR *jcr, MSGS *msg);
+void       term_msg              (void);
+void       close_msg             (JCR *jcr);
+void       add_msg_dest          (MSGS *msg, int dest, int type, char *where, char *dest_code);
+void       rem_msg_dest          (MSGS *msg, int dest, int type, char *where);
+void       Jmsg                  (JCR *jcr, int type, int level, const char *fmt, ...);
+void       dispatch_message      (JCR *jcr, int type, int level, char *buf);
+void       init_console_msg      (const char *wd);
+void       free_msgs_res         (MSGS *msgs);
+void       dequeue_messages      (JCR *jcr);
+void       set_trace             (int trace_flag);
+void       set_exit_on_error     (int value);
 
 /* bnet_server.c */
-void      bnet_thread_server(dlist *addr, int max_clients, workq_t *client_wq, 
-                  void *handle_client_request(void *bsock));
-void      bnet_stop_thread_server(pthread_t tid);
-void            bnet_server             (int port, void handle_client_request(BSOCK *bsock));
-int             net_connect             (int port);
-BSOCK *         bnet_bind               (int port);
-BSOCK *         bnet_accept             (BSOCK *bsock, char *who);
+void       bnet_thread_server(dlist *addr, int max_clients, workq_t *client_wq, 
+                   void *handle_client_request(void *bsock));
+void       bnet_stop_thread_server(pthread_t tid);
+void             bnet_server             (int port, void handle_client_request(BSOCK *bsock));
+int              net_connect             (int port);
+BSOCK *          bnet_bind               (int port);
+BSOCK *          bnet_accept             (BSOCK *bsock, char *who);
 
 /* idcache.c */
 char *getuser(uid_t uid);
@@ -175,41 +175,41 @@ void free_getgroup_cache();
 
 
 /* signal.c */
-void            init_signals             (void terminate(int sig));
-void            init_stack_dump          (void);
+void             init_signals             (void terminate(int sig));
+void             init_stack_dump          (void);
 
 /* scan.c */
-void            strip_trailing_junk     (char *str);
-void            strip_trailing_slashes  (char *dir);
-bool            skip_spaces             (char **msg);
-bool            skip_nonspaces          (char **msg);
-int             fstrsch                 (const char *a, const char *b);
-char           *next_arg(char **s);
-int             parse_args(POOLMEM *cmd, POOLMEM **args, int *argc, 
-                       char **argk, char **argv, int max_args);
-void           split_path_and_filename(const char *fname, POOLMEM **path, 
-                       int *pnl, POOLMEM **file, int *fnl);
-int            bsscanf(const char *buf, const char *fmt, ...);
+void             strip_trailing_junk     (char *str);
+void             strip_trailing_slashes  (char *dir);
+bool             skip_spaces             (char **msg);
+bool             skip_nonspaces          (char **msg);
+int              fstrsch                 (const char *a, const char *b);
+char            *next_arg(char **s);
+int              parse_args(POOLMEM *cmd, POOLMEM **args, int *argc, 
+                        char **argk, char **argv, int max_args);
+void            split_path_and_filename(const char *fname, POOLMEM **path, 
+                        int *pnl, POOLMEM **file, int *fnl);
+int             bsscanf(const char *buf, const char *fmt, ...);
 
 
 /* util.c */
-int             is_buf_zero             (char *buf, int len);
-void            lcase                   (char *str);
-void            bash_spaces             (char *str);
-void            bash_spaces             (POOL_MEM &pm);
-void            unbash_spaces           (char *str);
-void            unbash_spaces           (POOL_MEM &pm);
-char *          encode_time             (time_t time, char *buf);
-char *          encode_mode             (mode_t mode, char *buf);
-int             do_shell_expansion      (char *name, int name_len);
-void            jobstatus_to_ascii      (int JobStatus, char *msg, int maxlen);
-int             run_program             (char *prog, int wait, POOLMEM *results);
-const char *    job_type_to_str         (int type);
-const char *    job_status_to_str       (int stat);
-const char *    job_level_to_str        (int level);
-void            make_session_key        (char *key, char *seed, int mode);
-POOLMEM        *edit_job_codes(JCR *jcr, char *omsg, char *imsg, const char *to);
-void            set_working_directory(char *wd);
+int              is_buf_zero             (char *buf, int len);
+void             lcase                   (char *str);
+void             bash_spaces             (char *str);
+void             bash_spaces             (POOL_MEM &pm);
+void             unbash_spaces           (char *str);
+void             unbash_spaces           (POOL_MEM &pm);
+char *           encode_time             (time_t time, char *buf);
+char *           encode_mode             (mode_t mode, char *buf);
+int              do_shell_expansion      (char *name, int name_len);
+void             jobstatus_to_ascii      (int JobStatus, char *msg, int maxlen);
+int              run_program             (char *prog, int wait, POOLMEM *results);
+const char *     job_type_to_str         (int type);
+const char *     job_status_to_str       (int stat);
+const char *     job_level_to_str        (int level);
+void             make_session_key        (char *key, char *seed, int mode);
+POOLMEM         *edit_job_codes(JCR *jcr, char *omsg, char *imsg, const char *to);
+void             set_working_directory(char *wd);
 
 
 /* watchdog.c */
@@ -218,7 +218,6 @@ int stop_watchdog(void);
 watchdog_t *new_watchdog(void);
 bool register_watchdog(watchdog_t *wd);
 bool unregister_watchdog(watchdog_t *wd);
-bool unregister_watchdog_unlocked(watchdog_t *wd);
 
 /* timers.c */
 btimer_t *start_child_timer(pid_t pid, uint32_t wait);
index 629a890dff575b8911a9e2086e17d3c5c050c54d..f3d08b7485738a6444ce1874cf0c755b2cb57e01 100755 (executable)
 
 /* Exported globals */
 time_t watchdog_time = 0;            /* this has granularity of SLEEP_TIME */
-time_t watchdog_sleep_time = 10;      /* examine things every 10 seconds */
+time_t watchdog_sleep_time = 60;      /* examine things every 60 seconds */
 
+/* Locals */
+static pthread_mutex_t timer_mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t timer = PTHREAD_COND_INITIALIZER;
 
 /* Forward referenced functions */
 extern "C" void *watchdog_thread(void *arg);
@@ -82,6 +85,17 @@ int start_watchdog(void)
    return 0;
 }
 
+/*
+ * Wake watchdog timer thread so that it walks the
+ *  queue and adjusts its wait time (or exits).
+ */
+static void ping_watchdog()
+{
+   P(timer_mutex);
+   pthread_cond_signal(&timer);
+   V(timer_mutex);
+}
+
 /*
  * Terminate the watchdog thread
  *
@@ -100,6 +114,7 @@ int stop_watchdog(void)
    quit = true;                      /* notify watchdog thread to stop */
    wd_is_init = false;
 
+   ping_watchdog();
    stat = pthread_join(wd_tid, NULL);
 
    while (!wd_queue->empty()) {
@@ -168,23 +183,27 @@ bool register_watchdog(watchdog_t *wd)
    Dmsg3(400, "Registered watchdog %p, interval %d%s\n",
          wd, wd->interval, wd->one_shot ? " one shot" : "");
    wd_unlock();
+   ping_watchdog();
 
    return false;
 }
 
-bool unregister_watchdog_unlocked(watchdog_t *wd)
+bool unregister_watchdog(watchdog_t *wd)
 {
    watchdog_t *p;
+   bool ok = false;
 
    if (!wd_is_init) {
       Emsg0(M_ABORT, 0, "BUG! unregister_watchdog_unlocked called before start_watchdog\n");
    }
 
+   wd_lock();
    foreach_dlist(p, wd_queue) {
       if (wd == p) {
         wd_queue->remove(wd);
          Dmsg1(400, "Unregistered watchdog %p\n", wd);
-        return true;
+        ok = true;
+        goto get_out;
       }
    }
 
@@ -192,31 +211,26 @@ bool unregister_watchdog_unlocked(watchdog_t *wd)
       if (wd == p) {
         wd_inactive->remove(wd);
          Dmsg1(400, "Unregistered inactive watchdog %p\n", wd);
-        return true;
+        ok = true;
+        goto get_out;
       }
    }
 
    Dmsg1(400, "Failed to unregister watchdog %p\n", wd);
-   return false;
-}
-
-bool unregister_watchdog(watchdog_t *wd)
-{
-   bool ret;
-
-   if (!wd_is_init) {
-      Emsg0(M_ABORT, 0, "BUG! unregister_watchdog called before start_watchdog\n");
-   }
 
-   wd_lock();
-   ret = unregister_watchdog_unlocked(wd);
+get_out:
    wd_unlock();
-
-   return ret;
+   ping_watchdog();
+   return ok;
 }
 
 extern "C" void *watchdog_thread(void *arg)
 {
+   struct timespec timeout;
+   struct timeval tv;
+   struct timezone tz;
+   time_t next_time;
+
    Dmsg0(400, "NicB-reworked watchdog thread entered\n");
 
    while (!quit) {
@@ -234,9 +248,10 @@ extern "C" void *watchdog_thread(void *arg)
       lock_jcr_chain();
       wd_lock();
       watchdog_time = time(NULL);
+      next_time = watchdog_time + watchdog_sleep_time;
 
       foreach_dlist(p, wd_queue) {
-        if (p->next_fire < watchdog_time) {
+        if (p->next_fire <= watchdog_time) {
            /* Run the callback */
            p->callback(p);
 
@@ -256,11 +271,30 @@ extern "C" void *watchdog_thread(void *arg)
            } else {
               p->next_fire = watchdog_time + p->interval;
            }
+        } 
+        if (p->next_fire < next_time) {
+           next_time = p->next_fire;
         }
       }
       wd_unlock();
       unlock_jcr_chain();
-      bmicrosleep(watchdog_sleep_time, 0);
+
+      /*                  
+       * Wait sleep time or until someone wakes us 
+       */
+      gettimeofday(&tv, &tz);
+      timeout.tv_nsec = tv.tv_usec * 1000;
+      timeout.tv_sec = tv.tv_sec + next_time - time(NULL);
+      while (timeout.tv_nsec >= 1000000000) {
+        timeout.tv_nsec -= 1000000000;
+        timeout.tv_sec++;
+      }
+
+      Dmsg1(900, "pthread_cond_timedwait %d\n", timeout.tv_sec - tv.tv_sec);
+      /* Note, this unlocks mutex during the sleep */
+      P(timer_mutex);
+      pthread_cond_timedwait(&timer, &timer_mutex, &timeout);
+      V(timer_mutex);
    }
 
    Dmsg0(400, "NicB-reworked watchdog thread exited\n");
index 06dc096814113cfc0a6bc0594b956505bf2633db..9062465fdd899cc10b6b2f9b0ce5a78025301671 100644 (file)
@@ -309,6 +309,7 @@ static void terminate_btape(int stat)
       free_block(this_block);
    }
 
+   stop_watchdog();
    term_msg();
    close_memory_pool();              /* free memory in pool */
 
@@ -349,7 +350,7 @@ void quitcmd()
 static void labelcmd()
 {
    if (VolumeName) {
-      pm_strcpy(&cmd, VolumeName);
+      pm_strcpy(cmd, VolumeName);
    } else {
       if (!get_cmd("Enter Volume Name: ")) {
         return;
@@ -646,6 +647,7 @@ static int re_read_block_test()
       "tape to verify that the block was written correctly.\n\n"
       "This is not an *essential* feature ...\n\n")); 
    rewindcmd();
+   empty_block(block);
    rec = new_record();
    rec->data = check_pool_memory_size(rec->data, block->buf_len);
    len = rec->data_len = block->buf_len-100;
@@ -754,7 +756,7 @@ static int write_read_test()
       "then write 1000 records and an EOF, then rewind,\n"     
       "and re-read the data to verify that it is correct.\n\n"
       "This is an *essential* feature ...\n\n")); 
-   block = new_block(dev);
+   block = dcr->block;
    rec = new_record();
    if (!rewind_dev(dev)) {
       Pmsg1(0, "Bad status from rewind. ERR=%s\n", strerror_dev(dev));
@@ -836,7 +838,6 @@ read_again:
    stat = 1;
 
 bail_out:
-   free_block(block);
    free_record(rec);
    return stat;
 }
@@ -848,7 +849,7 @@ bail_out:
  */
 static int position_test()
 {
-   DEV_BLOCK *block;
+   DEV_BLOCK *block = dcr->block;
    DEV_RECORD *rec;
    int stat = 0;
    int len, i, j;
@@ -862,7 +863,7 @@ static int position_test()
       "then write 1000 records and an EOF, then rewind,\n"     
       "and position to a few blocks and verify that it is correct.\n\n"
       "This is an *essential* feature ...\n\n")); 
-   block = new_block(dev);
+   empty_block(block);
    rec = new_record();
    if (!rewind_dev(dev)) {
       Pmsg1(0, "Bad status from rewind. ERR=%s\n", strerror_dev(dev));
@@ -987,7 +988,6 @@ read_again:
    stat = 1;
 
 bail_out:
-   free_block(block);
    free_record(rec);
    return stat;
 }
@@ -1160,8 +1160,12 @@ try_again:
    if (!open_the_device()) {
       goto bail_out;
    }
+   /*  
+    * Start with sleep_time 0 then increment by 30 seconds if we get
+    * a failure.
+    */
    bmicrosleep(sleep_time, 0);
-   if (!rewind_dev(dev)) {
+   if (!rewind_dev(dev) || weof_dev(dev,1) < 0) {
       Pmsg1(0, "Bad status from rewind. ERR=%s\n", strerror_dev(dev));
       clrerror_dev(dev, -1);
       Pmsg0(-1, "\nThe test failed, probably because you need to put\n"
@@ -1460,7 +1464,10 @@ static void wrcmd()
    int i;
 
    sm_check(__FILE__, __LINE__, false);
-   dump_block(block, "test");
+   empty_block(block);
+   if (verbose > 1) {
+      dump_block(block, "test");
+   }
 
    i = block->buf_len - 100;
    ASSERT (i > 0);
@@ -1596,13 +1603,13 @@ static void scan_blocks()
    int blocks, tot_blocks, tot_files;
    uint32_t block_size;
    uint64_t bytes;
-   DEV_BLOCK *block;
+   DEV_BLOCK *block = dcr->block;
    char ec1[50];
 
-   block = new_block(dev);
    blocks = block_size = tot_blocks = 0;
    bytes = 0;
 
+   empty_block(block);
    update_pos_dev(dev);
    tot_files = dev->file;
    for (;;) {
@@ -1666,7 +1673,6 @@ static void scan_blocks()
 
    }
 bail_out:
-   free_block(block);
    tot_files = dev->file - tot_files;
    printf("Total files=%d, blocks=%d, bytes = %s\n", tot_files, tot_blocks, 
       edit_uint64_with_commas(bytes, ec1));
index 183e2ff019d374828066727a66d82c7dc24af682..654a4cd9c0341761e5436d9eb12fd511f5cd9f0a 100644 (file)
@@ -126,8 +126,12 @@ static DCR *setup_to_access_device(JCR *jcr, char *dev_name, const char *VolumeN
     * If no volume name already given and no bsr, and it is a file,
     * try getting name from Filename  
     */
-   VolName[0] = 0;
-   if (!jcr->bsr && VolumeName[0] == 0) {
+   if (VolumeName) {
+      bstrncpy(VolName, VolumeName, sizeof(VolName));
+   } else {
+      VolName[0] = 0;
+   }
+   if (!jcr->bsr && VolName[0] == 0) {
       if (strncmp(dev_name, "/dev/", 5) != 0) {
         /* Try stripping file part */
         p = dev_name + strlen(dev_name);
index 702c69730f8b0d9589992ef8ef5ad21b50220c13..35f27249cb47b338ddd958bf4a329e5ba408e44a 100644 (file)
@@ -1,8 +1,8 @@
 /* */
 #undef  VERSION
 #define VERSION "1.35.3"
-#define BDATE   "19 September 2004"
-#define LSMDATE "19Sep04"
+#define BDATE   "20 September 2004"
+#define LSMDATE "20Sep04"
 
 /* Debug flags */
 #undef  DEBUG