From patchwork Wed Aug 24 03:16:54 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 1090662 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p7O3GuF4008530 for ; Wed, 24 Aug 2011 03:16:57 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756007Ab1HXDQ4 (ORCPT ); Tue, 23 Aug 2011 23:16:56 -0400 Received: from mail-qw0-f46.google.com ([209.85.216.46]:60692 "EHLO mail-qw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756059Ab1HXDQz (ORCPT ); Tue, 23 Aug 2011 23:16:55 -0400 Received: by qwk3 with SMTP id 3so480858qwk.19 for ; Tue, 23 Aug 2011 20:16:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; bh=LS/rncgaChAWe9jfEtfPC3aKl3goWxGiWOmaMsgii1E=; b=Ss4uHLb+I2loa7R8v5ZPNOriu5uOtWXetvD5ipNwKCO7Bua7gH83dEN97oWcGm6BIC /Lv6CYQBVNsQtSLwOKXIkT1t7d/jjhop242zOhOEDNLF2y74OsHVyGv5mYJ1nQKPPxNa E29Dn8+yJxT3+ODs4NFFqtpk2rJ9z2r8GBzAI= MIME-Version: 1.0 Received: by 10.229.28.84 with SMTP id l20mr203139qcc.96.1314155814841; Tue, 23 Aug 2011 20:16:54 -0700 (PDT) Received: by 10.229.137.208 with HTTP; Tue, 23 Aug 2011 20:16:54 -0700 (PDT) Date: Tue, 23 Aug 2011 22:16:54 -0500 Message-ID: Subject: [PATCH] [CIFS] ls on mounts to WindowsCE failing with invalid level message From: Steve French To: linux-cifs@vger.kernel.org Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 24 Aug 2011 03:16:57 +0000 (UTC) From 9b7b518633fd3187c7efe260fe20a0961e4a5f0b Mon Sep 17 00:00:00 2001 From: Steve French Date: Tue, 23 Aug 2011 22:00:26 -0500 Subject: [CIFS] ls on mounts to WindowsCE failing with invalid level message Mount succeeds to WindowsCE but when user tries to access the contents of the directory gets "NT Status: STATUS_INVALID_LEVEL" according to wireshark. This server does not support the common windows readdir (Findfirst) level 257 nor level 258, so "fall back" to level 260 if get an EOPNOTSUPP on level FIND_FILE_DIRECTORY_INFO and while we are at it fall back to level 1 (FILE_INFO_STANDARD) for very old servers if we get an EOPNOTSUPP on level 260. (Note that the server returned errors on queries for inode numbers via QueryPathInfo so we don't use the infolevel SMB_FIND_FILE_ID_FULL_DIR_INFO) Reported-and-tested-by: Bryan James Signed-off-by: Steve French --- fs/cifs/readdir.c | 17 +++++++++++++++++ 1 files changed, 17 insertions(+), 0 deletions(-) diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c index 5de03ec..ed29706 100644 --- a/fs/cifs/readdir.c +++ b/fs/cifs/readdir.c @@ -270,6 +270,7 @@ ffirst_retry: cifsFile->srch_inf.info_level = SMB_FIND_FILE_DIRECTORY_INFO; } +ffirst_retry_with_std_level: rc = CIFSFindFirst(xid, pTcon, full_path, cifs_sb->local_nls, &cifsFile->netfid, &cifsFile->srch_inf, cifs_sb->mnt_cifs_flags & @@ -283,7 +284,23 @@ ffirst_retry: (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)) { cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_SERVER_INUM; goto ffirst_retry; + } else if ((rc == -EOPNOTSUPP) && (cifsFile->srch_inf.info_level == + SMB_FIND_FILE_DIRECTORY_INFO)) { + /* Windows CE can return EOPNOTSUPP on FILE_DIRECTORY_INFO */ + cifsFile->srch_inf.info_level = + SMB_FIND_FILE_BOTH_DIRECTORY_INFO; + goto ffirst_retry_with_std_level; + } else if ((rc == -EOPNOTSUPP) && (cifsFile->srch_inf.info_level == + SMB_FIND_FILE_BOTH_DIRECTORY_INFO)) { + cifsFile->srch_inf.info_level = + SMB_FIND_FILE_FULL_DIRECTORY_INFO; + goto ffirst_retry_with_std_level; + } else if ((rc == -EOPNOTSUPP) && (cifsFile->srch_inf.info_level == + SMB_FIND_FILE_FULL_DIRECTORY_INFO)) { + cifsFile->srch_inf.info_level = SMB_FIND_FILE_INFO_STANDARD; + goto ffirst_retry_with_std_level; } + error_exit: kfree(full_path); cifs_put_tlink(tlink);