linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gertjan van Wingerde <gertjan@vanwingerde.net>
To: stelian@popies.net
Cc: linux-ext4@vger.kernel.org, dump-devel@lists.sourceforge.net
Subject: [PATCH v2] dump: support for ext4 file-systems on Linux.
Date: Sun, 24 May 2009 18:08:57 +0200	[thread overview]
Message-ID: <4A197119.4000902@vanwingerde.net> (raw)
In-Reply-To: <4A1935AA.6090103@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 741 bytes --]

Hi,

version 2 attached. The original patch contained a bug in which ext4 extents index nodes were dumped as well as part of a regular file dump.
Still only for Linux.

---
Gertjan van Wingerde.


On 05/24/09 13:55, Gertjan van Wingerde wrote:
> Hi,
> 
> Find attached a patch I created to support the dumping and restoring of ext4 file-systems under Linux.
> For now it only works on Linux, as it uses the ext2fs library functions to get hold of the real data blocks.
> I don't understand dump enough to also handle the non-Linux case, although it would seems that relying on
> the ext2fs library for other systems would be appropriate.
> 
> N.B. Note that I am not subscribed to the mailing list, so cc me on replies.
> 
> ---
> Gertjan.


[-- Attachment #2: dump_ext4.diff --]
[-- Type: text/plain, Size: 1954 bytes --]

diff -u --recursive --new-file dump-0.4b41/dump/traverse.c dump-0.4b41.ext4/dump/traverse.c
--- dump-0.4b41/dump/traverse.c	2005-05-02 17:10:46.000000000 +0200
+++ dump-0.4b41.ext4/dump/traverse.c	2009-05-24 16:13:52.417643761 +0200
@@ -777,8 +777,6 @@
 	struct block_context *p;
 	e2_blkcnt_t i;
 
-	if (blockcnt < NDADDR)
-		return 0;
 	p = (struct block_context *)private;
 	for (i = p->next_block; i < blockcnt; i++) {
 		p->buf[p->cnt++] = 0;
@@ -986,19 +984,6 @@
 		msg("Warning: undefined file type 0%o\n", dp->di_mode & IFMT);
 		return;
 	}
-	if (i_size > (u_quad_t)NDADDR * sblock->fs_bsize)
-#ifdef	__linux__
-		cnt = NDADDR * EXT2_FRAGS_PER_BLOCK(fs->super);
-#else
-		cnt = NDADDR * sblock->fs_frag;
-#endif
-	else
-		cnt = howmany(i_size, sblock->fs_fsize);
-	blksout(&dp->di_db[0], cnt, ino);
-	if ((quad_t) (size = i_size - NDADDR * sblock->fs_bsize) <= 0) {
-		dump_xattr(ino, dp);
-		return;
-	}
 #ifdef	__linux__
 	bc.max = NINDIR(sblock) * EXT2_FRAGS_PER_BLOCK(fs->super);
 	bc.buf = (int *)malloc (bc.max * sizeof (int));
@@ -1006,7 +991,7 @@
 	bc.ino = ino;
 	bc.next_block = NDADDR;
 
-	ext2fs_block_iterate2(fs, (ext2_ino_t)ino, 0, NULL, dumponeblock, (void *)&bc);
+	ext2fs_block_iterate2(fs, (ext2_ino_t)ino, BLOCK_FLAG_DATA_ONLY, NULL, dumponeblock, (void *)&bc);
 	/* deal with holes at the end of the inode */
 	if (i_size > ((u_quad_t)bc.next_block) * sblock->fs_fsize) {
 		remaining = i_size - ((u_quad_t)bc.next_block) * sblock->fs_fsize;
@@ -1024,6 +1009,15 @@
 	free(bc.buf);
 	dump_xattr(ino, dp);
 #else
+	if (i_size > (u_quad_t)NDADDR * sblock->fs_bsize)
+		cnt = NDADDR * sblock->fs_frag;
+	else
+		cnt = howmany(i_size, sblock->fs_fsize);
+	blksout(&dp->di_db[0], cnt, ino);
+	if ((quad_t) (size = i_size - NDADDR * sblock->fs_bsize) <= 0) {
+		dump_xattr(ino, dp);
+		return;
+	}
 	for (ind_level = 0; ind_level < NIADDR; ind_level++) {
 		dmpindir(ino, dp->di_ib[ind_level], ind_level, &size);
 		if (size <= 0)

           reply	other threads:[~2009-05-24 16:08 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <4A1935AA.6090103@gmail.com>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A197119.4000902@vanwingerde.net \
    --to=gertjan@vanwingerde.net \
    --cc=dump-devel@lists.sourceforge.net \
    --cc=linux-ext4@vger.kernel.org \
    --cc=stelian@popies.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).