// Attr returns file attributes.
517130
func (*Root) Attr(ctx context.Context, a *fuse.Attr) error {
	log.Debug("Root Attr")
	a.Mode = os.ModeDir | 0111 // -rw+x
	return nil
}
659470
func (m *AttrWriter) Print(a []*Attribute) string {
	if len(a) <= 0 {
		return ""
	}

	attrs := []string{}

	for _, ar := range a {
		attrs = append(attrs, fmt.Sprintf(attrformt, ar.Name, ar.Value))
	}

	return strings.Join(attrs, " ")
}
27044
func Setxattr(path string, attr string, data []byte, flags int) (err error) {
	return setxattr(path, attr, data, 0, flags)
}
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)
}
646426
func GetAttr(e Markup, f string) (*Attribute, error) {
	for _, as := range e.Attributes() {
		if as.Name == f {
			return as, nil
		}
	}
	return nil, ErrNotFound
}
1247873
func (fl *FolderList) Attr(ctx context.Context, a *fuse.Attr) error {
	a.Mode = os.ModeDir | 0500
	a.Uid = uint32(os.Getuid())
	a.Inode = fl.inode
	return nil
}
967598
func getAttr(attribute string, node *html.Node) (string, bool) {
	for _, attr := range node.Attr {
		if attribute == attr.Key {
			return attr.Val, true
		}
	}
	return "", false
}
1117202
func (b *Builder) Attr(attr dwarf.Attr, val interface{}) {
	if len(b.tagStack) < 0 {
		panic("Attr with no open tags")
	}
	tag := b.tagStack[len(b.tagStack)-1]
	if tag.children {
		panic("Can't add attributes after adding children")
	}

	tag.attr = append(tag.attr, attr)

	switch x := val.(type) {
	case string:
		tag.form = append(tag.form, DW_FORM_string)
		b.info.Write([]byte(x))
		b.info.WriteByte(0)
	case uint8:
		tag.form = append(tag.form, DW_FORM_data1)
		binary.Write(&b.info, binary.LittleEndian, x)
	case uint16:
		tag.form = append(tag.form, DW_FORM_data2)
		binary.Write(&b.info, binary.LittleEndian, x)
	case Address:
		tag.form = append(tag.form, DW_FORM_addr)
		binary.Write(&b.info, binary.LittleEndian, x)
	case dwarf.Offset:
		tag.form = append(tag.form, DW_FORM_ref_addr)
		binary.Write(&b.info, binary.LittleEndian, x)
	case []byte:
		tag.form = append(tag.form, DW_FORM_block4)
		binary.Write(&b.info, binary.LittleEndian, uint32(len(x)))
		b.info.Write(x)
	case []LocEntry:
		tag.form = append(tag.form, DW_FORM_sec_offset)
		binary.Write(&b.info, binary.LittleEndian, uint32(b.loc.Len()))

		// base address
		binary.Write(&b.loc, binary.LittleEndian, ^uint64(0))
		binary.Write(&b.loc, binary.LittleEndian, uint64(0))

		for _, locentry := range x {
			binary.Write(&b.loc, binary.LittleEndian, uint64(locentry.Lowpc))
			binary.Write(&b.loc, binary.LittleEndian, uint64(locentry.Highpc))
			binary.Write(&b.loc, binary.LittleEndian, uint16(len(locentry.Loc)))
			b.loc.Write(locentry.Loc)
		}

		// end of loclist
		binary.Write(&b.loc, binary.LittleEndian, uint64(0))
		binary.Write(&b.loc, binary.LittleEndian, uint64(0))
	default:
		panic("unknown value type")
	}
}
1079527
func (l *Logger) SetAttr(name string, val interface{}) {
	l.attrs[name] = val
}
193096
func (o *Object) Attr(attr string) string {
	o.mu.RLock()
	defer o.mu.RUnlock()
	if v := o.attr[attr]; len(v) > 0 {
		return v[0]
	}
	return ""
}
746080
func (m *Message) Attr(name string) (starlark.Value, error) {
	// The field was already set?
	val, ok := m.fields[name]
	if ok {
		return val, nil
	}

	// The field wasn't set, but it is defined by the proto schema? Need to
	// generate and return the default value then, except for oneof alternatives
	// that do not have defaults. This is needed to make sure callers are
	// explicitly picking a oneof alternative by assigning a value to it, rather
	// than have it picked implicitly be reading an attribute (which is weird).
	if fd, ok := m.typ.fields[name]; ok {
		if !fd.defaultable {
			return starlark.None, nil
		}
		def, err := newDefaultValue(fd.typ)
		if err != nil {
			return nil, err
		}
		// Lazy initialization of fields is an implementation detail. From the
		// caller's point of view, all fields had their default values even before
		// the object was frozen. Lazy-initialize the field, even if we are frozen,
		// but make sure it is frozen itself too.
		//
		// TODO(vadimsh): This is not thread safe and should be improved if a frozen
		// *Message is shared between goroutines. Generally frozen values are
		// assumed to be safe for cross-goroutine use, which is not the case here.
		// If this becomes important, we can force-initialize and freeze all default
		// fields in Freeze().
		if m.frozen {
			def.Freeze()
		}
		m.fields[name] = def
		return def, nil
	}

	return nil, fmt.Errorf("proto message %q has no field %q", m.Type(), name)
}
10320
func (c *Config) Attrs() map[string]interface{} {
	if c.attrs == nil {
		return nil
	}
	attrs := make(map[string]interface{})
	for k, v := range c.attrs {
		attrs[k] = v
	}
	return attrs
}
555129
func Lgetxattr(path string, attr string) ([]byte, error) {
	pathBytes, err := syscall.BytePtrFromString(path)
	if err != nil {
		return nil, err
	}
	attrBytes, err := syscall.BytePtrFromString(attr)
	if err != nil {
		return nil, err
	}

	dest := make([]byte, 128)
	destBytes := unsafe.Pointer(&dest[0])
	sz, _, errno := syscall.Syscall6(syscall.SYS_LGETXATTR, uintptr(unsafe.Pointer(pathBytes)), uintptr(unsafe.Pointer(attrBytes)), uintptr(destBytes), uintptr(len(dest)), 0, 0)
	if errno == syscall.ENODATA {
		return nil, nil
	}
	if errno == syscall.ERANGE {
		dest = make([]byte, sz)
		destBytes := unsafe.Pointer(&dest[0])
		sz, _, errno = syscall.Syscall6(syscall.SYS_LGETXATTR, uintptr(unsafe.Pointer(pathBytes)), uintptr(unsafe.Pointer(attrBytes)), uintptr(destBytes), uintptr(len(dest)), 0, 0)
	}
	if errno != 0 {
		return nil, errno
	}

	return dest[:sz], nil
}
540455
func Attributes(co *js.Object) map[string]string {
	o := co.Get("attributes")

	if o == nil || o == js.Undefined {
		return nil
	}

	attrs := map[string]string{}

	length := o.Get("length").Int()

	for i := 0; i < length; i++ {
		item := o.Call("item", i)
		attrs[item.Get("name").String()] = item.Get("value").String()
	}

	return attrs
}
1227852
func (s *Symlink) Attr(ctx context.Context, a *fuse.Attr) (err error) {
	s.parent.folder.fs.vlog.CLogf(ctx, libkb.VLog1, "Symlink Attr")
	defer func() { err = s.parent.folder.processError(ctx, libkbfs.ReadMode, err) }()

	_, de, err := s.parent.folder.fs.config.KBFSOps().Lookup(ctx, s.parent.node, s.name)
	if err != nil {
		if _, ok := err.(idutil.NoSuchNameError); ok {
			return fuse.ESTALE
		}
		return err
	}

	s.parent.folder.fillAttrWithUIDAndWritePerm(ctx, s.parent.node, &de, a)
	a.Mode = os.ModeSymlink | a.Mode | 0500
	a.Inode = s.inode
	return nil
}
1073826
func (a *Attributes) Value(name string) (string, bool, error) {
	attr, ok := a.Attrs[name]
	return attr, ok, nil
}
227281
func (g *Graph) Attr(name string) (starlark.Value, error) {
	impl, ok := graphAttrs[name]
	if !ok {
		return nil, nil // per Attr(...) contract
	}
	return impl.BindReceiver(g), nil
}