Skip to content

Commit

Permalink
Btrfs: fix readdir on 32 bit machines
Browse files Browse the repository at this point in the history
After btrfs_readdir has gone through all the directory items, it
sets the directory f_pos to the largest possible int.  This way
applications that mix readdir with creating new files don't
end up in an endless loop finding the new directory items as they go.

It was a workaround for a bug in git, but the assumption was that if git
could make this looping mistake than it would be a common problem.

The largest possible int chosen was INT_LIMIT(typeof(file->f_pos),
and it is possible for that to be a larger number than 32 bit glibc
expects to come out of readdir.

This patches switches that to INT_LIMIT(off_t), which should keep
applications happy on 32 and 64 bit machines.

Signed-off-by: Chris Mason <[email protected]>
  • Loading branch information
chrismason-xx committed Jan 28, 2009
1 parent e4f722f commit 89f135d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -3263,7 +3263,7 @@ static int btrfs_real_readdir(struct file *filp, void *dirent,

/* Reached end of directory/root. Bump pos past the last item. */
if (key_type == BTRFS_DIR_INDEX_KEY)
filp->f_pos = INT_LIMIT(typeof(filp->f_pos));
filp->f_pos = INT_LIMIT(off_t);
else
filp->f_pos++;
nopos:
Expand Down

0 comments on commit 89f135d

Please sign in to comment.