Message ID | 4c5c62c05a00a97dce0ce5fbee020e82ee76c202.1681917551.git.alexl@redhat.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | ovl: Add support for fs-verity checking of lowerdata | expand |
On Thu, Apr 20, 2023 at 10:44 AM Alexander Larsson <alexl@redhat.com> wrote: > > This allows us to get the real path from the ovl_entry in ovl_lookup() > before having finished setting up the resulting inode. > > Signed-off-by: Alexander Larsson <alexl@redhat.com> > --- > fs/overlayfs/overlayfs.h | 2 ++ > fs/overlayfs/util.c | 25 ++++++++++++++++++------- > 2 files changed, 20 insertions(+), 7 deletions(-) > > diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h > index 4e327665c316..477008186d18 100644 > --- a/fs/overlayfs/overlayfs.h > +++ b/fs/overlayfs/overlayfs.h > @@ -395,6 +395,8 @@ void ovl_path_upper(struct dentry *dentry, struct path *path); > void ovl_path_lower(struct dentry *dentry, struct path *path); > void ovl_path_lowerdata(struct dentry *dentry, struct path *path); > void ovl_i_path_real(struct inode *inode, struct path *path); > +void ovl_entry_path_real(struct ovl_fs *ofs, struct ovl_entry *oe, > + struct dentry *upperdentry, struct path *path); > enum ovl_path_type ovl_path_real(struct dentry *dentry, struct path *path); > enum ovl_path_type ovl_path_realdata(struct dentry *dentry, struct path *path); > struct dentry *ovl_dentry_upper(struct dentry *dentry); > diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c > index 9a042768013e..77c954591daa 100644 > --- a/fs/overlayfs/util.c > +++ b/fs/overlayfs/util.c > @@ -351,19 +351,30 @@ struct dentry *ovl_i_dentry_upper(struct inode *inode) > return ovl_upperdentry_dereference(OVL_I(inode)); > } > > -void ovl_i_path_real(struct inode *inode, struct path *path) > -{ > - struct ovl_path *lowerstack = ovl_lowerstack(OVL_I_E(inode)); > +void ovl_entry_path_real(struct ovl_fs *ofs, Nit: I would use ovl_e_ prefix. Not critical. Thanks, Amir.
diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h index 4e327665c316..477008186d18 100644 --- a/fs/overlayfs/overlayfs.h +++ b/fs/overlayfs/overlayfs.h @@ -395,6 +395,8 @@ void ovl_path_upper(struct dentry *dentry, struct path *path); void ovl_path_lower(struct dentry *dentry, struct path *path); void ovl_path_lowerdata(struct dentry *dentry, struct path *path); void ovl_i_path_real(struct inode *inode, struct path *path); +void ovl_entry_path_real(struct ovl_fs *ofs, struct ovl_entry *oe, + struct dentry *upperdentry, struct path *path); enum ovl_path_type ovl_path_real(struct dentry *dentry, struct path *path); enum ovl_path_type ovl_path_realdata(struct dentry *dentry, struct path *path); struct dentry *ovl_dentry_upper(struct dentry *dentry); diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c index 9a042768013e..77c954591daa 100644 --- a/fs/overlayfs/util.c +++ b/fs/overlayfs/util.c @@ -351,19 +351,30 @@ struct dentry *ovl_i_dentry_upper(struct inode *inode) return ovl_upperdentry_dereference(OVL_I(inode)); } -void ovl_i_path_real(struct inode *inode, struct path *path) -{ - struct ovl_path *lowerstack = ovl_lowerstack(OVL_I_E(inode)); +void ovl_entry_path_real(struct ovl_fs *ofs, + struct ovl_entry *oe, + struct dentry *upperdentry, + struct path *path) +{ + if (upperdentry) { + path->dentry = upperdentry; + path->mnt = ovl_upper_mnt(ofs); + } else { + struct ovl_path *lowerstack = ovl_lowerstack(oe); - path->dentry = ovl_i_dentry_upper(inode); - if (!path->dentry) { path->dentry = lowerstack->dentry; path->mnt = lowerstack->layer->mnt; - } else { - path->mnt = ovl_upper_mnt(OVL_FS(inode->i_sb)); } } +void ovl_i_path_real(struct inode *inode, struct path *path) +{ + ovl_entry_path_real(OVL_FS(inode->i_sb), + OVL_I_E(inode), + ovl_i_dentry_upper(inode), + path); +} + struct inode *ovl_inode_upper(struct inode *inode) { struct dentry *upperdentry = ovl_i_dentry_upper(inode);
This allows us to get the real path from the ovl_entry in ovl_lookup() before having finished setting up the resulting inode. Signed-off-by: Alexander Larsson <alexl@redhat.com> --- fs/overlayfs/overlayfs.h | 2 ++ fs/overlayfs/util.c | 25 ++++++++++++++++++------- 2 files changed, 20 insertions(+), 7 deletions(-)