diff --git a/weed/mount/weedfs_xattr.go b/weed/mount/weedfs_xattr.go index e85b9d854..8ae6eb6d5 100644 --- a/weed/mount/weedfs_xattr.go +++ b/weed/mount/weedfs_xattr.go @@ -121,22 +121,23 @@ func (wfs *WFS) SetXAttr(cancel <-chan struct{}, input *fuse.SetXAttrIn, attr st if entry.Extended == nil { entry.Extended = make(map[string][]byte) } - oldData, _ := entry.Extended[XATTR_PREFIX+attr] + _, exists := entry.Extended[XATTR_PREFIX+attr] switch input.Flags { case sys.XATTR_CREATE: - if len(oldData) > 0 { - break + if exists { + return fuse.Status(syscall.EEXIST) } - fallthrough case sys.XATTR_REPLACE: - fallthrough - default: - // data aliases the FUSE request's pooled input buffer, which is - // recycled once this handler returns. Copy before storing so a - // later request reusing the buffer cannot corrupt the value. - entry.Extended[XATTR_PREFIX+attr] = append([]byte(nil), data...) + if !exists { + return fuse.ENODATA + } } + // data aliases the FUSE request's pooled input buffer, which is + // recycled once this handler returns. Copy before storing so a + // later request reusing the buffer cannot corrupt the value. + entry.Extended[XATTR_PREFIX+attr] = append([]byte(nil), data...) + if fh != nil { fh.dirtyMetadata = true return fuse.OK