Exemplo n.º 1
0
// Remove the attribute.
func Removexattr(path, name string) error {
	name = userPrefix + name
	if err := syscall.Removexattr(path, name); err != nil {
		return &XAttrError{"removexattr", path, name, err}
	}
	return nil
}
Exemplo n.º 2
0
func TestXAttrRead(t *testing.T) {
	nm := xattrFilename
	mountPoint, clean := xattrTestCase(t, nm)
	defer clean()

	mounted := filepath.Join(mountPoint, nm)
	attrs, err := listXAttr(mounted)
	readback := make(map[string][]byte)
	if err != nil {
		t.Error("Unexpected ListXAttr error", err)
	} else {
		for _, a := range attrs {
			val, err := readXAttr(mounted, a)
			if err != nil {
				t.Errorf("GetXAttr(%q) failed: %v", a, err)
			}
			readback[a] = val
		}
	}

	if len(readback) != len(xattrGolden) {
		t.Error("length mismatch", xattrGolden, readback)
	} else {
		for k, v := range readback {
			if bytes.Compare(xattrGolden[k], v) != 0 {
				t.Error("val mismatch", k, v, xattrGolden[k])
			}
		}
	}

	err = syscall.Setxattr(mounted, "third", []byte("value"), 0)
	if err != nil {
		t.Error("Setxattr error", err)
	}
	val, err := readXAttr(mounted, "third")
	if err != nil || string(val) != "value" {
		t.Error("Read back set xattr:", err, string(val))
	}

	syscall.Removexattr(mounted, "third")
	val, err = readXAttr(mounted, "third")
	if err != syscall.ENODATA {
		t.Error("Data not removed?", err, val)
	}
}
Exemplo n.º 3
0
// Removexattr calls syscall removexattr
func Removexattr(path string, attr string) (err error) {
	return syscall.Removexattr(path, attr)
}
Exemplo n.º 4
0
// deletes an attribute.
func (this *FileXattribsNS) Remove(tag string) error {
	return syscall.Removexattr(this.File.Name(), this.namespace+ssep+tag)
}