cifs: handle FindFirst failure gracefully
authorSuresh Jayaraman <sjayaraman@suse.de>
Fri, 1 Oct 2010 15:53:33 +0000 (21:23 +0530)
committerSteve French <sfrench@us.ibm.com>
Fri, 15 Oct 2010 15:19:55 +0000 (15:19 +0000)
commit6221ddd0f5e2ddc1d5d928119a2cde033d16f96d
treeded17afe18712966dcc26560d9036145a3f1f98c
parent5d0d28824c76409f0d1a645bf0ae81318c8ffa42
cifs: handle FindFirst failure gracefully

FindFirst failure due to permission errors or any other errors are silently
ignored by cifs_readdir(). This could cause problem to applications that depend
on the error to do further processing.

Reproducer:
  - mount a cifs share
  - mkdir tdir;touch tdir/1 tdir/2 tdir/3
  - chmod -x tdir
  - ls tdir

Currently, we start calling filldir() for '.' and '..' before we know we
whether FindFirst could succeed or not. If FindFirst fails later, there is no
way to notify VFS by setting buf.error and so VFS won't be able to catch this.
Fix this by moving the call to initiate_cifs_search() before we start doing
filldir().

This fixes https://bugzilla.samba.org/show_bug.cgi?id=7535

Reported-by: Tom Dexter <digitalaudiorock@gmail.com>
Signed-off-by: Suresh Jayaraman <sjayaraman@suse.de>
Signed-off-by: Steve French <sfrench@us.ibm.com>
fs/cifs/readdir.c