]> git.wh0rd.org - dump.git/blobdiff - dump/optr.c
64bit and glibc 2.2.2 fixes.
[dump.git] / dump / optr.c
index 6ac8bbde3d01821dfd3409530f6b7ae34b9b834a..f0be80bc263c59ae0f3c779049e6226b897052ed 100644 (file)
@@ -2,7 +2,8 @@
  *     Ported to Linux's Second Extended File System as part of the
  *     dump and restore backup suit
  *     Remy Card <card@Linux.EU.Org>, 1994-1997
- *     Stelian Pop <pop@cybercable.fr>, 1999-2000
+ *     Stelian Pop <pop@noos.fr>, 1999-2000
+ *     Stelian Pop <pop@noos.fr> - AlcĂ´ve <www.alcove.fr>, 2000
  */
 
 /*-
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: optr.c,v 1.13 2000/11/10 11:54:52 stelian Exp $";
+       "$Id: optr.c,v 1.20 2001/02/22 10:57:40 stelian Exp $";
 #endif /* not lint */
 
+#include <config.h>
 #include <sys/param.h>
 #include <sys/wait.h>
 #include <sys/time.h>
@@ -63,6 +65,7 @@ static const char rcsid[] =
 #include <ext2fs/ext2fs.h>
 #include <bsdcompat.h>
 #include <signal.h>
+#include <time.h>
 #endif
 
 #include "dump.h"
@@ -321,7 +324,7 @@ time_t      tschedule = 0;
 void
 timeest(void)
 {
-       time_t  tnow, deltat;
+       time_t tnow;
 
 #ifdef __linux__
        (void) time4(&tnow);
@@ -329,17 +332,13 @@ timeest(void)
        (void) time((time_t *) &tnow);
 #endif
        if (tnow >= tschedule) {
+               char *buf = mktimeest(tnow);
                tschedule = tnow + 300;
-               if (blockswritten < 500)
-                       return;
-               if (blockswritten > tapesize)
-                       tapesize = blockswritten;
-               deltat = tstart_writing - tnow +
-                       (1.0 * (tnow - tstart_writing))
-                       / blockswritten * tapesize;
-               msg("%3.2f%% done, finished in %d:%02d\n",
-                       (blockswritten * 100.0) / tapesize,
-                       deltat / 3600, (deltat % 3600) / 60);
+               if (buf) {
+                       fprintf(stderr, "  DUMP: ");
+                       fwrite(buf, strlen(buf), 1, stderr);
+                       fflush(stderr);
+               }
        }
 }
 
@@ -569,11 +568,14 @@ static void
 print_wmsg(char arg, int dumpme, const char *dev, int level,
           const char *mtpt, time_t ddate)
 {
-       char *date;
+       char *date = NULL;
        
-       if (ddate)
+       if (ddate) {
+               char *d;
                date = (char *)ctime(&ddate);
-       //date[16] = '\0';      /* blast away seconds and year */
+               d = strchr(date, '\n');
+               if (d) *d = '\0';
+       }
 
        if (!dumpme && arg == 'w')
                return;
@@ -627,8 +629,7 @@ lastdump(char arg) /* w ==> just what to do; W ==> most recent dumps */
                                sizeof(dtwalk->dd_name)) == 0)
                                continue;
                        lastname = dtwalk->dd_name;
-                       if ((dt = dtwalk->dd_fstab) != NULL &&
-                           dt->fs_freq != 0) {
+                       if ((dt = dtwalk->dd_fstab) != NULL) {
                                /* Overload fs_freq as dump level and
                                 * fs_passno as date, because we can't
                                 * change struct fstab format.
@@ -636,11 +637,11 @@ lastdump(char arg) /* w ==> just what to do; W ==> most recent dumps */
                                 * filesystem needs to be dumped.
                                 */
                                dt->fs_passno = dtwalk->dd_ddate;
-                               if (dtwalk->dd_ddate <
-                                   tnow - (dt->fs_freq * 86400))
-                                       dt->fs_freq = -dtwalk->dd_level;
+                               if (dt->fs_freq > 0 && (dtwalk->dd_ddate <
+                                   tnow - (dt->fs_freq * 86400)))
+                                       dt->fs_freq = -dtwalk->dd_level - 1;
                                else
-                                       dt->fs_freq = dtwalk->dd_level;
+                                       dt->fs_freq = dtwalk->dd_level + 1;
 
                        }
                }
@@ -655,9 +656,9 @@ lastdump(char arg) /* w ==> just what to do; W ==> most recent dumps */
                        if (strncmp(dt->fs_vfstype, *type,
                                    sizeof(dt->fs_vfstype)) == 0) {
                                const char *disk = get_device_name(dt->fs_spec);
-                               print_wmsg(arg, dt->fs_freq < 0 || !dt->fs_passno,
+                               print_wmsg(arg, dt->fs_freq < 0,
                                           disk ? disk : dt->fs_spec,
-                                          dt->fs_freq < 0 ? -dt->fs_freq : dt->fs_freq
+                                          dt->fs_freq < 0 ? -dt->fs_freq - 1 : dt->fs_freq - 1
                                           dt->fs_file,
                                           dt->fs_passno);
                        }