-
Nadav Har'El authored
Posix allows read() on directories in some filesystems. However, Linux always returns EISDIR in this case, so because we're emulating Linux, so should we, for every filesystem. All our filesystems except ZFS (e.g., ramfs) already return EISDIR when reading a directory, but ZFS doesn't, so this patch adds the missing check in ZFS. This patch is related to issue #94: the first step to fixing #94 is to return the right error when reading a directory. This patch also adds a test case, which can be compiled both on OSv and Linux, to verify they both have the same behavior. Before the patch, the test succeeded on Linux but failed on OSv when the directory is on ZFS. Instead of fixing zfs_read like I do in this patch, I could have also fixed sys_read() in vfs_syscalls.cc which is the top layer of all read() operations, and I could have done there (fp->f_dentry && fp->f_dentry->d_vnode->v_type == VDIR) { return EISDIR; } to cover all the filesystems. I decided not to do that, because all filesystems except ZFS already have this check, and because the lower layers like zfs_read() already have more natural access to d_vnode. Reviewed-by:
Glauber Costa <glommer@cloudius-systems.com> Signed-off-by:
Nadav Har'El <nyh@cloudius-systems.com> Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
Nadav Har'El authoredPosix allows read() on directories in some filesystems. However, Linux always returns EISDIR in this case, so because we're emulating Linux, so should we, for every filesystem. All our filesystems except ZFS (e.g., ramfs) already return EISDIR when reading a directory, but ZFS doesn't, so this patch adds the missing check in ZFS. This patch is related to issue #94: the first step to fixing #94 is to return the right error when reading a directory. This patch also adds a test case, which can be compiled both on OSv and Linux, to verify they both have the same behavior. Before the patch, the test succeeded on Linux but failed on OSv when the directory is on ZFS. Instead of fixing zfs_read like I do in this patch, I could have also fixed sys_read() in vfs_syscalls.cc which is the top layer of all read() operations, and I could have done there (fp->f_dentry && fp->f_dentry->d_vnode->v_type == VDIR) { return EISDIR; } to cover all the filesystems. I decided not to do that, because all filesystems except ZFS already have this check, and because the lower layers like zfs_read() already have more natural access to d_vnode. Reviewed-by:
Glauber Costa <glommer@cloudius-systems.com> Signed-off-by:
Nadav Har'El <nyh@cloudius-systems.com> Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>