X-Git-Url: https://git.wh0rd.org/?p=dump.git;a=blobdiff_plain;f=restore%2Frestore.c;h=b95e3569cd8b79e07c21ecc8c2f13c73fb5c8458;hp=2a398fc18816e9c7e5ada0ca2fb4c11c856d139b;hb=0556ca2241619d3aded24726dfe34a511da39d52;hpb=fe0e02857a1ff7db4bf8cb28780de7ecf2f24234 diff --git a/restore/restore.c b/restore/restore.c index 2a398fc..b95e356 100644 --- a/restore/restore.c +++ b/restore/restore.c @@ -18,11 +18,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -41,7 +37,7 @@ #ifndef lint static const char rcsid[] = - "$Id: restore.c,v 1.27 2002/02/04 11:18:46 stelian Exp $"; + "$Id: restore.c,v 1.33 2003/11/22 16:52:16 stelian Exp $"; #endif /* not lint */ #include @@ -58,8 +54,14 @@ static const char rcsid[] = #endif #include #else /* __linux__ */ +#ifdef sunos +#include +#include +#else #include +#endif #endif /* __linux__ */ + #include #include @@ -159,7 +161,7 @@ addfile(char *name, dump_ino_t ino, int type) */ /* ARGSUSED */ long -deletefile(char *name, dump_ino_t ino, int type) +deletefile(char *name, dump_ino_t ino, UNUSED(int type)) { long descend = hflag ? GOOD : FAIL; struct entry *ep; @@ -217,8 +219,11 @@ removeoldleaves(void) continue; #ifdef __linux__ (void)fprintf(stderr, "BUG! Should call delwhiteout\n"); +#else +#ifdef sunos #else delwhiteout(ep); +#endif #endif freeentry(ep); } @@ -746,6 +751,7 @@ createleaves(char *symtabfile) struct entry *ep; dump_ino_t first; long curvol; + int doremove; if (command == 'R') { Vprintf(stdout, "Continue extraction of new leaves\n"); @@ -796,18 +802,50 @@ createleaves(char *symtabfile) * be removed since its type may change from one leaf type * to another (e.g. "file" to "character special"). */ - if ((ep->e_flags & EXTRACT) != 0) { - removeleaf(ep); - ep->e_flags &= ~REMOVED; - } - (void) extractfile(myname(ep)); + if ((ep->e_flags & EXTRACT) != 0) + doremove = 1; + else + doremove = 0; + (void) extractfile(ep, doremove); ep->e_flags &= ~(NEW|EXTRACT); + +finderres: + if ((first == curfile.ino) && (spcl.c_flags & DR_EXTATTRIBUTES)) { + switch (spcl.c_extattributes) { + case EXT_MACOSFNDRINFO: +#ifdef DUMP_MACOSX + (void)extractfinderinfoufs(myname(ep)); +#else + msg("MacOSX not supported in this version, skipping\n"); + skipfile(); +#endif + break; + case EXT_MACOSRESFORK: +#ifdef DUMP_MACOSX + (void)extractresourceufs(myname(ep)); +#else + msg("MacOSX not supported in this version, skipping\n"); + skipfile(); +#endif + break; + case EXT_ACL: + msg("ACLs not supported in this version, skipping\n"); + skipfile(); + break; + default: + msg("unexpected inode extension %ld, skipping\n", spcl.c_extattributes); + skipfile(); + break; + } + goto finderres; + } + /* * We checkpoint the restore after every tape reel, so * as to simplify the amount of work required by the * 'R' command. */ - next: +next: if (curvol != volno) { dumpsymtable(symtabfile, volno); skipmaps(); @@ -847,8 +885,9 @@ createfiles(void) long curvol; #ifdef USE_QFA long tnum, tmpcnt; - long long tpos, curtpos; + long long tpos, curtpos = 0; time_t tistart, tiend, titaken; + int volChg; #endif Vprintf(stdout, "Extract requested files\n"); @@ -910,43 +949,41 @@ createfiles(void) #ifdef USE_QFA tistart = time(NULL); if (tapeposflag) { - /* get tape position for inode (position directly) */ - (void)Inode2Tapepos(next, &tnum, &tpos, 1); - if (tpos == 0) - /* get tape position for last available inode - * (position before) */ - (void)Inode2Tapepos(next, &tnum, &tpos, 0); + /* get tape position for inode */ + (void)Inode2Tapepos(next, &tnum, &tpos, 0); if (tpos != 0) { - if (tnum != volno) + if (tnum != volno) { (void)RequestVol(tnum); + volChg = 1; + } else { + volChg = 0; + } if (GetTapePos(&curtpos) == 0) { /* curtpos +1000 ???, some drives * might be too slow */ - if (tpos != curtpos) { + if (((tpos > (curtpos + 1000)) && (volChg == 0)) || ((tpos != curtpos) && (volChg == 1))) { + volChg = 0; #ifdef DEBUG_QFA - msg("positioning tape %ld from %lld to %lld for inode %10lu ...\n", volno, curtpos, tpos, (unsigned long)next); + msg("positioning tape %ld from %lld to %lld for inode %lu ...\n", volno, curtpos, tpos, (unsigned long)next); #endif if (GotoTapePos(tpos) == 0) { #ifdef DEBUG_QFA - if (GetTapePos(&curtpos) == 0) - msg("before resync at tape position %lld (%ld, %ld, %s)\n", curtpos, next, curfile.ino, curfile.name); + if (GetTapePos(&curtpos) == 0) { + msg("before resnyc at tape position %lld (%ld, %ld, %s)\n", curtpos, next, curfile.ino, curfile.name); + } #endif -msg("bobo1\n"); ReReadInodeFromTape(next); #ifdef DEBUG_QFA -msg("bobo2\n"); if (GetTapePos(&curtpos) == 0) { -msg("bobo3\n"); - msg("after resync at tape position %lld (%ld, %ld, %s)\n", curtpos, next, curfile.ino, curfile.name); -msg("bobo4\n"); + msg("after resnyc at tape position %lld (%ld, %ld, %s)\n", curtpos, next, curfile.ino, curfile.name); } #endif } - } + } else { #ifdef DEBUG_QFA - else - msg("already at tape %ld position %ld for inode %10lu ...\n", volno, tpos, (unsigned long)next); + msg("already at tape %ld position %ld for inode %lu ...\n", volno, tpos, (unsigned long)next); #endif + } } } } @@ -955,7 +992,7 @@ msg("bobo4\n"); if (volinfo[1] == ROOTINO) { int i, goodvol = 1; - for (i = 1; i < TP_NINOS && volinfo[i] != 0; ++i) + for (i = 1; i < (int)TP_NINOS && volinfo[i] != 0; ++i) if (volinfo[i] < next) goodvol = i; @@ -1007,9 +1044,9 @@ msg("bobo4\n"); panic("corrupted symbol table\n"); #ifdef USE_QFA if (!createtapeposflag) +#endif fprintf(stderr, "%s: (inode %lu) not found on tape\n", myname(ep), (unsigned long)next); -#endif ep->e_flags &= ~NEW; next = lowerbnd(next); } @@ -1027,14 +1064,44 @@ msg("bobo4\n"); msg("inode %ld at tapepos %ld\n", curfile.ino, curtapepos); #endif sprintf(gTps, "%ld\t%ld\t%lld\n", (unsigned long)curfile.ino, volno, curtapepos); - if (write(gTapeposfd, gTps, strlen(gTps)) != strlen(gTps)) - warn("error writing tapepos file.\n"); + if (write(gTapeposfd, gTps, strlen(gTps)) != (ssize_t)strlen(gTps)) + warn("error writing tapepos file.\n"); skipfile(); - } - else { - msg("restoring %s\n", myname(ep)); + } else { #endif /* USE_QFA */ - (void) extractfile(myname(ep)); + (void) extractfile(ep, 0); + +finderres: + if ((next == curfile.ino) && (spcl.c_flags & DR_EXTATTRIBUTES)) { + switch (spcl.c_extattributes) { + case EXT_MACOSFNDRINFO: +#ifdef DUMP_MACOSX + (void)extractfinderinfoufs(myname(ep)); +#else + msg("MacOSX not supported in this version, skipping\n"); + skipfile(); +#endif + break; + case EXT_MACOSRESFORK: +#ifdef DUMP_MACOSX + (void)extractresourceufs(myname(ep)); +#else + msg("MacOSX not supported in this version, skipping\n"); + skipfile(); +#endif + break; + case EXT_ACL: + msg("ACLs not supported in this version, skipping\n"); + skipfile(); + break; + default: + msg("unexpected inode extension %ld, skipping\n", spcl.c_extattributes); + skipfile(); + break; + } + goto finderres; + } + #ifdef USE_QFA } #endif /* USE_QFA */ @@ -1062,8 +1129,11 @@ createlinks(void) continue; #ifdef __linux__ (void)fprintf(stderr, "BUG! Should call addwhiteout\n"); +#else +#ifdef sunos #else (void) addwhiteout(myname(ep)); +#endif #endif ep->e_flags &= ~NEW; }