* [PATCH] btrfs: fix directory offsets for '.' and '..' entries
@ 2011-09-11 20:33 Grazvydas Ignotas
2011-09-11 21:06 ` Christoph Hellwig
2011-09-11 23:49 ` Tsutomu Itoh
0 siblings, 2 replies; 5+ messages in thread
From: Grazvydas Ignotas @ 2011-09-11 20:33 UTC (permalink / raw)
To: Chris Mason; +Cc: linux-btrfs, Grazvydas Ignotas
Currently getdents syscall returns wrong offset for '.' directory entry,
which confuses some programs like wine. This can be observed with an
example program getdents(2) manpage:
$ ./a.out /testfs/
--------------- nread=96 ---------------
i-node# file type d_reclen d_off d_name
256 directory 24 2 .
256 directory 24 2 ..
257 regular 24 3 a
258 regular 24 2147483647 b
Fix this by passing correct offsets to filldir().
Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
---
fs/btrfs/inode.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 0ccc743..5e7460b 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -4125,7 +4125,7 @@ static int btrfs_real_readdir(struct file *filp, void *dirent,
/* special case for "." */
if (filp->f_pos == 0) {
- over = filldir(dirent, ".", 1, 1, btrfs_ino(inode), DT_DIR);
+ over = filldir(dirent, ".", 1, 0, btrfs_ino(inode), DT_DIR);
if (over)
return 0;
filp->f_pos = 1;
@@ -4133,8 +4133,7 @@ static int btrfs_real_readdir(struct file *filp, void *dirent,
/* special case for .., just use the back ref */
if (filp->f_pos == 1) {
u64 pino = parent_ino(filp->f_path.dentry);
- over = filldir(dirent, "..", 2,
- 2, pino, DT_DIR);
+ over = filldir(dirent, "..", 2, 1, pino, DT_DIR);
if (over)
return 0;
filp->f_pos = 2;
--
1.7.0.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] btrfs: fix directory offsets for '.' and '..' entries
2011-09-11 20:33 [PATCH] btrfs: fix directory offsets for '.' and '..' entries Grazvydas Ignotas
@ 2011-09-11 21:06 ` Christoph Hellwig
2011-09-12 0:21 ` Grazvydas Ignotas
2011-09-11 23:49 ` Tsutomu Itoh
1 sibling, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2011-09-11 21:06 UTC (permalink / raw)
To: Grazvydas Ignotas; +Cc: Chris Mason, linux-btrfs
On Sun, Sep 11, 2011 at 11:33:36PM +0300, Grazvydas Ignotas wrote:
> Currently getdents syscall returns wrong offset for '.' directory entry,
> which confuses some programs like wine. This can be observed with an
> example program getdents(2) manpage:
Can you submit a patch to add your testcase to xfstests?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] btrfs: fix directory offsets for '.' and '..' entries
2011-09-11 20:33 [PATCH] btrfs: fix directory offsets for '.' and '..' entries Grazvydas Ignotas
2011-09-11 21:06 ` Christoph Hellwig
@ 2011-09-11 23:49 ` Tsutomu Itoh
2011-09-18 15:09 ` Chris Mason
1 sibling, 1 reply; 5+ messages in thread
From: Tsutomu Itoh @ 2011-09-11 23:49 UTC (permalink / raw)
To: Grazvydas Ignotas; +Cc: Chris Mason, linux-btrfs
The same patch has been posted about one month ago.
http://marc.info/?l=linux-btrfs&m=131363399500506&w=2
Thanks,
Tsutomu
(2011/09/12 5:33), Grazvydas Ignotas wrote:
> Currently getdents syscall returns wrong offset for '.' directory entry,
> which confuses some programs like wine. This can be observed with an
> example program getdents(2) manpage:
>
> $ ./a.out /testfs/
> --------------- nread=96 ---------------
> i-node# file type d_reclen d_off d_name
> 256 directory 24 2 .
> 256 directory 24 2 ..
> 257 regular 24 3 a
> 258 regular 24 2147483647 b
>
> Fix this by passing correct offsets to filldir().
>
> Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
> ---
> fs/btrfs/inode.c | 5 ++---
> 1 files changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index 0ccc743..5e7460b 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -4125,7 +4125,7 @@ static int btrfs_real_readdir(struct file *filp, void *dirent,
>
> /* special case for "." */
> if (filp->f_pos == 0) {
> - over = filldir(dirent, ".", 1, 1, btrfs_ino(inode), DT_DIR);
> + over = filldir(dirent, ".", 1, 0, btrfs_ino(inode), DT_DIR);
> if (over)
> return 0;
> filp->f_pos = 1;
> @@ -4133,8 +4133,7 @@ static int btrfs_real_readdir(struct file *filp, void *dirent,
> /* special case for .., just use the back ref */
> if (filp->f_pos == 1) {
> u64 pino = parent_ino(filp->f_path.dentry);
> - over = filldir(dirent, "..", 2,
> - 2, pino, DT_DIR);
> + over = filldir(dirent, "..", 2, 1, pino, DT_DIR);
> if (over)
> return 0;
> filp->f_pos = 2;
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] btrfs: fix directory offsets for '.' and '..' entries
2011-09-11 21:06 ` Christoph Hellwig
@ 2011-09-12 0:21 ` Grazvydas Ignotas
0 siblings, 0 replies; 5+ messages in thread
From: Grazvydas Ignotas @ 2011-09-12 0:21 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Chris Mason, linux-btrfs
On Mon, Sep 12, 2011 at 12:06 AM, Christoph Hellwig <hch@infradead.org>=
wrote:
> On Sun, Sep 11, 2011 at 11:33:36PM +0300, Grazvydas Ignotas wrote:
>> Currently getdents syscall returns wrong offset for '.' directory en=
try,
>> which confuses some programs like wine. This can be observed with an
>> example program getdents(2) manpage:
>
> Can you submit a patch to add your testcase to xfstests?
Sent, hopefully did it right.
--=20
Gra=C5=BEvydas
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" =
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] 5+ messages in thread
* Re: [PATCH] btrfs: fix directory offsets for '.' and '..' entries
2011-09-11 23:49 ` Tsutomu Itoh
@ 2011-09-18 15:09 ` Chris Mason
0 siblings, 0 replies; 5+ messages in thread
From: Chris Mason @ 2011-09-18 15:09 UTC (permalink / raw)
To: Tsutomu Itoh; +Cc: Grazvydas Ignotas, linux-btrfs
Excerpts from Tsutomu Itoh's message of 2011-09-11 19:49:22 -0400:
> The same patch has been posted about one month ago.
>
> http://marc.info/?l=linux-btrfs&m=131363399500506&w=2
Thanks, I've queued up the fujitsu version (just because they sent it
first).
-chris
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-09-18 15:09 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-11 20:33 [PATCH] btrfs: fix directory offsets for '.' and '..' entries Grazvydas Ignotas
2011-09-11 21:06 ` Christoph Hellwig
2011-09-12 0:21 ` Grazvydas Ignotas
2011-09-11 23:49 ` Tsutomu Itoh
2011-09-18 15:09 ` Chris Mason
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).