OSDN Git Service

ext2_readdir() filp->f_pos fix (try #2)
authorGlen Nakamura <glen@imodulo.com>
Wed, 16 Apr 2008 08:06:58 +0000 (10:06 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 16 Apr 2008 08:06:58 +0000 (10:06 +0200)
commit72a9d5aa5e1e1602f861f8b893d8d57a08f30734
tree8e0c54f6a3f0ea141d4f246db72b67336a0c48b8
parent3f4bf06af2e73fae03c8326c517e1e0a1151c40e
ext2_readdir() filp->f_pos fix (try #2)

This patch reintroduces a fixed version of reverted commit
c30306fb287323591c854a0982d9fa5351859b45 from Dann Frazier :

  This is a 2.4 backport of a linux-2.6 change by Jan Blunck
  (old-2.6-bkcvs commit 2196b4744393d4f6c06fc4d63b98556d05b90933)

  Commit log from 2.6 follows.

    [PATCH] ext2_readdir() filp->f_pos fix

    If the whole directory 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.

Note from Glen :

  Perhaps the "filp->f_pos += le16_to_cpu(de->rec_len);" line should be
  outside of the if statement like the indentation implies?
  As it is, filp->f_pos gets corrupted if de->inode is ever zero...
  This could possibly explain why I had a few strange directory
  entries until I checked the filesystem with:
  e2fsck -D -F -f /dev/{ext2 partition}

This fix was confirmed by both Dann Frazier and Pascal Hambourg.

Note from Willy :

The code now differs from 2.6 only by commit
2d7f2ea9c989853310c7f6e8be52cc090cc8e66b which is only in 2.6.

The reporter, Al Masoud, provided the test case which could not be
reproduced on 2.4 (neither with nor without the fix above), so the
patch in question has *not* been applied to 2.4.

Dann will take the same approach for the Debian update.
fs/ext2/dir.c