]>
git.wh0rd.org - dump.git/blob - restore/restore.c
2 * Ported to Linux's Second Extended File System as part of the
3 * dump and restore backup suit
4 * Remy Card <card@Linux.EU.Org>, 1994-1997
5 * Stelian Pop <stelian@popies.net>, 1999-2000
6 * Stelian Pop <stelian@popies.net> - AlcĂ´ve <www.alcove.com>, 2000-2002
10 * Copyright (c) 1983, 1993
11 * The Regents of the University of California. All rights reserved.
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * 3. Neither the name of the University nor the names of its contributors
22 * may be used to endorse or promote products derived from this software
23 * without specific prior written permission.
25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 static const char rcsid
[] =
40 "$Id: restore.c,v 1.33 2003/11/22 16:52:16 stelian Exp $";
44 #include <sys/types.h>
47 #include <sys/param.h>
50 #ifdef HAVE_EXT2FS_EXT2_FS_H
51 #include <ext2fs/ext2_fs.h>
53 #include <linux/ext2_fs.h>
55 #include <bsdcompat.h>
58 #include <sys/fcntl.h>
59 #include <bsdcompat.h>
61 #include <ufs/ufs/dinode.h>
63 #endif /* __linux__ */
65 #include <protocols/dumprestore.h>
67 #include <compaterr.h>
73 #include <ext2fs/ext2fs.h>
79 static char *keyval
__P((int));
82 * This implements the 't' option.
83 * List entries on the tape.
86 listfile(char *name
, dump_ino_t ino
, int type
)
88 long descend
= hflag
? GOOD
: FAIL
;
94 if (TSTINO(ino
, dumpmap
) == 0)
96 Vprintf(stdout
, "%s", type
== LEAF
? "leaf" : "dir ");
98 if (tapeposflag
) { /* add QFA positions to output */
99 (void)Inode2Tapepos(ino
, &tnum
, &tpos
, 1);
100 fprintf(stdout
, "%10lu\t%ld\t%lld\t%s\n", (unsigned long)ino
,
105 fprintf(stdout
, "%10lu\t%s\n", (unsigned long)ino
, name
);
110 * This implements the 'x' option.
111 * Request that new entries be extracted.
114 addfile(char *name
, dump_ino_t ino
, int type
)
116 struct entry
*ep
, *np
;
117 long descend
= hflag
? GOOD
: FAIL
;
120 if (TSTINO(ino
, dumpmap
) == 0) {
121 Dprintf(stdout
, "%s: not on the tape\n", name
);
124 if (ino
== WINO
&& command
== 'i' && !vflag
)
127 (void) snprintf(buf
, sizeof(buf
), "./%lu", (unsigned long)ino
);
130 (void) genliteraldir(name
, ino
);
136 if (strcmp(name
, myname(ep
)) == 0) {
141 for (np
= ep
->e_links
; np
; np
= np
->e_links
)
142 if (strcmp(name
, myname(np
)) == 0) {
147 ep
= addentry(name
, ino
, type
);
149 if ((type
== NODE
) && (!createtapeposflag
))
159 * This is used by the 'i' option to undo previous requests made by addfile.
160 * Delete entries from the request queue.
164 deletefile(char *name
, dump_ino_t ino
, UNUSED(int type
))
166 long descend
= hflag
? GOOD
: FAIL
;
169 if (TSTINO(ino
, dumpmap
) == 0)
171 ep
= lookupname(name
);
174 ep
->e_flags
|= REMOVED
;
175 if (ep
->e_type
!= NODE
)
182 * The following four routines implement the incremental
183 * restore algorithm. The first removes old entries, the second
184 * does renames and calculates the extraction list, the third
185 * cleans up link names missed by the first two, and the final
186 * one deletes old directories.
188 * Directories cannot be immediately deleted, as they may have
189 * other files in them which need to be moved out first. As
190 * directories to be deleted are found, they are put on the
191 * following deletion list. After all deletions and renames
192 * are done, this list is actually deleted.
194 static struct entry
*removelist
;
197 * Remove invalid whiteouts from the old tree.
198 * Remove unneeded leaves from the old tree.
199 * Remove directories from the lookup chains.
202 removeoldleaves(void)
204 struct entry
*ep
, *nextep
;
205 dump_ino_t i
, mydirino
;
207 Vprintf(stdout
, "Mark entries to be removed.\n");
208 if ((ep
= lookupino(WINO
))) {
209 Vprintf(stdout
, "Delete whiteouts\n");
210 for ( ; ep
!= NULL
; ep
= nextep
) {
211 nextep
= ep
->e_links
;
212 mydirino
= ep
->e_parent
->e_ino
;
214 * We remove all whiteouts that are in directories
215 * that have been removed or that have been dumped.
217 if (TSTINO(mydirino
, usedinomap
) &&
218 !TSTINO(mydirino
, dumpmap
))
221 (void)fprintf(stderr
, "BUG! Should call delwhiteout\n");
231 for (i
= ROOTINO
+ 1; i
< maxino
; i
++) {
235 if (TSTINO(i
, usedinomap
))
237 for ( ; ep
!= NULL
; ep
= ep
->e_links
) {
238 Dprintf(stdout
, "%s: REMOVE\n", myname(ep
));
239 if (ep
->e_type
== LEAF
) {
244 deleteino(ep
->e_ino
);
245 ep
->e_next
= removelist
;
253 * For each directory entry on the incremental tape, determine which
254 * category it falls into as follows:
255 * KEEP - entries that are to be left alone.
256 * NEW - new entries to be added.
257 * EXTRACT - files that must be updated with new contents.
258 * LINK - new links to be added.
259 * Renames are done at the same time.
262 nodeupdates(char *name
, dump_ino_t ino
, int type
)
264 struct entry
*ep
, *np
, *ip
;
269 # define ONTAPE 0x1 /* inode is on the tape */
270 # define INOFND 0x2 /* inode already exists */
271 # define NAMEFND 0x4 /* name already exists */
272 # define MODECHG 0x8 /* mode of inode changed */
275 * This routine is called once for each element in the
276 * directory hierarchy, with a full path name.
277 * The "type" value is incorrectly specified as LEAF for
278 * directories that are not on the dump tape.
280 * Check to see if the file is on the tape.
282 if (TSTINO(ino
, dumpmap
))
285 * Check to see if the name exists, and if the name is a link.
287 np
= lookupname(name
);
290 ip
= lookupino(np
->e_ino
);
292 panic("corrupted symbol table\n");
297 * Check to see if the inode exists, and if one of its links
298 * corresponds to the name (if one was found).
303 for (ep
= ip
->e_links
; ep
!= NULL
; ep
= ep
->e_links
) {
311 * If both a name and an inode are found, but they do not
312 * correspond to the same file, then both the inode that has
313 * been found and the inode corresponding to the name that
314 * has been found need to be renamed. The current pathname
315 * is the new name for the inode that has been found. Since
316 * all files to be deleted have already been removed, the
317 * named file is either a now unneeded link, or it must live
318 * under a new name in this dump level. If it is a link, it
319 * can be removed. If it is not a link, it is given a
320 * temporary name in anticipation that it will be renamed
321 * when it is later found by inode number.
323 if (((key
& (INOFND
|NAMEFND
)) == (INOFND
|NAMEFND
)) && ip
!= np
) {
324 if (lookuptype
== LINK
) {
328 Dprintf(stdout
, "name/inode conflict, mktempname %s\n",
335 if ((key
& ONTAPE
) &&
336 (((key
& INOFND
) && ip
->e_type
!= type
) ||
337 ((key
& NAMEFND
) && np
->e_type
!= type
)))
341 * Decide on the disposition of the file based on its flags.
342 * Note that we have already handled the case in which
343 * a name and inode are found that correspond to different files.
344 * Thus if both NAMEFND and INOFND are set then ip == np.
349 * A previously existing file has been found.
350 * Mark it as KEEP so that other links to the inode can be
351 * detected, and so that it will not be reclaimed by the search
352 * for unreferenced names.
356 Dprintf(stdout
, "[%s] %s: %s\n", keyval(key
), name
,
361 * A file on the tape has a name which is the same as a name
362 * corresponding to a different file in the previous dump.
363 * Since all files to be deleted have already been removed,
364 * this file is either a now unneeded link, or it must live
365 * under a new name in this dump level. If it is a link, it
366 * can simply be removed. If it is not a link, it is given a
367 * temporary name in anticipation that it will be renamed
368 * when it is later found by inode number (see INOFND case
369 * below). The entry is then treated as a new file.
372 case ONTAPE
|NAMEFND
|MODECHG
:
373 if (lookuptype
== LINK
) {
382 * A previously non-existent file.
383 * Add it to the file system, and request its extraction.
384 * If it is a directory, create it immediately.
385 * (Since the name is unused there can be no conflict)
388 ep
= addentry(name
, ino
, type
);
391 ep
->e_flags
|= NEW
|KEEP
;
392 Dprintf(stdout
, "[%s] %s: %s\n", keyval(key
), name
,
397 * A file with the same inode number, but a different
398 * name has been found. If the other name has not already
399 * been found (indicated by the KEEP flag, see above) then
400 * this must be a new name for the file, and it is renamed.
401 * If the other name has been found then this must be a
402 * link to the file. Hard links to directories are not
403 * permitted, and are either deleted or converted to
404 * symbolic links. Finally, if the file is on the tape,
405 * a request is made to extract it.
408 if (type
== LEAF
&& (ip
->e_flags
& KEEP
) == 0)
409 ip
->e_flags
|= EXTRACT
;
412 if ((ip
->e_flags
& KEEP
) == 0) {
413 renameit(myname(ip
), name
);
416 Dprintf(stdout
, "[%s] %s: %s\n", keyval(key
), name
,
420 if (ip
->e_type
== NODE
) {
423 "deleted hard link %s to directory %s\n",
427 ep
= addentry(name
, ino
, type
|LINK
);
429 Dprintf(stdout
, "[%s] %s: %s|LINK\n", keyval(key
), name
,
434 * A previously known file which is to be updated. If it is a link,
435 * then all names referring to the previous file must be removed
436 * so that the subset of them that remain can be recreated.
438 case ONTAPE
|INOFND
|NAMEFND
:
439 if (lookuptype
== LINK
) {
442 ep
= addentry(name
, ino
, type
|LINK
);
445 ep
->e_flags
|= NEW
|KEEP
;
446 Dprintf(stdout
, "[%s] %s: %s|LINK\n", keyval(key
), name
,
450 if (type
== LEAF
&& lookuptype
!= LINK
)
451 np
->e_flags
|= EXTRACT
;
453 Dprintf(stdout
, "[%s] %s: %s\n", keyval(key
), name
,
458 * An inode is being reused in a completely different way.
459 * Normally an extract can simply do an "unlink" followed
460 * by a "creat". Here we must do effectively the same
461 * thing. The complications arise because we cannot really
462 * delete a directory since it may still contain files
463 * that we need to rename, so we delete it from the symbol
464 * table, and put it on the list to be deleted eventually.
465 * Conversely if a directory is to be created, it must be
466 * done immediately, rather than waiting until the
469 case ONTAPE
|INOFND
|MODECHG
:
470 case ONTAPE
|INOFND
|NAMEFND
|MODECHG
:
471 if (ip
->e_flags
& KEEP
) {
472 badentry(ip
, "cannot KEEP and change modes");
475 if (ip
->e_type
== LEAF
) {
476 /* changing from leaf to node */
477 for ( ; ip
!= NULL
; ip
= ip
->e_links
) {
478 if (ip
->e_type
!= LEAF
)
479 badentry(ip
, "NODE and LEAF links to same inode");
483 ip
= addentry(name
, ino
, type
);
486 /* changing from node to leaf */
487 if ((ip
->e_flags
& TMPNAME
) == 0)
489 deleteino(ip
->e_ino
);
490 ip
->e_next
= removelist
;
492 ip
= addentry(name
, ino
, type
);
494 ip
->e_flags
|= NEW
|KEEP
;
495 Dprintf(stdout
, "[%s] %s: %s\n", keyval(key
), name
,
500 * A hard link to a directory that has been removed.
504 Dprintf(stdout
, "[%s] %s: Extraneous name\n", keyval(key
),
510 * If we find a directory entry for a file that is not on
511 * the tape, then we must have found a file that was created
512 * while the dump was in progress. Since we have no contents
513 * for it, we discard the name knowing that it will be on the
514 * next incremental tape.
517 if (compare_ignore_not_found
) break;
518 fprintf(stderr
, "%s: (inode %lu) not found on tape\n",
519 name
, (unsigned long)ino
);
524 * If any of these arise, something is grievously wrong with
525 * the current state of the symbol table.
527 case INOFND
|NAMEFND
|MODECHG
:
528 case NAMEFND
|MODECHG
:
530 fprintf(stderr
, "[%s] %s: inconsistent state\n", keyval(key
),
535 * These states "cannot" arise for any state of the symbol table.
540 panic("[%s] %s: impossible state\n", keyval(key
), name
);
547 * Calculate the active flags in a key.
552 static char keybuf
[32];
554 (void) strcpy(keybuf
, "|NIL");
557 (void) strcat(keybuf
, "|ONTAPE");
559 (void) strcat(keybuf
, "|INOFND");
561 (void) strcat(keybuf
, "|NAMEFND");
563 (void) strcat(keybuf
, "|MODECHG");
568 * Find unreferenced link names.
573 struct entry
*ep
, *np
;
576 Vprintf(stdout
, "Find unreferenced names.\n");
577 for (i
= ROOTINO
; i
< maxino
; i
++) {
579 if (ep
== NULL
|| ep
->e_type
== LEAF
|| TSTINO(i
, dumpmap
) == 0)
581 for (np
= ep
->e_entries
; np
!= NULL
; np
= np
->e_sibling
) {
582 if (np
->e_flags
== 0) {
584 "%s: remove unreferenced name\n",
592 * Any leaves remaining in removed directories is unreferenced.
594 for (ep
= removelist
; ep
!= NULL
; ep
= ep
->e_next
) {
595 for (np
= ep
->e_entries
; np
!= NULL
; np
= np
->e_sibling
) {
596 if (np
->e_type
== LEAF
) {
597 if (np
->e_flags
!= 0)
598 badentry(np
, "unreferenced with flags");
600 "%s: remove unreferenced name\n",
610 * Remove old nodes (directories).
611 * Note that this routine runs in O(N*D) where:
612 * N is the number of directory entries to be removed.
613 * D is the maximum depth of the tree.
614 * If N == D this can be quite slow. If the list were
615 * topologically sorted, the deletion could be done in
621 struct entry
*ep
, **prev
;
624 Vprintf(stdout
, "Remove old nodes (directories).\n");
628 for (ep
= removelist
; ep
!= NULL
; ep
= *prev
) {
629 if (ep
->e_entries
!= NULL
) {
639 for (ep
= removelist
; ep
!= NULL
; ep
= ep
->e_next
)
640 badentry(ep
, "cannot remove, non-empty");
643 /* Compare the file specified in `ep' (which is on tape) to the */
644 /* current copy of this file on disk. If do_compare is 0, then just */
645 /* make our caller think we did it--this is used to handle hard links */
646 /* to files and devices. */
648 compare_entry(struct entry
*ep
, int do_compare
)
650 if ((ep
->e_flags
& (NEW
|EXTRACT
)) == 0) {
651 badentry(ep
, "unexpected file on tape");
654 if (do_compare
) (void) comparefile(myname(ep
));
655 ep
->e_flags
&= ~(NEW
|EXTRACT
);
659 * This is the routine used to compare files for the 'C' command.
668 first
= lowerbnd(ROOTINO
);
670 while (curfile
.ino
< maxino
) {
671 first
= lowerbnd(first
);
673 * If the next available file is not the one which we
674 * expect then we have missed one or more files. Since
675 * we do not request files that were not on the tape,
676 * the lost files must have been due to a tape read error,
677 * or a file that was removed while the dump was in progress.
679 while (first
< curfile
.ino
) {
680 ep
= lookupino(first
);
682 panic("%d: bad first\n", first
);
683 fprintf(stderr
, "%s: not found on tape\n", myname(ep
));
685 ep
->e_flags
&= ~(NEW
|EXTRACT
);
686 first
= lowerbnd(first
);
689 * If we find files on the tape that have no corresponding
690 * directory entries, then we must have found a file that
691 * was created while the dump was in progress. Since we have
692 * no name for it, we discard it knowing that it will be
693 * on the next incremental tape.
695 if (first
!= curfile
.ino
) {
696 fprintf(stderr
, "expected next file %ld, got %lu\n",
697 (long)first
, (unsigned long)curfile
.ino
);
702 ep
= lookupino(curfile
.ino
);
704 panic("unknown file on tape\n");
707 compare_entry(ep
, 1);
708 for (ep
= ep
->e_links
; ep
!= NULL
; ep
= ep
->e_links
) {
709 compare_entry(ep
, 0);
713 * We checkpoint the restore after every tape reel, so
714 * as to simplify the amount of work re quired by the
718 if (curvol
!= volno
) {
724 * If we encounter the end of the tape and the next available
725 * file is not the one which we expect then we have missed one
726 * or more files. Since we do not request files that were not
727 * on the tape, the lost files must have been due to a tape
728 * read error, or a file that was removed while the dump was
731 first
= lowerbnd(first
);
732 while (first
< curfile
.ino
) {
733 ep
= lookupino(first
);
735 panic("%d: bad first\n", first
);
736 fprintf(stderr
, "%s: (inode %lu) not found on tape\n",
737 myname(ep
), (unsigned long)first
);
739 ep
->e_flags
&= ~(NEW
|EXTRACT
);
740 first
= lowerbnd(first
);
745 * This is the routine used to extract files for the 'r' command.
746 * Extract new leaves.
749 createleaves(char *symtabfile
)
756 if (command
== 'R') {
757 Vprintf(stdout
, "Continue extraction of new leaves\n");
759 Vprintf(stdout
, "Extract new leaves.\n");
760 dumpsymtable(symtabfile
, volno
);
762 first
= lowerbnd(ROOTINO
);
764 while (curfile
.ino
< maxino
) {
765 first
= lowerbnd(first
);
767 * If the next available file is not the one which we
768 * expect then we have missed one or more files. Since
769 * we do not request files that were not on the tape,
770 * the lost files must have been due to a tape read error,
771 * or a file that was removed while the dump was in progress.
773 while (first
< curfile
.ino
) {
774 ep
= lookupino(first
);
776 panic("%d: bad first\n", first
);
777 fprintf(stderr
, "%s: (inode %lu) not found on tape\n",
778 myname(ep
), (unsigned long)first
);
779 ep
->e_flags
&= ~(NEW
|EXTRACT
);
780 first
= lowerbnd(first
);
783 * If we find files on the tape that have no corresponding
784 * directory entries, then we must have found a file that
785 * was created while the dump was in progress. Since we have
786 * no name for it, we discard it knowing that it will be
787 * on the next incremental tape.
789 if (first
!= curfile
.ino
) {
790 fprintf(stderr
, "expected next file %ld, got %lu\n",
791 (long)first
, (unsigned long)curfile
.ino
);
795 ep
= lookupino(curfile
.ino
);
797 panic("unknown file on tape\n");
798 if ((ep
->e_flags
& (NEW
|EXTRACT
)) == 0)
799 badentry(ep
, "unexpected file on tape");
801 * If the file is to be extracted, then the old file must
802 * be removed since its type may change from one leaf type
803 * to another (e.g. "file" to "character special").
805 if ((ep
->e_flags
& EXTRACT
) != 0)
809 (void) extractfile(ep
, doremove
);
810 ep
->e_flags
&= ~(NEW
|EXTRACT
);
813 if ((first
== curfile
.ino
) && (spcl
.c_flags
& DR_EXTATTRIBUTES
)) {
814 switch (spcl
.c_extattributes
) {
815 case EXT_MACOSFNDRINFO
:
817 (void)extractfinderinfoufs(myname(ep
));
819 msg("MacOSX not supported in this version, skipping\n");
823 case EXT_MACOSRESFORK
:
825 (void)extractresourceufs(myname(ep
));
827 msg("MacOSX not supported in this version, skipping\n");
832 msg("ACLs not supported in this version, skipping\n");
836 msg("unexpected inode extension %ld, skipping\n", spcl
.c_extattributes
);
844 * We checkpoint the restore after every tape reel, so
845 * as to simplify the amount of work required by the
849 if (curvol
!= volno
) {
850 dumpsymtable(symtabfile
, volno
);
856 * If we encounter the end of the tape and the next available
857 * file is not the one which we expect then we have missed one
858 * or more files. Since we do not request files that were not
859 * on the tape, the lost files must have been due to a tape
860 * read error, or a file that was removed while the dump was
863 first
= lowerbnd(first
);
864 while (first
< curfile
.ino
) {
865 ep
= lookupino(first
);
867 panic("%d: bad first\n", first
);
868 fprintf(stderr
, "%s: (inode %lu) not found on tape\n",
869 myname(ep
), (unsigned long)first
);
871 ep
->e_flags
&= ~(NEW
|EXTRACT
);
872 first
= lowerbnd(first
);
877 * This is the routine used to extract files for the 'x' and 'i' commands.
878 * Efficiently extract a subset of the files on a tape.
883 dump_ino_t first
, next
, last
;
888 long long tpos
, curtpos
= 0;
889 time_t tistart
, tiend
, titaken
;
893 Vprintf(stdout
, "Extract requested files\n");
894 curfile
.action
= SKIP
;
900 if (volinfo
[1] == ROOTINO
)
906 first
= lowerbnd(ROOTINO
);
907 last
= upperbnd(maxino
- 1);
912 first
= lowerbnd(first
);
913 last
= upperbnd(last
);
915 * Check to see if any files remain to be extracted
920 * Reject any volumes with inodes greater
921 * than the last one needed
923 while (curfile
.ino
> last
) {
924 curfile
.action
= SKIP
;
927 if (curfile
.ino
== maxino
) {
928 next
= lowerbnd(first
);
929 while (next
< curfile
.ino
) {
930 ep
= lookupino(next
);
932 panic("corrupted symbol table\n");
933 fprintf(stderr
, "%s: (inode %lu) not found on tape\n",
934 myname(ep
), (unsigned long)next
);
936 next
= lowerbnd(next
);
944 * Decide on the next inode needed.
945 * Skip across the inodes until it is found
946 * or an out of order volume change is encountered
948 next
= lowerbnd(curfile
.ino
);
950 tistart
= time(NULL
);
952 /* get tape position for inode */
953 (void)Inode2Tapepos(next
, &tnum
, &tpos
, 0);
956 (void)RequestVol(tnum
);
961 if (GetTapePos(&curtpos
) == 0) {
962 /* curtpos +1000 ???, some drives
963 * might be too slow */
964 if (((tpos
> (curtpos
+ 1000)) && (volChg
== 0)) || ((tpos
!= curtpos
) && (volChg
== 1))) {
967 msg("positioning tape %ld from %lld to %lld for inode %lu ...\n", volno
, curtpos
, tpos
, (unsigned long)next
);
969 if (GotoTapePos(tpos
) == 0) {
971 if (GetTapePos(&curtpos
) == 0) {
972 msg("before resnyc at tape position %lld (%ld, %ld, %s)\n", curtpos
, next
, curfile
.ino
, curfile
.name
);
975 ReReadInodeFromTape(next
);
977 if (GetTapePos(&curtpos
) == 0) {
978 msg("after resnyc at tape position %lld (%ld, %ld, %s)\n", curtpos
, next
, curfile
.ino
, curfile
.name
);
984 msg("already at tape %ld position %ld for inode %lu ...\n", volno
, tpos
, (unsigned long)next
);
992 if (volinfo
[1] == ROOTINO
) {
995 for (i
= 1; i
< (int)TP_NINOS
&& volinfo
[i
] != 0; ++i
)
996 if (volinfo
[i
] < next
)
999 if (goodvol
!= volno
)
1000 RequestVol(goodvol
);
1005 while (next
> curfile
.ino
&& volno
== curvol
) {
1013 } while (volno
== curvol
+ 1);
1016 titaken
= tiend
- tistart
;
1018 if (titaken
/ 60 > 0)
1019 msg("%ld reads took %d:%02d:%02d\n",
1020 tmpcnt
, titaken
/ 3600,
1021 (titaken
% 3600) / 60, titaken
% 60);
1023 #endif /* USE_QFA */
1026 * If volume change out of order occurred the
1027 * current state must be recalculated
1029 if (volno
!= curvol
)
1032 * If the current inode is greater than the one we were
1033 * looking for then we missed the one we were looking for.
1034 * Since we only attempt to extract files listed in the
1035 * dump map, the lost files must have been due to a tape
1036 * read error, or a file that was removed while the dump
1037 * was in progress. Thus we report all requested files
1038 * between the one we were looking for, and the one we
1039 * found as missing, and delete their request flags.
1041 while (next
< curfile
.ino
) {
1042 ep
= lookupino(next
);
1044 panic("corrupted symbol table\n");
1046 if (!createtapeposflag
)
1048 fprintf(stderr
, "%s: (inode %lu) not found on tape\n",
1049 myname(ep
), (unsigned long)next
);
1050 ep
->e_flags
&= ~NEW
;
1051 next
= lowerbnd(next
);
1054 * The current inode is the one that we are looking for,
1055 * so extract it per its requested name.
1057 if (next
== curfile
.ino
&& next
<= last
) {
1058 ep
= lookupino(next
);
1060 panic("corrupted symbol table\n");
1062 if (createtapeposflag
) {
1064 msg("inode %ld at tapepos %ld\n", curfile
.ino
, curtapepos
);
1066 sprintf(gTps
, "%ld\t%ld\t%lld\n", (unsigned long)curfile
.ino
, volno
, curtapepos
);
1067 if (write(gTapeposfd
, gTps
, strlen(gTps
)) != (ssize_t
)strlen(gTps
))
1068 warn("error writing tapepos file.\n");
1071 #endif /* USE_QFA */
1072 (void) extractfile(ep
, 0);
1075 if ((next
== curfile
.ino
) && (spcl
.c_flags
& DR_EXTATTRIBUTES
)) {
1076 switch (spcl
.c_extattributes
) {
1077 case EXT_MACOSFNDRINFO
:
1079 (void)extractfinderinfoufs(myname(ep
));
1081 msg("MacOSX not supported in this version, skipping\n");
1085 case EXT_MACOSRESFORK
:
1087 (void)extractresourceufs(myname(ep
));
1089 msg("MacOSX not supported in this version, skipping\n");
1094 msg("ACLs not supported in this version, skipping\n");
1098 msg("unexpected inode extension %ld, skipping\n", spcl
.c_extattributes
);
1107 #endif /* USE_QFA */
1108 ep
->e_flags
&= ~NEW
;
1109 if (volno
!= curvol
)
1121 struct entry
*np
, *ep
;
1125 if ((ep
= lookupino(WINO
))) {
1126 Vprintf(stdout
, "Add whiteouts\n");
1127 for ( ; ep
!= NULL
; ep
= ep
->e_links
) {
1128 if ((ep
->e_flags
& NEW
) == 0)
1131 (void)fprintf(stderr
, "BUG! Should call addwhiteout\n");
1135 (void) addwhiteout(myname(ep
));
1138 ep
->e_flags
&= ~NEW
;
1141 Vprintf(stdout
, "Add links\n");
1142 for (i
= ROOTINO
; i
< maxino
; i
++) {
1146 for (np
= ep
->e_links
; np
!= NULL
; np
= np
->e_links
) {
1147 if ((np
->e_flags
& NEW
) == 0)
1149 (void) strcpy(name
, myname(ep
));
1150 if (ep
->e_type
== NODE
) {
1151 (void) linkit(name
, myname(np
), SYMLINK
);
1153 (void) linkit(name
, myname(np
), HARDLINK
);
1155 np
->e_flags
&= ~NEW
;
1161 * Check the symbol table.
1162 * We do this to insure that all the requested work was done, and
1163 * that no temporary names remain.
1171 Vprintf(stdout
, "Check the symbol table.\n");
1172 for (i
= WINO
; i
< maxino
; i
++) {
1173 for (ep
= lookupino(i
); ep
!= NULL
; ep
= ep
->e_links
) {
1174 ep
->e_flags
&= ~KEEP
;
1175 if (ep
->e_type
== NODE
)
1176 ep
->e_flags
&= ~(NEW
|EXISTED
);
1177 if (ep
->e_flags
/* != NULL */)
1178 badentry(ep
, "incomplete operations");
1184 * Compare with the directory structure on the tape
1185 * A paranoid check that things are as they should be.
1188 verifyfile(char *name
, dump_ino_t ino
, int type
)
1190 struct entry
*np
, *ep
;
1191 long descend
= GOOD
;
1193 ep
= lookupname(name
);
1195 fprintf(stderr
, "Warning: missing name %s\n", name
);
1198 np
= lookupino(ino
);
1201 for ( ; np
!= NULL
; np
= np
->e_links
)
1205 panic("missing inumber %d\n", ino
);
1206 if (ep
->e_type
== LEAF
&& type
!= LEAF
)
1207 badentry(ep
, "type should be LEAF");