Пример #1
0
func Set(path, name string, value []byte) error {
	err := xattr.Set(path, name, value)
	if IsErrno(err, syscall.ENOTSUP) {
		err = setAttr(path, name, value, 0)
	}
	return err
}
Пример #2
0
func SetForce(path, name string, value []byte, info os.FileInfo, force bool) (bool, error) {
	err := xattr.Set(path, name, value)
	if IsErrno(err, syscall.ENOTSUP) {
		return false, setAttr(path, name, value, 0)
	}
	forced := false
	if err != nil && force && os.IsPermission(err) {
		m := info.Mode()
		forced = true
		e1 := os.Chmod(path, m|0200)
		if e1 != nil {
			err = e1
		} else {
			err = xattr.Set(path, name, value)
			e2 := os.Chmod(path, m)
			if e2 != nil {
				panic(fmt.Errorf("%s: Could not chmod back to 0%o", path, m))
			}
		}
	}
	return forced, err
}