linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Lakshmipathi.G" <Lakshmipathi.G@giis.co.in>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH]btrfs-progs: btrfs-convert.c : check source file system state
Date: Thu, 15 Sep 2016 14:08:52 +0200	[thread overview]
Message-ID: <20160915120852.GA22577@fedori> (raw)

Signed-off-by: Lakshmipathi.G <Lakshmipathi.G@giis.co.in>
---
 btrfs-convert.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/btrfs-convert.c b/btrfs-convert.c
index c10dc17..27da9ce 100644
--- a/btrfs-convert.c
+++ b/btrfs-convert.c
@@ -2171,6 +2171,17 @@ static void ext2_copy_inode_item(struct btrfs_inode_item *dst,
 	}
 	memset(&dst->reserved, 0, sizeof(dst->reserved));
 }
+static int check_filesystem_state(struct btrfs_convert_context *cctx)
+{
+	ext2_filsys fs = cctx->fs_data;
+
+        if (!(fs->super->s_state & EXT2_VALID_FS))
+		return 1;
+	else if (fs->super->s_state & EXT2_ERROR_FS)
+		return 1;
+	else
+		return 0;
+}
 
 /*
  * copy a single inode. do all the required works, such as cloning
@@ -2340,6 +2351,10 @@ static int do_convert(const char *devname, int datacsum, int packing,
 	ret = convert_open_fs(devname, &cctx);
 	if (ret)
 		goto fail;
+	ret = check_filesystem_state(&cctx);
+	if (ret) 
+		warning("Source Filesystem is not clean, \
+			 running e2fsck is recommended.");
 	ret = convert_read_used_space(&cctx);
 	if (ret)
 		goto fail;
-- 
1.9.3


             reply	other threads:[~2016-09-15 12:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-15 12:08 Lakshmipathi.G [this message]
2016-09-19 17:10 ` [PATCH]btrfs-progs: btrfs-convert.c : check source file system state David Sterba

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=20160915120852.GA22577@fedori \
    --to=lakshmipathi.g@giis.co.in \
    --cc=linux-btrfs@vger.kernel.org \
    /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).