X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=dump%2Ftraverse.c;h=632a6a39d4350823cd042318a36b17dd41ff3fab;hb=c534413c6ada5778ccbb76f36bdcff672037d0cc;hp=c4e1e9ab0dde48fe1ab28bb3d7aa1dfd46f3b47b;hpb=aca7d867ae18bd62627f16ef90e58b433b881056;p=dump.git diff --git a/dump/traverse.c b/dump/traverse.c index c4e1e9a..632a6a3 100644 --- a/dump/traverse.c +++ b/dump/traverse.c @@ -41,7 +41,7 @@ #ifndef lint static const char rcsid[] = - "$Id: traverse.c,v 1.31 2001/03/28 12:59:48 stelian Exp $"; + "$Id: traverse.c,v 1.35 2001/07/18 08:50:58 stelian Exp $"; #endif /* not lint */ #include @@ -55,7 +55,11 @@ static const char rcsid[] = #include #include #ifdef __linux__ +#ifdef HAVE_EXT2FS_EXT2_FS_H +#include +#else #include +#endif #include #include #include @@ -369,6 +373,54 @@ mapfiles(dump_ino_t maxino, long *tapesize) } #endif /* __linux__ */ +#ifdef __linux__ +int +maponefile(dump_ino_t maxino, long *tapesize, char *directory) +{ + errcode_t retval; + ext2_ino_t dir_ino; + char dir_name [MAXPATHLEN]; + int i, anydirskipped = 0; + + /* + * Mark every directory in the path as being dumped + */ + for (i = 0; i < strlen (directory); i++) { + if (directory[i] == '/') { + strncpy (dir_name, directory, i); + dir_name[i] = '\0'; + retval = ext2fs_namei(fs, ROOTINO, ROOTINO, + dir_name, &dir_ino); + if (retval) { + com_err(disk, retval, + "while translating %s", dir_name); + exit(X_ABORT); + } + mapfileino((dump_ino_t) dir_ino, 0, + tapesize, &anydirskipped); + } + } + /* + * Mark the final directory + */ + retval = ext2fs_namei(fs, ROOTINO, ROOTINO, directory, &dir_ino); + if (retval) { + com_err(disk, retval, "while translating %s", directory); + exit(X_ABORT); + } + mapfileino((dump_ino_t)dir_ino, 0, tapesize, &anydirskipped); + + mapfileino(ROOTINO, 0, tapesize, &anydirskipped); + + /* + * Restore gets very upset if the root is not dumped, + * so ensure that it always is dumped. + */ + SETINO(ROOTINO, dumpdirmap); + return anydirskipped; +} +#endif /* __linux__ */ + #ifdef __linux__ struct mapfile_context { long *tapesize; @@ -748,9 +800,10 @@ void dumpino(struct dinode *dp, dump_ino_t ino) { unsigned long cnt; - fsizeT size; + fsizeT size, remaining; char buf[TP_BSIZE]; struct old_bsd_inode obi; + int i; #ifdef __linux__ struct block_context bc; #else @@ -867,6 +920,17 @@ dumpino(struct dinode *dp, dump_ino_t ino) bc.next_block = NDADDR; ext2fs_block_iterate2(fs, (ext2_ino_t)ino, 0, NULL, dumponeblock, (void *)&bc); + /* deal with holes at the end of the inode */ + if (i_size > bc.next_block*sblock->fs_fsize) { + remaining = i_size - bc.next_block*sblock->fs_fsize; + for (i = 0; i < howmany(remaining, sblock->fs_fsize); i++) { + bc.buf[bc.cnt++] = 0; + if (bc.cnt == bc.max) { + blksout (bc.buf, bc.cnt, bc.ino); + bc.cnt = 0; + } + } + } if (bc.cnt > 0) { blksout (bc.buf, bc.cnt, bc.ino); }