* 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.22 2001/03/20 09:14:58 stelian Exp $";
#endif /* not lint */
+#include <config.h>
#include <sys/param.h>
#include <sys/wait.h>
#include <sys/time.h>
#include <ext2fs/ext2fs.h>
#include <bsdcompat.h>
#include <signal.h>
+#include <time.h>
#endif
#include "dump.h"
FILE *mytty;
time_t firstprompt, when_answered;
-#ifdef __linux__
- (void)time4(&(firstprompt));
-#else
- (void)time((time_t *)&(firstprompt));
-#endif
+ firstprompt = time(NULL);
if ((mytty = fopen(_PATH_TTY, "r")) == NULL)
quit("fopen on %s fails: %s\n", _PATH_TTY, strerror(errno));
if (signal(SIGALRM, sig) == SIG_IGN)
signal(SIGALRM, SIG_IGN);
(void) fclose(mytty);
-#ifdef __linux__
- (void)time4(&(when_answered));
-#else
- (void)time((time_t *)&(when_answered));
-#endif
+ when_answered = time(NULL);
/*
* Adjust the base for time estimates to ignore time we spent waiting
* for operator input.
*/
- if ((tstart_writing != 0) && (when_answered != (time_t)-1) && (firstprompt != (time_t)-1))
+ if (tstart_writing != 0)
tstart_writing += (when_answered - firstprompt);
return(back);
}
return;
}
- clock = time((time_t *)0);
+ clock = time(NULL);
localclock = localtime(&clock);
if ((f_utmp = fopen(_PATH_UTMP, "r")) == NULL) {
void
timeest(void)
{
- time_t tnow, deltat;
+ time_t tnow = time(NULL);
-#ifdef __linux__
- (void) time4(&tnow);
-#else
- (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);
+ }
}
}
{
register struct pfstab *pf;
register struct fstab *fs;
- char *rn;
+ const char *rn;
for (pf = table; pf != NULL; pf = pf->pf_next) {
fs = pf->pf_fstab;
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;
struct pfstab *pf;
time_t tnow;
- (void) time(&tnow);
+ tnow = time(NULL);
getfstab(); /* /etc/fstab input */
initdumptimes(0); /* dumpdates input */
if (ddatev == NULL && table == NULL) {
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.
* 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;
}
}
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);
}