X-Git-Url: https://git.wh0rd.org/?p=dump.git;a=blobdiff_plain;f=dump%2Foptr.c;h=cd98e6664d36ba963f6fbd41c6001fbcd88b5b71;hp=c9c9239f6eaf74d38cba84e460e0b6ee8573847c;hb=e084ba00f03da98a6d260b0b3856aee2dfbb4c58;hpb=43ef843b59f89bb96ebec8647aa23ad43ae6789c diff --git a/dump/optr.c b/dump/optr.c index c9c9239..cd98e66 100644 --- a/dump/optr.c +++ b/dump/optr.c @@ -41,13 +41,14 @@ #ifndef lint static const char rcsid[] = - "$Id: optr.c,v 1.22 2001/03/20 09:14:58 stelian Exp $"; + "$Id: optr.c,v 1.26 2001/08/16 09:37:59 stelian Exp $"; #endif /* not lint */ #include #include #include #include +#include #include #include @@ -61,7 +62,11 @@ static const char rcsid[] = #include #ifdef __linux__ +#ifdef HAVE_EXT2FS_EXT2_FS_H +#include +#else #include +#endif #include #include #include @@ -101,6 +106,12 @@ query(const char *question) FILE *mytty; time_t firstprompt, when_answered; + if (qflag) { + msg("%s - forced abort\n", question); + dumpabort(0); + /* NOTREACHED */ + } + firstprompt = time(NULL); if ((mytty = fopen(_PATH_TTY, "r")) == NULL) @@ -459,7 +470,6 @@ getfstab(void) strcmp(fs->fs_type, FSTAB_RQ)) continue; fs = allocfsent(fs); - fs->fs_passno = 0; if ((pf = (struct pfstab *)malloc(sizeof (*pf))) == NULL) quit("%s\n", strerror(errno)); pf->pf_fstab = fs; @@ -555,15 +565,9 @@ static void print_wmsg(char arg, int dumpme, const char *dev, int level, const char *mtpt, time_t ddate) { - char *date = NULL; - - if (ddate) { - char *d; - date = (char *)ctime(&ddate); - d = strchr(date, '\n'); - if (d) *d = '\0'; - } - +#ifdef FDEBUG + printf("checking dev %s: lvl %d, mtpt %s\n", dev, level, mtpt); +#endif if (!dumpme && arg == 'w') return; @@ -572,10 +576,18 @@ print_wmsg(char arg, int dumpme, const char *dev, int level, dev, mtpt ? mtpt : ""); - if (ddate) - printf("Level %c, Date %s\n", - level, date); - else + /* + * Check ddate > 365 to avoid issues with fs in stab but not dumpdates. + * Not a problem, because ddate is in seconds since the epoch anyways. + */ + if (ddate > 365) { + char *date, *d; + + date = (char *)ctime(&ddate); + d = strchr(date, '\n'); + if (d) *d = '\0'; + printf("Level %c, Date %s\n", level, date); + } else printf("never\n"); } @@ -602,6 +614,7 @@ lastdump(char arg) /* w ==> just what to do; W ==> most recent dumps */ else (void) printf("Last dump(s) done (Dump '>' file systems):\n"); + /* For files in dumpdates, get the last dump level and date */ if (ddatev != NULL) { struct dumpdates *dtwalk = NULL; int i; @@ -620,16 +633,19 @@ lastdump(char arg) /* w ==> just what to do; W ==> most recent dumps */ /* Overload fs_freq as dump level and * fs_passno as date, because we can't * change struct fstab format. - * A negative fs_freq means this + * A positive fs_freq means this * filesystem needs to be dumped. */ dt->fs_passno = dtwalk->dd_ddate; if (dt->fs_freq > 0 && (dtwalk->dd_ddate < tnow - (dt->fs_freq * 86400))) - dt->fs_freq = -dtwalk->dd_level - 1; + dt->fs_freq = dtwalk->dd_level; else - dt->fs_freq = dtwalk->dd_level + 1; - + dt->fs_freq = -dtwalk->dd_level; +#ifdef FDEBUG + printf("%s fs_freq set to %d\n", lastname, + dt->fs_freq); +#endif } } } @@ -643,9 +659,10 @@ 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, + print_wmsg(arg, dt->fs_freq > 0, disk ? disk : dt->fs_spec, - dt->fs_freq < 0 ? -dt->fs_freq - 1 : dt->fs_freq - 1, + dt->fs_freq < 0 ? -dt->fs_freq : + dt->fs_freq, dt->fs_file, dt->fs_passno); }