aboutsummaryrefslogtreecommitdiff
path: root/weed/mount/weedfs_xattr.go
diff options
context:
space:
mode:
Diffstat (limited to 'weed/mount/weedfs_xattr.go')
-rw-r--r--weed/mount/weedfs_xattr.go32
1 files changed, 30 insertions, 2 deletions
diff --git a/weed/mount/weedfs_xattr.go b/weed/mount/weedfs_xattr.go
index c85a1b3a1..64cc0f6f0 100644
--- a/weed/mount/weedfs_xattr.go
+++ b/weed/mount/weedfs_xattr.go
@@ -20,6 +20,10 @@ const (
// with the required buffer size.
func (wfs *WFS) GetXAttr(cancel <-chan struct{}, header *fuse.InHeader, attr string, dest []byte) (size uint32, code fuse.Status) {
+ if wfs.option.DisableXAttr {
+ return 0, fuse.Status(syscall.ENOTSUP)
+ }
+
//validate attr name
if len(attr) > MAX_XATTR_NAME_SIZE {
if runtime.GOOS == "darwin" {
@@ -70,6 +74,10 @@ func (wfs *WFS) GetXAttr(cancel <-chan struct{}, header *fuse.InHeader, attr str
// attribute does not already exist.
func (wfs *WFS) SetXAttr(cancel <-chan struct{}, input *fuse.SetXAttrIn, attr string, data []byte) fuse.Status {
+ if wfs.option.DisableXAttr {
+ return fuse.Status(syscall.ENOTSUP)
+ }
+
if wfs.IsOverQuota {
return fuse.Status(syscall.ENOSPC)
}
@@ -94,10 +102,15 @@ func (wfs *WFS) SetXAttr(cancel <-chan struct{}, input *fuse.SetXAttrIn, attr st
}
}
- path, _, entry, status := wfs.maybeReadEntry(input.NodeId)
+ path, fh, entry, status := wfs.maybeReadEntry(input.NodeId)
if status != fuse.OK {
return status
}
+ if fh != nil {
+ fh.entryLock.Lock()
+ defer fh.entryLock.Unlock()
+ }
+
if entry.Extended == nil {
entry.Extended = make(map[string][]byte)
}
@@ -122,6 +135,11 @@ func (wfs *WFS) SetXAttr(cancel <-chan struct{}, input *fuse.SetXAttrIn, attr st
// slice, and return the number of bytes. If the buffer is too
// small, return ERANGE, with the required buffer size.
func (wfs *WFS) ListXAttr(cancel <-chan struct{}, header *fuse.InHeader, dest []byte) (n uint32, code fuse.Status) {
+
+ if wfs.option.DisableXAttr {
+ return 0, fuse.Status(syscall.ENOTSUP)
+ }
+
_, _, entry, status := wfs.maybeReadEntry(header.NodeId)
if status != fuse.OK {
return 0, status
@@ -151,13 +169,23 @@ func (wfs *WFS) ListXAttr(cancel <-chan struct{}, header *fuse.InHeader, dest []
// RemoveXAttr removes an extended attribute.
func (wfs *WFS) RemoveXAttr(cancel <-chan struct{}, header *fuse.InHeader, attr string) fuse.Status {
+
+ if wfs.option.DisableXAttr {
+ return fuse.Status(syscall.ENOTSUP)
+ }
+
if len(attr) == 0 {
return fuse.EINVAL
}
- path, _, entry, status := wfs.maybeReadEntry(header.NodeId)
+ path, fh, entry, status := wfs.maybeReadEntry(header.NodeId)
if status != fuse.OK {
return status
}
+ if fh != nil {
+ fh.entryLock.Lock()
+ defer fh.entryLock.Unlock()
+ }
+
if entry.Extended == nil {
return fuse.ENOATTR
}