aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorhujianyang <hujianyang@huawei.com>2014-11-24 05:25:21 -0500
committerMiklos Szeredi <mszeredi@suse.cz>2014-12-12 18:59:52 -0500
commitcead89bb08c0f64e23886f1c18df9bb98e97c55c (patch)
treedbf10b40ef83804ac343cbdf4f3776af685d1e62 /fs
parent1ba38725a351f91769918b132c17fb7fcaf6c2f5 (diff)
ovl: Use macros to present ovl_xattr
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>
Diffstat (limited to 'fs')
-rw-r--r--fs/overlayfs/dir.c4
-rw-r--r--fs/overlayfs/inode.c2
-rw-r--r--fs/overlayfs/overlayfs.h4
-rw-r--r--fs/overlayfs/super.c4
4 files changed, 7 insertions, 7 deletions
diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index dcae3ac5aa76..0dc4c33a0a1b 100644
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -118,14 +118,14 @@ int ovl_create_real(struct inode *dir, struct dentry *newdentry,
118 118
119static int ovl_set_opaque(struct dentry *upperdentry) 119static int ovl_set_opaque(struct dentry *upperdentry)
120{ 120{
121 return ovl_do_setxattr(upperdentry, ovl_opaque_xattr, "y", 1, 0); 121 return ovl_do_setxattr(upperdentry, OVL_XATTR_OPAQUE, "y", 1, 0);
122} 122}
123 123
124static void ovl_remove_opaque(struct dentry *upperdentry) 124static void ovl_remove_opaque(struct dentry *upperdentry)
125{ 125{
126 int err; 126 int err;
127 127
128 err = ovl_do_removexattr(upperdentry, ovl_opaque_xattr); 128 err = ovl_do_removexattr(upperdentry, OVL_XATTR_OPAQUE);
129 if (err) { 129 if (err) {
130 pr_warn("overlayfs: failed to remove opaque from '%s' (%i)\n", 130 pr_warn("overlayfs: failed to remove opaque from '%s' (%i)\n",
131 upperdentry->d_name.name, err); 131 upperdentry->d_name.name, err);
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index 5ac1236afb15..04f124884687 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -205,7 +205,7 @@ static int ovl_readlink(struct dentry *dentry, char __user *buf, int bufsiz)
205 205
206static bool ovl_is_private_xattr(const char *name) 206static bool ovl_is_private_xattr(const char *name)
207{ 207{
208 return strncmp(name, "trusted.overlay.", 14) == 0; 208 return strncmp(name, OVL_XATTR_PRE_NAME, OVL_XATTR_PRE_LEN) == 0;
209} 209}
210 210
211int ovl_setxattr(struct dentry *dentry, const char *name, 211int ovl_setxattr(struct dentry *dentry, const char *name,
diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
index d176b679f526..17ac5afc9ffb 100644
--- a/fs/overlayfs/overlayfs.h
+++ b/fs/overlayfs/overlayfs.h
@@ -23,7 +23,9 @@ enum ovl_path_type {
23#define OVL_TYPE_MERGE_OR_LOWER(type) \ 23#define OVL_TYPE_MERGE_OR_LOWER(type) \
24 (OVL_TYPE_MERGE(type) || !OVL_TYPE_UPPER(type)) 24 (OVL_TYPE_MERGE(type) || !OVL_TYPE_UPPER(type))
25 25
26extern const char *ovl_opaque_xattr; 26#define OVL_XATTR_PRE_NAME "trusted.overlay."
27#define OVL_XATTR_PRE_LEN 16
28#define OVL_XATTR_OPAQUE OVL_XATTR_PRE_NAME"opaque"
27 29
28static inline int ovl_do_rmdir(struct inode *dir, struct dentry *dentry) 30static inline int ovl_do_rmdir(struct inode *dir, struct dentry *dentry)
29{ 31{
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index e9ce4a9e8749..84f3144e1b33 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -62,8 +62,6 @@ struct ovl_entry {
62 62
63#define OVL_MAX_STACK 500 63#define OVL_MAX_STACK 500
64 64
65const char *ovl_opaque_xattr = "trusted.overlay.opaque";
66
67static struct dentry *__ovl_dentry_lower(struct ovl_entry *oe) 65static struct dentry *__ovl_dentry_lower(struct ovl_entry *oe)
68{ 66{
69 return oe->numlower ? oe->lowerstack[0].dentry : NULL; 67 return oe->numlower ? oe->lowerstack[0].dentry : NULL;
@@ -254,7 +252,7 @@ static bool ovl_is_opaquedir(struct dentry *dentry)
254 if (!S_ISDIR(inode->i_mode) || !inode->i_op->getxattr) 252 if (!S_ISDIR(inode->i_mode) || !inode->i_op->getxattr)
255 return false; 253 return false;
256 254
257 res = inode->i_op->getxattr(dentry, ovl_opaque_xattr, &val, 1); 255 res = inode->i_op->getxattr(dentry, OVL_XATTR_OPAQUE, &val, 1);
258 if (res == 1 && val == 'y') 256 if (res == 1 && val == 'y')
259 return true; 257 return true;
260 258