Patchwork [1/1] ecryptfs: read on a directory should return EISDIR if not supported

login
register
mail settings
Submitter Colin King
Date Feb. 16, 2012, 5:11 p.m.
Message ID <1329412267-19835-2-git-send-email-colin.king@canonical.com>
Download mbox | patch
Permalink /patch/141647/
State New
Headers show

Comments

Colin King - Feb. 16, 2012, 5:11 p.m.
From: Andy Whitcroft <apw@canonical.com>

read() calls against a file descriptor connected to a directory are
incorrectly returning EINVAL rather than EISDIR:

  [EISDIR]
    [XSI] [Option Start] The fildes argument refers to a directory and the
    implementation does not allow the directory to be read using read()
    or pread(). The readdir() function should be used instead. [Option End]

This occurs because we do not have a .read operation defined for
ecryptfs directories.  Connect this up to generic_read_dir().

BugLink: http://bugs.launchpad.net/bugs/719691
Signed-off-by: Andy Whitcroft <apw@canonical.com>
Signed-off-by: Tyler Hicks <tyhicks@linux.vnet.ibm.com>
(cherry picked from commit 323ef68faf1bbd9b1e66aea268fd09d358d7e8ab)
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 fs/ecryptfs/file.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

Patch

diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c
index d8adc51..3015389 100644
--- a/fs/ecryptfs/file.c
+++ b/fs/ecryptfs/file.c
@@ -323,6 +323,7 @@  ecryptfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
 const struct file_operations ecryptfs_dir_fops = {
 	.readdir = ecryptfs_readdir,
+	.read = generic_read_dir,
 	.unlocked_ioctl = ecryptfs_unlocked_ioctl,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = ecryptfs_compat_ioctl,