Received: by 10.192.165.156 with SMTP id m28csp2096756imm; Thu, 12 Apr 2018 08:33:24 -0700 (PDT) X-Google-Smtp-Source: AIpwx497hN/1X3lJtxnihrKXhpLUi5JQLE+doOEsISO8IRhsXDg2RFLOYFFRIqQh6O++jivQO64w X-Received: by 2002:a17:902:3181:: with SMTP id x1-v6mr1586642plb.338.1523547203982; Thu, 12 Apr 2018 08:33:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523547203; cv=none; d=google.com; s=arc-20160816; b=LPepjmq4kPsl44NOhiXkiJNNMovPjgln6gzCMAFTDd4SE1wtibk7XjrW8FZAGSEPOc Q59zgTmqoOYXX9uj+ZSQ0M5c7B4Vw0R2JjqdxSMorVl0hbGvc3KITxNfa3Zd21ZdA/ey +p6dCDKhhCPe+/bqq0vvIk584JUPsFdEi8S2z76bIfvZkIMk9DQ5xvFwGpOWcA1c9EvM kB7uoUtrTygzTcJIK54wgpAr1wv6/tFxR3u12+YGNx98gGGRX5EqMVdJSs4+eRUAhj3/ 9MOx1HKAs2JzMcM4iMDv5SK/na8okh3Eppmc/QL1LaaKfuiN2mLeW/8bFZcJki/wz5/Q bduA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=4WXD0vv9+eWoGR0E60ATHExkoMjrgmozLU5+vZLe2Sk=; b=LKY44Oq3/vWaMF05dbFstvJ4NtcHjrwZ/1Hh1F0fZoDsxLxAsFq5zd4uVH/FrQRnMP I3ASEKeY2jy5B1DtCulf/8tuC1Wrdi0nkv5SRS9PH/WLqxVCraUZmF2IDFTCCDNqkFnN Yo6sKSVOxcPNYoLaY5VexOZFBB6Tt8v4JQbOy8j1cHRjpGmwJmsaqjJqeD8MGTAx4NL3 /QrsUKGuCd3wRc6QQB6poMzRRu+6xFzCRAOfjDO+4KfuMjdPPSvguRQqvJiKoxxiR/U/ Ps1WAm26mLpBgoKsmMeiWoYQgMtybIzADN0L6kfbcXSmMGNObUZif/2diWfu4BD0+Cug 4Rlw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u74si2433132pgc.264.2018.04.12.08.32.46; Thu, 12 Apr 2018 08:33:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753258AbeDLPIi (ORCPT + 99 others); Thu, 12 Apr 2018 11:08:38 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:54393 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752985AbeDLPIf (ORCPT ); Thu, 12 Apr 2018 11:08:35 -0400 Received: by mail-wm0-f65.google.com with SMTP id r191so12291870wmg.4 for ; Thu, 12 Apr 2018 08:08:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4WXD0vv9+eWoGR0E60ATHExkoMjrgmozLU5+vZLe2Sk=; b=cInpFsPYTe5nQv6eXBbiG8yB1qfGupT9kEwnxH1yKshJ9nztyLzNjZKHUd9/zHeopg x7qiP6ANynCXipvLwP0gsa+LASHB/uw/WRIE1B0253Gke2x3t+J1K72VoXkQiSipfQT1 DUlzaTe1dRPkYeMkqr95lA7zuetom7xRObzpH1O1vAmGVTHL3Xbf5uf2L1kzqVOiFqs3 MLc1fZ2DLRq74T9Ej2UlJkTfzoMjiLLZ8G5V7clEL0c1rg0//z7CI94uDNqeomwJKn8G p+n9lEisRvdub7j75CB+QBAL2kapHNdpwL4Mb0fc2HGj4mwQjNk0IGa1vjmgYwPnPcUY /lqA== X-Gm-Message-State: ALQs6tCALDC0LVuKf/sg82vAHcLrHA4XK4AD4m4cpi1agCzH1UhDd4jV 40VwciEDte7Rk23WYo0x8/ThAKKKphI= X-Received: by 10.28.191.27 with SMTP id p27mr1091546wmf.97.1523545714084; Thu, 12 Apr 2018 08:08:34 -0700 (PDT) Received: from veci.piliscsaba.redhat.com (catv-176-63-54-97.catv.broadband.hu. [176.63.54.97]) by smtp.gmail.com with ESMTPSA id p197sm2621783wme.43.2018.04.12.08.08.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Apr 2018 08:08:33 -0700 (PDT) From: Miklos Szeredi To: linux-unionfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 02/35] vfs: add path_open() Date: Thu, 12 Apr 2018 17:07:53 +0200 Message-Id: <20180412150826.20988-3-mszeredi@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180412150826.20988-1-mszeredi@redhat.com> References: <20180412150826.20988-1-mszeredi@redhat.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently opening an overlay file results in: - the real file on the underlying layer being opened - f_path being set to the overlay {mount, dentry} pair This patch adds a new helper that allows the above to be explicitly performed. I.e. it's the same as dentry_open(), except the underlying inode to open is given as a separate argument. This is in preparation for stacking I/O operations on overlay files. Later, when implicit opening is removed, dentry_open() can be implemented by just calling path_open(). Signed-off-by: Miklos Szeredi --- fs/open.c | 27 +++++++++++++++++++++++++++ include/linux/fs.h | 2 ++ 2 files changed, 29 insertions(+) diff --git a/fs/open.c b/fs/open.c index 7ea118471dce..8c315f9ec2f6 100644 --- a/fs/open.c +++ b/fs/open.c @@ -866,6 +866,33 @@ int vfs_open(const struct path *path, struct file *file, return do_dentry_open(file, d_backing_inode(dentry), NULL, cred); } +struct file *path_open(const struct path *path, int flags, struct inode *inode, + const struct cred *cred) +{ + struct file *file; + int retval; + + file = get_empty_filp(); + if (!IS_ERR(file)) { + file->f_flags = flags; + file->f_path = *path; + retval = do_dentry_open(file, inode, NULL, cred); + if (retval) { + put_filp(file); + file = ERR_PTR(retval); + } else { + retval = open_check_o_direct(file); + if (retval) { + fput(file); + file = ERR_PTR(retval); + } + } + } + + return file; +} +EXPORT_SYMBOL(path_open); + struct file *dentry_open(const struct path *path, int flags, const struct cred *cred) { diff --git a/include/linux/fs.h b/include/linux/fs.h index f0f87f2beb79..c6d7e3b00163 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2401,6 +2401,8 @@ extern struct file *filp_open(const char *, int, umode_t); extern struct file *file_open_root(struct dentry *, struct vfsmount *, const char *, int, umode_t); extern struct file * dentry_open(const struct path *, int, const struct cred *); +extern struct file *path_open(const struct path *, int, struct inode *, + const struct cred *); extern int filp_close(struct file *, fl_owner_t id); extern struct filename *getname_flags(const char __user *, int, int *); -- 2.14.3