(ctx context.Context, name string, size uint64, d *dentry)
| 559 | } |
| 560 | |
| 561 | func (i *directfsInode) getXattr(ctx context.Context, name string, size uint64, d *dentry) (string, error) { |
| 562 | if ftype := d.inode.fileType(); ftype == linux.S_IFSOCK || ftype == linux.S_IFLNK { |
| 563 | // Sockets and symlinks use O_PATH control FDs. However, fgetxattr(2) fails |
| 564 | // with EBADF for O_PATH FDs. Fallback to lisafs. |
| 565 | if err := i.ensureLisafsControlFD(ctx, d); err != nil { |
| 566 | return "", err |
| 567 | } |
| 568 | return i.controlFDLisa.GetXattr(ctx, name, size) |
| 569 | } |
| 570 | |
| 571 | // getxattr(2) called with size 0 should return the attribute size. As a |
| 572 | // result, we need to return the entire attribute here so that the sentry |
| 573 | // can return the correct value. |
| 574 | if size > linux.XATTR_SIZE_MAX || size == 0 { |
| 575 | size = linux.XATTR_SIZE_MAX |
| 576 | } |
| 577 | bPtr := xattrBufPool.Get().(*[]byte) |
| 578 | defer xattrBufPool.Put(bPtr) |
| 579 | data := (*bPtr)[:size] |
| 580 | sz, err := unix.Fgetxattr(i.controlFD, name, data) |
| 581 | if err != nil { |
| 582 | return "", err |
| 583 | } |
| 584 | return string(data[:sz]), nil |
| 585 | } |
| 586 | |
| 587 | func (i *directfsInode) setXattr(ctx context.Context, opts *vfs.SetXattrOptions, d *dentry) error { |
| 588 | if ftype := d.inode.fileType(); ftype == linux.S_IFSOCK || ftype == linux.S_IFLNK { |
nothing calls this directly
no test coverage detected