linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Manish Katiyar <mkatiyar@gmail.com>
To: Akira Fujita <a-fujita@rs.jp.nec.com>
Cc: ext4 <linux-ext4@vger.kernel.org>
Subject: [PATCH] e4defrag : Open the source file for e4defrag in read write mode to avoid failures from EXT4_IOC_EXT_MOVE
Date: Tue, 19 Jan 2010 09:51:08 +0530	[thread overview]
Message-ID: <ea11fea31001182021m66f82afei1750a9e92b53e047@mail.gmail.com> (raw)

Hi Akira,

I am consistently getting -EBADF while trying out e4defrag and it
fails with below error.

/home/mkatiyar/e2fs-git/e2fsprogs/misc> ./e4defrag -v /tmp/ohsm/mntdir/f1
ext4 defragmentation for /tmp/ohsm/mntdir/f1
[1/1]/tmp/ohsm/mntdir/f1:	  0%
	Failed to defrag:Bad file descriptor	[ NG ]
 Success:			[0/1]

Below patch fixes the issue for me, though I am not sure if this is
the right fix to open the source file in readwrite mode or fix the
ext4 ioctl part.


Open the source file in read write mode to avoid failures from EXT4_IOC_EXT_MOVE

Signed-off-by: Manish Katiyar <mkatiyar@gmail.com>
---
 misc/e4defrag.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/misc/e4defrag.c b/misc/e4defrag.c
index 82e3868..424e0ca 100644
--- a/misc/e4defrag.c
+++ b/misc/e4defrag.c
@@ -1605,7 +1605,7 @@ static int file_defrag(const char *file, const
struct stat64 *buf,
 		return 0;
 	}

-	fd = open64(file, O_RDONLY);
+	fd = open64(file, O_RDWR);
 	if (fd < 0) {
 		if (mode_flag & DETAIL) {
 			PRINT_FILE_NAME(file);
-- 
1.6.3.3


-- 
Thanks -
Manish
==================================
[$\*.^ -- I miss being one of them
==================================

             reply	other threads:[~2010-01-19  4:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-19  4:21 Manish Katiyar [this message]
2010-01-19  4:37 ` [PATCH] e4defrag : Open the source file for e4defrag in read write mode to avoid failures from EXT4_IOC_EXT_MOVE Akira Fujita
2010-01-19  4:40   ` Manish Katiyar

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=ea11fea31001182021m66f82afei1750a9e92b53e047@mail.gmail.com \
    --to=mkatiyar@gmail.com \
    --cc=a-fujita@rs.jp.nec.com \
    --cc=linux-ext4@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).