#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.35 2001/07/18 08:50:58 stelian Exp $";
#endif /* not lint */
#include <config.h>
#include <sys/param.h>
#include <sys/stat.h>
#ifdef __linux__
+#ifdef HAVE_EXT2FS_EXT2_FS_H
+#include <ext2fs/ext2_fs.h>
+#else
#include <linux/ext2_fs.h>
+#endif
#include <ext2fs/ext2fs.h>
#include <bsdcompat.h>
#include <compaterr.h>
#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)
{
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;
}
#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;
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
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);
}