// Lgetxattr retrieves the value of the extended attribute identified by attr
// and associated with the given path in the file system.
// It will returns a nil slice and nil error if the xattr is not set.
328432
func Lgetxattr(path string, attr string) ([]byte, error) {
	dest := make([]byte, 128)
	sz, errno := unix.Lgetxattr(path, attr, dest)
	if errno == unix.ENODATA {
		return nil, nil
	}
	if errno == unix.ERANGE {
		dest = make([]byte, sz)
		sz, errno = unix.Lgetxattr(path, attr, dest)
	}
	if errno != nil {
		return nil, errno
	}

	return dest[:sz], nil
}
808635
func selectionAttr(selection *goquery.Selection, attr string) string {
	var results []string
	selection.Each(func(i int, element *goquery.Selection) {
		res, ok := element.Attr(attr)
		if ok {
			results = append(results, res)
		}
	})
	return strings.Join(results, " ")
}
987273
func LSetxattr(path string, attr string, data []byte, flags int) (err error) {
	return unix.Lsetxattr(path, attr, data, flags)
}
1340615
func getClassesAndAttr(n *html.Node, create bool) (classes string, attr *html.Attribute) {
	// Applies only to element nodes
	if n.Type == html.ElementNode {
		attr = getAttributePtr("class", n)
		if attr == nil && create {
			n.Attr = append(n.Attr, html.Attribute{
				Key: "class",
				Val: "",
			})
			attr = &n.Attr[len(n.Attr)-1]
		}
	}

	if attr == nil {
		classes = " "
	} else {
		classes = rxClassTrim.ReplaceAllString(" "+attr.Val+" ", " ")
	}

	return
}
783030
func (h *QuarantineXattrHandler) Getxattr(ctx context.Context,
	req *fuse.GetxattrRequest, resp *fuse.GetxattrResponse) (err error) {
	ctx = h.folder.fs.config.MaybeStartTrace(ctx, "QuarantineXattrHandler.Getxattr",
		fmt.Sprintf("%s %s", h.node.GetBasename(), req.Name))
	defer func() { h.folder.fs.config.MaybeFinishTrace(ctx, err) }()

	h.folder.fs.log.CDebugf(ctx,
		"QuarantineXattrHandler Getxattr %s %s", h.node.GetBasename(), req.Name)
	defer func() { err = h.folder.processError(ctx, libkbfs.ReadMode, err) }()

	if req.Name != quarantineXattrName {
		// The request is not about quarantine. Let the OS fallback to ._ file
		// based method.
		return fuse.ENOTSUP
	}

	xattr, err := h.folder.fs.config.XattrStore().GetXattr(
		ctx, h.node.GetBlockID(), libkbfs.XattrAppleQuarantine)
	switch errors.Cause(err) {
	case nil:
		if len(xattr) == 0 {
			return fuse.ENOATTR
		}
		resp.Xattr = xattr
		return nil
	case ldberrors.ErrNotFound:
		// We don't have an Xattr value stored locally, so just use a
		// quarantine value.

		// Stat on the node to get the Mtime.

		// This fits in situation 1 as described in
		// libkbfs/delayed_cancellation.go
		if err = libcontext.EnableDelayedCancellationWithGracePeriod(ctx,
			h.folder.fs.config.DelayedCancellationGracePeriod()); err != nil {
			return err
		}
		de, err := h.folder.fs.config.KBFSOps().Stat(ctx, h.node)
		if err != nil {
			if _, ok := err.(idutil.NoSuchNameError); ok {
				// The node is not found, so just return ENOTSUP
				return fuse.ENOTSUP
			}
			return err
		}

		resp.Xattr = makeQuarantine(time.Unix(0, de.Mtime))
		return nil
	default:
		return err
	}
}
1374463
func GetAttribute(e xml.StartElement, name xml.Name) string {
	for _, a := range e.Attr {
		if NameEquals(a.Name, name) {
			return a.Value
		}
	}
	return ""
}
853329
func (s Slice) Get(attributePath ...string) (Slice, error) {
	result := s
	parent := s
	for _, a := range attributePath {
		var err error
		result, err = parent.get(a)
		if err != nil {
			return nil, WithStack(err)
		}
		if result.IsNone() {
			return result, nil
		}
		parent = result
	}
	return result, nil
}
257733
func Tcgetattr(fd uintptr, argp *syscall.Termios) error {
	termios, err := unix.IoctlGetTermios(int(fd), unix.TCGETS)
	*argp = *(tiosToSyscall(termios))
	return err
}
737803
func (d *Dir) Attr(ctx context.Context, a *fuse.Attr) (err error) {
	ctx = d.folder.fs.config.MaybeStartTrace(
		ctx, "Dir.Attr", d.node.GetBasename())
	defer func() { d.folder.fs.config.MaybeFinishTrace(ctx, err) }()

	d.folder.fs.vlog.CLogf(ctx, libkb.VLog1, "Dir Attr")
	defer func() { err = d.folder.processError(ctx, libkbfs.ReadMode, err) }()

	// This fits in situation 1 as described in libkbfs/delayed_cancellation.go
	err = libcontext.EnableDelayedCancellationWithGracePeriod(
		ctx, d.folder.fs.config.DelayedCancellationGracePeriod())
	if err != nil {
		return err
	}

	return d.attr(ctx, a)
}
1203902
func Getxattr(path, attr string) ([]byte, error) {
	return getxattrAll(path, attr, unix.Getxattr)
}
687489
func setxattr(path string, attr string, data []byte, position uint32, flags int) (err error) {
	var _p0 *byte
	_p0, err = syscall.BytePtrFromString(path)
	if err != nil {
		return
	}
	var _p1 *byte
	_p1, err = syscall.BytePtrFromString(attr)
	if err != nil {
		return
	}
	var _p2 unsafe.Pointer
	if len(data) > 0 {
		_p2 = unsafe.Pointer(&data[0])
	} else {
		_p2 = unsafe.Pointer(&_zero)
	}
	_, _, e1 := syscall.Syscall6(syscall.SYS_SETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(data)), uintptr(position), uintptr(flags))
	if e1 != 0 {
		err = e1
	}
	return
}
1152632
func LSet(path, name string, data []byte) error {
	if err := lsetxattr(path, name, data, 0); err != nil {
		return &Error{"xattr.LSet", path, name, err}
	}
	return nil
}
126613
func (fi *FileNode) Attr(ctx context.Context, a *fuse.Attr) error {
	log.Debug("File Attr")
	size, err := fi.fi.Size()
	if err != nil {
		// In this case, the dag node in question may not be unixfs
		return fmt.Errorf("fuse/ipns: failed to get file.Size(): %s", err)
	}
	a.Mode = os.FileMode(0666)
	a.Size = uint64(size)
	a.Uid = uint32(os.Getuid())
	a.Gid = uint32(os.Getgid())
	return nil
}
450146
func getXAttr(path, key string) (string, error) {
	data, e := xattr.Get(path, key)
	if e != nil {
		return "", e
	}
	if utf8.ValidString(string(data)) {
		return string(data), nil
	}
	return hex.EncodeToString(data), nil
}
1319863
func Lsetxattr(path string, attr string, data []byte, flags int) error {
	return ErrNotSupportedPlatform
}
129281
func (s *sessionImpl) Attr(name string) interface{} {
	s.mux.RLock()
	defer s.mux.RUnlock()

	return s.AttrsF[name]
}
23813
func (e *Element) GetAttribute(name string) string {
	attr, err := e.GetAttributes()
	if err != nil {
		return ""
	}
	return attr[name]
}