* [PATCH-e2fsprogs] filefrag: accept positive ioctl return value
@ 2009-06-02 12:12 Peng Tao
2009-06-02 12:40 ` Theodore Tso
2009-06-02 12:59 ` Theodore Tso
0 siblings, 2 replies; 4+ messages in thread
From: Peng Tao @ 2009-06-02 12:12 UTC (permalink / raw)
To: linux-ext4; +Cc: tytso, Peng Tao
Some ioctl() returns non-negative value on success. filefrag_fiemap should
treat positive ioctl() return values as success.
This can be triggered by running filefrag on btrfs partitions.
Signed-off-by: Peng Tao <bergwolf@gmail.com>
---
misc/filefrag.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/misc/filefrag.c b/misc/filefrag.c
index 80ac05c..3dc966a 100644
--- a/misc/filefrag.c
+++ b/misc/filefrag.c
@@ -208,7 +208,7 @@ int filefrag_fiemap(int fd, int blk_shift, int *num_extents)
fiemap_incompat_printed = 1;
}
}
- if (rc)
+ if (rc < 0)
return rc;
if (!verbose) {
--
1.6.2.GIT
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH-e2fsprogs] filefrag: accept positive ioctl return value
2009-06-02 12:12 [PATCH-e2fsprogs] filefrag: accept positive ioctl return value Peng Tao
@ 2009-06-02 12:40 ` Theodore Tso
2009-06-02 17:10 ` Peng Tao
2009-06-02 12:59 ` Theodore Tso
1 sibling, 1 reply; 4+ messages in thread
From: Theodore Tso @ 2009-06-02 12:40 UTC (permalink / raw)
To: Peng Tao; +Cc: linux-ext4
On Tue, Jun 02, 2009 at 08:12:41PM +0800, Peng Tao wrote:
> Some ioctl() returns non-negative value on success. filefrag_fiemap should
> treat positive ioctl() return values as success.
> This can be triggered by running filefrag on btrfs partitions.
What does the positive fiemap ioctl return mean? It's not documented
in Documentation/filesystems/fiemap.txt.
- Ted
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH-e2fsprogs] filefrag: accept positive ioctl return value
2009-06-02 12:40 ` Theodore Tso
@ 2009-06-02 17:10 ` Peng Tao
0 siblings, 0 replies; 4+ messages in thread
From: Peng Tao @ 2009-06-02 17:10 UTC (permalink / raw)
To: Theodore Tso; +Cc: linux-ext4
On Tue, Jun 2, 2009 at 8:40 PM, Theodore Tso <tytso@mit.edu> wrote:
> What does the positive fiemap ioctl return mean? It's not documented
> in Documentation/filesystems/fiemap.txt.
The positive btrfs_fiemap ioctl return comes from
fiemap_fill_next_extent(), which returns 1 to indicate that
user-supplied fm_extents array is full according to
Documentation/filesystems/fiemap.txt.
--
Cheers,
Bergwolf
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH-e2fsprogs] filefrag: accept positive ioctl return value
2009-06-02 12:12 [PATCH-e2fsprogs] filefrag: accept positive ioctl return value Peng Tao
2009-06-02 12:40 ` Theodore Tso
@ 2009-06-02 12:59 ` Theodore Tso
1 sibling, 0 replies; 4+ messages in thread
From: Theodore Tso @ 2009-06-02 12:59 UTC (permalink / raw)
To: Peng Tao; +Cc: linux-ext4
On Tue, Jun 02, 2009 at 08:12:41PM +0800, Peng Tao wrote:
> Some ioctl() returns non-negative value on success. filefrag_fiemap should
> treat positive ioctl() return values as success.
> This can be triggered by running filefrag on btrfs partitions.
Thanks for reporting this!
It turns out that wasn't the only bug in that code; the syscall
infrastructure will take a negative return value and maps that to -1,
and moves the (negative) error code to a positive value in errno. So
the more appropriate patch is as follows.
- Ted
commit e78968f7a42fb1fa75c356dd323d957b307b887f
Author: Theodore Ts'o <tytso@mit.edu>
Date: Tue Jun 2 08:45:22 2009 -0400
filefrag: Fix error checking for the fiemap ioctl
Thanks to Peng Tao for reporting this problem.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
diff --git a/misc/filefrag.c b/misc/filefrag.c
index 80ac05c..7095949 100644
--- a/misc/filefrag.c
+++ b/misc/filefrag.c
@@ -201,15 +201,14 @@ int filefrag_fiemap(int fd, int blk_shift, int *num_extents)
fiemap->fm_flags = flags;
fiemap->fm_extent_count = count;
rc = ioctl(fd, FS_IOC_FIEMAP, (unsigned long) fiemap);
- if (rc == -EBADR) {
- if (fiemap_incompat_printed == 0) {
+ if (rc < 0) {
+ if (errno == EBADR && fiemap_incompat_printed == 0) {
printf("FIEMAP failed with unsupported "
"flags %x\n", fiemap->fm_flags);
fiemap_incompat_printed = 1;
}
- }
- if (rc)
return rc;
+ }
if (!verbose) {
*num_extents = fiemap->fm_mapped_extents;
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-06-02 17:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-02 12:12 [PATCH-e2fsprogs] filefrag: accept positive ioctl return value Peng Tao
2009-06-02 12:40 ` Theodore Tso
2009-06-02 17:10 ` Peng Tao
2009-06-02 12:59 ` Theodore Tso
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).