From patchwork Tue Nov 19 16:33:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shirish Pargaonkar X-Patchwork-Id: 3203341 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 45CAB9F243 for ; Tue, 19 Nov 2013 16:33:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0DA5720328 for ; Tue, 19 Nov 2013 16:33:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 566FD20378 for ; Tue, 19 Nov 2013 16:33:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753261Ab3KSQdj (ORCPT ); Tue, 19 Nov 2013 11:33:39 -0500 Received: from mail-oa0-f45.google.com ([209.85.219.45]:48504 "EHLO mail-oa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753214Ab3KSQdi (ORCPT ); Tue, 19 Nov 2013 11:33:38 -0500 Received: by mail-oa0-f45.google.com with SMTP id o6so2690227oag.32 for ; Tue, 19 Nov 2013 08:33:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=+/R0iJNZe092RagvogVcJcCiT7b675kuiQZsYFNwFYU=; b=eFnNKE92ltPVUxoLMIO7RO6f6wrz4/BD/n5n+vLglCNIwwa2FsWX/0J13hHe8KAFmt 0eqjtZLqPImd6INiHF92lkjgEqUaSCE/xTsbHWYAYr23ytNv+JxS4XDPnXYK5VXXgZz+ byddP0lNpahuICGEPUUgSg9vnHEDWDZQuY3LUP4klRv/WVMIlyNj7dLuVIYs+PhQoFDw BrTZ716DgnYz/tkThk0nYaBQoHDa5gB3ovyl+jGeXMh69o9Z7DvsVuWNq7V8ozgeDMEs ODQuk7tvh7m2XTm4l0WZOImB1Asxg4hHfW17eVpvWMg++ruyvb9j2Y4blf3KhgHxibo2 K+bQ== X-Received: by 10.182.88.202 with SMTP id bi10mr2279648obb.52.1384878818026; Tue, 19 Nov 2013 08:33:38 -0800 (PST) Received: from localhost (75-13-85-90.lightspeed.austtx.sbcglobal.net. [75.13.85.90]) by mx.google.com with ESMTPSA id ru3sm30329152obc.2.2013.11.19.08.33.36 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 19 Nov 2013 08:33:37 -0800 (PST) From: shirishpargaonkar@gmail.com To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org, Shirish Pargaonkar , Shirish Pargaonkar Subject: [PATCH] cifs: Allow mounts for paths for restricted intermediate paths Date: Tue, 19 Nov 2013 10:33:33 -0600 Message-Id: <1384878813-7413-1-git-send-email-shirishpargaonkar@gmail.com> X-Mailer: git-send-email 1.8.3.2 Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Shirish Pargaonkar Allow cifs mounts for a prefixpath with intermediate paths without access, so as to continue with the shared superblock model. For the intermediate path entries that do not allow access, create "placeholder" inodes and instantiate dentries with those inodes. If and when such a path entry becomes accessible it is filled with correct info. Reference: Samba bugzilla 6950 Signed-off-by: Shirish Pargaonkar --- fs/cifs/cifsfs.c | 17 +++++++++++++++-- fs/cifs/cifsproto.h | 3 +++ fs/cifs/inode.c | 16 ++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 849f613..bce185c 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -584,6 +584,9 @@ cifs_get_root(struct smb_vol *vol, struct super_block *sb) char *full_path = NULL; char *s, *p; char sep; + struct inode *dir, *phinode; + struct dentry *child; + struct cifs_fattr phfattr; full_path = cifs_build_path_to_root(vol, cifs_sb, cifs_sb_master_tcon(cifs_sb)); @@ -592,13 +595,13 @@ cifs_get_root(struct smb_vol *vol, struct super_block *sb) cifs_dbg(FYI, "Get root dentry for %s\n", full_path); + fill_phfattr(&phfattr, sb); sep = CIFS_DIR_SEP(cifs_sb); dentry = dget(sb->s_root); p = s = full_path; do { - struct inode *dir = dentry->d_inode; - struct dentry *child; + dir = dentry->d_inode; if (!dir) { dput(dentry); @@ -626,6 +629,16 @@ cifs_get_root(struct smb_vol *vol, struct super_block *sb) mutex_unlock(&dir->i_mutex); dput(dentry); dentry = child; + if (!IS_ERR(dentry)) { + if (*s) { + /* EACCESS on an intermediate dir */ + if (!dentry->d_inode) { + phinode = cifs_iget(sb, &phfattr); + if (phinode) + d_instantiate(dentry, phinode); + } + } + } } while (!IS_ERR(dentry)); kfree(full_path); return dentry; diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h index aa33976..9a84e5c 100644 --- a/fs/cifs/cifsproto.h +++ b/fs/cifs/cifsproto.h @@ -498,4 +498,7 @@ void cifs_writedata_release(struct kref *refcount); int open_query_close_cifs_symlink(const unsigned char *path, char *pbuf, unsigned int *pbytes_read, struct cifs_sb_info *cifs_sb, unsigned int xid); + +extern void fill_phfattr(struct cifs_fattr *, struct super_block *); + #endif /* _CIFSPROTO_H */ diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index 36f9ebb..4f5a09a 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c @@ -322,6 +322,22 @@ cifs_create_dfs_fattr(struct cifs_fattr *fattr, struct super_block *sb) fattr->cf_flags |= CIFS_FATTR_DFS_REFERRAL; } +void +fill_phfattr(struct cifs_fattr *cf, struct super_block *sb) +{ + struct cifs_sb_info *cifs_sb = CIFS_SB(sb); + + memset(cf, 0, sizeof(*cf)); + cf->cf_uniqueid = iunique(sb, ROOT_I); + cf->cf_nlink = 1; + cf->cf_atime = CURRENT_TIME; + cf->cf_ctime = CURRENT_TIME; + cf->cf_mtime = CURRENT_TIME; + cf->cf_mode = S_IFDIR | S_IXUGO | S_IRWXU; + cf->cf_uid = cifs_sb->mnt_uid; + cf->cf_gid = cifs_sb->mnt_gid; +} + static int cifs_get_file_info_unix(struct file *filp) {