mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-27 03:19:35 +03:00
Truncate the xattr znode when updating existing attributes.
If the attribute's new value was shorter than the old one the old code would leave parts of the old value in the xattr znode. Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #203
This commit is contained in:
parent
274b7e79f3
commit
bec30953cd
@ -191,6 +191,7 @@ zpl_xattr_set(struct inode *ip, const char *name, const void *value,
|
|||||||
cred_t *cr = CRED();
|
cred_t *cr = CRED();
|
||||||
ssize_t wrote;
|
ssize_t wrote;
|
||||||
int error;
|
int error;
|
||||||
|
const int xattr_mode = S_IFREG | 0644;
|
||||||
|
|
||||||
crhold(cr);
|
crhold(cr);
|
||||||
|
|
||||||
@ -230,7 +231,7 @@ zpl_xattr_set(struct inode *ip, const char *name, const void *value,
|
|||||||
/* Lookup failed create a new xattr. */
|
/* Lookup failed create a new xattr. */
|
||||||
if (xip == NULL) {
|
if (xip == NULL) {
|
||||||
vap = kmem_zalloc(sizeof(vattr_t), KM_SLEEP);
|
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_mask = ATTR_MODE;
|
||||||
vap->va_uid = crgetfsuid(cr);
|
vap->va_uid = crgetfsuid(cr);
|
||||||
vap->va_gid = crgetfsgid(cr);
|
vap->va_gid = crgetfsgid(cr);
|
||||||
@ -242,6 +243,11 @@ zpl_xattr_set(struct inode *ip, const char *name, const void *value,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(xip != 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);
|
wrote = zpl_write_common(xip, value, size, 0, UIO_SYSSPACE, 0, cr);
|
||||||
if (wrote < 0)
|
if (wrote < 0)
|
||||||
error = wrote;
|
error = wrote;
|
||||||
|
Loading…
Reference in New Issue
Block a user