From: Stefan Berger <stefanb@linux.ibm.com>
To: linux-integrity@vger.kernel.org, linux-unionfs@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, zohar@linux.ibm.com,
roberto.sassu@huawei.com, amir73il@gmail.com, miklos@szeredi.hu,
brauner@kernel.org, Stefan Berger <stefanb@linux.ibm.com>
Subject: [RFC PATCH v2 1/2] ovl: Define D_REAL_FILEDATA for d_real to return dentry with data
Date: Mon, 22 Apr 2024 11:06:50 -0400 [thread overview]
Message-ID: <20240422150651.2908169-2-stefanb@linux.ibm.com> (raw)
In-Reply-To: <20240422150651.2908169-1-stefanb@linux.ibm.com>
Define D_REAL_FILEDATA which is to be used as a parameter for d_real()
to return the dentry that is holding the file data, which is either the
upper or the lower denry. The caller is expected to call d_real() again
on the returned dentry to get to lower layers of a stacked filesystem,
if available. This allows a caller to get all dentries involved in hold
a file's data and iterate through the layers.
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
---
fs/overlayfs/super.c | 6 ++++++
include/linux/dcache.h | 1 +
2 files changed, 7 insertions(+)
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index 06a231970cb5..f466ad89b005 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -36,6 +36,7 @@ static struct dentry *ovl_d_real(struct dentry *dentry, enum d_real_type type)
switch (type) {
case D_REAL_DATA:
case D_REAL_METADATA:
+ case D_REAL_FILEDATA:
break;
default:
goto bug;
@@ -47,6 +48,11 @@ static struct dentry *ovl_d_real(struct dentry *dentry, enum d_real_type type)
}
upper = ovl_dentry_upper(dentry);
+ if (type == D_REAL_FILEDATA) {
+ if (ovl_has_upperdata(d_inode(dentry)))
+ return upper;
+ return ovl_dentry_lower(dentry);
+ }
if (upper && (type == D_REAL_METADATA ||
ovl_has_upperdata(d_inode(dentry))))
return upper;
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index bf53e3894aae..e4e54fb2cf4e 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -128,6 +128,7 @@ enum dentry_d_lock_class
enum d_real_type {
D_REAL_DATA,
D_REAL_METADATA,
+ D_REAL_FILEDATA,
};
struct dentry_operations {
--
2.43.0
next prev parent reply other threads:[~2024-04-22 15:07 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-22 15:06 [RFC PATCH v2 0/2] ima: Fix detection of read/write violations on stacked filesystems Stefan Berger
2024-04-22 15:06 ` Stefan Berger [this message]
2024-04-23 5:54 ` [RFC PATCH v2 1/2] ovl: Define D_REAL_FILEDATA for d_real to return dentry with data Amir Goldstein
2024-04-22 15:06 ` [RFC PATCH v2 2/2] ima: Fix detection of read/write violations on stacked filesystems Stefan Berger
2024-04-22 16:15 ` Roberto Sassu
2024-04-23 6:02 ` [RFC PATCH v2 0/2] " Amir Goldstein
2024-04-23 10:53 ` Stefan Berger
2024-04-23 13:20 ` Roberto Sassu
2024-04-23 14:30 ` Amir Goldstein
2024-04-26 9:51 ` Christian Brauner
2024-04-25 11:30 ` Roberto Sassu
2024-04-25 12:37 ` Amir Goldstein
2024-04-26 7:34 ` Roberto Sassu
2024-04-27 9:03 ` Amir Goldstein
2024-05-06 12:34 ` Roberto Sassu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240422150651.2908169-2-stefanb@linux.ibm.com \
--to=stefanb@linux.ibm.com \
--cc=amir73il@gmail.com \
--cc=brauner@kernel.org \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-unionfs@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=roberto.sassu@huawei.com \
--cc=zohar@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).