From patchwork Thu Apr 16 14:42:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 6226621 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9AE929F1C4 for ; Thu, 16 Apr 2015 14:43:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BAFB7202AE for ; Thu, 16 Apr 2015 14:43:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B4D3D202A1 for ; Thu, 16 Apr 2015 14:43:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933533AbbDPOm7 (ORCPT ); Thu, 16 Apr 2015 10:42:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59717 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932074AbbDPOm6 (ORCPT ); Thu, 16 Apr 2015 10:42:58 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t3GEgs5G008123 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 16 Apr 2015 10:42:55 -0400 Received: from warthog.procyon.org.uk ([10.3.112.12]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t3GEgpK6016351; Thu, 16 Apr 2015 10:42:52 -0400 Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH 1/4] Overlayfs: Convert S_ISDIR(dentry->d_inode) to d_is_dir()/d_can_lookup() From: David Howells To: viro@zeniv.linux.org.uk, miklos@szeredi.hu Cc: dhowells@redhat.com, linux-fsdevel@vger.kernel.org, linux-unionfs@vger.kernel.org Date: Thu, 16 Apr 2015 15:42:51 +0100 Message-ID: <20150416144251.12620.49589.stgit@warthog.procyon.org.uk> In-Reply-To: <20150416144241.12620.85836.stgit@warthog.procyon.org.uk> References: <20150416144241.12620.85836.stgit@warthog.procyon.org.uk> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 Convert S_ISDIR(dentry->d_inode) to d_is_dir(dentry) or d_can_lookup(dentry) as appropriate. This is slightly complicated as there are two options for directories. The difference is whether the directory in question is a real dir with a ->lookup op or whether it's a fake dir with a ->d_automount op. Note that if there is a directory at this position, in both overlayfs and unionmount it must be represented as a directory inode in the union layer and will not be represented as a dentry with NULL ->d_inode with a fallthrough. This means that the d_is_dir() and d_can_lookup() tests are safe no matter whether we're looking at overlayfs's own inodes or its subordinate inodes. Signed-off-by: David Howells --- fs/overlayfs/inode.c | 2 +- fs/overlayfs/super.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c index 04f124884687..8c8f024edcc0 100644 --- a/fs/overlayfs/inode.c +++ b/fs/overlayfs/inode.c @@ -239,7 +239,7 @@ static bool ovl_need_xattr_filter(struct dentry *dentry, enum ovl_path_type type) { if ((type & (__OVL_PATH_PURE | __OVL_PATH_UPPER)) == __OVL_PATH_UPPER) - return S_ISDIR(dentry->d_inode->i_mode); + return d_is_dir(dentry); else return false; } diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index 5f0d1993e6e3..d5f7117caf5e 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c @@ -76,7 +76,7 @@ enum ovl_path_type ovl_path_type(struct dentry *dentry) type = __OVL_PATH_UPPER; if (oe->numlower) { - if (S_ISDIR(dentry->d_inode->i_mode)) + if (d_is_dir(dentry)) type |= __OVL_PATH_MERGE; } else if (!oe->opaque) { type |= __OVL_PATH_PURE; @@ -395,8 +395,8 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry, if (i < poe->numlower - 1 && ovl_is_opaquedir(this)) opaque = true; - if (prev && (!S_ISDIR(prev->d_inode->i_mode) || - !S_ISDIR(this->d_inode->i_mode))) { + if (prev && (!d_is_dir(prev) || + !d_is_dir(this))) { /* * FIXME: check for upper-opaqueness maybe better done * in remove code. @@ -731,7 +731,7 @@ static int ovl_mount_dir_noesc(const char *name, struct path *path) pr_err("overlayfs: filesystem on '%s' not supported\n", name); goto out_put; } - if (!S_ISDIR(path->dentry->d_inode->i_mode)) { + if (!d_can_lookup(path->dentry)) { pr_err("overlayfs: '%s' not a directory\n", name); goto out_put; }