Skip to content

Commit fee0f29

Browse files
author
Miklos Szeredi
committed
duplicate ovl_getxattr()
ovl_getattr() returns the value of an xattr in a kmalloced buffer. There are two callers: ovl_copy_up_meta_inode_data() (copy_up.c) ovl_get_redirect_xattr() (util.c) This patch just copies ovl_getxattr() to copy_up.c, the following patches will deal with the differences in idividual callers. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
1 parent c86243b commit fee0f29

3 files changed

Lines changed: 35 additions & 4 deletions

File tree

fs/overlayfs/copy_up.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,39 @@ static bool ovl_need_meta_copy_up(struct dentry *dentry, umode_t mode,
784784
return true;
785785
}
786786

787+
static ssize_t ovl_getxattr(struct dentry *dentry, char *name, char **value,
788+
size_t padding)
789+
{
790+
ssize_t res;
791+
char *buf = NULL;
792+
793+
res = vfs_getxattr(dentry, name, NULL, 0);
794+
if (res < 0) {
795+
if (res == -ENODATA || res == -EOPNOTSUPP)
796+
return -ENODATA;
797+
goto fail;
798+
}
799+
800+
if (res != 0) {
801+
buf = kzalloc(res + padding, GFP_KERNEL);
802+
if (!buf)
803+
return -ENOMEM;
804+
805+
res = vfs_getxattr(dentry, name, buf, res);
806+
if (res < 0)
807+
goto fail;
808+
}
809+
*value = buf;
810+
811+
return res;
812+
813+
fail:
814+
pr_warn_ratelimited("failed to get xattr %s: err=%zi)\n",
815+
name, res);
816+
kfree(buf);
817+
return res;
818+
}
819+
787820
/* Copy up data of an inode which was copied up metadata only in the past. */
788821
static int ovl_copy_up_meta_inode_data(struct ovl_copy_up_ctx *c)
789822
{

fs/overlayfs/overlayfs.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,6 @@ int ovl_lock_rename_workdir(struct dentry *workdir, struct dentry *upperdir);
299299
int ovl_check_metacopy_xattr(struct dentry *dentry);
300300
bool ovl_is_metacopy_dentry(struct dentry *dentry);
301301
char *ovl_get_redirect_xattr(struct dentry *dentry, int padding);
302-
ssize_t ovl_getxattr(struct dentry *dentry, char *name, char **value,
303-
size_t padding);
304302

305303
static inline bool ovl_is_impuredir(struct dentry *dentry)
306304
{

fs/overlayfs/util.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -882,8 +882,8 @@ bool ovl_is_metacopy_dentry(struct dentry *dentry)
882882
return (oe->numlower > 1);
883883
}
884884

885-
ssize_t ovl_getxattr(struct dentry *dentry, char *name, char **value,
886-
size_t padding)
885+
static ssize_t ovl_getxattr(struct dentry *dentry, char *name, char **value,
886+
size_t padding)
887887
{
888888
ssize_t res;
889889
char *buf = NULL;

0 commit comments

Comments
 (0)