diff mbox series

[RFC,2/3] overlay: Add ovl_do_getxattr helper

Message ID 20201116045758.21774-3-sargun@sargun.me (mailing list archive)
State New, archived
Headers show
Series [RFC,1/3] fs: Add s_instance_id field to superblock for unique identification | expand

Commit Message

Sargun Dhillon Nov. 16, 2020, 4:57 a.m. UTC
We already have a helper for getting xattrs from inodes, namely
ovl_getxattr, but it doesn't allow for copying xattrs onto the current
stack. In addition, it is not instrumented like the rest of the helpers.

Signed-off-by: Sargun Dhillon <sargun@sargun.me>
Cc: linux-fsdevel@vger.kernel.org
Cc: linux-unionfs@vger.kernel.org
Cc: Miklos Szeredi <miklos@szeredi.hu>
Cc: Amir Goldstein <amir73il@gmail.com>
---
 fs/overlayfs/overlayfs.h | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Amir Goldstein Nov. 16, 2020, 11 a.m. UTC | #1
On Mon, Nov 16, 2020 at 6:58 AM Sargun Dhillon <sargun@sargun.me> wrote:
>
> We already have a helper for getting xattrs from inodes, namely
> ovl_getxattr, but it doesn't allow for copying xattrs onto the current
> stack. In addition, it is not instrumented like the rest of the helpers.
>
> Signed-off-by: Sargun Dhillon <sargun@sargun.me>
> Cc: linux-fsdevel@vger.kernel.org
> Cc: linux-unionfs@vger.kernel.org
> Cc: Miklos Szeredi <miklos@szeredi.hu>
> Cc: Amir Goldstein <amir73il@gmail.com>
> ---
>  fs/overlayfs/overlayfs.h | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
> index 29bc1ec699e7..9eb911f243e1 100644
> --- a/fs/overlayfs/overlayfs.h
> +++ b/fs/overlayfs/overlayfs.h
> @@ -179,6 +179,15 @@ static inline int ovl_do_setxattr(struct dentry *dentry, const char *name,
>         return err;
>  }
>
> +static inline int ovl_do_getxattr(struct dentry *dentry, const char *name,
> +                                 void *value, size_t size)
> +{
> +       int err = vfs_getxattr(dentry, name, value, size);
> +       pr_debug("getxattr(%pd2, \"%s\", \"%*pE\", %zu) = %i\n",
> +                dentry, name, min((int)size, 48), value, size, err);
> +       return err;
> +}
> +

upstream already has this helper.

>  static inline int ovl_do_removexattr(struct dentry *dentry, const char *name)
>  {
>         int err = vfs_removexattr(dentry, name);
> --
> 2.25.1
>
diff mbox series

Patch

diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
index 29bc1ec699e7..9eb911f243e1 100644
--- a/fs/overlayfs/overlayfs.h
+++ b/fs/overlayfs/overlayfs.h
@@ -179,6 +179,15 @@  static inline int ovl_do_setxattr(struct dentry *dentry, const char *name,
 	return err;
 }
 
+static inline int ovl_do_getxattr(struct dentry *dentry, const char *name,
+				  void *value, size_t size)
+{
+	int err = vfs_getxattr(dentry, name, value, size);
+	pr_debug("getxattr(%pd2, \"%s\", \"%*pE\", %zu) = %i\n",
+		 dentry, name, min((int)size, 48), value, size, err);
+	return err;
+}
+
 static inline int ovl_do_removexattr(struct dentry *dentry, const char *name)
 {
 	int err = vfs_removexattr(dentry, name);