static int
zpl_xattr_filldir(xattr_filldir_t *xf, const char *name, int name_len)
{
- if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN))
+ if (strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN) == 0)
if (!(ITOZSB(xf->inode)->z_flags & ZSB_XATTR))
return (0);
- if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN))
+ if (strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN) == 0)
if (!capable(CAP_SYS_ADMIN))
return (0);
ASSERT3U(nvpair_type(nvp), ==, DATA_TYPE_BYTE_ARRAY);
error = zpl_xattr_filldir(xf, nvpair_name(nvp),
- strlen(nvpair_name(nvp)));
+ strlen(nvpair_name(nvp)));
if (error)
return (error);
}
/* Lookup failed create a new xattr. */
if (xip == NULL) {
- vap = kmem_zalloc(sizeof(vattr_t), KM_SLEEP);
+ vap = kmem_zalloc(sizeof (vattr_t), KM_SLEEP);
vap->va_mode = xattr_mode;
vap->va_mask = ATTR_MODE;
vap->va_uid = crgetfsuid(cr);
out:
if (vap)
- kmem_free(vap, sizeof(vattr_t));
+ kmem_free(vap, sizeof (vattr_t));
if (xip)
iput(xip);
if (error == -ENOENT)
error = zpl_xattr_set_dir(ip, name, NULL, 0, flags, cr);
} else {
- /* Do not allow SA xattrs in symlinks (issue #1648) */
- if (S_ISLNK(ip->i_mode))
- return (-EMLINK);
-
/* Limited to 32k to keep nvpair memory allocations small */
if (size > DXATTR_MAX_ENTRY_SIZE)
return (-EFBIG);
int error;
if (strcmp(name, "") == 0)
- return -EINVAL;
+ return (-EINVAL);
if (!(ITOZSB(ip)->z_flags & ZSB_XATTR))
- return -EOPNOTSUPP;
+ return (-EOPNOTSUPP);
xattr_name = kmem_asprintf("%s%s", XATTR_USER_PREFIX, name);
error = zpl_xattr_get(ip, xattr_name, value, size);
int error;
if (strcmp(name, "") == 0)
- return -EINVAL;
+ return (-EINVAL);
if (!(ITOZSB(ip)->z_flags & ZSB_XATTR))
- return -EOPNOTSUPP;
+ return (-EOPNOTSUPP);
xattr_name = kmem_asprintf("%s%s", XATTR_USER_PREFIX, name);
error = zpl_xattr_set(ip, xattr_name, value, size, flags);
int error;
if (!capable(CAP_SYS_ADMIN))
- return -EACCES;
+ return (-EACCES);
if (strcmp(name, "") == 0)
- return -EINVAL;
+ return (-EINVAL);
xattr_name = kmem_asprintf("%s%s", XATTR_TRUSTED_PREFIX, name);
error = zpl_xattr_get(ip, xattr_name, value, size);
int error;
if (!capable(CAP_SYS_ADMIN))
- return -EACCES;
+ return (-EACCES);
if (strcmp(name, "") == 0)
- return -EINVAL;
+ return (-EINVAL);
xattr_name = kmem_asprintf("%s%s", XATTR_TRUSTED_PREFIX, name);
error = zpl_xattr_set(ip, xattr_name, value, size, flags);
int error;
if (strcmp(name, "") == 0)
- return -EINVAL;
+ return (-EINVAL);
xattr_name = kmem_asprintf("%s%s", XATTR_SECURITY_PREFIX, name);
error = zpl_xattr_get(ip, xattr_name, value, size);
int error;
if (strcmp(name, "") == 0)
- return -EINVAL;
+ return (-EINVAL);
xattr_name = kmem_asprintf("%s%s", XATTR_SECURITY_PREFIX, name);
error = zpl_xattr_set(ip, xattr_name, value, size, flags);
char *name;
error = zpl_security_inode_init_security(ip, dip, qstr,
- &name, &value, &len);
+ &name, &value, &len);
if (error) {
if (error == -EOPNOTSUPP)
- return 0;
+ return (0);
+
return (error);
}
.set = zpl_xattr_security_set,
};
+#ifdef CONFIG_FS_POSIX_ACL
+
int
zpl_set_acl(struct inode *ip, int type, struct posix_acl *acl)
{
if (S_ISLNK(ip->i_mode))
return (-EOPNOTSUPP);
- switch(type) {
+ switch (type) {
case ACL_TYPE_ACCESS:
name = POSIX_ACL_XATTR_ACCESS;
if (acl) {
name = POSIX_ACL_XATTR_DEFAULT;
break;
default:
- return ERR_PTR(-EINVAL);
+ return (ERR_PTR(-EINVAL));
}
size = zpl_xattr_get(ip, name, NULL, 0);
int
zpl_check_acl(struct inode *ip, int mask, unsigned int flags)
{
- return __zpl_check_acl(ip, mask);
+ return (__zpl_check_acl(ip, mask));
}
#elif defined(HAVE_CHECK_ACL)
int
zpl_check_acl(struct inode *ip, int mask)
{
- return __zpl_check_acl(ip , mask);
+ return (__zpl_check_acl(ip, mask));
}
#elif defined(HAVE_PERMISSION_WITH_NAMEIDATA)
int
zpl_permission(struct inode *ip, int mask, struct nameidata *nd)
{
- return generic_permission(ip, mask, __zpl_check_acl);
+ return (generic_permission(ip, mask, __zpl_check_acl));
}
#elif defined(HAVE_PERMISSION)
int
zpl_permission(struct inode *ip, int mask)
{
- return generic_permission(ip, mask, __zpl_check_acl);
+ return (generic_permission(ip, mask, __zpl_check_acl));
}
#endif /* HAVE_CHECK_ACL | HAVE_PERMISSION */
#endif /* !HAVE_GET_ACL */
}
mode = ip->i_mode;
- error = posix_acl_create(&acl,GFP_KERNEL, &mode);
+ error = posix_acl_create(&acl, GFP_KERNEL, &mode);
if (error >= 0) {
ip->i_mode = mode;
mark_inode_dirty(ip);
if (IS_ERR(acl) || !acl)
return (PTR_ERR(acl));
- error = posix_acl_chmod(&acl,GFP_KERNEL, ip->i_mode);
+ error = posix_acl_chmod(&acl, GFP_KERNEL, ip->i_mode);
if (!error)
- error = zpl_set_acl(ip,ACL_TYPE_ACCESS, acl);
+ error = zpl_set_acl(ip, ACL_TYPE_ACCESS, acl);
zpl_posix_acl_release(acl);
switch (type) {
case ACL_TYPE_ACCESS:
xattr_name = POSIX_ACL_XATTR_ACCESS;
- xattr_size = sizeof(xattr_name);
+ xattr_size = sizeof (xattr_name);
break;
case ACL_TYPE_DEFAULT:
xattr_name = POSIX_ACL_XATTR_DEFAULT;
- xattr_size = sizeof(xattr_name);
+ xattr_size = sizeof (xattr_name);
break;
default:
return (0);
void *buffer, size_t size, int type)
{
ASSERT3S(type, ==, ACL_TYPE_ACCESS);
- return zpl_xattr_acl_get(dentry->d_inode, name, buffer, size, type);
+ return (zpl_xattr_acl_get(dentry->d_inode, name, buffer, size, type));
}
static int
void *buffer, size_t size, int type)
{
ASSERT3S(type, ==, ACL_TYPE_DEFAULT);
- return zpl_xattr_acl_get(dentry->d_inode, name, buffer, size, type);
+ return (zpl_xattr_acl_get(dentry->d_inode, name, buffer, size, type));
}
#else
zpl_xattr_acl_get_access(struct inode *ip, const char *name,
void *buffer, size_t size)
{
- return zpl_xattr_acl_get(ip, name, buffer, size, ACL_TYPE_ACCESS);
+ return (zpl_xattr_acl_get(ip, name, buffer, size, ACL_TYPE_ACCESS));
}
static int
zpl_xattr_acl_get_default(struct inode *ip, const char *name,
void *buffer, size_t size)
{
- return zpl_xattr_acl_get(ip, name, buffer, size, ACL_TYPE_DEFAULT);
+ return (zpl_xattr_acl_get(ip, name, buffer, size, ACL_TYPE_DEFAULT));
}
#endif /* HAVE_DENTRY_XATTR_GET */
zpl_xattr_acl_set_access(struct dentry *dentry, const char *name,
const void *value, size_t size, int flags, int type)
{
- ASSERT3S(type, ==, ACL_TYPE_ACCESS);
- return zpl_xattr_acl_set(dentry->d_inode,
- name, value, size, flags, type);
+ ASSERT3S(type, ==, ACL_TYPE_ACCESS);
+ return (zpl_xattr_acl_set(dentry->d_inode,
+ name, value, size, flags, type));
}
static int
zpl_xattr_acl_set_default(struct dentry *dentry, const char *name,
- const void *value, size_t size,int flags, int type)
+ const void *value, size_t size, int flags, int type)
{
- ASSERT3S(type, ==, ACL_TYPE_DEFAULT);
- return zpl_xattr_acl_set(dentry->d_inode,
+ ASSERT3S(type, ==, ACL_TYPE_DEFAULT);
+ return zpl_xattr_acl_set(dentry->d_inode,
name, value, size, flags, type);
}
zpl_xattr_acl_set_access(struct inode *ip, const char *name,
const void *value, size_t size, int flags)
{
- return zpl_xattr_acl_set(ip,
+ return zpl_xattr_acl_set(ip,
name, value, size, flags, ACL_TYPE_ACCESS);
}
zpl_xattr_acl_set_default(struct inode *ip, const char *name,
const void *value, size_t size, int flags)
{
- return zpl_xattr_acl_set(ip,
+ return zpl_xattr_acl_set(ip,
name, value, size, flags, ACL_TYPE_DEFAULT);
}
#endif /* HAVE_DENTRY_XATTR_SET */
#endif /* HAVE_DENTRY_XATTR_LIST */
};
+#endif /* CONFIG_FS_POSIX_ACL */
+
xattr_handler_t *zpl_xattr_handlers[] = {
&zpl_xattr_security_handler,
&zpl_xattr_trusted_handler,
&zpl_xattr_user_handler,
+#ifdef CONFIG_FS_POSIX_ACL
&zpl_xattr_acl_access_handler,
&zpl_xattr_acl_default_handler,
+#endif /* CONFIG_FS_POSIX_ACL */
NULL
};