Comment 0 for bug 719691

Revision history for this message
Mark Schreiber (mark7) wrote :

Binary package hint: linux-generic

When using ecryptfs (the filesystem used for encrypted home directories on Ubuntu by default), attempts to read(2)/read(3) from an open()ed directory return EINVAL, rather than EISDIR. This causes, for example, grep to spit out errors.

Test case:
(on ext4, working correctly)
$ mkdir foo
$ grep blah foo
$ strace -fe open,read grep blah foo
[clip]
open("foo", O_RDONLY) = 3
read(3, 0x890000, 32768) = -1 EISDIR (Is a directory)

(on an ecryptfs mount, broken)
$ mkdir foo
$ grep blah foo
grep: foo: Invalid argument
$ strace -fe open,read grep blah foo
[clip]
open("foo", O_RDONLY) = 3
read(3, 0x7fe000, 32768) = -1 EINVAL (Invalid argument)
[clip]

According to SUSv2, the ecryptfs behavior is indeed incorrect:
[EINVAL]
    [OB XSR] [Option Start] The STREAM or multiplexer referenced by fildes is linked (directly or indirectly) downstream from a multiplexer. [Option End]
[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]