X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=restore%2Futilities.c;h=e897344a1e0a85ef5bec3d5f0bdb9aee51fae362;hb=6c8b464ab6bbfa954c7770df135ea5621250045b;hp=f052071484824a7fc41db11ad265f0e90507c728;hpb=c60338a56124b7cef872965711e81af4b396d28e;p=dump.git diff --git a/restore/utilities.c b/restore/utilities.c index f052071..e897344 100644 --- a/restore/utilities.c +++ b/restore/utilities.c @@ -2,7 +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 , 1999-2000 + * Stelian Pop - AlcĂ´ve , 2000-2002 */ /* @@ -40,31 +41,34 @@ #ifndef lint static const char rcsid[] = - "$Id: utilities.c,v 1.8 2000/02/08 12:22:43 stelian Exp $"; + "$Id: utilities.c,v 1.20 2002/02/04 11:18:46 stelian Exp $"; #endif /* not lint */ +#include +#include +#include +#include +#include +#include + #include #include #ifdef __linux__ #include +#include +#ifdef HAVE_EXT2FS_EXT2_FS_H +#include +#else #include +#endif +#include #include #else /* __linux__ */ #include #include #endif /* __linux__ */ -#include -#include -#include -#include -#include - -#ifdef __linux__ -#include -#endif - #include "restore.h" #include "extern.h" @@ -74,7 +78,7 @@ static const char rcsid[] = void pathcheck(char *name) { - register char *cp; + char *cp; struct entry *ep; char *start; @@ -232,7 +236,7 @@ linkit(char *existing, char *new, int type) if (!Nflag && (ret = link(existing, new)) < 0) { -#ifndef __linux__ +#if !defined(__linux__) && !defined(sunos) struct stat s; /* @@ -272,7 +276,7 @@ linkit(char *existing, char *new, int type) return (GOOD); } -#ifndef __linux__ +#if !defined(__linux__) && !defined(sunos) /* * Create a whiteout. */ @@ -312,10 +316,10 @@ delwhiteout(struct entry *ep) /* * find lowest number file (above "start") that needs to be extracted */ -ino_t -lowerbnd(ino_t start) +dump_ino_t +lowerbnd(dump_ino_t start) { - register struct entry *ep; + struct entry *ep; for ( ; start < maxino; start++) { ep = lookupino(start); @@ -330,10 +334,10 @@ lowerbnd(ino_t start) /* * find highest number file (below "start") that needs to be extracted */ -ino_t -upperbnd(ino_t start) +dump_ino_t +upperbnd(dump_ino_t start) { - register struct entry *ep; + struct entry *ep; for ( ; start > ROOTINO; start--) { ep = lookupino(start); @@ -398,11 +402,11 @@ flagvalues(struct entry *ep) /* * Check to see if a name is on a dump tape. */ -ino_t +dump_ino_t dirlookup(const char *name) { struct direct *dp; - ino_t ino; + dump_ino_t ino; ino = ((dp = pathsearch(name)) == NULL) ? 0 : dp->d_ino; @@ -466,3 +470,76 @@ panic(fmt, va_alist) exit(1); } } + +#ifdef USE_QFA +/* + * search for ino in QFA file + * + * if exactmatch: + * if ino found return tape number and tape position + * if ino not found return tnum=0 and tpos=0 + * + * if not exactmatch: + * if ino found return tape number and tape position + * if ino not found return tape number and tape position of last smaller ino + * if no smaller inode found return tnum=0 and tpos=0 + */ +int +Inode2Tapepos(dump_ino_t ino, long *tnum, long long *tpos, int exactmatch) +{ + char *p, *pp; + char numbuff[32]; + unsigned long tmpino; + long tmptnum; + long long tmptpos; + + *tpos = 0; + *tnum = 0; + if (fseek(gTapeposfp, gSeekstart, SEEK_SET) == -1) + return errno; + while (fgets(gTps, sizeof(gTps), gTapeposfp) != NULL) { + gTps[strlen(gTps) - 1] = 0; /* delete end of line */ + p = gTps; + bzero(numbuff, sizeof(numbuff)); + pp = numbuff; + /* read inode */ + while ((*p != 0) && (*p != '\t')) + *pp++ = *p++; + tmpino = atol(numbuff); + if (*p == 0) + return 1; /* may NOT happen */ + p++; + bzero(numbuff, sizeof(numbuff)); + pp = numbuff; + /* read tapenum */ + while ((*p != 0) && (*p != '\t')) + *pp++ = *p++; + if (*p == 0) + return 1; /* may NOT happen */ + tmptnum = atol(numbuff); + p++; + bzero(numbuff, sizeof(numbuff)); + pp = numbuff; + /* read tapepos */ + while ((*p != 0) && (*p != '\t')) + *pp++ = *p++; + tmptpos = atoll(numbuff); + + if (exactmatch) { + if (tmpino == ino) { + *tnum = tmptnum; + *tpos = tmptpos; + return 0; + } + } else { + if (tmpino > ino) { + return 0; + } else { + *tnum = tmptnum; + *tpos = tmptpos; + } + } + } + return 0; +} +#endif /* USE_QFA */