UPSTREAM: ecryptfs: fix handling of directory opening
authorAl Viro <viro@zeniv.linux.org.uk>
Wed, 4 May 2016 18:04:13 +0000 (14:04 -0400)
committerAmit Pundir <amit.pundir@linaro.org>
Thu, 18 Aug 2016 13:26:03 +0000 (18:56 +0530)
commitb4d9d427c64f803e0797f3ea15f9b3acf27e0201
tree27a95cc59ba1d1609771aadc1df37d395ef68b9c
parent6acba5b6a1507f6282cbe985da7c0c3276d247d7
UPSTREAM: ecryptfs: fix handling of directory opening

(cherry picked from commit 6a480a7842545ec520a91730209ec0bae41694c1)

First of all, trying to open them r/w is idiocy; it's guaranteed to fail.
Moreover, assigning ->f_pos and assuming that everything will work is
blatantly broken - try that with e.g. tmpfs as underlying layer and watch
the fireworks.  There may be a non-trivial amount of state associated with
current IO position, well beyond the numeric offset.  Using the single
struct file associated with underlying inode is really not a good idea;
we ought to open one for each ecryptfs directory struct file.

Additionally, file_operations both for directories and non-directories are
full of pointless methods; non-directories should *not* have ->iterate(),
directories should not have ->flush(), ->fasync() and ->splice_read().

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Change-Id: I4813ce803f270fdd364758ce1dc108b76eab226e
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
fs/ecryptfs/file.c