zfsonlinux/zfs — pull request #1625 by ryao (2013-08-04 20:05:59+00:00)
Title: Return correct type and offset from zfs_readdir

zfs_readdir() is used by getdents(), which provides a list of all files
in directory, their types and an offset that be used by llseek() to seek
to the next directory entry.

On Solaris, the first two directory entries "." and ".." respectively
have offsets 1 and 2 on ZFS while the other files have rather large
numbers. Currently, ZFSOnLinux is giving "." offset 0 and all other entries
large numbers. Software such as Wine will enter an infinite loop when it
calls llseek() to seek to the next entry, which is really the same
entry. The offsets used for each directory entry are filesystem specific
on all platforms, so we can fix this by adopting the Solaris behavior.

Also, we currently report each directory entry as having type 0 (???).
This is not wrong, but we can do better. Solaris does not have this
information, but Linux and Mac OS X do. ZFS provides easy access to type
information in zfs_readdir(), so this patch provides this as well.

Closes zfsonlinux/zfs#1624

Reported-by: Andrey
Signed-off-by: Richard Yao