xattr.c (7efb35af738e96565934cc640d863eb18dba0206) xattr.c (42492594043d621a7910ff5877c3eb9202870b45)
1/*
2 File: fs/xattr.c
3
4 Extended attribute handling.
5
6 Copyright (C) 2001 by Andreas Gruenbacher <a.gruenbacher@computer.org>
7 Copyright (C) 2001 SGI - Silicon Graphics, Inc <linux-xfs@oss.sgi.com>
8 Copyright (c) 2004 Red Hat, Inc., James Morris <jmorris@redhat.com>

--- 91 unchanged lines hidden (view full) ---

100 }
101out:
102 mutex_unlock(&inode->i_mutex);
103 return error;
104}
105EXPORT_SYMBOL_GPL(vfs_setxattr);
106
107ssize_t
1/*
2 File: fs/xattr.c
3
4 Extended attribute handling.
5
6 Copyright (C) 2001 by Andreas Gruenbacher <a.gruenbacher@computer.org>
7 Copyright (C) 2001 SGI - Silicon Graphics, Inc <linux-xfs@oss.sgi.com>
8 Copyright (c) 2004 Red Hat, Inc., James Morris <jmorris@redhat.com>

--- 91 unchanged lines hidden (view full) ---

100 }
101out:
102 mutex_unlock(&inode->i_mutex);
103 return error;
104}
105EXPORT_SYMBOL_GPL(vfs_setxattr);
106
107ssize_t
108xattr_getsecurity(struct inode *inode, const char *name, void *value,
109 size_t size)
110{
111 void *buffer = NULL;
112 ssize_t len;
113
114 if (!value || !size) {
115 len = security_inode_getsecurity(inode, name, &buffer, false);
116 goto out_noalloc;
117 }
118
119 len = security_inode_getsecurity(inode, name, &buffer, true);
120 if (len < 0)
121 return len;
122 if (size < len) {
123 len = -ERANGE;
124 goto out;
125 }
126 memcpy(value, buffer, len);
127out:
128 security_release_secctx(buffer, len);
129out_noalloc:
130 return len;
131}
132EXPORT_SYMBOL_GPL(xattr_getsecurity);
133
134ssize_t
108vfs_getxattr(struct dentry *dentry, char *name, void *value, size_t size)
109{
110 struct inode *inode = dentry->d_inode;
111 int error;
112
113 error = xattr_permission(inode, name, MAY_READ);
114 if (error)
115 return error;

--- 5 unchanged lines hidden (view full) ---

121 if (inode->i_op->getxattr)
122 error = inode->i_op->getxattr(dentry, name, value, size);
123 else
124 error = -EOPNOTSUPP;
125
126 if (!strncmp(name, XATTR_SECURITY_PREFIX,
127 XATTR_SECURITY_PREFIX_LEN)) {
128 const char *suffix = name + XATTR_SECURITY_PREFIX_LEN;
135vfs_getxattr(struct dentry *dentry, char *name, void *value, size_t size)
136{
137 struct inode *inode = dentry->d_inode;
138 int error;
139
140 error = xattr_permission(inode, name, MAY_READ);
141 if (error)
142 return error;

--- 5 unchanged lines hidden (view full) ---

148 if (inode->i_op->getxattr)
149 error = inode->i_op->getxattr(dentry, name, value, size);
150 else
151 error = -EOPNOTSUPP;
152
153 if (!strncmp(name, XATTR_SECURITY_PREFIX,
154 XATTR_SECURITY_PREFIX_LEN)) {
155 const char *suffix = name + XATTR_SECURITY_PREFIX_LEN;
129 int ret = security_inode_getsecurity(inode, suffix, value,
130 size, error);
156 int ret = xattr_getsecurity(inode, suffix, value, size);
131 /*
132 * Only overwrite the return value if a security module
133 * is actually active.
134 */
135 if (ret != -EOPNOTSUPP)
136 error = ret;
137 }
138

--- 482 unchanged lines hidden ---
157 /*
158 * Only overwrite the return value if a security module
159 * is actually active.
160 */
161 if (ret != -EOPNOTSUPP)
162 error = ret;
163 }
164

--- 482 unchanged lines hidden ---