Skip to content

Commit

Permalink
ovl: Use macros to present ovl_xattr
Browse files Browse the repository at this point in the history
This patch adds two macros:

OVL_XATTR_PRE_NAME and OVL_XATTR_PRE_LEN

to present ovl_xattr name prefix and its length. Also, a
new macro OVL_XATTR_OPAQUE is introduced to replace old
*ovl_opaque_xattr*.

Fix the length of "trusted.overlay." to *16*.

Signed-off-by: hujianyang <hujianyang@huawei.com>
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
  • Loading branch information
hujianyang authored and Miklos Szeredi committed Dec 12, 2014
1 parent 1ba3872 commit cead89b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions fs/overlayfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,14 @@ int ovl_create_real(struct inode *dir, struct dentry *newdentry,

static int ovl_set_opaque(struct dentry *upperdentry)
{
return ovl_do_setxattr(upperdentry, ovl_opaque_xattr, "y", 1, 0);
return ovl_do_setxattr(upperdentry, OVL_XATTR_OPAQUE, "y", 1, 0);
}

static void ovl_remove_opaque(struct dentry *upperdentry)
{
int err;

err = ovl_do_removexattr(upperdentry, ovl_opaque_xattr);
err = ovl_do_removexattr(upperdentry, OVL_XATTR_OPAQUE);
if (err) {
pr_warn("overlayfs: failed to remove opaque from '%s' (%i)\n",
upperdentry->d_name.name, err);
Expand Down
2 changes: 1 addition & 1 deletion fs/overlayfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ static int ovl_readlink(struct dentry *dentry, char __user *buf, int bufsiz)

static bool ovl_is_private_xattr(const char *name)
{
return strncmp(name, "trusted.overlay.", 14) == 0;
return strncmp(name, OVL_XATTR_PRE_NAME, OVL_XATTR_PRE_LEN) == 0;
}

int ovl_setxattr(struct dentry *dentry, const char *name,
Expand Down
4 changes: 3 additions & 1 deletion fs/overlayfs/overlayfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ enum ovl_path_type {
#define OVL_TYPE_MERGE_OR_LOWER(type) \
(OVL_TYPE_MERGE(type) || !OVL_TYPE_UPPER(type))

extern const char *ovl_opaque_xattr;
#define OVL_XATTR_PRE_NAME "trusted.overlay."
#define OVL_XATTR_PRE_LEN 16
#define OVL_XATTR_OPAQUE OVL_XATTR_PRE_NAME"opaque"

static inline int ovl_do_rmdir(struct inode *dir, struct dentry *dentry)
{
Expand Down
4 changes: 1 addition & 3 deletions fs/overlayfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ struct ovl_entry {

#define OVL_MAX_STACK 500

const char *ovl_opaque_xattr = "trusted.overlay.opaque";

static struct dentry *__ovl_dentry_lower(struct ovl_entry *oe)
{
return oe->numlower ? oe->lowerstack[0].dentry : NULL;
Expand Down Expand Up @@ -254,7 +252,7 @@ static bool ovl_is_opaquedir(struct dentry *dentry)
if (!S_ISDIR(inode->i_mode) || !inode->i_op->getxattr)
return false;

res = inode->i_op->getxattr(dentry, ovl_opaque_xattr, &val, 1);
res = inode->i_op->getxattr(dentry, OVL_XATTR_OPAQUE, &val, 1);
if (res == 1 && val == 'y')
return true;

Expand Down

0 comments on commit cead89b

Please sign in to comment.