X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=dump%2Ftraverse.c;h=e4cf7d383d924e6dfd45140e1eac77de9d174bdb;hb=2c99ad2dc97978b437794b14d58d9ae698ecabb9;hp=ebf605abe47edf3f2c6b382e3a7dbb1d0fba70b7;hpb=7422942fcabc3e5735e850fce8113e9751ddd399;p=dump.git diff --git a/dump/traverse.c b/dump/traverse.c index ebf605a..e4cf7d3 100644 --- a/dump/traverse.c +++ b/dump/traverse.c @@ -41,7 +41,7 @@ #ifndef lint static const char rcsid[] = - "$Id: traverse.c,v 1.30 2001/03/23 14:40:12 stelian Exp $"; + "$Id: traverse.c,v 1.33 2001/04/11 13:42:52 stelian Exp $"; #endif /* not lint */ #include @@ -128,6 +128,9 @@ typedef ino_t ext2_ino_t; #define EXT2_LIB_FEATURE_INCOMPAT_SUPP (EXT3_FEATURE_INCOMPAT_RECOVER | \ EXT2_FEATURE_INCOMPAT_FILETYPE) #endif +#ifndef EXT2_RESIZE_INO +#define EXT2_RESIZE_INO 7 +#endif int dump_fs_open(const char *disk, ext2_filsys *fs) { @@ -152,12 +155,16 @@ int dump_fs_open(const char *disk, ext2_filsys *fs) retval = EXT2_ET_UNSUPP_FEATURE; ext2fs_close(*fs); } - else if (es->s_feature_compat & + else { + if (es->s_feature_compat & EXT3_FEATURE_COMPAT_HAS_JOURNAL && journal_ino && !exclude_ino(journal_ino)) { - iexclude_list[iexclude_num++] = journal_ino; - msg("Added ext3 journal inode %u to exclude list\n", - journal_ino); + iexclude_list[iexclude_num++] = journal_ino; + msg("Exclude ext3 journal inode %u\n", + journal_ino); + } + if (!exclude_ino(EXT2_RESIZE_INO)) + iexclude_list[iexclude_num++] = EXT2_RESIZE_INO; } } return retval; @@ -362,6 +369,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; @@ -741,9 +796,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 @@ -860,6 +916,16 @@ 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 */ + remaining = i_size - bc.next_block*sblock->fs_fsize; + if (remaining > 0) + 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); }