X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=restore%2Futilities.c;h=1d88c855b36f0fe190f5d5454cda23683a667512;hb=5bbb0926a5e765575c199573ea3b3d0f5ecd99a2;hp=34f9f8d7f14c4f8bba849178577088e708d0d6c3;hpb=a1b67fc50f87e9febfd56bd2a7089eb569b852f6;p=dump.git diff --git a/restore/utilities.c b/restore/utilities.c index 34f9f8d..1d88c85 100644 --- a/restore/utilities.c +++ b/restore/utilities.c @@ -41,7 +41,7 @@ #ifndef lint static const char rcsid[] = - "$Id: utilities.c,v 1.13 2001/03/20 10:02:48 stelian Exp $"; + "$Id: utilities.c,v 1.16 2001/06/18 10:58:28 stelian Exp $"; #endif /* not lint */ #include @@ -56,7 +56,12 @@ static const char rcsid[] = #ifdef __linux__ #include +#include +#ifdef HAVE_EXT2FS_EXT2_FS_H +#include +#else #include +#endif #include #include #else /* __linux__ */ @@ -465,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 *tpos, int exactmatch) +{ + char *p, *pp; + char numbuff[32]; + unsigned long tmpino; + long tmptnum; + 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 = atol(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 */