xattr_filldir_t *xf = arg;
if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN))
- if (!(ITOZSB(xf->inode)->z_flags & ZSB_XATTR_USER))
+ if (!(ITOZSB(xf->inode)->z_flags & ZSB_XATTR))
return (0);
if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN))
struct inode *ip = dentry->d_inode;
struct inode *dxip = NULL;
loff_t pos = 3; /* skip '.', '..', and '.zfs' entries. */
- cred_t *cr;
+ cred_t *cr = CRED();
int error;
xattr_filldir_t xf = { buffer_size, 0, buffer, ip };
- cr = (cred_t *)get_current_cred();
+ crhold(cr);
/* Lookup the xattr directory */
error = -zfs_lookup(ip, NULL, &dxip, LOOKUP_XATTR, cr, NULL, NULL);
if (dxip)
iput(dxip);
- put_cred(cr);
+ crfree(cr);
return (error);
}
{
struct inode *dxip = NULL;
struct inode *xip = NULL;
- cred_t *cr;
+ cred_t *cr = CRED();
int error;
- cr = (cred_t *)get_current_cred();
+ crhold(cr);
/* Lookup the xattr directory */
error = -zfs_lookup(ip, NULL, &dxip, LOOKUP_XATTR, cr, NULL, NULL);
if (dxip)
iput(dxip);
- put_cred(cr);
+ crfree(cr);
if (error == -ENOENT)
error = -ENODATA;
struct inode *dxip = NULL;
struct inode *xip = NULL;
vattr_t *vap = NULL;
- cred_t *cr;
+ cred_t *cr = CRED();
ssize_t wrote;
int error;
+ const int xattr_mode = S_IFREG | 0644;
- cr = (cred_t *)get_current_cred();
+ crhold(cr);
/* Lookup the xattr directory and create it if required. */
error = -zfs_lookup(ip, NULL, &dxip, LOOKUP_XATTR | CREATE_XATTR_DIR,
/* Lookup failed create a new xattr. */
if (xip == NULL) {
vap = kmem_zalloc(sizeof(vattr_t), KM_SLEEP);
- vap->va_mode = S_IFREG | 0644;
+ vap->va_mode = xattr_mode;
vap->va_mask = ATTR_MODE;
- vap->va_uid = current_fsuid();
- vap->va_gid = current_fsgid();
+ vap->va_uid = crgetfsuid(cr);
+ vap->va_gid = crgetfsgid(cr);
error = -zfs_create(dxip, (char *)name, vap, 0, 0644, &xip,
cr, 0, NULL);
}
ASSERT(xip != NULL);
+
+ error = -zfs_freesp(ITOZ(xip), 0, 0, xattr_mode, TRUE);
+ if (error)
+ goto out;
+
wrote = zpl_write_common(xip, value, size, 0, UIO_SYSSPACE, 0, cr);
if (wrote < 0)
error = wrote;
if (dxip)
iput(dxip);
- put_cred(cr);
+ crfree(cr);
if (error == -ENOENT)
error = -ENODATA;
}
static int
-zpl_xattr_user_get(struct inode *ip, const char *name,
+__zpl_xattr_user_get(struct inode *ip, const char *name,
void *buffer, size_t size)
{
char *xattr_name;
if (strcmp(name, "") == 0)
return -EINVAL;
- if (!(ITOZSB(ip)->z_flags & ZSB_XATTR_USER))
+ if (!(ITOZSB(ip)->z_flags & ZSB_XATTR))
return -EOPNOTSUPP;
xattr_name = kmem_asprintf("%s%s", XATTR_USER_PREFIX, name);
return (error);
}
+ZPL_XATTR_GET_WRAPPER(zpl_xattr_user_get);
static int
-zpl_xattr_user_set(struct inode *ip, const char *name,
+__zpl_xattr_user_set(struct inode *ip, const char *name,
const void *value, size_t size, int flags)
{
char *xattr_name;
if (strcmp(name, "") == 0)
return -EINVAL;
- if (!(ITOZSB(ip)->z_flags & ZSB_XATTR_USER))
+ if (!(ITOZSB(ip)->z_flags & ZSB_XATTR))
return -EOPNOTSUPP;
xattr_name = kmem_asprintf("%s%s", XATTR_USER_PREFIX, name);
return (error);
}
+ZPL_XATTR_SET_WRAPPER(zpl_xattr_user_set);
-struct xattr_handler zpl_xattr_user_handler = {
+xattr_handler_t zpl_xattr_user_handler = {
.prefix = XATTR_USER_PREFIX,
.get = zpl_xattr_user_get,
.set = zpl_xattr_user_set,
};
static int
-zpl_xattr_trusted_get(struct inode *ip, const char *name,
+__zpl_xattr_trusted_get(struct inode *ip, const char *name,
void *buffer, size_t size)
{
char *xattr_name;
return (error);
}
+ZPL_XATTR_GET_WRAPPER(zpl_xattr_trusted_get);
static int
-zpl_xattr_trusted_set(struct inode *ip, const char *name,
+__zpl_xattr_trusted_set(struct inode *ip, const char *name,
const void *value, size_t size, int flags)
{
char *xattr_name;
return (error);
}
+ZPL_XATTR_SET_WRAPPER(zpl_xattr_trusted_set);
-struct xattr_handler zpl_xattr_trusted_handler = {
+xattr_handler_t zpl_xattr_trusted_handler = {
.prefix = XATTR_TRUSTED_PREFIX,
.get = zpl_xattr_trusted_get,
.set = zpl_xattr_trusted_set,
};
static int
-zpl_xattr_security_get(struct inode *ip, const char *name,
+__zpl_xattr_security_get(struct inode *ip, const char *name,
void *buffer, size_t size)
{
char *xattr_name;
return (error);
}
+ZPL_XATTR_GET_WRAPPER(zpl_xattr_security_get);
static int
-zpl_xattr_security_set(struct inode *ip, const char *name,
+__zpl_xattr_security_set(struct inode *ip, const char *name,
const void *value, size_t size, int flags)
{
char *xattr_name;
return (error);
}
+ZPL_XATTR_SET_WRAPPER(zpl_xattr_security_set);
int
-zpl_xattr_security_init(struct inode *ip, struct inode *dip)
+zpl_xattr_security_init(struct inode *ip, struct inode *dip,
+ const struct qstr *qstr)
{
int error;
size_t len;
void *value;
char *name;
- error = security_inode_init_security(ip, dip, &name, &value, &len);
+ error = zpl_security_inode_init_security(ip, dip, qstr,
+ &name, &value, &len);
if (error) {
if (error == -EOPNOTSUPP)
return 0;
return (error);
}
- error = zpl_xattr_security_set(ip, name, value, len, 0);
+ error = __zpl_xattr_security_set(ip, name, value, len, 0);
kfree(name);
kfree(value);
return (error);
}
-struct xattr_handler zpl_xattr_security_handler = {
+xattr_handler_t zpl_xattr_security_handler = {
.prefix = XATTR_SECURITY_PREFIX,
.get = zpl_xattr_security_get,
.set = zpl_xattr_security_set,
};
-struct xattr_handler *zpl_xattr_handlers[] = {
+xattr_handler_t *zpl_xattr_handlers[] = {
&zpl_xattr_security_handler,
&zpl_xattr_trusted_handler,
&zpl_xattr_user_handler,