X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=dump%2Foptr.c;h=a79462b24764c4f3aa42204e27ac5f5e36305949;hb=cf88ef4c26cd622c715573e07c3f1faf9e640eb5;hp=c9c9239f6eaf74d38cba84e460e0b6ee8573847c;hpb=43ef843b59f89bb96ebec8647aa23ad43ae6789c;p=dump.git diff --git a/dump/optr.c b/dump/optr.c index c9c9239..a79462b 100644 --- a/dump/optr.c +++ b/dump/optr.c @@ -2,8 +2,8 @@ * Ported to Linux's Second Extended File System as part of the * dump and restore backup suit * Remy Card , 1994-1997 - * Stelian Pop , 1999-2000 - * Stelian Pop - Alcôve , 2000 + * Stelian Pop , 1999-2000 + * Stelian Pop - Alcôve , 2000-2002 */ /*- @@ -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.31 2002/02/04 11:18:45 stelian Exp $"; #endif /* not lint */ #include #include #include #include +#include #include #include @@ -61,11 +62,14 @@ static const char rcsid[] = #include #ifdef __linux__ +#ifdef HAVE_EXT2FS_EXT2_FS_H +#include +#else #include +#endif #include #include #include -#include #endif #include "dump.h" @@ -101,6 +105,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) @@ -275,7 +285,7 @@ static void sendmes(const char *tty, const char *message) { char t[MAXPATHLEN], buf[BUFSIZ]; - register const char *cp; + const char *cp; int lmsg = 1; FILE *f_tty; @@ -416,7 +426,7 @@ quit(fmt, va_alist) static struct fstab * allocfsent(struct fstab *fs) { - register struct fstab *new; + struct fstab *new; new = (struct fstab *)malloc(sizeof (*fs)); if (new == NULL) @@ -490,8 +500,8 @@ getfstab(void) struct fstab * fstabsearch(const char *key) { - register struct pfstab *pf; - register struct fstab *fs; + struct pfstab *pf; + struct fstab *fs; const char *rn; for (pf = table; pf != NULL; pf = pf->pf_next) { @@ -518,9 +528,9 @@ fstabsearch(const char *key) struct fstab * fstabsearchdir(const char *key, char *directory) { - register struct pfstab *pf; - register struct fstab *fs; - register struct fstab *found_fs = NULL; + struct pfstab *pf; + struct fstab *fs; + struct fstab *found_fs = NULL; unsigned int size = 0; struct stat buf; @@ -530,7 +540,7 @@ fstabsearchdir(const char *key, char *directory) for (pf = table; pf != NULL; pf = pf->pf_next) { fs = pf->pf_fstab; if (strlen(fs->fs_file) > size && - strlen(key) > strlen(fs->fs_file) + 1 && + strlen(key) > strlen(fs->fs_file) && strncmp(fs->fs_file, key, strlen(fs->fs_file)) == 0 && (key[strlen(fs->fs_file)] == '/' || fs->fs_file[strlen(fs->fs_file) - 1] == '/')) { @@ -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); }