public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jan Blunck <j.blunck@tu-harburg.de>
To: linux-kernel@vger.kernel.org
Cc: akpm@osdl.org
Subject: [PATCH] ext2_readdir() filp->f_pos fix
Date: Thu, 29 Jul 2004 21:18:01 +0200	[thread overview]
Message-ID: <41094D69.9030008@tu-harburg.de> (raw)

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

If the whole inode is read, ext2_readdir() sets the f_pos to a multiple 
of the page size (because of the conditions of the outer for loop). This 
sets the wrong f_pos for directory inodes on ext2 partitions with a 
block size differing from the page size.


[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 1014 bytes --]

Signed-off-by: Jan Blunck <j.blunck@tu-harburg.de>

 dir.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Index: testing-2.5/fs/ext2/dir.c
===================================================================
--- testing-2.5.orig/fs/ext2/dir.c	2004-07-27 19:24:00.000000000 +0200
+++ testing-2.5/fs/ext2/dir.c	2004-07-29 20:32:10.141354816 +0200
@@ -251,7 +251,7 @@
 	loff_t pos = filp->f_pos;
 	struct inode *inode = filp->f_dentry->d_inode;
 	struct super_block *sb = inode->i_sb;
-	unsigned offset = pos & ~PAGE_CACHE_MASK;
+	unsigned int offset = pos & ~PAGE_CACHE_MASK;
 	unsigned long n = pos >> PAGE_CACHE_SHIFT;
 	unsigned long npages = dir_pages(inode);
 	unsigned chunk_mask = ~(ext2_chunk_size(inode)-1);
@@ -303,6 +303,7 @@
 					goto success;
 				}
 			}
+			filp->f_pos += le16_to_cpu(de->rec_len);
 		}
 		ext2_put_page(page);
 	}
@@ -310,7 +311,6 @@
 success:
 	ret = 0;
 done:
-	filp->f_pos = (n << PAGE_CACHE_SHIFT) | offset;
 	filp->f_version = inode->i_version;
 	return ret;
 }

             reply	other threads:[~2004-07-29 19:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-29 19:18 Jan Blunck [this message]
2004-07-29 22:46 ` [PATCH] ext2_readdir() filp->f_pos fix Andrew Morton
2004-07-30  0:00   ` viro
2004-07-30 10:49   ` Jan Blunck

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=41094D69.9030008@tu-harburg.de \
    --to=j.blunck@tu-harburg.de \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@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